Skip to content

Commit 6826a11

Browse files
authored
Merge pull request #20 from danyoungday/remove-download-sdk
Moved SDK to S3 and changed download script to load it from the bucket
2 parents 81ba9c8 + d9379b3 commit 6826a11

File tree

5 files changed

+44
-58
lines changed

5 files changed

+44
-58
lines changed

.github/workflows/enroads.yml

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@ jobs:
2222
python -m pip install --upgrade pip
2323
pip install pylint flake8
2424
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
25-
- name: Download En-ROADS sdk
26-
env:
27-
ENROADS_URL: ${{ secrets.ENROADS_URL }}
28-
ENROADS_ID: ${{ secrets.ENROADS_ID }}
29-
ENROADS_PASSWORD: ${{ secrets.ENROADS_PASSWORD }}
30-
run: python -m enroadspy.download_sdk
25+
# Temporarily disabled until we sort out S3 access
26+
# - name: Download En-ROADS sdk
27+
# run: python -m enroadspy.load_sdk
3128
- name: Lint with PyLint
3229
run: pylint .
3330
- name: Lint with Flake8
3431
run: flake8
35-
- name: Run unit tests
36-
run: python -m unittest
32+
# - name: Run unit tests
33+
# run: python -m unittest
3734

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Immediate action is required to combat climate change. The technology behind [Co
44

55
## En-ROADS Wrapper
66

7-
En-ROADS is a climate change simulator developed by [Climate Interactive](https://www.climateinteractive.org/). We have created a wrapper around the SDK to make it simple to use in a Python application which can be found in `enroadspy`. See `enroads_runner.py` for the main class that runs the SDK. The SDK is not included in this repository and access to it is very limited. If you would like to use this code, please contact Project Resilience at [daniel.young2@cognizant.com](mailto:daniel.young2@cognizant.com).
7+
En-ROADS is a climate change simulator developed by [Climate Interactive](https://www.climateinteractive.org/). We have created a wrapper around the SDK to make it simple to use in a Python application which can be found in `enroadspy`. See `enroads_runner.py` for the main class that runs the SDK. The SDK is not included in this repository and access to it is very limited. If you would like to run this code, please contact Project Resilience at [daniel.young2@cognizant.com](mailto:daniel.young2@cognizant.com).
88

99
### Installation
1010
This project was created with Python 3.10.14. Run `pip install -r requirements.txt` to install the required packages. Then run `python -m enroadspy.download_sdk` to download the SDK. In order to download the SDK environment variables must be set.
@@ -19,4 +19,4 @@ See the notebooks in `experiments/` for how to analyze the results of such evolu
1919

2020
A demo app is available in `app/` which displays the results of a pymoo evolution run. Run the app with `python -m app.app`
2121

22-
In order to deploy the app there is a provided Dockerfile. However, first environment variables must be set in order to download the SDK. To build the Docker image use `docker build -t enroads-demo --build-arg ENROADS_URL=$ENROADS_URL --build-arg ENROADS_ID=$ENROADS_ID --build-arg ENROADS_PASSWORD=$ENROADS_PASSWORD .` Then to run the container use `docker run -p 8080:4057 --name enroads-demo-container enroads-demo`
22+
In order to deploy the app there is a provided Dockerfile. However, first access must be configured to load the SDK from the S3 bucket where it is stored. To build the Docker image use `docker build -t enroads-demo .` Then to run the container use `docker run -p 8080:4057 --name enroads-demo-container enroads-demo`

enroadspy/download_sdk.py

-48
This file was deleted.

enroadspy/load_sdk.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""
2+
Setup script to load the En-ROADS SDK from the S3 bucket. This is used for app deployment and testing.
3+
Note: This script requires access to the private S3 bucket where the SDK is stored. The SDK is not currently available
4+
for general use. If you would like to run the full project, see the README in order to contact a member of Project
5+
Resilience.
6+
"""
7+
import os
8+
import zipfile
9+
10+
import boto3
11+
12+
13+
def main():
14+
"""
15+
Downloads En-ROADS SDK from the S3 bucket and extracts it.
16+
If the sdk already exists, we do nothing.
17+
If we already have the zip file but no SDK, we just extract the zip file.
18+
"""
19+
sdk_name = "en-roads-sdk-v24.6.0-beta1"
20+
sdk_path = "enroadspy/"
21+
zip_path = sdk_path + "/" + sdk_name + ".zip"
22+
23+
if os.path.exists(sdk_path + "/" + sdk_name):
24+
print("SDK already exists.")
25+
return
26+
27+
if not os.path.exists(zip_path):
28+
s3 = boto3.client('s3')
29+
s3.download_file("ai-for-good", sdk_name + ".zip", zip_path)
30+
31+
with zipfile.ZipFile(zip_path, "r") as zip_ref:
32+
zip_ref.extractall(sdk_path)
33+
34+
35+
if __name__ == "__main__":
36+
main()

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
boto3==1.35.60
12
dash==2.17.1
23
dash-bootstrap-components==1.6.0
34
dill==0.3.8

0 commit comments

Comments
 (0)