Baseline Ensemble Upload #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Baseline Ensemble Upload | |
on: | |
# scheduled submission every Wednesday at 04.00 a.m. (Wednesday 03.00 a.m.UTC) | |
# TODO for the time being upload is Thursday at 04.00 a.m. (Thursday 03.00 a.m. UTC) | |
schedule: | |
#- cron: '00 03 * * 3' | |
- cron: '00 12 * * 3' | |
workflow_dispatch: | |
jobs: | |
scheduled-submit: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the python tools repo | |
# used to authenticate and validate the PR | |
# ------------------------------------------- | |
- name: checkout python tools repo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: 'Predizioni-Epidemiologiche-Italia/hub-tools' | |
ref: 'main' | |
path: './tools/' | |
- name: checkout data repo | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
repository: 'Predizioni-Epidemiologiche-Italia/Influcast' | |
ref: 'main' | |
path: './repo/' | |
# Get the list of changes from a json file | |
- name: Get changes list | |
id: get_changes | |
run: | | |
content=`cat ./repo/.github/data-storage/ensemble_db.json` | |
content="${content//'%'/'%25'}" | |
content="${content//$'\n'/'%0A'}" | |
content="${content//$'\r'/'%0D'}" | |
echo "::set-output name=packageJson::$content" | |
- run: | | |
echo "${{ steps.get_changes.outputs.packageJson }}" | |
# Trigger server-side updating and UI deploy | |
# -------------------------------------------- | |
# WEBHOOK | |
- name: Invoke deployment hook | |
id: invoke_webhook | |
env: | |
webhook_url: ${{ secrets.WEB_HOOK_URL }} | |
webhook_secret: ${{ secrets.WEB_HOOK_SECRET }} | |
data: ${{ steps.get_changes.outputs.packageJson }} | |
data_type: "forecast" | |
season: "NA" | |
run: | | |
pip install requests | |
python ./tools/code/workflow_webhook.py | |
- name: trace only | |
run: | | |
echo "webhook results: ${{ steps.invoke_webhook.outputs.run_results }}" | |
# SUCCESSFUL RUN | |
# -------------------------------------------- | |
- name: Successful run | |
if: ${{ fromJSON(steps.invoke_webhook.outputs.run_results).status == 'success'}} | |
env: | |
wh_response: ${{ steps.invoke_webhook.outputs.run_results }} | |
run: | | |
echo "UPLOAD SUCCEEDED - clear djson db" | |
python ./tools/code/clear_data_storage.py --storage_type "ensemble" | |
# RUN FAILURE | |
# -------------------------------------------- | |
- name: Some ingestion failed | |
if: ${{ fromJSON(steps.invoke_webhook.outputs.run_results).status == 'failure'}} | |
env: | |
wh_response: ${{ steps.invoke_webhook.outputs.run_results }} | |
run: | | |
echo "UPLOAD FAILED - Some ingestion failed" | |
python ./tools/code/clear_data_storage.py --storage_type "ensemble" | |
# ERROR RUN | |
# -------------------------------------------- | |
- name: Error | |
if: ${{ steps.invoke_webhook.outputs.run_results.status == 'error'}} | |
run: | | |
echo "EnsambleUPLOAD FAILED - ignore djson db cleaning" | |
# Final commit | |
# -------------------------------------------- | |
- name: Commit changes | |
if: ${{ fromJSON(steps.invoke_webhook.outputs.run_results).status == 'failure' || fromJSON(steps.invoke_webhook.outputs.run_results).status == 'success' }} | |
uses: EndBug/add-and-commit@v7 | |
with: | |
cwd: './repo' | |
message: "Update model-output db json" | |
default_author: github_actions | |
push: true |