acoustic-carpenter-78188
11/09/2023, 1:31 AMPythonInstanceTask.
Type
☑︎ Bug Fix
☐ Feature
☐ Plugin
Are all requirements met?
☑︎ Code completed
☐ Smoke tested
☐ Unit tests added
☐ Code documentation added
☐ Any pending items have an associated Issue
Complete description
from flytekit import task, workflow, ImageSpec, dynamic, kwtypes
from flytekit.extras.tasks.shell import ShellTask, OutputLocation
from flytekit.types.file import FlyteFile
new_flytekit = "git+https://github.com/flyteorg/flytekit.git@master"
image = ImageSpec(apt_packages=["git"], packages=[new_flytekit], registry="pingsutw")
cache_repro = ShellTask(
name="cache_repro",
debug=True,
cache=True,
cache_version="1.0",
script=
"""
echo "Hello World1, {inputs.msg}" > {outputs.o}
""",
inputs=kwtypes(msg=str),
output_locs=[OutputLocation(var="o", var_type=FlyteFile, location='/tmp/repro.txt')],
)
@task(cache=True, cache_version="1.0")
def t1(a: int) -> int:
print(a)
return a + 2
@task(cache=True, cache_version="1.0")
def t2(f: FlyteFile) -> FlyteFile:
print(f)
return f
@workflow
def wf():
f = cache_repro(msg="hello")
t2(f=f)
t1(a=3)
if __name__ == "__main__":
wf()
image▾