Instructions for creating and running Solar Protocol scripts from a local development environment.
Some of the SP scripts rely on the open API and some require private API access.
Scripts that do not require API keys and will run in a local dev environment:
- create_html.py
- viz.py
- getRemoteData.py
Scripts the require API keys (These will run, but will fail because the API key is fake. More work is needed to enable them to safely make test posts with dummy data without it breaker the client.):
- clientPostIP.py
- solarProtocol.py
Static example data for these scripts lives in the dev-data directory. Data/files created from these scripts is saved to the dev-data/temp directory and is ignored from the repo.
Note that Cairo is required for viz.py and this is notoriously difficult to install on Windows.
These instructions come from this link, which provides syntax for both Unix/MacOS and Windows. https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment
You should create a virtual environment called 'env'. This will create a directory called env. (This is in the git ignore and wont get pushed to the repo.)
- Navigate to the solar-protocol root directory
- run
python3 -m venv env
note the python3 may change depending on your OS and environment paths
Unix/MacOS
source env/bin/activate
Windows
.\env\Scripts\activate
Use command deactivate
to exit the virtual environment. (This is the same regardless of OS.)
Install the dependencies from our requirements file, which is located in the solar-protocol root directory
python3 -m pip install -r requirements.txt
The DEV file paths are relative so these scripts must be run from their directory.
Note that 'python3' may be 'py', 'python', etc. depending on your OS and environment.
To run in unix/MacOS:
ENV=DEV python3 create_html.py
To run in Windows (this should also work in unix/MacOS):
python3 create_html.py DEV