https://prefect.io logo
Title
t

Thuy Tran

11/25/2022, 4:00 PM
I have a function that has a task decorator:
@task(cache_result_in_memory=False)
But I'm getting the error below that it's an unexpected keyword. Not sure what I'm doing wrong. It's running on prem using version 2.6.9.
Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/prefect/processor.py", line 3, in <module>
    from data_import import data_import_process
  File "/opt/prefect/data_import.py", line 8, in <module>
    from data_cleaning import cleaning_process
  File "/opt/prefect/data_cleaning.py", line 42, in <module>
    @task(cache_result_in_memory=False)
TypeError: task() got an unexpected keyword argument 'cache_result_in_memory'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/engine.py", line 256, in retrieve_flow_then_begin_flow_run
    flow = await load_flow_from_flow_run(flow_run, client=client)
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/client.py", line 103, in with_injected_client
    return await fn(*args, **kwargs)
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/deployments.py", line 69, in load_flow_from_flow_run
    flow = await run_sync_in_worker_thread(import_object, str(import_path))
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/utilities/asyncutils.py", line 57, in run_sync_in_worker_thread
    return await anyio.to_thread.run_sync(call, cancellable=True)
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 193, in import_object
    module = load_script_as_module(script_path)
  File "/opt/conda/envs/prefect/lib/python3.10/site-packages/prefect/utilities/importtools.py", line 156, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at 'processor.py' encountered an exception
1
o

Oscar Björhn

11/25/2022, 4:48 PM
That's really odd! I don't use the flag myself but I got curious and tried it out, seems to work fine here. I'm also on 2.6.9
t

Thuy Tran

11/25/2022, 4:57 PM
Thank you for checking that. What's strange is I don't get that error when testing it locally on my dev machine. But when I deploy it on our test server that uses prefect image 2.6.9-python3.10-conda, I get that error.
o

Oscar Björhn

11/25/2022, 5:01 PM
Is it at all possible that it isn't actually running that image? I'm not sure of what else could be the cause, but I'm still learning when it comes to Python.
t

Thuy Tran

11/25/2022, 5:45 PM
I'm checking now to see if I can confirm if it's using that image.
Ok, I discovered the problem. I had to set the ImagePullPolicy on the docker container to
ALWAYS
. The docker container pulls a custom image (which pulls the prefect image). But since that custom image existed on the server, it wasn't pulling the image that was updated to use the latest prefect version.
🙌 1
o

Oscar Björhn

11/25/2022, 7:20 PM
Oh, makes sense. I haven't dared fiddle with the default ImagePullPolicy settings yet, I will keep this in mind if I do. Glad you managed to solve it!