Skip to content

Instantly share code, notes, and snippets.

@fg91
Last active November 17, 2021 20:22
Show Gist options
  • Save fg91/a0736a500dc283fd2cdae3b2782347e9 to your computer and use it in GitHub Desktop.
Save fg91/a0736a500dc283fd2cdae3b2782347e9 to your computer and use it in GitHub Desktop.
Flyte remote build and register
from x import task2
@task
def my_task():
...
def relocate(task, context="."):
traceback.print_stack()
s = traceback.extract_stack()
print(f"Filename: {s[0].filename}")
file = s[-1].filename
@click.option("--default_image", ...)
@click.option("--local_run_only, ...)
def package_and_register():
if local_run_only:
my_wf()
return
default_image = build_image(dockerfile="../../Dockerfile", build_context="../../")
remote = FlyteRemote(
#image_config=ImageConfig(... default_image, ...)
)
if not default_image:
remote.build_register(my_task, version="...", dockerfile="../../../Dockerfile", build_context="../../")
else:
remote.register(my_task, image=default_image)
remote.build_register(my_task2, version="...", dockerfile="../../../Dockerfile.spark", build_context="../../../")
__file__
if __name__ == "__main__":
package_and_register()
"""
User story during development:
python myapp/workflows/example.py
User story for CICD:
python myapp/workflows/example.py --default_image some_tag --version ${GIT_TAG}
"""
@YmirKhang
Copy link

Where is the relocate function used?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment