Trying to understand how to use `ImageSpec.is_cont...
# flyte-support
e
Trying to understand how to use
ImageSpec.is_container()
and I found this old thread interesting: https://discuss.flyte.org/t/15616465/hey-guys-how-do-i-add-new-packages-to-the-project-in-flyte-i#01266f7b-9c80-4c3c-907e-2f8e47325480 TL;DR:
pyflyte
expects the dependency (
cv2
in this case) to be installed locally even though it's guarded by
if cv2_image_spec.is_container():
which, in my understanding, should imply that the dependency is only needed at run time in the task pod. This happens because the
ExecutionState.mode
is
None
and
is_container()
returns
True
when running
pyflyte run --remote
or
pyflyte register
. I've confirmed this behavior with
flytekit==1.16.1
. Is this the expected behavior or a bug? If the former, is late import within the task definition the only recourse for this scenario?
g
is_container()
returns True locally because you need to import the dependency during local execution, but I think in your case (at registration time), we can make it return False, so you don’t need to import it when registering the workflow. mind filing an issue, we will fix it.
[flyte-bug]
e