Andre Muraro
08/25/2021, 7:02 PMprefect register --project "some-project" --path flows/some_flow.py
my flow will get registered using the entire path(/workspaces....) . My agent searches for flows at ~/.prefect/flows, so I get a "Failed to load and execute Flow's environment" error.
At the same time, even though I did not specify any labels, and there's no reference to any label whatsoever in any part of the source code, that flow gets created with one label that looks like an id of some sort (ie. 447c6079d9b5).
My local agent is created using: prefect agent local start --name $$(hostname) --no-hostname-label
Both of these issues came up with my latest flow, but I have used the same setup for a few months now without any of these issues. Any idea on what might be going on?Kevin Kho
Local(…,add_default_labels=False)
Kevin Kho
Andre Muraro
08/25/2021, 7:18 PMZanie
Andre Muraro
08/25/2021, 8:09 PMstorage=Local(add_default_labels=False)
has indeed solved the label issue. However I'm still getting the flow environment issue. Seems to be mapping the full path, instead of the relative path as previouslyKevin Kho
directory
where to create and look for the Flow. Docs hereKevin Kho
path
argument there to specify where to save itKevin Kho
Andre Muraro
08/25/2021, 8:33 PMKevin Kho
flow.register()
and using the CLI for registration. Will ask the team about this, but I think that is why your behavior changed. Where you using flow.register()
before instead of the CLI?
For your setup, sorry trying to understand but am still a bit unclear. You are saying that the server ~/.prefect
maps to your development path -_/vscode/home/.prefect
,_ which means you can’t specify the directory because the two paths are not the same?
And then after trying that, you tried to register from the server to a local path on the server but that’s when you got the permission error?Zanie
Andre Muraro
08/25/2021, 9:09 PMZanie
validate=False
to your Local
storage so the user path is not expanded on registrationZanie
~
anywhere else so I'm not sure this will work / I'm not sure how it worked before if you were using a path relative to your homedir.Andre Muraro
08/25/2021, 9:20 PMLocal(directory='~/.prefect', add_default_labels=False, validate=False)
and
Local(path='~/.prefect/flows/some_flow.py', add_default_labels=False, validate=False, stored_as_script=True)
Both resulted in:
Failed to load and execute Flow's environment: ModuleNotFoundError("No module named '~/'")
Zanie
Andre Muraro
08/25/2021, 9:47 PMZanie
Zanie
~
and things should work as you want.Andre Muraro
08/25/2021, 9:58 PMLocal(directory='.prefect', add_default_labels=False)
State Message:
Failed to load and execute Flow's environment: ModuleNotFoundError("No module named '/workspaces/prefect-dev/'")
That mapped to my working directory in the dev machine...Zanie
Andre Muraro
08/25/2021, 10:03 PMLocal(directory='.prefect', add_default_labels=False, validate=False)
State Message:
Failed to load and execute Flow's environment: TypeError("the 'package' argument is required to perform a relative import for '.prefect/extracao-spw-fi/2021-08-25t22-02-17-252954-00-00'")Zanie
os.path.isfile(".prefect/extracao-spw-fi/2021-08-25t22-02-17-252954-00-00")
returned False
so it tried to load it as a moduleZanie
Zanie
/flows
part?Andre Muraro
08/25/2021, 10:09 PMLocal(directory='.prefect/flows', add_default_labels=False, validate=False)
State Message:
Failed to load and execute Flow's environment: TypeError("the 'package' argument is required to perform a relative import for '.prefect/flows/extracao-spw-fi/2021-08-25t22-06-04-588590-00-00'")
trying just Local(directory='flows', add_default_labels=False, validate=False)
yielded an error during registration, instead of flow run time:
Traceback (most recent call last):
File "/usr/local/pip-global/bin/prefect", line 8, in <module>
sys.exit(cli())
File "/usr/local/pip-global/click/core.py", line 829, in call
return self.main(*args, **kwargs)
File "/usr/local/pip-global/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/pip-global/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/pip-global/click/core.py", line 1236, in invoke
return Command.invoke(self, ctx)
File "/usr/local/pip-global/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/pip-global/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/pip-global/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/pip-global/prefect/cli/build_register.py", line 65, in inner
return func(*args, **kwargs)
File "/usr/local/pip-global/prefect/cli/build_register.py", line 827, in register
register_internal(
File "/usr/local/pip-global/prefect/cli/build_register.py", line 551, in register_internal
stats += build_and_register(
File "/usr/local/pip-global/prefect/cli/build_register.py", line 447, in build_and_register
prepare_flows(flows, labels)
File "/usr/local/pip-global/prefect/cli/build_register.py", line 320, in prepare_flows
flow.storage.add_flow(flow)
File "/usr/local/pip-global/prefect/storage/local.py", line 141, in add_flow
os.makedirs(os.path.dirname(flow_location), exist_ok=True)
File "/usr/local/lib/python3.9/os.py", line 225, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: 'flows/extracao-spw-fi'Zanie
Andre Muraro
08/25/2021, 10:12 PMZanie
directory=".prefect"
your flow would be written to a path relative to where you called the CLI e.g. ./.prefect/flow.pkl
Zanie
Zanie
Andre Muraro
08/25/2021, 10:20 PMLocal(path='flows/fiim/extrair_cvm.py', add_default_labels=False, validate=False, stored_as_script=True)
Although I'm still confused as to why that worked fine without even instantiating a Local object at all and now suddenly it didn't work...Zanie
Zanie
Zanie
prefect register flow
vs prefect register
?Andre Muraro
08/25/2021, 10:21 PMprefect register --project "Automações" -p flows/fiim/extrair_cvm.py
Zanie
prefect register flow
) calls flow.register()
and does not always resolve paths to absolute paths. The new one resolves to absolute paths unless you define a Local
storage explicitly. I presume you switched to the new one recently since they're similar? Otherwise I can't think of a way it would have worked before.Andre Muraro
08/25/2021, 10:25 PMZanie