-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-batch-runner.yaml
80 lines (69 loc) · 2.64 KB
/
azure-batch-runner.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
id: azure-batch-runner
namespace: company.team
variables:
pool_id: poolId
container_name: containerName
tasks:
- id: scrape_environment_info
type: io.kestra.plugin.scripts.python.Commands
containerImage: ghcr.io/kestra-io/pydata:latest
taskRunner:
type: io.kestra.plugin.ee.azure.runner.Batch
account: "{{ secret('AZURE_ACCOUNT') }}"
accessKey: "{{ secret('AZURE_ACCESS_KEY') }}"
endpoint: "{{ secret('AZURE_ENDPOINT') }}"
poolId: "{{ vars.pool_id }}"
blobStorage:
containerName: "{{ vars.container_name }}"
connectionString: "{{ secret('AZURE_CONNECTION_STRING') }}"
commands:
- python {{ workingDir }}/main.py
namespaceFiles:
enabled: true
outputFiles:
- environment_info.json
inputFiles:
main.py: >
import platform
import socket
import sys
import json
from kestra import Kestra
print("Hello from Azure Batch and kestra!")
def print_environment_info():
print(f"Host's network name: {platform.node()}")
print(f"Python version: {platform.python_version()}")
print(f"Platform information (instance type): {platform.platform()}")
print(f"OS/Arch: {sys.platform}/{platform.machine()}")
env_info = {
"host": platform.node(),
"platform": platform.platform(),
"OS": sys.platform,
"python_version": platform.python_version(),
}
Kestra.outputs(env_info)
filename = 'environment_info.json'
with open(filename, 'w') as json_file:
json.dump(env_info, json_file, indent=4)
if __name__ == '__main__':
print_environment_info()
extend:
title: Run a Python script on Azure with Azure Batch VMs
description: >
This flow will execute a Python script on Azure Batch. This requires you to
setup Azure Batch, Azure Blob Storage in the same region that you want to
run Azure Batch Jobs and Azure credentials.
In order to support inputFiles, namespaceFiles, and outputFiles, the Azure
Batch task runner currently relies on resource files and output files which
transit through Azure Blob Storage.
Since we don't know the working directory of the container in advance, we
always need to explicitly define the working directory and output directory
when using the Azure Batch runner, e.g. use cat `{{ workingDir
}}/myFile.txt` rather than `cat myFile.txt`.
tags:
- Azure
- Python
- Task Runner
ee: true
demo: false
meta_description: Run a Python script on Azure with Azure Batch VMs