https://prefect.io logo
Title
p

Paco Ibañez

08/19/2022, 9:28 PM
Hello, what is the correct way to create a deployment for a flow so that the flow code gets uploaded to remote storage? I have seen examples using
packager
or
storage
arguments but none of them are working for me.
deployment = Deployment.build_from_flow(
    name="docker-example",
    flow=my_docker_flow,
    packager=FilePackager(filesystem=RemoteFileSystem.load('minio-docker')),
    # storage_block=RemoteFileSystem.load('minio-docker'),
    infrastructure=DockerContainer(
        image = 'prefect-orion:2.1.1',
        image_pull_policy = 'IF_NOT_PRESENT',
        networks = ['prefect'],
        env = {
            "USE_SSL": False,
            "AWS_ACCESS_KEY_ID": "blablabla",
            "AWS_SECRET_ACCESS_KEY": "blablabla",
            "ENDPOINT_URL": '<http://minio:9000>',
        }
    ),
)
deployment.apply()
With the above code the deployment is created but the flow is not uploaded to minio
i

Ilya Galperin

08/19/2022, 9:37 PM
Hey Paco - I don’t think that packager is supported in 2.0 anymore unless i’m mistaken. The way we package our code is by creating a storage block for it then referencing that storage block in the Deployment object i.e.
from prefect.deployments import Deployment
from prefect.filesystems import S3
from my_project.flow import entrypoint

# creating the storage block
block = S3(bucket_path="cdp-prefect-storage/flows", aws_access_key=aws_access_key, aws_secret_access_key=aws_secret_access_key)
block.save("default-block", overwrite=True)

# building the deployment
deployment = Deployment.build_from_flow(
    flow=entrypoint,
    name="my_deployment",
    work_queue_name="default",
    storage=S3.load("default-block"),
    infrastructure=infrastructure,
)
🙌 1
👍 1
p

Paco Ibañez

08/20/2022, 1:29 PM
thank you! I can see my flow is uploaded to minio! now I need to figure out how to get the
DockerContainer
infrastructure to load the flow from minio