Creating own module
A classical error is to forget adding empty __init__.py
files
in all folder to be sure they are processed by platform pythonic explorations:
be sure there are __init__.py
files in all your folders !
Move to your sos-trades-dev folder and load virtual environment
-
move in the sostrades-dev-tools where the platform was installed
cd <path to your installation folder>\sostrades-dev-tools
-
activate the virtual environment
.\.venv\Scripts\activate
You should see a(.venv)
appear at the beginning of yout DOS prompt
Every time you want to work with SoSTrades to develop or use the platform,
activate this virtual environment first by reruning this .\.venv\Scripts\activate
command
Create the module folder structure in one of your repositories
-
move to one of your repositories
sostrades-dev-tools/models/<your repository>
cd ...\sostrades-dev-tools\models\<your repository
-
add a folder for your new module in
sostrades-dev-tools/models/<your repository>
mkdir <your-new-module>
cd <your-new-module>
type NUL > __init__.py
-
create a models folder named
sos_wrapping
in your new<your-new-module>
folder
mkdir sos_wrapping
type NUL > sos_wrapping\__init__.py
-
create a processes folder named
sos_processes
in your new<your-new-module>
folder
mkdir sos_processes
type NUL > sos_processes\__init__.py
Reference your new module on the platform
-
Locate and open the file
.../sostrades-dev-tools/platform/sostrades-webapi/sos_trades_api/configuration_template/configuration.json
cd ...\sostrades-dev-tools
notepad platform\sostrades-webapi\sos_trades_api\configuration_template\configuration.json
-
Add your repository module name (e.g. the name you would use in python import) :
SOS_TRADES_PROCESS_REPOSITORY": [ "sostrades_core.sos_processes", "sostrades_optimization_plugins.sos_processes", "climateeconomics.sos_processes", "energy_models.sos_processes", "<your-new-module>>.sos_processes" ],