Hello guys, so we are migrating our stack to prefe...
# ask-community
r
Hello guys, so we are migrating our stack to prefect 3.0 and we encountered some issues. We had a some flow that were run on process infrastructure with some queue prioritisation. But right now I cannot pass queue_name or pool_name to
.serve()
method of the Flow, while on
deploy()
I am required to pass the image which is not supported by process type queues… Am I missing something here? How can I automatically register Deployment from flow that would go to specific work pool similar to.
Copy code
await Deployment.build_from_flow(
                    flow=flow_setting.flow,
                    name=flow_setting.name,
                    work_queue_name=queue_setting.name,
                    work_pool_name=pool_setting.name,
                    skip_upload=True,
                    apply=True,
                    version=flow_setting.version,
                    schedules=[CronSchedule(cron=flow_setting.cron)] if flow_setting.cron else None,
                )
n
hi @Rafał Bielicki
Copy code
from pathlib import Path

from prefect import flow


@flow
def hello_world():
    print("Hello, World!")


if __name__ == "__main__":
    flow.from_source(
        source=str(Path(__file__).parent.resolve()),
        entrypoint="deploy_process.py:hello_world",
    ).deploy(
        name="hello-world", work_pool_name="local", build=False, ignore_warnings=True
    )
this might be helpful, in particular here I: • use
from_source
to define where to get my code at runtime (this file in this case) • pass
build=False
more examples in the docs
r
Thank you! Will try that 🙂
catjam 1
I have another one 😄 Now that we have everything registered, some of the flows need to run other serivces deployment.
Copy code
Until now we did this by running run_deployment but now I keep getting an error File /usr/local/lib/python3.11/site-packages/httpx/_client.py:1585, in AsyncClient.request(self, method, url, content, data, files, json, params, headers, cookies, auth, follow_redirects, timeout, extensions)
   1570     warnings.warn(message, DeprecationWarning)
   1572 request = self.build_request(
   1573     method=method,
   1574     url=url,
   (...)
   1583     extensions=extensions,
   1584 )
-> 1585 return await self.send(request, auth=auth, follow_redirects=follow_redirects)

File /usr/local/lib/python3.11/site-packages/prefect/client/base.py:361, in PrefectHttpxAsyncClient.send(self, request, *args, **kwargs)
    358 response = PrefectResponse.from_httpx_response(response)
    360 if self.raise_on_all_errors:
--> 361     response.raise_for_status()
    363 return response

File /usr/local/lib/python3.11/site-packages/prefect/client/base.py:174, in PrefectResponse.raise_for_status(self)
    172     return super().raise_for_status()
    173 except HTTPStatusError as exc:
--> 174     raise PrefectHTTPStatusError.from_httpx_error(exc) from exc.__cause__

PrefectHTTPStatusError: Client error '409 Conflict' for url '<http://prefect_server:4200/api/deployments/effbc2e1-997e-4414-bcfa-1d0a4d120aac/create_flow_run>'
Response: {'detail': "Error creating flow run: Validation failed. Failure reason: 'period_seconds' is a required property"}
For more information check: <https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409>
Seems like
run_deployment
function wasn’t updated to new server contract.
Or am I missing something again xD
@Nate any ideas?
Was my mistake ;d