From bd0ececf993faae44ab2e94fe0ab36db91b9a4be Mon Sep 17 00:00:00 2001 From: Gert Mertes Date: Tue, 9 Apr 2024 13:56:37 +0000 Subject: [PATCH] Include model version in metadata request --- ai_models/remote/api.py | 10 +++++++--- ai_models/remote/model.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ai_models/remote/api.py b/ai_models/remote/api.py index 031477c..53aa03f 100644 --- a/ai_models/remote/api.py +++ b/ai_models/remote/api.py @@ -124,11 +124,15 @@ def run(self, cfg: dict): LOG.debug("Result written to %s", self.output_file) - def metadata(self, model, param) -> dict: + def metadata(self, model, model_version, param) -> dict: if isinstance(param, str): - return self._request(requests.get, f"metadata/{model}/{param}") + return self._request( + requests.get, f"metadata/{model}/{model_version}/{param}" + ) elif isinstance(param, (list, dict)): - return self._request(requests.post, f"metadata/{model}", json=param) + return self._request( + requests.post, f"metadata/{model}/{model_version}", json=param + ) else: raise ValueError("param must be a string, list, or dict with 'param' key.") diff --git a/ai_models/remote/model.py b/ai_models/remote/model.py index 7e3eb38..9a2fc4c 100644 --- a/ai_models/remote/model.py +++ b/ai_models/remote/model.py @@ -19,6 +19,7 @@ def __init__(self, **kwargs): self.cfg["assets_extra_dir"] = None self.model = self.cfg["model"] + self.model_version = self.cfg.get("model_version", "latest") self._param = {} self.api = RemoteAPI() @@ -61,6 +62,7 @@ def patch_retrieve_request(self, request): def load_parameters(self): params = self.api.metadata( self.model, + self.model_version, [ "expver", "version", @@ -80,7 +82,8 @@ def get_parameter(self, name): if (param := self._param.get(name)) is not None: return param - self._param.update(self.api.metadata(self.model, name)) + _param = self.api.metadata(self.model, self.model_version, name) + self._param.update(_param) return self._param.get(name)