forked from european-modelling-hubs/ari-forecast-hub_archive
-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (99 loc) · 3.86 KB
/
upload_scoring.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Scoring Upload
on:
workflow_run:
workflows: [Scoring]
types:
- completed
# needed to trigger manually
workflow_dispatch:
jobs:
scheduled-submit:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'european-modelling-hubs' }}
runs-on: ubuntu-latest
steps:
# Introduce some delay to complete DB write
- name: Sleep for 90 seconds
run: sleep 90s
shell: bash
# 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: 'european-modelling-hubs/hub-tools'
ref: 'main'
path: tools
# Checkout the data repo
- name: checkout data repo
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: 'european-modelling-hubs/ari-forecast-hub'
ref: 'main'
path: './repo/'
# Get the list of changes from a json file
- name: Get changes list
id: get_changes
run: |
echo "Read changes list from json"
content=`cat ./repo/.github/data-storage/evaluation_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:
disease_name: ${{ vars.DISEASE_NAME }}
webhook_url: ${{ secrets.WEB_HOOK_URL }}
webhook_secret: ${{ secrets.WEB_HOOK_SECRET }}
data: ${{ steps.get_changes.outputs.packageJson }}
data_type: "scoring"
run: |
pip install requests
python ./tools/.github/scripts/utils/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 "scoring"
# 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 "scoring"
# ERROR RUN
# --------------------------------------------
- name: Error
if: ${{ steps.invoke_webhook.outputs.run_results.status == 'error'}}
run: |
echo "UPLOAD FAILED - ignore djson db cleaning"
exit 1
# 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 metadata db json"
default_author: github_actions
push: true