-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhello_eks.py
44 lines (31 loc) · 1022 Bytes
/
hello_eks.py
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
import os
import covalent as ct
from covalent.executor import KubernetesExecutor
k8s_config = os.environ["KUBECONFIG"] or os.path.join(os.environ["HOME"], ".kube/config")
# Change these before running!
region = "us-east-1"
account = ""
cluster_name = "" # Corresponds to 'name' in .tfvars
aws_s3_bucket = "" # Corresponds to 'aws_s3_bucket' in .tfvars
k8s_context = f"arn:aws:eks:{region}:{account}:cluster/{cluster_name}-cluster"
registry = f"{account}.dkr.ecr.{region}.amazonaws.com"
data_store = f"s3://{aws_s3_bucket}"
eks_executor = KubernetesExecutor(
k8s_config_file=k8s_config,
k8s_context=k8s_context,
registry=registry,
data_store=data_store,
region=region,
)
@ct.electron(executor=eks_executor)
def join_words(a, b):
return ", ".join([a, b])
@ct.electron
def excitement(a):
return f"{a}!"
@ct.lattice
def simple_workflow(a, b):
phrase = join_words(a, b)
return excitement(phrase)
dispatch_id = ct.dispatch(simple_workflow)("Hello", "world")
print(dispatch_id)