Skip to content

Commit

Permalink
[EAGLE-5414]: validate with API arg (#483)
Browse files Browse the repository at this point in the history
* validate with API arg

* validate with API arg
  • Loading branch information
zeiler authored Jan 15, 2025
1 parent f58e1b8 commit a244416
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion clarifai/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "11.0.2"
__version__ = "11.0.3"
10 changes: 9 additions & 1 deletion clarifai/runners/models/model_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a244416

Please sign in to comment.