Hey team i am getting this error while deploying f...
# ask-community
s
Hey team i am getting this error while deploying flows using prefect-docker
Copy code
stacktrace is in thread
👍 1
Has anyone seen this before?
n
@Sagar Arora please move your stack trace to the thread
s
oh sorry will do that
🙏 1
Copy code
Running deployment build steps...
 > Running run_shell_script step...
 > Running build_docker_image step...
Collecting prefect-docker==0.3.1
  Downloading prefect_docker-0.3.1-py3-none-any.whl (24 kB)
Requirement already satisfied: pyasn1<0.7.0,>=0.4.6 in ./.venv/lib/python3.11/site-packages (from pyasn1-modules>=0.2.1->google-auth>=1.0.1->kubernetes<30.0.0,>=24.2.0->prefect>=2.10.7->prefect-docker==0.3.1) (0.6.0)
Installing collected packages: prefect-docker
Successfully installed prefect-docker-0.3.1
Notice:  A new release of pip is available: 23.1 -> 24.2
Notice:  To update, run: pip install --upgrade pip
Traceback (most recent call last):
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 154, in run_steps
    step_output = await run_step(step, upstream_outputs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 124, in run_step
    step_func = _get_function_for_step(fqn, requires=keywords.get("requires"))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 91, in _get_function_for_step
    step_func = import_object(fully_qualified_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/importtools.py", line 212, in import_object
    module = load_module(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/importtools.py", line 183, in load_module
    return importlib.import_module(module_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1126, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect_docker/__init__.py", line 2, in <module>
    from .host import DockerHost  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect_docker/host.py", line 28, in <module>
    class DockerHost(Block):
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/main.py", line 282, in __new__
    cls = super().__new__(mcs, name, bases, new_namespace, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen abc>", line 106, in __new__
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/dispatch.py", line 100, in _register_subclass_of_base_type
    register_type(cls)
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/dispatch.py", line 154, in register_type
    key = get_dispatch_key(cls)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/dispatch.py", line 77, in get_dispatch_key
    dispatch_key = dispatch_key()
Unable to load step function: prefect_docker.deployments.steps.build_docker_image. Attempting install of prefect-docker==0.3.1.
An exception occurred.
                   ^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/blocks/core.py", line 315, in __dispatch_key__
    return block_schema_to_key(cls._to_block_schema())
                               ^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/blocks/core.py", line 487, in _to_block_schema
    fields = cls.schema()
             ^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/main.py", line 664, in schema
    s = model_schema(cls, by_alias=by_alias, ref_template=ref_template)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 188, in model_schema
    m_schema, m_definitions, nested_models = model_process_schema(
                                             ^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 581, in model_process_schema
    m_schema, m_definitions, nested_models = model_type_schema(
                                             ^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 622, in model_type_schema
    f_schema, f_definitions, f_nested_models = field_schema(
                                               ^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 248, in field_schema
    s, schema_overrides = get_field_info_schema(field)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 216, in get_field_info_schema
    schema_['default'] = encode_default(field.default)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/schema.py", line 995, in encode_default
    return pydantic_encoder(dft)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/json.py", line 90, in pydantic_encoder
    raise TypeError(f"Object of type '{obj.__class__.__name__}' is not JSON serializable")
TypeError: Object of type 'FieldInfo' is not JSON serializable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/cli/_utilities.py", line 41, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 259, in coroutine_wrapper
    return call()
           ^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 432, in __call__
    return self.result()
           ^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 318, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 179, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 389, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/cli/deploy.py", line 325, in deploy
    await _run_multi_deploy(
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/cli/deploy.py", line 810, in _run_multi_deploy
    await _run_single_deploy(
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/client/utilities.py", line 78, in with_injected_client
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/cli/deploy.py", line 627, in _run_single_deploy
    await run_steps(build_steps, step_outputs, print_function=app.console.print)
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect/deployments/steps/core.py", line 182, in run_steps
    raise StepExecutionError(f"Encountered error while running {fqn}") from exc
prefect.deployments.steps.core.StepExecutionError: Encountered error while running prefect_docker.deployments.steps.build_docker_image
Error: Process completed with exit code 1.
n
this is likely a similar problem to the one addressed in the message I sent above
Copy code
File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/pydantic/v1/json.py", line 90, in pydantic_encoder
    raise TypeError(f"Object of type '{obj.__class__.__name__}' is not JSON serializable")
TypeError: Object of type 'FieldInfo' is not JSON serializable
s
to install extra?
n
basically you likely have 2.x prefect and a 3.x integration, so pydantics are incompatible so yes, if you use the extras to install
prefect[docker]<3
you should get the correct version of your integration
s
got it thanks let me try
n
out of curiosity: are you using
run_shell_script
to
pip install
stuff?
s
no we are using poetry commands
n
sorry, in general i meant, are you using
run_shell_script
to install deps at runtime but it sounds like the answer is yes 👍
1
s
so to do this in poetry i guess in my pyproject.toml file i will replace this
Copy code
prefect-aws = "^0.4.7"
to
Copy code
prefect[aws]<3
n
hmm, on its own
^0.4.7
should keep you under
0.5.0
s
but generally i am asking if i want to replace it
n
what does your pull step look like?
s
you mean docker pull step?
n
nope the one where you're doing poetry stuff
s
so it looks like this
Copy code
- name: Install Poetry
        uses: abatilo/actions-poetry@v2.1.3
        with:
          poetry-version: 1.3.2

      - name: Poetry Install
        run: |
          export POETRY_HTTP_BASIC_CCDE_CODE_ARTIFACTS_USERNAME=aws
          export POETRY_HTTP_BASIC_CCDE_CODE_ARTIFACTS_PASSWORD=$(aws codeartifact get-authorization-token --domain ccde-code-artifacts --domain-owner 271868244475 --query authorizationToken --output text)
          poetry config virtualenvs.in-project true
          poetry install
sorry its in github actions
n
hm so that
Install Poetry
bit is not the pull step, but instead the GHA step before you call
prefect deploy
in CI right?
s
yes sire
n
can you share what you're doing in the
run_shell_script
pull
step that would occur at runtime on the worker (not at deployment time in GHA)?
s
this is what i am doing after that step
Copy code
- name: Authenticate with Prefect
        run: |
          source ./.venv/bin/activate
          prefect cloud login --key ${{ secrets.PREFECT_API_KEY }} --workspace ${{ env.PREFECT_WORKSPACE }}

      - name: Deploy flows
        run: |
          source ./.venv/bin/activate
          prefect --no-prompt deploy --all
n
oh i see, i was thinking the error was occurring in a
pull
step, but its in your
build
step that occurs immediately after running
prefect deploy
okay so the problem is that somehow you have the wrong deps at deployment time how do you have
prefect
itself defined in your
pyproject.toml
s
like this
Copy code
prefect = "2.17.1"
prefect-dask = "0.2.5"
prefect-slack = "0.1.2"
prefect-aws = "^0.4.7"
n
🧐
hrm okay im not sure why this is happening, but here is what's happening
Copy code
File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect_docker/__init__.py", line 2, in <module>
    from .host import DockerHost  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/runner/_work/ccbi-prefect/ccbi-prefect/flows/.venv/lib/python3.11/site-packages/prefect_docker/host.py", line 28, in <module>
    class DockerHost(Block):
this
DockerHost
object is somehow a pydantic basemodel v1 object, which will not play nice with
Block
classes based on pydantic basemodel v2 objects would you be able to add a
run_shell_script
section to your
build
step that
echo
out
prefect version
?
s
yeah sure
n
oh also, in 2.x
prefect version
doesnt show integration versions so maybe
pip list | grep -E 'prefect|pydantic'
instead
s
got it thanks
prefect 2.17.1 prefect-aws 0.4.18 prefect-dask 0.2.9 prefect-dbt 0.4.3 prefect-shell 0.2.5 prefect-snowflake 0.27.6 pydantic 2.9.1 pydantic_core 2.23.3
just fyi