Hey all! Thanks in advance for your time. Looking ...
# prefect-community
a
Hey all! Thanks in advance for your time. Looking how we can use the python prefect client to access the project name the current flow is being ran under. This is how we will determine which environment our processes are being ran under. We used to have different Tenants for the environments and used the
TenantView
class but for security purposes we now have all environments (projects) under one tenant/team. Appreciate the help!
1
a
Try:
Copy code
prefect.context.get("project_name")
prefect.context.get("project_id")
a
Thank you @Anna Geller for the prompt response!
I am not able to get a return value for those methods. Running the method with other inputs such as
flow_id
and
task_id
return values though.
I don't see those options in the prefect context docs / github code either
a
try calling this from a Flow:
Copy code
import task, Flow, prefect

@task
def some_task():
   print(prefect.context.get("project_name"))
a
It was returning None for me when running locally. I will try to deploy the flow and see what returns when i run it there.
It works when running the flow in the cloud! Thank you for your help @Anna Geller
🙌 1