ambitious-airplane-25777
07/04/2024, 11:24 AMFlyteRemote.register_workflow()
to register and run workflow. We discovered that if an ___init__.py_
file is present in the directory where the register code resided, like
# flyte_playground directory
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config, ImageConfig
from autojoin_flyte_workflow.workflow import wf
from flytekit.configuration import SerializationSettings, FastSerializationSettings
remote = FlyteRemote(config=Config.auto(), default_project="flytesnacks", default_domain="development")
_, native_url = remote.fast_package(root=".")
flyte_workflow = remote.register_workflow(
entity=wf,
serialization_settings=SerializationSettings(
image_config=ImageConfig.auto_default_image(),
project="flytesnacks",
domain="development",
version="remote_registration_v0",
fast_serialization_settings=FastSerializationSettings(enabled=True, destination_dir=".", distribution_location=native_url),
),
)
remote.execute(
entity=flyte_workflow,
# inputs={"dirpath": "<s3://my-s3-bucket/input-data-test>", "output_location": "<s3://my-s3-bucket/output-data-test/>"},
inputs={"dirpath": "<gs://igenius-flyte-userdata/alessandro-test/input-data>", "output_location": "<gs://igenius-flyte-userdata/alessandro-test/output-data/>"}
)
, the Task wonβt be able to execute because of a ModuleNotFoundError: No module named 'flyte_playground'
error. As soon as we remove the __init__.py
it starts working but weβll lack the possibility to import the code above from in our project.
Do you have any advice how to manage a situation like this?
Thankstall-lock-23197
brash-autumn-99506
07/05/2024, 10:14 AMflyte_playground
... with this tree
flyte_playground
βββ hello_world_dir
β βββ __init__.py
β βββ hello_world.py
βββ register_workflow.py
registration and run both work, but with this
flyte_playground
βββ __init__.py
βββ hello_world_dir
β βββ __init__.py
β βββ hello_world.py
βββ register_workflow.py
the workflow is registered but then at run time we get ModuleNotFoundError: No module named 'flyte_playground'
. However, without the init we can't really import the workflows in hello_world_dir from other parts of the project (where flyte_playground resides).
This is how we're registering the workflow (the content of register_workflow.py
, we just run python register_workflow.py
from within flyte_playground):
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config, ImageConfig
from hello_world_dir.hello_world import hello_world_workflow
from flytekit.configuration import SerializationSettings, FastSerializationSettings
remote = FlyteRemote(config=Config.auto(), default_project="flytesnacks", default_domain="development")
_, native_url = remote.fast_package(root=".")
flyte_workflow = remote.register_workflow(
entity=hello_world_workflow,
serialization_settings=SerializationSettings(
image_config=ImageConfig.auto_default_image(),
project="flytesnacks",
domain="development",
version="1.0.1",
fast_serialization_settings=FastSerializationSettings(enabled=True, destination_dir=".", distribution_location=native_url),
),
)
remote.execute(
entity=flyte_workflow,
inputs={"name": "foo", "answer": "bar"},
)
We were taking inspiration from this old thread of yours. Is there a way to handle this with root
and destination_dir
at fast registration?tall-lock-23197
destination_dir
to say, /root
? cc @glamorous-carpet-83516brash-autumn-99506
07/08/2024, 8:33 AMdestination_dir="/root"
yields ModuleNotFoundError: No module named 'flyte_playground'
upon execution (workflow gets registered)tall-lock-23197
brash-autumn-99506
07/09/2024, 7:27 AMflyte_playground
and destination_dir=="/root"
, the workflow gets registered as flyte_playground.hello_world_dir.hello_world.hello_world_workflow
and doesn't run with ModuleNotFoundError: No module named 'flyte_playground'
. Instead without the init in flyte_playground
(still destination_dir=="/root"
) the workflow is registered as hello_world_dir.hello_world.hello_world_workflow
and runs successfullytall-lock-23197
flyte_playground
.brash-autumn-99506
07/09/2024, 7:49 AMModuleNotFoundError: No module named 'flyte_playground'
. I also changed the root in remote.fast_package to "flyte_playground"
to avoid registering everything that's one level above (a lot of stuff), and kept destination_dir="/root"
. Anything else I should have changed?tall-lock-23197
__init__.py
file?brash-autumn-99506
07/09/2024, 7:56 AMparent.flyte_playground.hello_world_dir.hello_world.hello_world_workflow
and the error at execution is ModuleNotFoundError: No module named 'parent'
tall-lock-23197
brash-autumn-99506
07/09/2024, 8:19 AMx hello_world_dir/
x hello_world_dir/__init__.py
x hello_world_dir/hello_world.py
x __init__.py
with respect to this message, the remote execution file is missing since moved one level above.
(FYI: couldn't find the tar file in the UI, had to rely on the message that I get on terminal when running the remote registration script: No output path provided, using a temporary directory at /var/folders/... instead
)tall-lock-23197
flyte_playground
directory, not the contents of it. makes sense?tall-lock-23197
remote.fast_package(root="flyte-playground")
. when you move the remove script one level above and modify the root, it'll package the contents in the flyte-playground directory, when it indeed must have the flyte-playground directory.brash-autumn-99506
07/09/2024, 8:23 AMtall-lock-23197
parent
directory.brash-autumn-99506
07/09/2024, 8:25 AMparent
, that will get packaged too, am I wrong?tall-lock-23197
brash-autumn-99506
07/09/2024, 1:08 PM.flyteignore
, is there any?)
In the meantime, thank you, Samhita! πtall-lock-23197
so the gist is that in the root dir where we run the registration file there has not to be any init file, right?that's right. that's how the task path is determined.
I didn't find any documentation aboutwe'll need to document this but it's available: https://github.com/flyteorg/flytekit/blob/5b3e7256c8cb14f19dd727e964b26be346d491b5/flytekit/tools/ignore.py#L90, is there any?.flyteignore
brash-autumn-99506
07/09/2024, 2:26 PMroot
in remote.fast_package only changes the fast registration package path but not the task path? I would have expected them to be related, so that changing root at registration also changed the task path. Might that be a bit of a limitation for some use cases?tall-lock-23197
__init__.py
files. it'll begin from the directory whose parent directory doesn't have an init file.