trismik 0.9.6__py3-none-any.whl → 0.9.9__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.
trismik/_mapper.py CHANGED
@@ -8,7 +8,7 @@ from trismik.types import (
8
8
  TrismikItem,
9
9
  TrismikMeResponse,
10
10
  TrismikMultipleChoiceTextItem,
11
- TrismikOrganization,
11
+ TrismikProject,
12
12
  TrismikReplayResponse,
13
13
  TrismikResponse,
14
14
  TrismikResult,
@@ -17,6 +17,7 @@ from trismik.types import (
17
17
  TrismikRunResponse,
18
18
  TrismikRunState,
19
19
  TrismikRunSummary,
20
+ TrismikTeam,
20
21
  TrismikTextChoice,
21
22
  TrismikUserInfo,
22
23
  )
@@ -274,7 +275,7 @@ class TrismikResponseMapper:
274
275
  TrismikMeResponse: Me response object.
275
276
  """
276
277
  user_data = json["user"]
277
- organizations_data = json["organizations"]
278
+ teams_data = json["teams"]
278
279
 
279
280
  user_info = TrismikUserInfo(
280
281
  id=user_data["id"],
@@ -282,22 +283,20 @@ class TrismikResponseMapper:
282
283
  firstname=user_data["firstname"],
283
284
  lastname=user_data["lastname"],
284
285
  createdAt=user_data.get("createdAt"),
286
+ account_id=user_data.get("accountId"),
285
287
  )
286
288
 
287
- organizations = [
288
- TrismikOrganization(
289
- id=org_data["id"],
290
- name=org_data["name"],
291
- type=org_data["type"],
292
- role=org_data["role"],
289
+ teams = [
290
+ TrismikTeam(
291
+ id=team_data["id"],
292
+ name=team_data["name"],
293
+ role=team_data["role"],
294
+ account_id=team_data["accountId"],
293
295
  )
294
- for org_data in organizations_data
296
+ for team_data in teams_data
295
297
  ]
296
298
 
297
- return TrismikMeResponse(
298
- user=user_info,
299
- organizations=organizations,
300
- )
299
+ return TrismikMeResponse(user=user_info, teams=teams)
301
300
 
302
301
  @staticmethod
303
302
  def to_classic_eval_response(
@@ -319,11 +318,12 @@ class TrismikResponseMapper:
319
318
  email=user_data["email"],
320
319
  firstname=user_data["firstname"],
321
320
  lastname=user_data["lastname"],
321
+ account_id=user_data.get("accountId"),
322
322
  )
323
323
 
324
324
  return TrismikClassicEvalResponse(
325
325
  id=json["id"],
326
- organizationId=json["organizationId"],
326
+ accountId=json["accountId"],
327
327
  projectId=json["projectId"],
328
328
  experimentId=json["experimentId"],
329
329
  experimentName=json["experimentName"],
@@ -336,3 +336,23 @@ class TrismikResponseMapper:
336
336
  user=user_info,
337
337
  responseCount=json["responseCount"],
338
338
  )
339
+
340
+ @staticmethod
341
+ def to_project(json: Dict[str, Any]) -> TrismikProject:
342
+ """
343
+ Convert JSON response to a TrismikProject object.
344
+
345
+ Args:
346
+ json (Dict[str, Any]): JSON response from project creation endpoint.
347
+
348
+ Returns:
349
+ TrismikProject: Project object.
350
+ """
351
+ return TrismikProject(
352
+ id=json["id"],
353
+ name=json["name"],
354
+ description=json.get("description"),
355
+ organizationId=json["organizationId"],
356
+ createdAt=json["createdAt"],
357
+ updatedAt=json["updatedAt"],
358
+ )
trismik/adaptive_test.py CHANGED
@@ -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,
trismik/client_async.py CHANGED
@@ -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,
@@ -71,7 +72,7 @@ class TrismikAsyncClient:
71
72
  default_headers = {"x-api-key": self._api_key}
72
73
 
73
74
  self._http_client = http_client or httpx.AsyncClient(
74
- base_url=self._service_url, headers=default_headers
75
+ base_url=self._service_url, headers=default_headers, timeout=30.0
75
76
  )
76
77
 
77
78
  def _handle_http_error(self, e: httpx.HTTPStatusError) -> Exception:
@@ -214,7 +215,7 @@ class TrismikAsyncClient:
214
215
  TrismikApiError: If API request fails.
215
216
  """
216
217
  try:
217
- url = f"/runs/{run_id}"
218
+ url = f"/runs/adaptive/{run_id}"
218
219
  response = await self._http_client.get(url)
219
220
  response.raise_for_status()
220
221
  json = response.json()
@@ -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
trismik/types.py CHANGED
@@ -222,13 +222,13 @@ class TrismikReplayResponse:
222
222
 
223
223
 
224
224
  @dataclass
225
- class TrismikOrganization:
226
- """Organization information."""
225
+ class TrismikTeam:
226
+ """Team information."""
227
227
 
228
228
  id: str
229
229
  name: str
230
- type: str
231
230
  role: str
231
+ account_id: str
232
232
 
233
233
 
234
234
  @dataclass
@@ -239,6 +239,7 @@ class TrismikUserInfo:
239
239
  email: str
240
240
  firstname: str
241
241
  lastname: str
242
+ account_id: str
242
243
  createdAt: Optional[str] = None
243
244
 
244
245
 
@@ -247,7 +248,7 @@ class TrismikMeResponse:
247
248
  """Response from the /admin/api-keys/me endpoint."""
248
249
 
249
250
  user: TrismikUserInfo
250
- organizations: List[TrismikOrganization]
251
+ teams: List[TrismikTeam]
251
252
 
252
253
 
253
254
  @dataclass
@@ -287,7 +288,7 @@ class TrismikClassicEvalResponse:
287
288
  """Response from a classic evaluation submission."""
288
289
 
289
290
  id: str
290
- organizationId: str
291
+ accountId: str
291
292
  projectId: str
292
293
  experimentId: str
293
294
  experimentName: str
@@ -299,3 +300,23 @@ class TrismikClassicEvalResponse:
299
300
  createdAt: str
300
301
  user: TrismikUserInfo
301
302
  responseCount: int
303
+
304
+
305
+ @dataclass
306
+ class TrismikProjectRequest:
307
+ """Request to create a new project."""
308
+
309
+ name: str
310
+ description: Optional[str] = None
311
+
312
+
313
+ @dataclass
314
+ class TrismikProject:
315
+ """Project information."""
316
+
317
+ id: str
318
+ name: str
319
+ description: Optional[str]
320
+ organizationId: str
321
+ createdAt: str
322
+ updatedAt: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: trismik
3
- Version: 0.9.6
3
+ Version: 0.9.9
4
4
  Summary:
5
5
  License-File: LICENSE
6
6
  Author: Bartosz Kielczewski
@@ -15,11 +15,14 @@ Classifier: Programming Language :: Python :: 3.13
15
15
  Classifier: Programming Language :: Python :: 3.14
16
16
  Provides-Extra: examples
17
17
  Requires-Dist: accelerate (>=1.7.0,<2.0.0) ; extra == "examples"
18
+ Requires-Dist: httpx (>=0.27.2,<1.0.0)
19
+ Requires-Dist: nest-asyncio (>=1.6.0,<2.0.0)
18
20
  Requires-Dist: notebook (>=7.4.4,<8.0.0) ; extra == "examples"
19
21
  Requires-Dist: openai (>=1.81.0,<2.0.0) ; extra == "examples"
20
22
  Requires-Dist: torch (>=2.7.0,<3.0.0) ; extra == "examples"
21
23
  Requires-Dist: torchaudio (>=2.7.0,<3.0.0) ; extra == "examples"
22
24
  Requires-Dist: torchvision (>=0.22.0,<1.0.0) ; extra == "examples"
25
+ Requires-Dist: tqdm (>=4.67.1,<5.0.0)
23
26
  Requires-Dist: transformers (>=4.51.3,<5.0.0) ; extra == "examples"
24
27
  Description-Content-Type: text/markdown
25
28
 
@@ -0,0 +1,12 @@
1
+ trismik/__init__.py,sha256=20SwXrda9YsgykaoPohwz6foj2FkraniPA-GTQS9m00,197
2
+ trismik/_mapper.py,sha256=wHrwmoTx8Z5B1BQH2_NUPaX3xCpBLKkidp245I4feno,11004
3
+ trismik/_utils.py,sha256=WZ7x0EaG7PdXdFZMIs1wzgwqiPQm59QDDmQzBKYGCEg,3753
4
+ trismik/adaptive_test.py,sha256=Fmc6PJZg_SKQjV_xQF29ZJQwPxpGwfKuvi2VznAmOB0,21646
5
+ trismik/client_async.py,sha256=7NYcYomIfETjL5BLGQnJWhL249GBS67otGLH9Rue0sI,13906
6
+ trismik/exceptions.py,sha256=2wb4_K7GdDf00s3xUaiSfw6718ZV3Eaa4M2lYbiEZl4,1945
7
+ trismik/settings.py,sha256=FCP-d8ZEiYWUTWoa9nOVzSwTOLvg8y0pU08dAseiOwY,412
8
+ trismik/types.py,sha256=-HHnOTzMeXfryKJCuZ7LHAPyS0G6uzsOJFUtIU0VB3k,6560
9
+ trismik-0.9.9.dist-info/METADATA,sha256=gZtOCSIn4VaEIsKo-MugwvEjatgpAYRkwl3gWf8Y2Ic,6814
10
+ trismik-0.9.9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
11
+ trismik-0.9.9.dist-info/licenses/LICENSE,sha256=tgetRhapGLh7ZxfknW6Mm-WobfziPd64nAK52X5XKaw,1077
12
+ trismik-0.9.9.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.0
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,12 +0,0 @@
1
- trismik/__init__.py,sha256=20SwXrda9YsgykaoPohwz6foj2FkraniPA-GTQS9m00,197
2
- trismik/_mapper.py,sha256=8iQ-cvKG5IkKoAHhmb9PSjB4Xwim5fEU2btgaw8aPsw,10375
3
- trismik/_utils.py,sha256=WZ7x0EaG7PdXdFZMIs1wzgwqiPQm59QDDmQzBKYGCEg,3753
4
- trismik/adaptive_test.py,sha256=hLGdf0jgLmJJ55I9c5QjaEd1bCA8QNfhJJoOBkF38ik,20002
5
- trismik/client_async.py,sha256=ZOvAH-nTnh_S3mrpLuprxtByZBasTnNCysBwUPwXMb0,12523
6
- trismik/exceptions.py,sha256=2wb4_K7GdDf00s3xUaiSfw6718ZV3Eaa4M2lYbiEZl4,1945
7
- trismik/settings.py,sha256=FCP-d8ZEiYWUTWoa9nOVzSwTOLvg8y0pU08dAseiOwY,412
8
- trismik/types.py,sha256=CNjvMQGnRM-ghjiZ-OWi6ZBI8RiyphuT_ABt0lhrtIA,6247
9
- trismik-0.9.6.dist-info/METADATA,sha256=LIfHvXxhQ7RftF7pMf7WuTW9sc6X9cC7A2i6AMbvZGc,6692
10
- trismik-0.9.6.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
11
- trismik-0.9.6.dist-info/licenses/LICENSE,sha256=tgetRhapGLh7ZxfknW6Mm-WobfziPd64nAK52X5XKaw,1077
12
- trismik-0.9.6.dist-info/RECORD,,