https://flyte.org logo
#ask-the-community
Title
# ask-the-community
a

Arshak Ulubabyan

09/30/2022, 8:34 AM
Hi, I have a question: Is there a way from within a task code execution to retrieve information on under what domain & project is it running. on? E.g. I have Development/Staging/Production domains, and when I run the workflow, I want task to load configs for the right environment.
n

Nick Müller (MorpheusXAUT)

09/30/2022, 9:50 AM
I'm not sure off the top of my head if flytekit offers the info as well, but you should be able to read it from the env variables of your container
there's a few being set:
Copy code
FLYTE_INTERNAL_DOMAIN
FLYTE_INTERNAL_EXECUTION_DOMAIN
FLYTE_INTERNAL_EXECUTION_ID
FLYTE_INTERNAL_EXECUTION_PROJECT
FLYTE_INTERNAL_EXECUTION_WORKFLOW
FLYTE_INTERNAL_NAME
FLYTE_INTERNAL_PROJECT
FLYTE_INTERNAL_TASK_DOMAIN
FLYTE_INTERNAL_TASK_NAME
FLYTE_INTERNAL_TASK_PROJECT
FLYTE_INTERNAL_TASK_VERSION
FLYTE_INTERNAL_VERSION
should probably be able to grab the info from there
r

Robin Eklund

09/30/2022, 12:07 PM
@Nick Müller (MorpheusXAUT) is this documented somewhere? Was wondering specifically about the difference between
FLYTE_INTERNAL_DOMAIN
and
FLYTE_INTERNAL_EXECUTION_DOMAIN
s

Samhita Alla

09/30/2022, 12:11 PM
@Arshak Ulubabyan, you can use
flytekit.current_context().execution_id.project
construct to retrieve project; same for domain.
n

Nick Müller (MorpheusXAUT)

09/30/2022, 12:11 PM
I figured there'd the something less hacky than reading env vars 😅
I'm not aware of any public documentation regarding those env vars, since I believe they're just used for flytekit/flyte's internal components, but @Samhita Alla might be able to confirm that
s

Samhita Alla

09/30/2022, 12:21 PM
Yeah, the env variables haven’t been documented.
difference between
FLYTE_INTERNAL_DOMAIN
and
FLYTE_INTERNAL_EXECUTION_DOMAIN
I don’t think
FLYTE_INTERNAL_DOMAIN
exists anymore. It got to be the latter var.
n

Nick Müller (MorpheusXAUT)

09/30/2022, 12:22 PM
both seem to existing on a recently created container in one of our flyte namespaces, but the former one is probably deprecated
b

Bernhard Stadlbauer

09/30/2022, 1:14 PM
@Robin Eklund I’m not 100% certain, but I believe
FLYTE_INTERNAL_DOMAIN
will point to the domain the task was registered to, whereas
FLYTE_INTERNAL_EXECUTION_DOMAIN
will point to the domain the task is running in. This makes a difference in case you run a task “by reference” (docs) where you can e.g. run a task which was registered to
production
within the
development
domain
r

Robin Eklund

09/30/2022, 1:17 PM
Thanks for the explanation @Bernhard Stadlbauer
k

Ketan (kumare3)

09/30/2022, 1:46 PM
Please use the context
And we should document it cc @Niels Bantilan can we add it to wd-40
81 Views