trismik 0.9.4__tar.gz → 0.9.5__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.
- {trismik-0.9.4 → trismik-0.9.5}/PKG-INFO +4 -2
- {trismik-0.9.4 → trismik-0.9.5}/pyproject.toml +1 -1
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/_mapper.py +32 -8
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/adaptive_test.py +54 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/client_async.py +42 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/types.py +21 -1
- {trismik-0.9.4 → trismik-0.9.5}/LICENSE +0 -0
- {trismik-0.9.4 → trismik-0.9.5}/README.md +0 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/__init__.py +0 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/_utils.py +0 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/exceptions.py +0 -0
- {trismik-0.9.4 → trismik-0.9.5}/src/trismik/settings.py +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: trismik
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.5
|
|
4
4
|
Summary:
|
|
5
|
+
License-File: LICENSE
|
|
5
6
|
Author: Bartosz Kielczewski
|
|
6
7
|
Author-email: bk352@cam.ac.uk
|
|
7
8
|
Requires-Python: >=3.9
|
|
@@ -11,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
11
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
13
14
|
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
16
|
Provides-Extra: examples
|
|
15
17
|
Requires-Dist: accelerate (>=1.7.0,<2.0.0) ; extra == "examples"
|
|
16
18
|
Requires-Dist: notebook (>=7.4.4,<8.0.0) ; extra == "examples"
|
|
@@ -9,6 +9,7 @@ from trismik.types import (
|
|
|
9
9
|
TrismikMeResponse,
|
|
10
10
|
TrismikMultipleChoiceTextItem,
|
|
11
11
|
TrismikOrganization,
|
|
12
|
+
TrismikProject,
|
|
12
13
|
TrismikReplayResponse,
|
|
13
14
|
TrismikResponse,
|
|
14
15
|
TrismikResult,
|
|
@@ -274,7 +275,7 @@ class TrismikResponseMapper:
|
|
|
274
275
|
TrismikMeResponse: Me response object.
|
|
275
276
|
"""
|
|
276
277
|
user_data = json["user"]
|
|
277
|
-
|
|
278
|
+
organizations_data = json["organizations"]
|
|
278
279
|
|
|
279
280
|
user_info = TrismikUserInfo(
|
|
280
281
|
id=user_data["id"],
|
|
@@ -284,16 +285,19 @@ class TrismikResponseMapper:
|
|
|
284
285
|
createdAt=user_data.get("createdAt"),
|
|
285
286
|
)
|
|
286
287
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
288
|
+
organizations = [
|
|
289
|
+
TrismikOrganization(
|
|
290
|
+
id=org_data["id"],
|
|
291
|
+
name=org_data["name"],
|
|
292
|
+
type=org_data["type"],
|
|
293
|
+
role=org_data["role"],
|
|
294
|
+
)
|
|
295
|
+
for org_data in organizations_data
|
|
296
|
+
]
|
|
293
297
|
|
|
294
298
|
return TrismikMeResponse(
|
|
295
299
|
user=user_info,
|
|
296
|
-
|
|
300
|
+
organizations=organizations,
|
|
297
301
|
)
|
|
298
302
|
|
|
299
303
|
@staticmethod
|
|
@@ -333,3 +337,23 @@ class TrismikResponseMapper:
|
|
|
333
337
|
user=user_info,
|
|
334
338
|
responseCount=json["responseCount"],
|
|
335
339
|
)
|
|
340
|
+
|
|
341
|
+
@staticmethod
|
|
342
|
+
def to_project(json: Dict[str, Any]) -> TrismikProject:
|
|
343
|
+
"""
|
|
344
|
+
Convert JSON response to a TrismikProject object.
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
json (Dict[str, Any]): JSON response from project creation endpoint.
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
TrismikProject: Project object.
|
|
351
|
+
"""
|
|
352
|
+
return TrismikProject(
|
|
353
|
+
id=json["id"],
|
|
354
|
+
name=json["name"],
|
|
355
|
+
description=json.get("description"),
|
|
356
|
+
organizationId=json["organizationId"],
|
|
357
|
+
createdAt=json["createdAt"],
|
|
358
|
+
updatedAt=json["updatedAt"],
|
|
359
|
+
)
|
|
@@ -22,6 +22,7 @@ from trismik.types import (
|
|
|
22
22
|
TrismikDataset,
|
|
23
23
|
TrismikItem,
|
|
24
24
|
TrismikMeResponse,
|
|
25
|
+
TrismikProject,
|
|
25
26
|
TrismikReplayRequest,
|
|
26
27
|
TrismikReplayRequestItem,
|
|
27
28
|
TrismikRunMetadata,
|
|
@@ -140,6 +141,59 @@ class AdaptiveTest:
|
|
|
140
141
|
"""
|
|
141
142
|
return await self._client.me()
|
|
142
143
|
|
|
144
|
+
def create_project(
|
|
145
|
+
self,
|
|
146
|
+
name: str,
|
|
147
|
+
organization_id: str,
|
|
148
|
+
description: Optional[str] = None,
|
|
149
|
+
) -> TrismikProject:
|
|
150
|
+
"""
|
|
151
|
+
Create a new project synchronously.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
name (str): Name of the project.
|
|
155
|
+
organization_id (str): ID of the organization to create the
|
|
156
|
+
project in.
|
|
157
|
+
description (Optional[str]): Optional description of the project.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
TrismikProject: Created project information.
|
|
161
|
+
|
|
162
|
+
Raises:
|
|
163
|
+
TrismikValidationError: If the request fails validation.
|
|
164
|
+
TrismikApiError: If API request fails.
|
|
165
|
+
"""
|
|
166
|
+
loop = self._get_loop()
|
|
167
|
+
return loop.run_until_complete(
|
|
168
|
+
self.create_project_async(name, organization_id, description)
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
async def create_project_async(
|
|
172
|
+
self,
|
|
173
|
+
name: str,
|
|
174
|
+
organization_id: str,
|
|
175
|
+
description: Optional[str] = None,
|
|
176
|
+
) -> TrismikProject:
|
|
177
|
+
"""
|
|
178
|
+
Create a new project asynchronously.
|
|
179
|
+
|
|
180
|
+
Args:
|
|
181
|
+
name (str): Name of the project.
|
|
182
|
+
organization_id (str): ID of the organization to create the
|
|
183
|
+
project in.
|
|
184
|
+
description (Optional[str]): Optional description of the project.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
TrismikProject: Created project information.
|
|
188
|
+
|
|
189
|
+
Raises:
|
|
190
|
+
TrismikValidationError: If the request fails validation.
|
|
191
|
+
TrismikApiError: If API request fails.
|
|
192
|
+
"""
|
|
193
|
+
return await self._client.create_project(
|
|
194
|
+
name, organization_id, description
|
|
195
|
+
)
|
|
196
|
+
|
|
143
197
|
@overload
|
|
144
198
|
def run( # noqa: E704
|
|
145
199
|
self,
|
|
@@ -22,6 +22,7 @@ from trismik.types import (
|
|
|
22
22
|
TrismikClassicEvalResponse,
|
|
23
23
|
TrismikDataset,
|
|
24
24
|
TrismikMeResponse,
|
|
25
|
+
TrismikProject,
|
|
25
26
|
TrismikReplayRequest,
|
|
26
27
|
TrismikReplayResponse,
|
|
27
28
|
TrismikRunMetadata,
|
|
@@ -360,3 +361,44 @@ class TrismikAsyncClient:
|
|
|
360
361
|
raise self._handle_http_error(e) from e
|
|
361
362
|
except httpx.HTTPError as e:
|
|
362
363
|
raise TrismikApiError(str(e)) from e
|
|
364
|
+
|
|
365
|
+
async def create_project(
|
|
366
|
+
self,
|
|
367
|
+
name: str,
|
|
368
|
+
organization_id: str,
|
|
369
|
+
description: Optional[str] = None,
|
|
370
|
+
) -> TrismikProject:
|
|
371
|
+
"""
|
|
372
|
+
Create a new project.
|
|
373
|
+
|
|
374
|
+
Args:
|
|
375
|
+
name (str): Name of the project.
|
|
376
|
+
organization_id (str): ID of the organization to create the
|
|
377
|
+
project in.
|
|
378
|
+
description (Optional[str]): Optional description of the project.
|
|
379
|
+
|
|
380
|
+
Returns:
|
|
381
|
+
TrismikProject: Created project information.
|
|
382
|
+
|
|
383
|
+
Raises:
|
|
384
|
+
TrismikValidationError: If the request fails validation.
|
|
385
|
+
TrismikApiError: If API request fails.
|
|
386
|
+
"""
|
|
387
|
+
try:
|
|
388
|
+
url = "../admin/public/projects"
|
|
389
|
+
|
|
390
|
+
body = {"name": name}
|
|
391
|
+
if description is not None:
|
|
392
|
+
body["description"] = description
|
|
393
|
+
|
|
394
|
+
headers = {"x-organization-id": organization_id}
|
|
395
|
+
response = await self._http_client.post(
|
|
396
|
+
url, json=body, headers=headers
|
|
397
|
+
)
|
|
398
|
+
response.raise_for_status()
|
|
399
|
+
json = response.json()
|
|
400
|
+
return TrismikResponseMapper.to_project(json)
|
|
401
|
+
except httpx.HTTPStatusError as e:
|
|
402
|
+
raise self._handle_http_error(e) from e
|
|
403
|
+
except httpx.HTTPError as e:
|
|
404
|
+
raise TrismikApiError(str(e)) from e
|
|
@@ -247,7 +247,7 @@ class TrismikMeResponse:
|
|
|
247
247
|
"""Response from the /admin/api-keys/me endpoint."""
|
|
248
248
|
|
|
249
249
|
user: TrismikUserInfo
|
|
250
|
-
|
|
250
|
+
organizations: List[TrismikOrganization]
|
|
251
251
|
|
|
252
252
|
|
|
253
253
|
@dataclass
|
|
@@ -299,3 +299,23 @@ class TrismikClassicEvalResponse:
|
|
|
299
299
|
createdAt: str
|
|
300
300
|
user: TrismikUserInfo
|
|
301
301
|
responseCount: int
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
@dataclass
|
|
305
|
+
class TrismikProjectRequest:
|
|
306
|
+
"""Request to create a new project."""
|
|
307
|
+
|
|
308
|
+
name: str
|
|
309
|
+
description: Optional[str] = None
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
@dataclass
|
|
313
|
+
class TrismikProject:
|
|
314
|
+
"""Project information."""
|
|
315
|
+
|
|
316
|
+
id: str
|
|
317
|
+
name: str
|
|
318
|
+
description: Optional[str]
|
|
319
|
+
organizationId: str
|
|
320
|
+
createdAt: str
|
|
321
|
+
updatedAt: str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|