Can a python script API know which infra it is deployed on?
I'm deploying a python script API that will communicate with another (external) API, made by another department.
Both my team and the other team use separate Test/Acceptance/Production environments.
The url of the other team's API will change depending on the environment it is deployed in.
I'd like to change the url to call from within my Dataiku API depending on the current environment/infra, so both the DS API and the external API can match up through the delivery environments.
Is it possible for a python script API to somehow know which infra it's currently deployed in (through the python public API)? That way I could set up a mapping to the external url to call.
Operating system used: Windows
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker
Hi,
The infra ID is not available from the API endpoint, but you can set you own env variables if these are static API nodes and retrieve via code:import os
# get the value of a specific environment variable
env_var_value = os.environ.get("ENV_VAR_NAME")
Thanks -
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,226 Dataiker
Hi,
For Static API nodes, you can include this in the DATADIR/bin/env-site.sh
by adding a line like :export APINODE_INFRA_ID='your_infra_id'
Thanks