A python module that interfaces with Zoltar https://github.com/reichlab/forecast-repository
- python 3.6
- pipenv for managing packages - see Pipfile
- click - for the demo application's handling of args
- pandas - for use of dataframe function
Zoltpy is hosted on the Python Package Index (pypi.org), a repository for Python modules https://pypi.org/project/zoltpy/.
Install Zoltpy with the following command:
pip install zoltpy
Users must add their Zoltar username and password to environment variables on their machine before using this module.
cd ~ nano .bash_profile
Add the following to your bash_profile:
export Z_USERNAME=<your zoltar username> export Z_PASSWORD=<your zoltar password>
After you are finished, press
X to save and quit.
Then enter the command:
To ensure your environment variable is configured properly, run this command and check for Z_USERNAME and Z_PASSWORD:
In the command prompt, run the following commands:
set Z_USERNAME="<your zoltar username>" set Z_PASSWORD="<your zoltar password>"
Zoltpy is a python module that communicates with Zoltar, the Reich Lab's forecast repository. To import the Zoltpy functions, run the following command after installing the package:
import zoltpy as zp
Zoltpy currently has 5 Key Functions:
- print_projects() - Print project names
project_name) - Print model names for a specified project
timezero_date) - Deletes a forecast from Zoltar
forecast_csv_file) - Upload a forecast to Zoltar
timezero_date) - Returns forecast as a Pandas Dataframe
Print Project Names
This fuction returns the project names that you have authorization to view in Zoltar.
Print Model Names
Given a project, this function prints the models in that project.
zp.print_models(project_name = 'My Project')
Delete a Forecast
Deletes a single forecast for a specified model and timezero.
zp.delete_forecast(project_name='My Project', model_name='My Model', timezero_date='YYYYMMDD')
zp.delete_forecast('Impetus Province Forecasts','gam_lag1_tops3','20181203')
Upload a Forecast
zp.upload_forecast(project_name='My Project', model_name='My Model', timezero_date='YYYYMMDD', 'C:\\Users\\house\\Desktop\\20181203-gam_lag1_tops3-20190114.csv')
zp.upload_forecast('Impetus Province Forecasts','gam_lag1_tops3','20181203','C:\\Users\\house\\Desktop\\20181203-gam_lag1_tops3-20190114.csv')
Return Forecast as a Pandas Dataframe
zp.forecast_to_dataframe('Impetus Province Forecasts','gam_lag1_tops3','20181203')