Mathijs Carlu
07/15/2022, 9:00 AMprefect deployment create file.py
the deployment gets created.
Now, when I modify the flow a little (flow name stays the same), change the deployment name and then re-execute the above command, a new deployment is created. This deployment points at the same flow object (flow_id is the same for both). However, both deployments execute different code, 'different versions of the same flow' if you will, although this 'version number' is not saved anywhere (I think).
This all is due to the fact that the location of the flow code (flow_data) is saved with the deployment, and not with the flow, which seems a little counterintuitive for me. If I see 2 flow runs in the UI that executed the same flow, I would expect them to have executed the same code.Anna Geller
07/15/2022, 10:43 AMimport prefect
from prefect import task, flow
from prefect import get_run_logger
from prefect_dataops.deployments import deploy_to_s3
@task
def say_hi():
logger = get_run_logger()
<http://logger.info|logger.info>("Hello from the Health Check Flow! 👋")
@task
def log_platform_info():
import platform
import sys
from prefect.orion.api.server import ORION_API_VERSION
logger = get_run_logger()
<http://logger.info|logger.info>("Host's network name = %s", platform.node())
<http://logger.info|logger.info>("OS/Architecture = %s/%s", sys.platform, platform.machine())
<http://logger.info|logger.info>("Platform information (instance type) = %s 💻", platform.platform())
<http://logger.info|logger.info>("Python version = %s", platform.python_version())
<http://logger.info|logger.info>("Prefect version = %s 🚀", prefect.__version__)
<http://logger.info|logger.info>("Prefect API version = %s", ORION_API_VERSION)
@flow
def healthcheck():
hi = say_hi()
log_platform_info(wait_for=[hi])
and a separate deployment file pointing to that flow:
from prefect.deployments import FlowScript, Deployment
Deployment(
name="manual",
flow=FlowScript(path="flows/healthcheck.py", name="healthcheck"),
)
after creating deployment and running it, at first this will fail because the prefect_dataops doesn't exist - see first image
then I comment out this line with bad import and without having to redeploy, it works because deployment using FlowScript is just a pointer to the flow script and flow object - image 2prefect deployment inspect flowname/deployname
Mathijs Carlu
07/18/2022, 9:09 AMThis deployment points at the same flow object (flow_id is the same for both). However, both deployments execute different codeHere, assume I create a deployment "DeploymentA" for a flow "abc". Then, one of my colleagues creates a deployment "DeploymentB" for a completely different flow, but he also calls it "abc". Both deployments would execute the flow code that was intended, i.e. DeploymentA executes my code and DeploymentB my colleagues' code. However, flow-runs from both deployments point at exactly the same flow_id in the database, and thus in the UI it seems like both execute the same code. But, that isn't the case actually. Does that make any sense?
Anna Geller
07/18/2022, 11:15 AMDeployment(
name="xxx",
flow=hello,
flow_runner=KubernetesFlowRunner(...),
packager=OrionPackager(serializer=ImportSerializer()),
)
Mathijs Carlu
07/18/2022, 11:19 AM