-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow-gbfs-validator.yaml
131 lines (130 loc) · 5.53 KB
/
workflow-gbfs-validator.yaml
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
122
123
124
125
126
127
128
129
130
131
#
# Validates a GBFS dataset given the system.csv row as a JSON parameter
#
## Input
# {
# "location": "Dubai, AE",
# "systemId": "careem_bike",
# "autoDiscoveryUrl": "https://dubai.publicbikesystem.net/customer/gbfs/v2/gbfs.json",
# "resultsBucketName": "mobilitydata-gbfs-validation-results",
# "datasetId": "Dubai_AE_careem_bike"
# "reportFilename": "Dubai_AE_careem_bike.json"
# }
##
# Output:
# {
# "dataset": {
# "autoDiscoveryUrl": "https://dubai.publicbikesystem.net/customer/gbfs/v2/gbfs.json",
# "location": "Dubai, AE",
# "systemId": "careem_bike"
# },
# "execution": {
# "reportFilename": "Dubai_AE__careem_bike.json",
# "status": "succeeded"
# },
# "summary": {
# "errorsCount": 0,
# "hasErrors": false,
# "validatorVersion": "1.0.0",
# "version": {
# "detected": "1.0",
# "validated": "1.0"
# },
# "filesSummary": [
# {
# "required": true,
# "exists": true,
# "file": "gbfs.json",
# "hasErrors": false,
# "errorsCount": 0
# }
# ]
# }
main:
params: [args]
steps:
- validate:
try:
steps:
- init:
assign:
- resultsBucketName: $${args["resultsBucketName"]}
- datasetId: $${args["datasetId"]}
- reportFilename: $${args["reportFilename"]}
- datasetUrl: $${args["autoDiscoveryUrl"]}
- validatorUrl: ${app_gbs_validator_url} # replaced by terraform variable
- initLog:
call: sys.log
args:
text: $${"Validating dataset " + datasetUrl}
severity: INFO
- validateDataset:
call: http.post
args:
url: $${validatorUrl}
body:
url: $${datasetUrl}
result: validationResult
- logValidationResults:
call: sys.log
args:
text: $${"Dataset validation HTTP code result " + validationResult.code}
severity: INFO
- persistValidation:
call: googleapis.storage.v1.objects.insert
args:
bucket: $${resultsBucketName}
uploadType: "media"
name: $${reportFilename}
body:
execution:
status: "succeeded"
reportFilename: $${reportFilename}
dataset:
autoDiscoveryUrl: $${args["autoDiscoveryUrl"]}
systemId: $${args["systemId"]}
location: $${args["location"]}
summary: $${json.decode(validationResult.body).summary}
filesSummary: $${json.decode(validationResult.body).filesSummary}
- return:
return:
execution:
status: "succeeded"
reportFilename: $${reportFilename}
dataset:
autoDiscoveryUrl: $${args["autoDiscoveryUrl"]}
systemId: $${args["systemId"]}
location: $${args["location"]}
summary: $${json.decode(validationResult.body).summary}
filesSummary: $${json.decode(validationResult.body).filesSummary}
except:
as: e
steps:
- logException:
call: sys.log
args:
text: $${"Error validating dataset " + datasetId + " exception " + json.encode_to_string(e)}
severity: ERROR
- persistErrorValidation:
call: googleapis.storage.v1.objects.insert
args:
bucket: $${resultsBucketName}
uploadType: "media"
name: $${reportFilename}
body:
execution:
status: "failed"
reportFilename: $${reportFilename}
dataset:
autoDiscoveryUrl: $${args["autoDiscoveryUrl"]}
systemId: $${args["systemId"]}
location: $${args["location"]}
summary: {}
- unhandled_exception:
return:
execution:
status: "failed"
dataset:
autoDiscoveryUrl: $${args["autoDiscoveryUrl"]}
systemId: $${args["systemId"]}
location: $${args["location"]}