Search code examples
python-3.xprefect

Prefect Server: No Tenant Found


I am attempting to spin up a Prefect Agent, in order to complete the setup with a Prefect Server. Rather than using prefect server start for out-of-the-box setup, I used prefect server config to generate the Docker Compose file and then docker compose up to spin up the server's services. When I tried to start the Agent, I got the following error:

prefect.utilities.exceptions.ClientError:
[{'message': 'No tenant found.', 
  'locations': [{'line': 2, 'column': 5}], 
  'path': ['register_agent'], 
  'extensions': {
    'code': 'INTERNAL_SERVER_ERROR', 
    'exception': {'message': 'No tenant found.'}
  }
}]

How do I fix this?


Solution

  • Using the Prefect CLI: prefect backend server, then prefect server create-tenant -n default

    Using Prefect Server GraphQL API, as done in the Prefect source code:

    tenant_info = self.graphql(
                {
                    "mutation($input: create_tenant_input!)": {
                        "create_tenant(input: $input)": {"id"}
                    }
                },
                variables=dict(input=dict(name=name, slug=slug)),
            )