gmicloud 0.1.9__py3-none-any.whl → 0.1.10__py3-none-any.whl
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.
- gmicloud/_internal/_client/_http_client.py +7 -7
- gmicloud/_internal/_client/_video_client.py +22 -22
- gmicloud/_internal/_config.py +4 -3
- gmicloud/_internal/_exceptions.py +17 -0
- gmicloud/_internal/_manager/_iam_manager.py +1 -1
- gmicloud/_internal/_models.py +4 -2
- gmicloud/client.py +3 -6
- {gmicloud-0.1.9.dist-info → gmicloud-0.1.10.dist-info}/METADATA +1 -1
- {gmicloud-0.1.9.dist-info → gmicloud-0.1.10.dist-info}/RECORD +11 -11
- {gmicloud-0.1.9.dist-info → gmicloud-0.1.10.dist-info}/WHEEL +0 -0
- {gmicloud-0.1.9.dist-info → gmicloud-0.1.10.dist-info}/top_level.txt +0 -0
@@ -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
|
43
|
-
logger.error(f"
|
44
|
-
return
|
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
|
60
|
-
logger.error(f"
|
61
|
-
return
|
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
|
76
|
-
logger.error(f"
|
77
|
-
return
|
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
|
92
|
-
logger.error(f"
|
93
|
-
return
|
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
|
108
|
-
logger.error(f"
|
109
|
-
return
|
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
|
|
gmicloud/_internal/_config.py
CHANGED
@@ -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://
|
8
|
-
TASK_SERVICE_BASE_URL = "https://
|
9
|
-
IAM_SERVICE_BASE_URL = "https://
|
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"
|
@@ -17,3 +17,20 @@ class UnauthorizedError(Exception):
|
|
17
17
|
Exception for unauthorized access errors.
|
18
18
|
"""
|
19
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,
|
30
|
+
CreateAPIKeyRequest(name=name, scope="ie_model", expiresAt=expires_at))
|
31
31
|
|
32
32
|
def get_org_api_keys(self) -> List[APIKey]:
|
33
33
|
"""
|
gmicloud/_internal/_models.py
CHANGED
@@ -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] = "" #
|
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] = "" #
|
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.
|
gmicloud/client.py
CHANGED
@@ -16,21 +16,18 @@ logger = logging.getLogger(__name__)
|
|
16
16
|
|
17
17
|
|
18
18
|
class Client:
|
19
|
-
def __init__(self,
|
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,23 +1,23 @@
|
|
1
1
|
gmicloud/__init__.py,sha256=xSzrAxiby5Te20yhy1ZylGHmQKVV_w1QjFe6D99VZxw,968
|
2
|
-
gmicloud/client.py,sha256=
|
2
|
+
gmicloud/client.py,sha256=wKHj0yqhWKbHl16DE47a4frOy_CXU6hSCjnBEzQGpdA,10759
|
3
3
|
gmicloud/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
gmicloud/_internal/_config.py,sha256=
|
4
|
+
gmicloud/_internal/_config.py,sha256=YlXLfQLAXO1n5dB6tE91lIWx8fnob_YOR5N1764eNaU,469
|
5
5
|
gmicloud/_internal/_constants.py,sha256=Y085dwFlqdFkCf39iBfxz39QiiB7lX59ayNJjB86_m4,378
|
6
6
|
gmicloud/_internal/_enums.py,sha256=aN3At0_iV_6aaUsrOy-JThtRUokeY4nTyxxPLZmIDBU,1093
|
7
|
-
gmicloud/_internal/_exceptions.py,sha256=
|
8
|
-
gmicloud/_internal/_models.py,sha256=
|
7
|
+
gmicloud/_internal/_exceptions.py,sha256=8hDjXfXqdyP4pUHVOmRddRSDQYv4wqQ84OqkbhE5wKk,811
|
8
|
+
gmicloud/_internal/_models.py,sha256=0dDnlnhaZl5nloZ8GKXu-GlJjLxwvHJm0HsQahdOjT4,25184
|
9
9
|
gmicloud/_internal/_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
10
|
gmicloud/_internal/_client/_artifact_client.py,sha256=0lyHAdUybN8A1mEwZ7p1yK2yQEyoDG2vTB4Qe5RI2ik,9974
|
11
11
|
gmicloud/_internal/_client/_auth_config.py,sha256=zlCUPHN_FgWmOAxOAgjBtGRbaChqMa9PPGPuVNKvnc8,2700
|
12
12
|
gmicloud/_internal/_client/_decorator.py,sha256=sy4gxzsUB6ORXHw5pqmMf7TTlK41Nmu1fhIhK2AIsbY,670
|
13
13
|
gmicloud/_internal/_client/_file_upload_client.py,sha256=r29iXG_0DOi-uTLu9plpfZMWGqOck_AdDHJZprcf8uI,4918
|
14
|
-
gmicloud/_internal/_client/_http_client.py,sha256=
|
14
|
+
gmicloud/_internal/_client/_http_client.py,sha256=q-58vpTOfR2UfnxcYYyx4qlUzoijTfGVU2NAnYnEdjI,5950
|
15
15
|
gmicloud/_internal/_client/_iam_client.py,sha256=iXam-UlTCJWCpXmxAhqCo0J2m6nPzNOWa06R5xAy5nQ,8297
|
16
16
|
gmicloud/_internal/_client/_task_client.py,sha256=69OqZC_kwSDkTSVVyi51Tn_OyUV6R0nin4z4gLfZ-Lg,6141
|
17
|
-
gmicloud/_internal/_client/_video_client.py,sha256=
|
17
|
+
gmicloud/_internal/_client/_video_client.py,sha256=yq8vqFceJnoj4XDRjG6zF4aPiADrdOWny6hPsbumrAU,4882
|
18
18
|
gmicloud/_internal/_manager/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
19
|
gmicloud/_internal/_manager/_artifact_manager.py,sha256=Fq5Qifrdq5yn_QkMAoykuWE04FgqNOd9yZrFQdAi5J8,21874
|
20
|
-
gmicloud/_internal/_manager/_iam_manager.py,sha256=
|
20
|
+
gmicloud/_internal/_manager/_iam_manager.py,sha256=hXlnJIHpwvJO556u45UVUJ68T6DTO0ZWOgjSoVyrj74,1168
|
21
21
|
gmicloud/_internal/_manager/_task_manager.py,sha256=g2K0IG1EXzcZRAfXLhUp78em0ZVvKyqlr1PGTBR04JQ,12501
|
22
22
|
gmicloud/_internal/_manager/_video_manager.py,sha256=_PwooKf9sZkIx4mYTy57pXtP7J3uwHQHgscns5hQYZ0,3376
|
23
23
|
gmicloud/_internal/_manager/serve_command_utils.py,sha256=0PXDRuGbLw_43KBwCxPRdb4QqijZrzYyvM6WOZ2-Ktg,4583
|
@@ -25,7 +25,7 @@ gmicloud/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
gmicloud/tests/test_artifacts.py,sha256=w0T0EpATIGLrSUPaBfTZ2ZC_X2XeaTlFEi3DZ4evIcE,15825
|
26
26
|
gmicloud/tests/test_tasks.py,sha256=yL-aFf80ShgTyxEONTWh-xbWDf5XnUNtIeA5hYvhKM0,10963
|
27
27
|
gmicloud/utils/uninstall_packages.py,sha256=zzuuaJPf39oTXWZ_7tUAGseoxocuCbbkoglJSD5yDrE,1127
|
28
|
-
gmicloud-0.1.
|
29
|
-
gmicloud-0.1.
|
30
|
-
gmicloud-0.1.
|
31
|
-
gmicloud-0.1.
|
28
|
+
gmicloud-0.1.10.dist-info/METADATA,sha256=mMLF_5IWBtTIxA0vlfaUJXf5LKUhhFAneeQ5Fw8e1I0,9029
|
29
|
+
gmicloud-0.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
30
|
+
gmicloud-0.1.10.dist-info/top_level.txt,sha256=AZimLw3y0WPpLiSiOidZ1gD0dxALh-jQNk4fxC05hYE,9
|
31
|
+
gmicloud-0.1.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|