Hey all! We recently subscribed to the pro plan to...
# ask-community
c
Hey all! We recently subscribed to the pro plan to migrate some infra onto Prefect. We're having some trouble setting up work pools with modal push at the moment. Our flow runs crash without logging despite having our work pool configured ready
j
hey, do you seen anything in the modal logs that would indicate what's going wrong? The
prefect.flow_runs
logger indicates that the modal container at least began to run your flow, but might have crashed while trying to download your code?
c
Ah yes, I get a file not found error. How can I import the relevant files + env setup to modal? Can I do that in my deployment specification in python?
Copy code
backfill_comppany_table_aggregated_deployment = backfill_company_table_aggregated.to_deployment(
        name="backfill-company-table-aggregated",
        tags=["companies"],
        cron="0 1 * * *",
        description="Backfill the company table in both DB and Vespa. This flow calls the add-companies-to-vespa flow.",
        work_pool_name="default-modal-pool",
    )
...
serve(
     backfill_comppany_table_aggregated_deployment, ...)
j
if your code is in an image, you can specify that image on your modal work pool or you can define a pull step: https://docs.prefect.io/3.0/deploy/infrastructure-concepts/prefect-yaml#the-pull-action so that your code is pulled from github or a storage location at runtime
c
Thanks. That's super helpful. Currently do you have an integration for environment variables with doppler?
j
Prefect does not unfortunately. Could you tell me a little more about when the doppler env vars would be needed? it for downloading the code at runtime?
c
yes exactly 🙂 Would be great if we could push to different modal environments depending on the git branch and pull in the respective doppler env variables on modal
for instance we have ~300 env variables that frequently change. How/where would you recommend syncing that to?
Thanks for helping our Jake. One other question. I'm getting a connection error one the code below:
Copy code
backfill_company_table_aggregated.deploy(
        name="backfill-company-table-aggregated",
        tags=["companies"],
        cron="0 8 * * *",
        description="Backfill the company table in both DB and Vespa. This flow calls the add-companies-to-vespa flow.",
        work_pool_name="default-modal-pool",
        image="prefect:dev",
        # push=False,
    )
    add_companies_to_vespa.deploy(
        name="add-companies-to-vespa",
        tags=["companies", "vespa"],
        cron="0 8 * * *",
        description="Add companies to Vespa.",
        work_pool_name="default-modal-pool",
        image="prefect:dev",
        # push=False,
    )
Copy code
Traceback (most recent call last):
  File "/Users/charlesliu/Developer/endex/backend/src/endex/prefect/deploy.py", line 12, in <module>
    backfill_company_table_aggregated.deploy(
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 392, in coroutine_wrapper
    return run_coro_as_sync(ctx_call())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 243, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 312, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 182, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/.pyenv/versions/3.12.4/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/_internal/concurrency/calls.py", line 383, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 225, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 382, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/flows.py", line 1199, in deploy
    deployment_ids = await deploy(
                     ^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/asyncutils.py", line 382, in ctx_call
    result = await async_fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/deployments/runner.py", line 879, in deploy
    image.build()
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/docker/docker_image.py", line 70, in build
    build_image(**build_kwargs)
  File "/Users/charlesliu/.pyenv/versions/3.12.4/lib/python3.12/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/charlesliu/Developer/endex/.venv/lib/python3.12/site-packages/prefect/utilities/dockerutils.py", line 193, in build_image
    raise BuildError(event["error"])
prefect.utilities.dockerutils.BuildError: Get "<https://registry-1.docker.io/v2/>": dialing registry-1.docker.io:443 container via direct connection because  has no HTTPS proxy: connecting to 34.226.69.105:443: dial tcp 34.226.69.105:443: connect: network is unreachable
Do you recognize this?
p
Thanks for the help Jake! Do you have a pointer for what baking our code into an image looks like? Do we just define a Dockerfile that copies in our code + requirements, and then when we do
deploy
that'll build the appropriate image for modal?
j
You can configure your deployment with a build step to build an image. You'll need to update your modal work pool to reference that image's tag though. If you don't want to build an image, you can always pull your code from source at runtime. The error you're getting above seems to be because dockerhub is not reachable from wherever you are executing?
c
Thanks a ton help the help Jake. Another thing:
Copy code
backfill_company_table_aggregated.deploy(
        name="backfill-company-table-aggregated",
        tags=["companies"],
        cron="0 8 * * *",
        description="Backfill the company table in both DB and Vespa. This flow calls the add-companies-to-vespa flow.",
        work_pool_name="default-modal-pool",
        image=DockerImage(
            name="charlesendex/endex", tag="dev", dockerfile="auto", timeout=1200
        ),
        # push=False,
    )
    add_companies_to_vespa.deploy(
        name="add-companies-to-vespa",
        tags=["companies", "vespa"],
        cron="0 8 * * *",
        description="Add companies to Vespa.",
        work_pool_name="default-modal-pool",
        image=DockerImage(
            name="charlesendex/endex", tag="dev", dockerfile="auto", timeout=1200
        ),
        # push=False,
    )
I'm getting a configuration issue with Modal now