https://prefect.io logo
#prefect-community
Title
# prefect-community
y

yu zeng

07/18/2022, 5:30 AM
hi, i call a create_flow_run task on prefect server, but got "ValueError: You have not set an API key for authentication"
1
here is my code and response
Copy code
with Flow("m20m30_trigger_daily",storage = STORAGE) as flow:
    flow_run = create_flow_run(flow_name="epl",
                               project_name="epl",
                               parameters={"param-key":  {
                                "config": "base",
                                "cus_config": {},
                                "dataset_name": "eftp_m20_0701_0716_no_sensor_tiny_400",
                                "run_checker": 0,
                                "run_labeling": 0,
                                "run_tagging": 0,
                                "tags": "eftp_m20_0701_0716_no_sensor_tiny_400"
                                } })
Copy code
Task 'create_flow_run': Exception encountered during task execution!
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/prefect/engine/task_runner.py", line 884, in get_task_run_state
    logger=self.logger,
  File "/opt/conda/lib/python3.7/site-packages/prefect/utilities/executors.py", line 468, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.7/dist-packages/prefect/tasks/prefect/flow_run.py", line 167, in create_flow_run
  File "/opt/conda/lib/python3.7/site-packages/prefect/client/client.py", line 1008, in get_cloud_url
    tenant_slug = self.get_default_tenant_slug()
  File "/opt/conda/lib/python3.7/site-packages/prefect/client/client.py", line 1035, in get_default_tenant_slug
    if tenant.id == self.tenant_id:
  File "/opt/conda/lib/python3.7/site-packages/prefect/client/client.py", line 271, in tenant_id
    self._tenant_id = self._get_auth_tenant()
  File "/opt/conda/lib/python3.7/site-packages/prefect/client/client.py", line 162, in _get_auth_tenant
    raise ValueError("You have not set an API key for authentication.")
ValueError: You have not set an API key for authentication.
a

Anna Geller

07/18/2022, 10:41 AM
You need to switch your backend to Server:
Copy code
prefect backend server
check this page with resources on troubleshooting Server issues https://discourse.prefect.io/t/troubleshooting-prefect-server-issues-list-of-resources-you-may-check/1011
a

Arun Giridharan

09/20/2022, 6:29 PM
Hi Anna I'm running into the same issue as yu. I have my PREFECT__BACKEND set to server in a yaml file. And my prefect version is 1.3.1
1
a

Anna Geller

09/20/2022, 6:35 PM
are you getting started with Prefect? if so, I highly recommend Prefect 2 which is the default version of Prefect - you can deploy it using a single command
prefect orion start
- docs: docs.prefect.io
a

Arun Giridharan

09/20/2022, 6:37 PM
I'm not looking at a lift to prefect 2 right now. Is there anything that could be done on prefect 1.3.1?
a

Anna Geller

09/20/2022, 6:51 PM
if you get an error that API key is not set, then setting the backend to server didn't work
I'd try using env variable or one of the ways mentioned in the Discourse topic
5 Views