Hi, I'm completely new to prefect, I'm currently t...
# prefect-azure
p
Hi, I'm completely new to prefect, I'm currently testing it as a way to run simple pipelines on azure container instances. I'm currently trying to run a snippet from the azure tutorial
Copy code
from prefect import flow, get_run_logger, task


@task
def log_hello(name="Marvin"):
    logger = get_run_logger()
    logger.info(f"{name} said hello!")
    return name


@flow
def log_hello_flow():
    for name in ["Marvin", "Alice", "Bob"]:
        log_hello(name)


if __name__ == "__main__":
    # log_hello_flow.deploy(
    #     name="local-deployment",
    #     work_pool_name="local-docker-pool",
    #     image="localhost:5000/prefect-test",
    # )

    log_hello_flow.deploy(
        name="my-first-aci-deployment",
        work_pool_name="my-aci-work-pool",
        image="XXX.azurecr.io/prefect-test",
    )
now when I run it with the local docker pool (commented out section) it seems to be working fine. But when I try to run it on ACI I'm getting
Copy code
Completed submission of flow run '9a62b3a4-c7ff-4d28-96b5-9769694a03d9'
15:25:21.332 | INFO    | prefect.worker.azure-container-instance.azurecontainerworker 4378b7ad-b02b-4c43-b1b9-0b8609a74da9 - AzureContainerInstanceJob 'AzureContainerWorker 4378b7ad-b02b-4c43-b1b9-0b8609a74da9': Container deleted.
15:25:21.374 | INFO    | prefect.flow_runs.worker - Reported flow run '9a62b3a4-c7ff-4d28-96b5-9769694a03d9' as crashed: Flow run infrastructure exited with non-zero status code 1.
The run ends up in a failed state, but I can't find any more info on the issue, neither in prefect nor in azure. On azure activity log I see no failed tasks, the only seeming relevant information there is the following. So the credentials seem fine, as it responds to flow run by creating some container groups but that's it. The image got pushed to ACR as I see it listed there.
I should also add that I'm rather new to azure as well 😉
k
did you build the docker image you're using on your own computer?
p
yes
k
are you on an m1/2/3/4 mac?
p
nope
k
hm so no ARM cpu?
p
no, Intel
k
sometimes I see this when there's a mismatch between the build platform and exec platform
p
sounds plausible but the architecture seems compatbile
k
yeah that doesn't seem like the issue
p
I noticed the instance gets created, but I don't see any logs there, and then it just dies and disappears.
k
maybe it's related to pulling the image from ACR?
💡 1
p
so I managed to access container logs
Copy code
File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 372, in handle_async_request
    with map_httpcore_exceptions():
  File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: All connection attempts failed
An exception occurred.
so it starts, and runs the prefect process, but fails at connecting to something (prefect server? does it require access to the prefect server?)
k
you're using prefect cloud, right?
p
nope, so that's probably the issue 😅
I just started a local instance of the server, I guess this is not the way its intended to be set up
I might have missed the fundamental assumption of the server being accessible by the workers...
k
yeah, there's no way that ACI is going to be able to talk to your self-hosted server just like that
p
there went a few hours of my life 😄
ok, I'll have to figure out how to make it work, I guess I'll have to run the server on some sort of VM on azure...
k
I would definitely go make a free prefect cloud account if you're interested in getting code running on azure ASAP
p
ok, I will check it out
k
we have this guide for use in conjunction with prefect cloud that should get you going! https://docs.prefect.io/latest/integrations/prefect-azure/aci_worker/
👍 1
l
Hi @Paweł Biernat, I'm curious how you access the container logs in Azure? Since the container only exist temporarily I'm now refreshing the logs page in the Azure portal, which is a very tedious task... I'm doing this because not all container logs are visible in the Prefect UI, only the last error message.
k
if you're using the latest version of the ACI worker, there's an option on the work pool to keep the instance after the flow run is finished
l
That sounds great, where can I find this option? I can't find it in the base job template
Ah wait, I'm using a push pool by the way. Is this option also available for push pool?
k
ah it isn't, at least not yet
p
I was able to inspect the logs even for some time after the containers died with
Copy code
az container logs --resource-group <rg-name> --name <container-name>
You can list the active containers with
Copy code
az container list --resource-group <rg-name> --output table
For some reason I still see some of the containers I created a few days ago (all terminated).
l
@Paweł Biernat Thanks! 🙌