https://prefect.io logo
#prefect-community
Title
# prefect-community
c

Carlos Cueto

04/14/2022, 4:27 AM
Hi. I'm having an issue using a
LocalRun
flow's
working_dir
parameter. Whenever I specify the following:
flow.run_config = LocalRun(_working_dir_='C:/scripts/GetADUsers', _labels_=["SVRBIPTH01"])
Whenever I register the flow (I'm using Prefect 1.2.0 on MacOS python 3.10) I get the following working_dir on the UI of Prefect Cloud:
/Users/carloscueto/Documents/Python_Scripts/Prefect-Flows/PowerShell/GetADUsers/C:/scripts/GetADUsers
It seems to be adding the path from where I register the script from (on the local machine) to the working_dir string I specified on the run_config. Has anybody encountered this before? Everything works fine when I register the flow from a Windows computer.
1
k

Kevin Kho

04/14/2022, 4:29 AM
This path is more related to storage than RunConfig. Did you define a storage?
Have you seen this ? It’s a bit related. You can also used
stored_as_script=True
and point to the
path
with LocalStorage
a

Anna Geller

04/14/2022, 9:37 AM
Kevin is right, it's mainly about storage. When you register via CLI, you don't even need to specify storage and local run label, you can just do:
Copy code
from prefect import task, Flow


@task(log_stdout=True)
def hello_world():
    print("hello world")


with Flow("hello") as flow:
    hw = hello_world()
then register via CLI:
Copy code
prefect register --project xxx -p hw.py
this will automatically add storage and run config host name labels
c

Carlos Cueto

04/14/2022, 12:51 PM
I also specified storage, just didn't include that line of code in my question. I am using Git storage with stored_as_script=true. Either way, what is really weird is how registering on MacOS causes this issue and when registering in Windows it's all fine.
k

Kevin Kho

04/14/2022, 1:34 PM
I don’t think it’s right to say “registering on MacOS causes the issue”. I think you’ll run into it the other way around as well if you register on Windows and try to run on MacOS
s

Sohail Ali

05/19/2022, 8:39 PM
I encounter similar issue. I register my flow in linux and run in Windows as LocalRun. Working directory path value override my default working_dir value.
k

Kevin Kho

05/19/2022, 8:42 PM
Is it the working directory that is overriden or storage? Can I see your storage definition?
s

Sohail Ali

05/19/2022, 8:45 PM
flow_storage = Git( repo="MYORG/DataBI/_git/ProcessTabular", flow_path="./tabular_flow.py", repo_host="MYORG@dev.azure.com", branch_name="main", git_clone_url_secret_name="processtabular_git_url" ) with Flow("ProcessTabular", executor=LocalDaskExecutor(scheduler="threads"), result=LocalResult(), storage=flow_storage, run_config=LocalRun(working_dir="C:/prefect/agent") ) as flow:
k

Kevin Kho

05/19/2022, 8:47 PM
Ah and then what your working dir become?
s

Sohail Ali

05/19/2022, 8:48 PM
k

Kevin Kho

05/19/2022, 8:49 PM
Ah man I see yes this is an issue. Could you open one on Github with what you’ve showed me?
s

Sohail Ali

05/19/2022, 8:58 PM
Issue#5810
k

Kevin Kho

05/19/2022, 8:59 PM
Thank you so much!
43 Views