From a244416c7732625680dcdad7ef9a450a5345321c Mon Sep 17 00:00:00 2001 From: Matthew Zeiler Date: Tue, 14 Jan 2025 21:23:31 -0500 Subject: [PATCH] [EAGLE-5414]: validate with API arg (#483) * validate with API arg * validate with API arg --- CHANGELOG.md | 8 ++++++++ clarifai/__init__.py | 2 +- clarifai/runners/models/model_upload.py | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99139b7..8baa6da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [[11.0.3]](https://github.com/Clarifai/clarifai-python/releases/tag/11.0.3) - [PyPI](https://pypi.org/project/clarifai/11.0.3/) - 2025-01-14 + +### Changed + + - Make API validation optional [(#483)] (https://github.com/Clarifai/clarifai-python/pull/483) + - Env var to control logging [(#482)] (https://github.com/Clarifai/clarifai-python/pull/482) + + ## [[11.0.2]](https://github.com/Clarifai/clarifai-python/releases/tag/11.0.2) - [PyPI](https://pypi.org/project/clarifai/11.0.2/) - 2025-01-14 ### Changed diff --git a/clarifai/__init__.py b/clarifai/__init__.py index 4123898..b774f70 100644 --- a/clarifai/__init__.py +++ b/clarifai/__init__.py @@ -1 +1 @@ -__version__ = "11.0.2" +__version__ = "11.0.3" diff --git a/clarifai/runners/models/model_upload.py b/clarifai/runners/models/model_upload.py index f64e974..eba4300 100644 --- a/clarifai/runners/models/model_upload.py +++ b/clarifai/runners/models/model_upload.py @@ -29,10 +29,16 @@ def _clear_line(n: int = 1) -> None: class ModelUploader: - def __init__(self, folder: str): + def __init__(self, folder: str, validate_api_ids: bool = True): + """ + :param folder: The folder containing the model.py, config.yaml, requirements.txt and + checkpoints. + :param validate_api_ids: Whether to validate the user_id and app_id in the config file. + """ self._client = None self.folder = self._validate_folder(folder) self.config = self._load_config(os.path.join(self.folder, 'config.yaml')) + self.validate_api_ids = validate_api_ids self._validate_config() self.model_proto = self._get_model_proto() self.model_id = self.model_proto.id @@ -76,6 +82,8 @@ def _validate_config_checkpoints(self): return repo_id, hf_token def _check_app_exists(self): + if not self.validate_api_ids: + return True resp = self.client.STUB.GetApp(service_pb2.GetAppRequest(user_app_id=self.client.user_app_id)) if resp.status.code == status_code_pb2.SUCCESS: return True