unitlab 2.4.3__tar.gz → 2.4.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitlab
3
- Version: 2.4.3
3
+ Version: 2.4.4
4
4
  Summary: Python SDK for the Unitlab.ai data annotation platform
5
5
  Project-URL: Homepage, https://unitlab.ai
6
6
  Project-URL: Documentation, https://docs.unitlab.ai
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "unitlab"
7
- version = "2.4.3"
7
+ version = "2.4.4"
8
8
  description = "Python SDK for the Unitlab.ai data annotation platform"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -37,12 +37,6 @@ class DownloadType(str, Enum):
37
37
  files = "files"
38
38
 
39
39
 
40
- class DatasetSplit(str, Enum):
41
- train = "train"
42
- validation = "validation"
43
- test = "test"
44
-
45
-
46
40
  @app.command(help="Configure the credentials")
47
41
  def configure(
48
42
  api_key: Annotated[
@@ -124,11 +118,14 @@ def dataset_download(
124
118
  typer.Option(help="Export type (e.g. COCO, YOLOv8, YOLOv5, UUEF)"),
125
119
  ] = "COCO",
126
120
  split_type: Annotated[
127
- DatasetSplit, typer.Option(help="Dataset split (train, validation, test)")
128
- ] = DatasetSplit.train,
121
+ str | None,
122
+ typer.Option(
123
+ help="Dataset split (e.g. train, validation). Auto-detected if omitted."
124
+ ),
125
+ ] = None,
129
126
  ):
130
127
  if download_type == DownloadType.annotation:
131
- get_client(api_key).dataset_download(str(pk), export_type, split_type.value)
128
+ get_client(api_key).dataset_download(str(pk), export_type, split_type)
132
129
  else:
133
130
  typer.echo(get_client(api_key).dataset_download_files(str(pk)))
134
131
 
@@ -308,9 +308,41 @@ class UnitlabClient:
308
308
  def datasets(self, pretty: int = 0) -> Any:
309
309
  return self._get(f"/api/sdk/datasets/?pretty={pretty}")
310
310
 
311
+ def dataset_info(self, dataset_id: str) -> Any:
312
+ """Return metadata for a dataset.
313
+
314
+ Includes name, version, annotation_type, number_of_data,
315
+ download_formats and the list of available ``splits``.
316
+ """
317
+ return self._get(f"/api/sdk/datasets/{dataset_id}/")
318
+
311
319
  def dataset_download(
312
- self, dataset_id: str, export_type: str, split_type: str
320
+ self,
321
+ dataset_id: str,
322
+ export_type: str,
323
+ split_type: str | None = None,
313
324
  ) -> str:
325
+ if split_type is None:
326
+ info = self.dataset_info(dataset_id)
327
+ splits = info.get("splits") or []
328
+ if not splits:
329
+ raise NetworkError(
330
+ message=(
331
+ "No splits available for this dataset. Nothing to download."
332
+ ),
333
+ detail=None,
334
+ )
335
+ if len(splits) > 1:
336
+ raise NetworkError(
337
+ message=(
338
+ f"Multiple splits available: {', '.join(splits)}. "
339
+ f"Specify one with split_type=..."
340
+ ),
341
+ detail=None,
342
+ )
343
+ split_type = splits[0]
344
+ logger.info(f"Auto-selected split: {split_type}")
345
+
314
346
  response = self._post(
315
347
  f"/api/sdk/datasets/{dataset_id}/",
316
348
  data={
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes