Hi, I have a question: Is there a way from within ...
# ask-the-community
a
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
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
@Nick Müller (MorpheusXAUT) is this documented somewhere? Was wondering specifically about the difference between
FLYTE_INTERNAL_DOMAIN
and
FLYTE_INTERNAL_EXECUTION_DOMAIN
s
@Arshak Ulubabyan, you can use
flytekit.current_context().execution_id.project
construct to retrieve project; same for domain.
n
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
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
both seem to existing on a recently created container in one of our flyte namespaces, but the former one is probably deprecated
b
@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
Thanks for the explanation @Bernhard Stadlbauer
k
Please use the context
And we should document it cc @Niels Bantilan can we add it to wd-40
235 Views