supervisely 6.73.450__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>'
@@ -24,6 +24,7 @@ from supervisely.io.fs import (
24
24
  get_file_name_with_ext,
25
25
  list_files_recursively,
26
26
  )
27
+ from supervisely.io.env import team_id
27
28
  from supervisely.io.json import load_json_file
28
29
  from supervisely.project.project_settings import LabelingInterface
29
30
 
@@ -78,16 +79,16 @@ class CSVConverter(ImageConverter):
78
79
  }
79
80
 
80
81
  def __init__(
81
- self,
82
- input_data: str,
83
- labeling_interface: Optional[Union[LabelingInterface, str]],
84
- upload_as_links: bool,
85
- remote_files_map: Optional[Dict[str, str]] = None,
82
+ self,
83
+ input_data: str,
84
+ labeling_interface: Optional[Union[LabelingInterface, str]],
85
+ upload_as_links: bool,
86
+ remote_files_map: Optional[Dict[str, str]] = None,
86
87
  ):
87
88
  super().__init__(input_data, labeling_interface, upload_as_links, remote_files_map)
88
89
 
90
+ self._supports_links = True
89
91
  self._csv_reader = None
90
- self._team_id = None
91
92
 
92
93
  def __str__(self):
93
94
  return AvailableImageConverters.CSV
@@ -121,6 +122,12 @@ class CSVConverter(ImageConverter):
121
122
 
122
123
  full_path = valid_files[0]
123
124
 
125
+ if self.upload_as_links and self._supports_links:
126
+ for local_path, remote_path in self._remote_files_map.items():
127
+ if local_path.endswith(full_path):
128
+ self._api.storage.download(self._team_id, remote_path, local_path)
129
+ break
130
+
124
131
  file_ext = get_file_ext(full_path)
125
132
  if file_ext in self.conversion_functions:
126
133
  csv_full_path = os.path.splitext(full_path)[0] + ".csv"
@@ -147,7 +154,7 @@ class CSVConverter(ImageConverter):
147
154
  team_files = False
148
155
  break
149
156
  if item_path is None:
150
- logger.warn(f"Failed to find image path in row: {row}. Skipping.")
157
+ logger.warning(f"Failed to find image path in row: {row}. Skipping.")
151
158
  continue
152
159
  ann_data = row.get("tag")
153
160
  item = CSVConverter.Item(
@@ -192,7 +199,7 @@ class CSVConverter(ImageConverter):
192
199
  ann_json = csv_helper.rename_in_json(ann_json, renamed_classes, renamed_tags)
193
200
  return Annotation.from_json(ann_json, meta)
194
201
  except Exception as e:
195
- logger.warn(f"Failed to convert annotation: {repr(e)}")
202
+ logger.warning(f"Failed to convert annotation: {repr(e)}")
196
203
  return item.create_empty_annotation()
197
204
 
198
205
  def process_remote_image(
@@ -209,19 +216,21 @@ class CSVConverter(ImageConverter):
209
216
  image_path = image_path.strip()
210
217
  if is_team_file:
211
218
  if not api.file.exists(team_id, image_path):
212
- logger.warn(f"File {image_path} not found in Team Files. Skipping...")
219
+ logger.warning(f"File {image_path} not found in Team Files. Skipping...")
213
220
  return None
214
221
  team_file_image_info = api.file.list(team_id, image_path)
215
222
  image_path = team_file_image_info[0]["fullStorageUrl"]
216
223
  if not image_path:
217
- logger.warn(f"Failed to get full storage URL for file '{image_path}'. Skipping...")
224
+ logger.warning(
225
+ f"Failed to get full storage URL for file '{image_path}'. Skipping..."
226
+ )
218
227
  return None
219
228
 
220
229
  extension = os.path.splitext(image_path)[1]
221
230
  if not extension:
222
- logger.warn(f"FYI: Image [{image_path}] doesn't have extension.")
231
+ logger.warning(f"FYI: Image [{image_path}] doesn't have extension.")
223
232
  elif extension.lower() not in SUPPORTED_IMG_EXTS:
224
- logger.warn(
233
+ logger.warning(
225
234
  f"Image [{image_path}] has unsupported extension [{extension}]. Skipping..."
226
235
  )
227
236
  return None
@@ -234,7 +243,7 @@ class CSVConverter(ImageConverter):
234
243
  force_metadata_for_links=force_metadata,
235
244
  )
236
245
  except Exception:
237
- logger.warn(f"Failed to upload image {image_name}. Skipping...")
246
+ logger.warning(f"Failed to link image {image_name}. Skipping...")
238
247
  return None
239
248
  if progress_cb is not None:
240
249
  progress_cb(1)
@@ -312,7 +321,7 @@ class CSVConverter(ImageConverter):
312
321
  success = False
313
322
  continue
314
323
  if item.name not in info.name:
315
- logger.warn(
324
+ logger.warning(
316
325
  f"Batched image with name '{item.name}' doesn't match uploaded image name '{info.name}'"
317
326
  )
318
327
  success = False
@@ -339,4 +348,4 @@ class CSVConverter(ImageConverter):
339
348
  if success:
340
349
  logger.info(f"Dataset ID:'{dataset_id}' has been successfully uploaded.")
341
350
  else:
342
- logger.warn(f"Dataset ID:'{dataset_id}' has been uploaded.")
351
+ logger.warning(f"Dataset ID:'{dataset_id}' has been uploaded.")
@@ -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.450
3
+ Version: 6.73.452
4
4
  Summary: Supervisely Python SDK.
5
5
  Home-page: https://github.com/supervisely/supervisely
6
6
  Author: Supervisely
@@ -24,7 +24,7 @@ Requires-Dist: cachetools<=5.5.0,>=4.2.3
24
24
  Requires-Dist: numpy<2.0.0,>=1.19
25
25
  Requires-Dist: opencv-python<5.0.0.0,>=4.6.0.66
26
26
  Requires-Dist: PTable<1.0.0,>=0.9.2
27
- Requires-Dist: pillow<=10.2.0,>=5.4.1
27
+ Requires-Dist: pillow<=10.4.0,>=5.4.1
28
28
  Requires-Dist: protobuf<=3.20.3,>=3.19.5
29
29
  Requires-Dist: python-json-logger<3.0.0,>=0.1.11
30
30
  Requires-Dist: requests<3.0.0,>=2.27.1
@@ -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
@@ -599,7 +599,7 @@ supervisely/convert/image/coco/coco_anntotation_converter.py,sha256=O1PQbwrbnpQB
599
599
  supervisely/convert/image/coco/coco_converter.py,sha256=7dW7vE6yTRz7O31vTVSnEA4MDCc_UXTqc2UFEqaKorI,5650
600
600
  supervisely/convert/image/coco/coco_helper.py,sha256=gkSLgLPUQh-xFN1A7Nh41nZE7rwHvdZSzcPG_C1dh8I,39473
601
601
  supervisely/convert/image/csv/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
602
- supervisely/convert/image/csv/csv_converter.py,sha256=iLyc2PAVtlsAq7blnGH4iS1_D7Ai6-4UsdI_RlDVB9Q,11677
602
+ supervisely/convert/image/csv/csv_converter.py,sha256=FNuNKOdNWp0JoXAvUlCp8JWXVJ7uJbBgeFFb8Wbyo_k,12064
603
603
  supervisely/convert/image/csv/csv_helper.py,sha256=-nR192IfMU0vTlNRoKXu5FS6tTs9fENqySyeKKyemRs,8409
604
604
  supervisely/convert/image/high_color/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
605
605
  supervisely/convert/image/high_color/high_color_depth.py,sha256=t1LsOnEwhSmXUWxs2K7e_EHit5H0132_UibtFIt1P_w,5276
@@ -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.450.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
1132
- supervisely-6.73.450.dist-info/METADATA,sha256=zWQ1yBvKetrO79_43cLFyW2uZrlzRt56bNFIsRUsPes,35480
1133
- supervisely-6.73.450.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
1134
- supervisely-6.73.450.dist-info/entry_points.txt,sha256=U96-5Hxrp2ApRjnCoUiUhWMqijqh8zLR03sEhWtAcms,102
1135
- supervisely-6.73.450.dist-info/top_level.txt,sha256=kcFVwb7SXtfqZifrZaSE3owHExX4gcNYe7Q2uoby084,28
1136
- supervisely-6.73.450.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,,