-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (30 loc) · 1.31 KB
/
main.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
45
46
47
import flytekit as fk
import hydra
from omegaconf import DictConfig
from union.remote import UnionRemote
from flyte_hydra.structs import Column, Configuration
image = fk.ImageSpec(packages=["flytekit==1.14.0b5", "hydra-core", "pydantic"])
@fk.task(container_image=image)
def show_lr(lr: float):
print(lr)
@fk.task(container_image=image)
def show_column(column: Column):
print(column)
@fk.workflow
def my_workflow(config: Configuration):
# use only the "learning_rate" attribute of the "hyperparameters" dataclass
show_lr(config.hyperparameters.learning_rate)
# map over the list of "features" in the "schema" dataclass
fk.map_task(show_column)(config.schema.features)
@hydra.main(version_base="1.3", config_path="config", config_name="config")
def app(config: DictConfig) -> None:
# instantiate dataclasses from DictConfig
config: Configuration = hydra.utils.instantiate(config, _convert_="object", _target_=Configuration)
# create Union remote connection
remote = UnionRemote(default_domain="development", default_project="default")
# execute workflow with configurations
run = remote.execute(remote.fast_register_workflow(my_workflow), inputs={"config": config})
# print execution URL
print(run.execution_url)
if __name__ == "__main__":
app()