Identify API endpoint generation from within python function
![Helm](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar18.png)
I have created and deployed end points in the API deployer which use custom python functions.
Within these functions I have built functionality which outputs various information to SQL server.
This all works fine but I would like to save the generation of the end point (e.g. v45) in my logging each time it is called - so my question is how do I find out the generation of the end point from within my code? Is there e.g. an environmental variable or something?
Really I need to create a clear audit trail of the version of the code used to generate a particular record and am using generation as a tag in git to achieve this linkage.
Best Answer
-
Hi @Helm
,You can get the current generation of an API service by checking the DKU_CURRENT_APISERVICE_GENERATION environment variable.
Here's an example Python endpoint that returns the current generation:
import os def api_py_function(): generation = os.environ["DKU_CURRENT_APISERVICE_GENERATION"] return generation
Thanks,
Zach
Answers
-
Works perfectly, many thanks