Skip to content
Snippets Groups Projects
Commit 74f6ae6e authored by Yoann Schneider's avatar Yoann Schneider :tennis: Committed by Bastien Abadie
Browse files

Add model version id as worker attribute

parent 3af756ad
No related branches found
No related tags found
1 merge request!307Add model version id as worker attribute
Pipeline #80120 passed
......@@ -198,6 +198,9 @@ class BaseWorker(object):
"'ARKINDEX_CORPUS_ID' was not set in the environment. Any API request involving a `corpus_id` will fail."
)
# Define model_version_id from environment
self.model_version_id = os.environ.get("ARKINDEX_MODEL_VERSION_ID")
# Load all required secrets
self.secrets = {name: self.load_secret(name) for name in required_secrets}
......@@ -258,6 +261,9 @@ class BaseWorker(object):
logger.info("Loaded model version configuration from WorkerRun")
self.model_configuration.update(model_version.get("configuration"))
# Set model_version ID as worker attribute
self.model_version_id = model_version.get("id")
# if debug mode is set to true activate debug mode in logger
if self.user_configuration.get("debug"):
logger.setLevel(logging.DEBUG)
......
......@@ -126,6 +126,9 @@ Many attributes are set on the worker during at the configuration stage. Here is
`model_configuration`
: The parsed configuration as stored in the `ModelVersion` object on Arkindex.
`model_version_id`
: The ID of the model version linked to the current `WorkerRun` object on Arkindex. You may set it in developer mode via the `ARKINDEX_MODEL_VERSION_ID` environment variable.
`process_information`
: The details about the process parent to this worker execution. Only set in Arkindex mode.
......
......@@ -494,6 +494,7 @@ def test_configure_load_model_configuration(mocker, monkeypatch, responses):
"param2": 2,
"param3": None,
}
assert worker.model_version_id == "12341234-1234-1234-1234-123412341234"
def test_load_missing_secret():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment