sparse-carpenter-66912
08/28/2025, 2:03 PM@task(container_image=union.ImageSpec(builder="union", name="my-image", requirements="uv.lock"))
def show_stats(location: str) -> None:
print("this works")
if __name__ == '__main__':
remote = UnionRemote(
FlyteConfig.for_endpoint("my-endpoint"),
default_project="my-project",
default_domain="development",
)
my_task = remote.execute(
show_stats,
inputs={
"location": "<s3://my-s3-location>",
},
version="latest",
)
When I run this I get the following error: FileNotFoundError: [Errno 2] No such file or directory: 'uv.lock'
When I run the whole workflow it works thoughancient-wolf-19325
08/28/2025, 2:03 PMancient-wolf-19325
08/28/2025, 2:04 PMFileNotFoundError: <https://github.com/flyteorg/flyte/blob/master/docs/user_guide/customizing_dependencies/imagespec.md#copy-additional-files-or-directories|Errno 2] No such file or directory: 'uv.lock'
occurs because when you run a single task remotely with an ImageSpec
that references a uv.lock
file, Flyte expects that file to be present in your current working directory (or the path you specify) at the time of image build. When running a full workflow, the build context is usually set up correctly, but for ad-hoc task execution, the context may not include the uv.lock
file unless you explicitly provide it. According to the [ImageSpec documentation>, you can use the copy
parameter in your ImageSpec
to ensure required files like uv.lock
are included in the build context.
Try updating your ImageSpec
as follows to copy the uv.lock
file into the image:
@task(container_image=union.ImageSpec(builder="union", name="my-image", requirements="uv.lock", copy=["uv.lock"]))
def show_stats(location: str) -> None:
print("this works")
Would you like more detail on how Flyte builds images for ad-hoc task execution or how to structure your project for consistent results?
Sources:
- https://github.com/flyteorg/flyte/issues/6392
- https://github.com/flyteorg/flyte/issues/6438 š 0 button š 0 button š” Hint: Mention @runllm in the thread for followups.