Skip to content

Commit

Permalink
Merge pull request #20 from danyoungday/remove-download-sdk
Browse files Browse the repository at this point in the history
Moved SDK to S3 and changed download script to load it from the bucket
  • Loading branch information
danyoungday authored Nov 25, 2024
2 parents 81ba9c8 + d9379b3 commit 6826a11
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 58 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/enroads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ jobs:
python -m pip install --upgrade pip
pip install pylint flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Download En-ROADS sdk
env:
ENROADS_URL: ${{ secrets.ENROADS_URL }}
ENROADS_ID: ${{ secrets.ENROADS_ID }}
ENROADS_PASSWORD: ${{ secrets.ENROADS_PASSWORD }}
run: python -m enroadspy.download_sdk
# Temporarily disabled until we sort out S3 access
# - name: Download En-ROADS sdk
# run: python -m enroadspy.load_sdk
- name: Lint with PyLint
run: pylint .
- name: Lint with Flake8
run: flake8
- name: Run unit tests
run: python -m unittest
# - name: Run unit tests
# run: python -m unittest

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Immediate action is required to combat climate change. The technology behind [Co

## En-ROADS Wrapper

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).
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).

### Installation
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.
Expand All @@ -19,4 +19,4 @@ See the notebooks in `experiments/` for how to analyze the results of such evolu

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

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`
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`
48 changes: 0 additions & 48 deletions enroadspy/download_sdk.py

This file was deleted.

36 changes: 36 additions & 0 deletions enroadspy/load_sdk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Setup script to load the En-ROADS SDK from the S3 bucket. This is used for app deployment and testing.
Note: This script requires access to the private S3 bucket where the SDK is stored. The SDK is not currently available
for general use. If you would like to run the full project, see the README in order to contact a member of Project
Resilience.
"""
import os
import zipfile

import boto3


def main():
"""
Downloads En-ROADS SDK from the S3 bucket and extracts it.
If the sdk already exists, we do nothing.
If we already have the zip file but no SDK, we just extract the zip file.
"""
sdk_name = "en-roads-sdk-v24.6.0-beta1"
sdk_path = "enroadspy/"
zip_path = sdk_path + "/" + sdk_name + ".zip"

if os.path.exists(sdk_path + "/" + sdk_name):
print("SDK already exists.")
return

if not os.path.exists(zip_path):
s3 = boto3.client('s3')
s3.download_file("ai-for-good", sdk_name + ".zip", zip_path)

with zipfile.ZipFile(zip_path, "r") as zip_ref:
zip_ref.extractall(sdk_path)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
boto3==1.35.60
dash==2.17.1
dash-bootstrap-components==1.6.0
dill==0.3.8
Expand Down

0 comments on commit 6826a11

Please sign in to comment.