Hi! When registering a workflow, is there a conven...
# ask-the-community
g
Hi! When registering a workflow, is there a convenient way to prevent Flyte wanting to install any Python dependencies locally? We just want to register and run it on remote (where we have all of our dependencies in the Docker environment already). A workaround that we use is this, but it’s not very nice:
Copy code
if "SKIP_HEAVY_IMPORTS" not in os.environ:
    import some_package
y
there’s a related feature in image spec called
is_container
but i don’t think that will suffice for your purposes. you can always hack things around like moving imports into the body of tasks, but fundamentally task signatures are inspected by flytekit and inspected for typetransformers, etc. i think we to establish a good pattern for this @Thomas Fan @Eduardo Apolinario (eapolinario)
also ties into the discussion around lazy loading internally in flytekit.
g
Aha, we’ll look into
is_container()
, but I gather this is just something we have to deal with for now then? There is no way to not install task-specific Python requirements when registering. Flyte needs them all installed locally.
y
the way to do it is by getting python to not load it.
so when you register only the body of workflows are run, not the body of task functions. task functions only get their signatures inspected. if you can figure out a way to delay the loading of the libraries you don’t want until the body of the function is run, that should do it
t
Most code I have seen that want to delay the import end up placing the imports into the function body. The other pattern is to use a library such as https://github.com/scientific-python/lazy_loader which implements lazy loading, but it is not well established.
g
That is a doable fix for us, thanks for the input!