-
Notifications
You must be signed in to change notification settings - Fork 24
/
workflow.yaml
74 lines (74 loc) · 2.56 KB
/
workflow.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
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START workflows_batch_primegen]
main:
params: [args]
steps:
- init:
assign:
- projectId: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
- region: "us-central1"
- imageUri: ${region + "-docker.pkg.dev/" + projectId + "/containers/primegen-service:v1"}
- jobId: ${"job-primegen-" + string(int(sys.now()))}
- bucket: ${projectId + "-" + jobId}
- createBucket:
call: googleapis.storage.v1.buckets.insert
args:
query:
project: ${projectId}
body:
name: ${bucket}
- logCreateBucket:
call: sys.log
args:
data: ${"Created bucket " + bucket}
- logCreateBatchJob:
call: sys.log
args:
data: ${"Creating and running the batch job " + jobId}
- createAndRunBatchJob:
call: googleapis.batch.v1.projects.locations.jobs.create
args:
parent: ${"projects/" + projectId + "/locations/" + region}
jobId: ${jobId}
body:
taskGroups:
taskSpec:
runnables:
- container:
imageUri: ${imageUri}
environment:
variables:
BUCKET: ${bucket}
# Run 6 tasks on 2 VMs
taskCount: 6
parallelism: 2
logsPolicy:
destination: CLOUD_LOGGING
result: createAndRunBatchJobResponse
# You can delete the batch job or keep it for debugging
- logDeleteBatchJob:
call: sys.log
args:
data: ${"Deleting the batch job " + jobId}
- deleteBatchJob:
call: googleapis.batch.v1.projects.locations.jobs.delete
args:
name: ${"projects/" + projectId + "/locations/" + region + "/jobs/" + jobId}
result: deleteResult
- returnResult:
return:
jobId: ${jobId}
bucket: ${bucket}
# [END workflows_batch_primegen]