supervisely 6.73.451__py3-none-any.whl → 6.73.452__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.
supervisely/_utils.py CHANGED
@@ -319,6 +319,87 @@ def resize_image_url(
319
319
  return full_storage_url
320
320
 
321
321
 
322
+ def get_storage_url(
323
+ entity_type: Literal["dataset-entities", "dataset", "project", "file-storage"],
324
+ entity_id: int,
325
+ source_type: Literal["original", "preview"],
326
+ ) -> str:
327
+ """
328
+ Generate URL for storage resources endpoints.
329
+
330
+ :param entity_type: Type of entity ("dataset-entities", "dataset", "project", "file-storage")
331
+ :type entity_type: str
332
+ :param entity_id: ID of the entity
333
+ :type entity_id: int
334
+ :param source_type: Type of source ("original" or "preview")
335
+ :type source_type: Literal["original", "preview"]
336
+ :return: Storage URL
337
+ :rtype: str
338
+ """
339
+ relative_url = f"/storage-resources/{entity_type}/{source_type}/{entity_id}"
340
+ if is_development():
341
+ return abs_url(relative_url)
342
+ return relative_url
343
+
344
+
345
+ def get_image_storage_url(image_id: int, source_type: Literal["original", "preview"]) -> str:
346
+ """
347
+ Generate URL for image storage resources.
348
+
349
+ :param image_id: ID of the image
350
+ :type image_id: int
351
+ :param source_type: Type of source ("original" or "preview")
352
+ :type source_type: Literal["original", "preview"]
353
+ :return: Storage URL for image
354
+ :rtype: str
355
+ """
356
+ return get_storage_url("dataset-entities", image_id, source_type)
357
+
358
+
359
+ def get_dataset_storage_url(
360
+ dataset_id: int, source_type: Literal["original", "preview", "raw"]
361
+ ) -> str:
362
+ """
363
+ Generate URL for dataset storage resources.
364
+
365
+ :param dataset_id: ID of the dataset
366
+ :type dataset_id: int
367
+ :param source_type: Type of source ("original", "preview", or "raw")
368
+ :type source_type: Literal["original", "preview", "raw"]
369
+ :return: Storage URL for dataset
370
+ :rtype: str
371
+ """
372
+ return get_storage_url("dataset", dataset_id, source_type)
373
+
374
+
375
+ def get_project_storage_url(
376
+ project_id: int, source_type: Literal["original", "preview", "raw"]
377
+ ) -> str:
378
+ """
379
+ Generate URL for project storage resources.
380
+
381
+ :param project_id: ID of the project
382
+ :type project_id: int
383
+ :param source_type: Type of source ("original", "preview", or "raw")
384
+ :type source_type: Literal["original", "preview", "raw"]
385
+ :return: Storage URL for project
386
+ :rtype: str
387
+ """
388
+ return get_storage_url("project", project_id, source_type)
389
+
390
+
391
+ def get_file_storage_url(file_id: int) -> str:
392
+ """
393
+ Generate URL for file storage resources (raw files).
394
+
395
+ :param file_id: ID of the file
396
+ :type file_id: int
397
+ :return: Storage URL for file
398
+ :rtype: str
399
+ """
400
+ return get_storage_url("file-storage", file_id, "raw")
401
+
402
+
322
403
  def get_preview_link(title="preview"):
323
404
  return (
324
405
  f'<a href="javascript:;">{title}<i class="zmdi zmdi-cast" style="margin-left: 5px"></i></a>'
@@ -1598,13 +1598,18 @@ class TrainApp:
1598
1598
  project_id = self.project_id
1599
1599
 
1600
1600
  dataset_infos = [dataset for _, dataset in self._api.dataset.tree(project_id)]
1601
+ id_to_info = {ds.id: ds for ds in dataset_infos}
1601
1602
  ds_infos_dict = {}
1602
1603
  for dataset in dataset_infos:
1603
- if dataset.parent_id is not None:
1604
- parent_ds = self._api.dataset.get_info_by_id(dataset.parent_id)
1605
- dataset_name = f"{parent_ds.name}/{dataset.name}"
1606
- else:
1607
- dataset_name = dataset.name
1604
+ name_parts = [dataset.name]
1605
+ parent_id = dataset.parent_id
1606
+ while parent_id is not None:
1607
+ parent_ds = id_to_info.get(parent_id)
1608
+ if parent_ds is None:
1609
+ parent_ds = self._api.dataset.get_info_by_id(parent_id)
1610
+ name_parts.append(parent_ds.name)
1611
+ parent_id = parent_ds.parent_id
1612
+ dataset_name = "/".join(reversed(name_parts))
1608
1613
  ds_infos_dict[dataset_name] = dataset
1609
1614
 
1610
1615
  def get_image_infos_by_split(ds_infos_dict: dict, split: list):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: supervisely
3
- Version: 6.73.451
3
+ Version: 6.73.452
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -1,6 +1,6 @@
1
1
  supervisely/README.md,sha256=XM-DiMC6To3I9RjQZ0c61905EFRR_jnCUx2q3uNR-X8,3331
2
2
  supervisely/__init__.py,sha256=_zh2UIxLUyf2krDKY-yurV9enqg1drEubCRX5nDlqR4,15333
3
- supervisely/_utils.py,sha256=59vOeNOnmVHODnlAvULT8jdwvHHVTs2FOtAFw8mvaqE,20643
3
+ supervisely/_utils.py,sha256=WsfBpnSqtj2zAO-VKgJneoI49RCVpLugvKAnGQE_KQQ,23152
4
4
  supervisely/function_wrapper.py,sha256=R5YajTQ0GnRp2vtjwfC9hINkzQc0JiyGsu8TER373xY,1912
5
5
  supervisely/sly_logger.py,sha256=z92Vu5hmC0GgTIJO1n6kPDayRW9__8ix8hL6poDZj-Y,6274
6
6
  supervisely/tiny_timer.py,sha256=hkpe_7FE6bsKL79blSs7WBaktuPavEVu67IpEPrfmjE,183
@@ -1013,7 +1013,7 @@ supervisely/nn/tracker/botsort/tracker/kalman_filter.py,sha256=waTArMcbmpHAzb57a
1013
1013
  supervisely/nn/tracker/botsort/tracker/matching.py,sha256=bgnheHwWD3XZSI3OJVfdrU5bYJ44rxPHzzSElfg6LZM,6600
1014
1014
  supervisely/nn/tracker/botsort/tracker/mc_bot_sort.py,sha256=dFjWmubyJLrUP4i-CJaOhPEkQD-WD144deW7Ua5a7Rc,17775
1015
1015
  supervisely/nn/training/__init__.py,sha256=gY4PCykJ-42MWKsqb9kl-skemKa8yB6t_fb5kzqR66U,111
1016
- supervisely/nn/training/train_app.py,sha256=l4t4zzE-nPwV-tXzbw4ENQcGMQ1PCeqmyxfkLg_eFDI,133159
1016
+ supervisely/nn/training/train_app.py,sha256=6pAP7_B_pTA_OL1MtdevNRXKkL3FE-keb1YCNvzpT0U,133429
1017
1017
  supervisely/nn/training/gui/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
1018
1018
  supervisely/nn/training/gui/classes_selector.py,sha256=tqmVwUfC2u5K53mZmvDvNOhu9Mw5mddjpB2kxRXXUO8,12453
1019
1019
  supervisely/nn/training/gui/gui.py,sha256=_CtpzlwP6WLFgOTBDB_4RPcaqrQPK92DwSCDvO-dIKM,51749
@@ -1128,9 +1128,9 @@ supervisely/worker_proto/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
1128
1128
  supervisely/worker_proto/worker_api_pb2.py,sha256=VQfi5JRBHs2pFCK1snec3JECgGnua3Xjqw_-b3aFxuM,59142
1129
1129
  supervisely/worker_proto/worker_api_pb2_grpc.py,sha256=3BwQXOaP9qpdi0Dt9EKG--Lm8KGN0C5AgmUfRv77_Jk,28940
1130
1130
  supervisely_lib/__init__.py,sha256=yRwzEQmVwSd6lUQoAUdBngKEOlnoQ6hA9ZcoZGJRNC4,331
1131
- supervisely-6.73.451.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1132
- supervisely-6.73.451.dist-info/METADATA,sha256=UDSRIdFR3U9VbWpLqzckQ9YqL2IsB0wdyP_4Ny3asac,35480
1133
- supervisely-6.73.451.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
1134
- supervisely-6.73.451.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1135
- supervisely-6.73.451.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1136
- supervisely-6.73.451.dist-info/RECORD,,
1131
+ supervisely-6.73.452.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1132
+ supervisely-6.73.452.dist-info/METADATA,sha256=o1IIrOeH7ZDHD8bH7l_R6v7BpmNSoI1i5P0O0c-eNFg,35480
1133
+ supervisely-6.73.452.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
1134
+ supervisely-6.73.452.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1135
+ supervisely-6.73.452.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1136
+ supervisely-6.73.452.dist-info/RECORD,,