gmicloud 0.1.9__tar.gz → 0.1.10__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {gmicloud-0.1.9 → gmicloud-0.1.10}/PKG-INFO +1 -1
  2. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_http_client.py +7 -7
  3. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_video_client.py +22 -22
  4. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_config.py +4 -3
  5. gmicloud-0.1.10/gmicloud/_internal/_exceptions.py +36 -0
  6. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/_iam_manager.py +1 -1
  7. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_models.py +4 -2
  8. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/client.py +3 -6
  9. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud.egg-info/PKG-INFO +1 -1
  10. {gmicloud-0.1.9 → gmicloud-0.1.10}/pyproject.toml +1 -1
  11. gmicloud-0.1.9/gmicloud/_internal/_exceptions.py +0 -19
  12. {gmicloud-0.1.9 → gmicloud-0.1.10}/README.md +0 -0
  13. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/__init__.py +0 -0
  14. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/__init__.py +0 -0
  15. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/__init__.py +0 -0
  16. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_artifact_client.py +0 -0
  17. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_auth_config.py +0 -0
  18. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_decorator.py +0 -0
  19. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_file_upload_client.py +0 -0
  20. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_iam_client.py +0 -0
  21. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_client/_task_client.py +0 -0
  22. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_constants.py +0 -0
  23. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_enums.py +0 -0
  24. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/__init__.py +0 -0
  25. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/_artifact_manager.py +0 -0
  26. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/_task_manager.py +0 -0
  27. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/_video_manager.py +0 -0
  28. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/_internal/_manager/serve_command_utils.py +0 -0
  29. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/tests/__init__.py +0 -0
  30. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/tests/test_artifacts.py +0 -0
  31. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/tests/test_tasks.py +0 -0
  32. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud/utils/uninstall_packages.py +0 -0
  33. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud.egg-info/SOURCES.txt +0 -0
  34. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud.egg-info/dependency_links.txt +0 -0
  35. {gmicloud-0.1.9 → gmicloud-0.1.10}/gmicloud.egg-info/top_level.txt +0 -0
  36. {gmicloud-0.1.9 → gmicloud-0.1.10}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gmicloud
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: GMI Cloud Python SDK
5
5
  Author-email: GMI <gmi@gmitec.net>
6
6
  License: MIT
@@ -57,28 +57,28 @@ class HTTPClient:
57
57
  response = requests.request(method, url, params=params, json=data, headers=headers)
58
58
  logger.debug(response.text)
59
59
  if response.status_code == 401:
60
- raise UnauthorizedError("Access token expired or invalid.")
60
+ raise UnauthorizedError(f"Unauthorized Error : {response.status_code} - Access token expired or invalid.")
61
61
  elif response.status_code != 200 and response.status_code != 201:
62
- if url.find("ie/artifact") != -1 or url.find("ie/task") != -1:
62
+ if url.find("ie/artifact") != -1 or url.find("ie/task") != -1 or url.find("ie/requestqueue") != -1:
63
63
  error_message = response.json().get('error', 'Unknown error')
64
64
  else:
65
65
  error_message = response.json().get('message', 'Unknown error')
66
- raise APIError(f"HTTP Request failed: {error_message}")
66
+ raise APIError(f"HTTP Request failed: {response.status_code} - {error_message}")
67
67
  # Raise for HTTP errors
68
68
  response.raise_for_status()
69
69
 
70
70
  except requests.exceptions.RequestException as e:
71
- raise APIError(f"HTTP Request failed: {str(e)}")
71
+ raise APIError(f"HTTP Request failed: {response.status_code} - {str(e)}")
72
72
  except ValueError as e:
73
73
  # Fallback if response JSON is invalid
74
- raise APIError(f"Failed to parse JSON response: {response.text}")
74
+ raise APIError(f"Failed to parse JSON response: {response.status_code} - {response.text}")
75
75
 
76
76
  if response.headers.get(CONTENT_TYPE_HEADER).find(JSON_CONTENT_TYPE) != -1:
77
77
  return response.json()
78
78
  elif response.headers.get(CONTENT_TYPE_HEADER).find(TEXT_CONTENT_TYPE) != -1:
79
- raise APIError(f"Got text response: {response.text}")
79
+ raise APIError(f"Got text response: {response.status_code} - {response.text}")
80
80
  else:
81
- raise APIError(f"Unsupported content type: {response.headers.get(CONTENT_TYPE_HEADER)}")
81
+ raise APIError(f"Unsupported content type: {response.status_code} - {response.headers.get(CONTENT_TYPE_HEADER)}")
82
82
 
83
83
  def post(self, endpoint, custom_headers=None, data=None):
84
84
  """
@@ -7,7 +7,7 @@ from ._decorator import handle_refresh_token
7
7
  from ._iam_client import IAMClient
8
8
  from .._config import IAM_SERVICE_BASE_URL
9
9
  from .._models import *
10
-
10
+ from .._exceptions import formated_exception
11
11
 
12
12
  logger = logging.getLogger(__name__)
13
13
 
@@ -29,7 +29,7 @@ class VideoClient:
29
29
 
30
30
 
31
31
  @handle_refresh_token
32
- def get_request_detail(self, request_id: str) -> GetRequestResponse:
32
+ def get_request_detail(self, request_id: str) -> GetRequestResponse | dict:
33
33
  """
34
34
  Retrieves detailed information about a specific request by its ID. This endpoint requires authentication with a bearer token and only returns requests belonging to the authenticated organization.
35
35
 
@@ -39,13 +39,13 @@ class VideoClient:
39
39
  try:
40
40
  response = self.client.get(f"/requests/{request_id}", self.iam_client.get_custom_headers())
41
41
  return GetRequestResponse.model_validate(response) if response else None
42
- except (RequestException, ValueError) as e:
43
- logger.error(f"Failed to retrieve request details for {request_id}: {e}")
44
- return None
42
+ except Exception as e:
43
+ logger.error(f"An unexpected error occurred while retrieving request details for {request_id}: {e}")
44
+ return formated_exception(e)
45
45
 
46
46
 
47
47
  @handle_refresh_token
48
- def get_requests(self, model_id: str) -> List[GetRequestResponse]:
48
+ def get_requests(self, model_id: str) -> List[GetRequestResponse] | dict:
49
49
  """
50
50
  Retrieves a list of requests submitted by the authenticated user for a specific model. This endpoint requires authentication with a bearer token and filters results by the authenticated organization.
51
51
 
@@ -56,13 +56,13 @@ class VideoClient:
56
56
  response = self.client.get("/requests", self.iam_client.get_custom_headers(), {"model_id": model_id})
57
57
  requests = response.get('requests', []) if response else []
58
58
  return [GetRequestResponse.model_validate(req) for req in requests] if requests else None
59
- except (RequestException, ValueError) as e:
60
- logger.error(f"Failed to retrieve requests for model {model_id}: {e}")
61
- return None
59
+ except Exception as e:
60
+ logger.error(f"An unexpected error occurred while retrieving requests for model {model_id}: {e}")
61
+ return formated_exception(e)
62
62
 
63
63
 
64
64
  @handle_refresh_token
65
- def create_request(self, request: SubmitRequestRequest) -> SubmitRequestResponse:
65
+ def create_request(self, request: SubmitRequestRequest) -> SubmitRequestResponse | dict:
66
66
  """
67
67
  Submits a new asynchronous request to process a specified model with provided parameters. This endpoint requires authentication with a bearer token.
68
68
 
@@ -72,13 +72,13 @@ class VideoClient:
72
72
  try:
73
73
  response = self.client.post("/requests", self.iam_client.get_custom_headers(), request.model_dump())
74
74
  return SubmitRequestResponse.model_validate(response) if response else None
75
- except (RequestException, ValueError) as e:
76
- logger.error(f"Failed to create request: {e}")
77
- return None
75
+ except Exception as e:
76
+ logger.error(f"An unexpected error occurred while creating a request: {e}")
77
+ return formated_exception(e)
78
78
 
79
79
 
80
80
  @handle_refresh_token
81
- def get_model_detail(self, model_id: str) -> GetModelResponse:
81
+ def get_model_detail(self, model_id: str) -> GetModelResponse | dict:
82
82
  """
83
83
  Retrieves detailed information about a specific model by its ID.
84
84
 
@@ -88,13 +88,13 @@ class VideoClient:
88
88
  try:
89
89
  response = self.client.get(f"/models/{model_id}", self.iam_client.get_custom_headers())
90
90
  return GetModelResponse.model_validate(response) if response else None
91
- except (RequestException, ValueError) as e:
92
- logger.error(f"Failed to retrieve model details for {model_id}: {e}")
93
- return None
91
+ except Exception as e:
92
+ logger.error(f"An unexpected error occurred while retrieving model details for {model_id}: {e}")
93
+ return formated_exception(e)
94
94
 
95
95
 
96
96
  @handle_refresh_token
97
- def get_models(self) -> List[GetModelResponse]:
97
+ def get_models(self) -> List[GetModelResponse] | dict:
98
98
  """
99
99
  Retrieves a list of available models from the video service.
100
100
 
@@ -104,8 +104,8 @@ class VideoClient:
104
104
  response = self.client.get("/models", self.iam_client.get_custom_headers())
105
105
  models = response.get('models', []) if response else []
106
106
  return [GetModelResponse.model_validate(model) for model in models] if models else None
107
- except (RequestException, ValueError) as e:
108
- logger.error(f"Failed to retrieve models: {e}")
109
- return None
110
-
107
+ except Exception as e:
108
+ logger.error(f"An unexpected error occurred while retrieving models: {e}")
109
+ return formated_exception(e)
110
+
111
111
 
@@ -3,7 +3,8 @@
3
3
  # TASK_SERVICE_BASE_URL = "https://ce-tot.gmicloud-dev.com/api/v1/ie/task"
4
4
  # IAM_SERVICE_BASE_URL = "https://ce-tot.gmicloud-dev.com/api/v1"
5
5
 
6
+
6
7
  # Prod environment
7
- ARTIFACT_SERVICE_BASE_URL = "https://inference-engine.gmicloud.ai/api/v1/ie/artifact"
8
- TASK_SERVICE_BASE_URL = "https://inference-engine.gmicloud.ai/api/v1/ie/task"
9
- IAM_SERVICE_BASE_URL = "https://inference-engine.gmicloud.ai/api/v1"
8
+ ARTIFACT_SERVICE_BASE_URL = "https://console.gmicloud.ai/api/v1/ie/artifact"
9
+ TASK_SERVICE_BASE_URL = "https://console.gmicloud.ai/api/v1/ie/task"
10
+ IAM_SERVICE_BASE_URL = "https://console.gmicloud.ai/api/v1"
@@ -0,0 +1,36 @@
1
+ class APIError(Exception):
2
+ """
3
+ Generic exception for API-related errors.
4
+ """
5
+ pass
6
+
7
+
8
+ class UploadFileError(Exception):
9
+ """
10
+ Exception for file upload errors.
11
+ """
12
+ pass
13
+
14
+
15
+ class UnauthorizedError(Exception):
16
+ """
17
+ Exception for unauthorized access errors.
18
+ """
19
+ pass
20
+
21
+
22
+
23
+ def formated_exception(error: Exception) -> dict:
24
+ """
25
+ Formats the exception message for logging.
26
+
27
+ :param error: The exception to format.
28
+ :return: A dictionary containing the error code and message.
29
+ """
30
+ message = str(error).split(":")[1]
31
+ status = str(message).split(" - ")[0] if " - " in str(message) else "0"
32
+ error_message = str(message).split(" - ")[1] if " - " in str(message) else str(message)
33
+ return {
34
+ "code": status,
35
+ "error": error_message
36
+ }
@@ -27,7 +27,7 @@ class IAMManager:
27
27
  print(expires_at)
28
28
 
29
29
  return self.iam_client.create_org_api_key(
30
- CreateAPIKeyRequest(name=name, type="ie_model", expiresAt=expires_at))
30
+ CreateAPIKeyRequest(name=name, scope="ie_model", expiresAt=expires_at))
31
31
 
32
32
  def get_org_api_keys(self) -> List[APIKey]:
33
33
  """
@@ -550,7 +550,8 @@ class CreateAPIKeyRequest(BaseModel):
550
550
  Request object for creating an API key.
551
551
  """
552
552
  name: str # Name of the API key.
553
- type: Optional[str] = "" # Type of the API key.
553
+ type: Optional[str] = "" # Declaration: This field is about to be abandoned
554
+ scope: Optional[str] = "" # Scope of the API key.
554
555
  expiresAt: Optional[int] = 0 # Expiration timestamp for the API key.
555
556
 
556
557
 
@@ -567,7 +568,8 @@ class APIKey(BaseModel):
567
568
  """
568
569
  id: Optional[str] = "" # API key ID.
569
570
  name: Optional[str] = "" # API key name.
570
- type: Optional[str] = "" # API key type.
571
+ type: Optional[str] = "" # Declaration: This field is about to be abandoned
572
+ scope: Optional[str] = "" # Scope of the API key.
571
573
  partialKey: Optional[str] = "" # Partial key for the API key.
572
574
  expiresAt: Optional[int] = 0 # Expiration timestamp for the API key.
573
575
  createdAt: Optional[int] = 0 # Creation timestamp for the API key.
@@ -16,21 +16,18 @@ logger = logging.getLogger(__name__)
16
16
 
17
17
 
18
18
  class Client:
19
- def __init__(self, client_id: Optional[str] = "", email: Optional[str] = "", password: Optional[str] = ""):
20
- if not client_id or not client_id.strip():
21
- client_id = os.getenv("GMI_CLOUD_CLIENT_ID")
19
+ def __init__(self, email: Optional[str] = "", password: Optional[str] = ""):
22
20
  if not email or not email.strip():
23
21
  email = os.getenv("GMI_CLOUD_EMAIL")
24
22
  if not password or not password.strip():
25
23
  password = os.getenv("GMI_CLOUD_PASSWORD")
26
-
27
- if not client_id:
28
- raise ValueError("Client ID must be provided.")
24
+
29
25
  if not email:
30
26
  raise ValueError("Email must be provided.")
31
27
  if not password:
32
28
  raise ValueError("Password must be provided.")
33
29
 
30
+ client_id = "gmisdk"
34
31
  self.iam_client = IAMClient(client_id, email, password)
35
32
  self.iam_client.login()
36
33
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gmicloud
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: GMI Cloud Python SDK
5
5
  Author-email: GMI <gmi@gmitec.net>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gmicloud"
7
- version = "0.1.9"
7
+ version = "0.1.10"
8
8
  description = "GMI Cloud Python SDK"
9
9
  authors = [{ name = "GMI", email = "gmi@gmitec.net" }]
10
10
  license = { text = "MIT" }
@@ -1,19 +0,0 @@
1
- class APIError(Exception):
2
- """
3
- Generic exception for API-related errors.
4
- """
5
- pass
6
-
7
-
8
- class UploadFileError(Exception):
9
- """
10
- Exception for file upload errors.
11
- """
12
- pass
13
-
14
-
15
- class UnauthorizedError(Exception):
16
- """
17
- Exception for unauthorized access errors.
18
- """
19
- pass
File without changes
File without changes
File without changes