Hi, is there a way how I could define the `working...
# ask-the-community
v
Hi, is there a way how I could define the
working_dir
on task level? Per default its
/root
, but in my container image this folder does not exist and would like to use another directory instead. I am aware that I could define it via CLI of the workflow, but I would rather have it set for this specific task/container in code.
k
Do you mean when you use pyflyte run?
v
Yes I use pyflyte run. I would love to see it Independent of the cli tool. Rather be part of the code. Something like this:
@task(working_dir="/home/user_a", container_image="a")
def do_a():
@task(working_dir="/home/user_b", container_image="a")
def do_b():
@workflow
def wf():
do_a()
do_b()
k
?
In imagespec? Or dockerfile
v
pardon updated the the message
it would be fine if you could that via imagespec
k
The problem with putting it there is we cannot guarantee that dir 1. In local and 2. in docker images it’s harder to change as you have to update code
This is why it should be available in every cli
Package run and register
v
I understand the issue with local. But would it be possible to set it for a container image. Since I set the container image I also know if the directory exist in the docker image or not. (and the default does not exist in many of ours.) I could imagen:
@task(container_working_dir="/home/a", container_image="a")
but also
@task(container_image=ImageSpec(working_dir="/home/a", base_image="a"))
I may miss some understanding, but the downside of the CLI is: • How do I set different working_dirs for task_a and task_b inside the same workflow? • The working_dir depends on the "env" (local or docker image) you execute it and therefore should also be specified where your env is specified. Or people would need to also type in the working dir for every task on the CLI.
k
@Vitali you are right
i think maybe a better ux is
Copy code
@task(container_image=Container(image="....", working_dir="..."))
def foo():
  ...
As this is more extensible and it is obvious you are controlling working dir
though i really hope we can eventually move most folks to imagespec
take this pain away
@Vitali if you agree, with the ux can you file an issue
v
@Ketan (kumare3) thanks! Here is the link to the issue: https://github.com/flyteorg/flyte/issues/4638
k
Actually I had some conversations with the team, would installing in the worksite solve the problem
Can we not simply set the right workdir in docker and then let it install in the right way
This way the code remains relatively error proof
@Vitali
v
Good point. I think this should work for everybody
k
Ok then I will just make the default as current dir • awesome 👏
v
@Ketan (kumare3) and @Eduardo Apolinario (eapolinario) since the ticket was closed, I wanted to understand what are the next steps to resolve the described issue? Do have another ticket for this? Or do I just miss howto implement it on our side?
k
Ohh sorry never realized it was closed, let me check if we changed the default
I will follow up
v
@Ketan (kumare3) Any updates?
k
It will be part of next flytekit release.