Search code examples
pythonservergraphqlorchestrationprefect

How to deploy flow remotly on Prefect server?


I started working with the Prefect Orchestration tool. My goal is to set up a server managing my automation on different other PCs and servers. I do not fully understand the architecture of Prefect yet (with all these Agents etc.) but I managed to start a server on a remote Ubuntu environment. To access the UI remotely I created a config.toml and added following lines:

[server]
endpoint = "<IPofserver>:4200/graphql"
    [server.ui]
        apollo_url = "http://<IPofserver>:4200/graphql"
[telemetry]
    [server.telemetry]
        enabled = false

The telemetry part is just to disable sending analysis data to Prefect. Afterswards it was possible to accesss the UI from another PC and also to start an Agent on another PC with:

prefect agent local start --api "http://<IPofserver>:4200/graphql"

But how can I deploy flows now? A do not find an option to set their api like for the agent. Even if I try to register a flow on the machine where the server itself is runnig I get following error message:

Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.10/dist-packages/prefect/core/flow.py", line 1726, in register registered_flow = client.register( File "/usr/local/lib/python3.10/dist-packages/prefect/client/client.py", line 831, in register project = self.graphql(query_project).data.project # type: ignore File "/usr/local/lib/python3.10/dist-packages/prefect/client/client.py", line 443, in graphql result = self.post( File "/usr/local/lib/python3.10/dist-packages/prefect/client/client.py", line 398, in post response = self._request( File "/usr/local/lib/python3.10/dist-packages/prefect/client/client.py", line 633, in _request response = self._send_request( File "/usr/local/lib/python3.10/dist-packages/prefect/client/client.py", line 497, in _send_request response = session.post( File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 635, in post return self.request("POST", url, data=data, json=json, **kwargs) File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 587, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 695, in send adapter = self.get_adapter(url=request.url) File "/usr/local/lib/python3.10/dist-packages/requests/sessions.py", line 792, in get_adapter raise InvalidSchema(f"No connection adapters were found for {url!r}") requests.exceptions.InvalidSchema: No connection adapters were found for ':4200/graphql'

Used Example Code:

import prefect
from prefect import task, Flow

@task
def say_hello():
    logger = prefect.context.get("logger")
    logger.info("Hello, Cloud!")

with Flow("hello-flow") as flow:
    say_hello()

# Register the flow under the "tutorial" project
flow.register(project_name="Test")

Solution

  • If you are getting started with Prefect, I'd recommend using Prefect 2.0 - check this documentation page on getting started and this one about the underlying architecture.

    If you still need help with Prefect Server and Prefect 1.0, check this extensive troubleshooting guide and if that doesn't help, send us a message on Slack, and we'll try to help you there.