Emerson Franks

09/07/2022, 11:40 PM
Hello, I recently upgraded my package from 2.2.0 -> 2.3.2. When attempting to run a deployment build command that worked on 2.2.0, I am now getting the error in my following reply. If I go back to 2.2.0 things work fine. My flow is just the health_check that is in documentation. Did I miss a step when upgrading the package?
👀 1
$ prefect deployment build -n health_check -t kubernetes -i kubernetes-job -sb azure/logblock -o health_check_20220907 --override image=<|> --override namespace=aug2022 --interval=300 -q kubernetes
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 "C:\repos\RecNetDP.Orchestration\flows\", line 5, in <module>
  File "C:\Python310\lib\site-packages\prefect\utilities\", line 198, in wrapper
    raise RuntimeError(
RuntimeError: A 'sync_compatible' method was called from a context that was previously async but is now sync. The sync call must be changed to run in a worker thread to support sending the coroutine for 'load' to the main thread.

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

Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\prefect\cli\", line 41, in wrapper
    return fn(*args, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\", line 212, in wrapper
    return run_async_in_new_loop(async_fn, *args, **kwargs)
  File "C:\Python310\lib\site-packages\prefect\utilities\", line 141, in run_async_in_new_loop
    return, *args, **kwargs))
  File "C:\Python310\lib\site-packages\anyio\_core\", line 70, in run
    return, *args, **backend_options)
  File "C:\Python310\lib\site-packages\anyio\_backends\", line 292, in run
    return native_run(wrapper(), debug=debug)
  File "C:\Python310\lib\asyncio\", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python310\lib\asyncio\", line 646, in run_until_complete
    return future.result()
  File "C:\Python310\lib\site-packages\anyio\_backends\", line 287, in wrapper
    return await func(*args)
  File "C:\Python310\lib\site-packages\prefect\cli\", line 494, in build
    flow = prefect.utilities.importtools.import_object(entrypoint)
  File "C:\Python310\lib\site-packages\prefect\utilities\", line 193, in import_object
    module = load_script_as_module(script_path)
  File "C:\Python310\lib\site-packages\prefect\utilities\", line 156, in load_script_as_module
    raise ScriptError(user_exc=exc, path=path) from exc
prefect.exceptions.ScriptError: Script at '' encountered an exception
An exception occurred.
import prefect
from prefect import task, flow, get_run_logger
from prefect.filesystems import Azure


def log_platform_info():
    import platform
    import sys
    from prefect.orion.api.server import ORION_API_VERSION

    <|>(f"Host's network name: {platform.node()}")
    <|>(f"Python version: {platform.python_version()}")
    <|>(f"Platform information (instance type): {platform.platform()}")
    <|>(f"OS/Arch: {sys.platform} {platform.machine()}")
    <|>(f"Prefect Version: {prefect.__version__}")
    <|>(f"Prefect API Version: {ORION_API_VERSION}")

def health_check():

if __name__ == "__main__":
prefect deployment build -n health_check -t kubernetes -i kubernetes-job -sb azure/logblock -o health_check_20220907 --override image=${acr} --override namespace=aug2022 --interval=300 -q kubernetes
So apparently it was the Azure.load call causing the issue, removing that gets rid of the exception. Should I not be making this call in 2.3+?


09/09/2022, 8:28 PM
I am having the same issue with GCS, it looks like there is a ticket open but not sure on the resolution:
I fixed it by moving the GCS block inside the Flow
🙌 1

Emerson Franks

09/14/2022, 7:54 PM
Thanks @Keith! That fixes the Azure version as well!
👍 2


09/21/2022, 11:55 AM
So basically, don’t you need the part az_block = Azure.load(“blockName”) in the code if you have it in the prefect build command? What if I want all my build parameters part of the code and nothing in the cli line?