t2d2-sdk 1.4.20.dev1__tar.gz → 1.4.20.dev3__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.
@@ -16,8 +16,7 @@ jobs:
16
16
  uses: reecetech/version-increment@2024.4.3
17
17
  id: version
18
18
  with:
19
- scheme: semver
20
- increment: patch
19
+ scheme: conventional_commits
21
20
  pypi-publish:
22
21
  name: upload release to PyPI
23
22
  runs-on: ubuntu-latest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t2d2-sdk
3
- Version: 1.4.20.dev1
3
+ Version: 1.4.20.dev3
4
4
  Summary: T2D2 SDK
5
5
  Author-email: Badri Hiriyur <badri@t2d2.ai>
6
6
  Project-URL: Homepage, https://t2d2.ai
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.4.20.dev1'
16
- __version_tuple__ = version_tuple = (1, 4, 20, 'dev1')
15
+ __version__ = version = '1.4.20.dev3'
16
+ __version_tuple__ = version_tuple = (1, 4, 20, 'dev3')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t2d2-sdk
3
- Version: 1.4.20.dev1
3
+ Version: 1.4.20.dev3
4
4
  Summary: T2D2 SDK
5
5
  Author-email: Badri Hiriyur <badri@t2d2.ai>
6
6
  Project-URL: Homepage, https://t2d2.ai
@@ -16,6 +16,7 @@ TIMEOUT = 60
16
16
  BASE_URL = os.getenv("T2D2_API_URL", "https://api-v3.t2d2.ai/api/")
17
17
  # DEV https://api-v3-dev.t2d2.ai/api/
18
18
 
19
+
19
20
  ####################################################################################################
20
21
  # COMMON HELPER FUNCTIONS
21
22
  ####################################################################################################
@@ -246,14 +247,14 @@ class T2D2(object):
246
247
  ################################################################################################
247
248
  # CRUD Regions
248
249
  ################################################################################################
249
- def add_region(self, region_name:str):
250
+ def add_region(self, region_name: str):
250
251
  """Add region to project"""
251
252
  if not self.project:
252
253
  raise ValueError("Project not set")
253
254
 
254
255
  url = f"{self.project['id']}/categories/regions"
255
- json_data = self.request(url, RequestType.POST, data={'name': region_name})
256
- return json_data
256
+ json_data = self.request(url, RequestType.POST, data={"name": region_name})
257
+ return json_data
257
258
 
258
259
  ################################################################################################
259
260
  # CRUD Assets
@@ -385,7 +386,7 @@ class T2D2(object):
385
386
  raise ValueError("Project not set")
386
387
 
387
388
  url = f"{self.project['id']}/images/bulk.delete"
388
- payload = {"image_ids" : image_ids}
389
+ payload = {"image_ids": image_ids}
389
390
  return self.request(url, RequestType.DELETE, data=payload)
390
391
 
391
392
  ################################################################################################
@@ -457,7 +458,7 @@ class T2D2(object):
457
458
  raise ValueError("Project not set")
458
459
 
459
460
  url = f"{self.project['id']}/drawings/bulk.delete"
460
- payload = {"drawing_ids" : drawing_ids}
461
+ payload = {"drawing_ids": drawing_ids}
461
462
  return self.request(url, RequestType.DELETE, data=payload)
462
463
 
463
464
  ################################################################################################
@@ -529,7 +530,7 @@ class T2D2(object):
529
530
  raise ValueError("Project not set")
530
531
 
531
532
  url = f"{self.project['id']}/videos/bulk.delete"
532
- payload = {"video_ids" : video_ids}
533
+ payload = {"video_ids": video_ids}
533
534
  return self.request(url, RequestType.DELETE, data=payload)
534
535
 
535
536
  ################################################################################################
@@ -547,7 +548,8 @@ class T2D2(object):
547
548
  base, ext = os.path.splitext(os.path.basename(file_path))
548
549
  filename = f"{base}_{random_string(6)}{ext}"
549
550
  s3_path = (
550
- self.s3_base_url + f"/projects/{self.project['id']}/3d_models/{filename}"
551
+ self.s3_base_url
552
+ + f"/projects/{self.project['id']}/3d_models/{filename}"
551
553
  )
552
554
  upload_file(file_path, s3_path)
553
555
  assets.append(
@@ -601,7 +603,7 @@ class T2D2(object):
601
603
  raise ValueError("Project not set")
602
604
 
603
605
  url = f"{self.project['id']}/3d-models/bulk.delete"
604
- payload = {"model_ids" : model_ids}
606
+ payload = {"model_ids": model_ids}
605
607
  return self.request(url, RequestType.DELETE, data=payload)
606
608
 
607
609
  ################################################################################################
@@ -656,7 +658,25 @@ class T2D2(object):
656
658
  results.append(json_data["data"])
657
659
  return results
658
660
 
659
- # TODO: Delete / Update Reports
661
+ def update_reports(self, report_ids, payload):
662
+ """Update reports"""
663
+ if not self.project:
664
+ raise ValueError("Project not set")
665
+
666
+ url = f"{self.project['id']}/reports/bulk.update"
667
+ payload["report_ids"] = report_ids
668
+ payload["project_id"] = self.project["id"]
669
+ return self.request(url, RequestType.PUT, data=payload)
670
+
671
+ def delete_reports(self, report_ids):
672
+ """Delete reports"""
673
+ if not self.project:
674
+ raise ValueError("Project not set")
675
+
676
+ url = f"{self.project['id']}/reports/bulk.delete"
677
+ payload = {"report_ids": report_ids}
678
+ return self.request(url, RequestType.DELETE, data=payload)
679
+
660
680
  ################################################################################################
661
681
  # CRUD Tags
662
682
  ################################################################################################
@@ -682,6 +702,7 @@ class T2D2(object):
682
702
  for tag in tags:
683
703
  payload = {"name": tag}
684
704
  try:
705
+ # Use POST to create new tag
685
706
  result = self.request(url, RequestType.POST, data=payload)
686
707
  results.append(result)
687
708
  except Exception as e:
@@ -929,14 +950,14 @@ class T2D2(object):
929
950
  defaultdict(int),
930
951
  )
931
952
  for img in images:
932
- img_region = img["region"]['name']
933
- img_date = ts2date(img["captured_date"]).split(' ')[0]
953
+ img_region = img["region"]["name"]
954
+ img_date = ts2date(img["captured_date"]).split(" ")[0]
934
955
  img_tags = img["tags"]
935
956
 
936
957
  region_group[img_region] += 1
937
958
  date_group[img_date] += 1
938
959
  for img_tag in img_tags:
939
- tag_group[img_tag['name']] += 1
960
+ tag_group[img_tag["name"]] += 1
940
961
 
941
962
  return {
942
963
  "region_group": region_group,
@@ -953,32 +974,32 @@ class T2D2(object):
953
974
 
954
975
  anns = defaultdict(list)
955
976
  for img in imgs:
956
- reg = img['region']['name']
957
- anns_img = self.get_annotations(image_id=img['id'])
977
+ reg = img["region"]["name"]
978
+ anns_img = self.get_annotations(image_id=img["id"])
958
979
  anns[reg] += anns_img
959
980
 
960
981
  result = {}
961
982
  for reg, annotations in anns.items():
962
983
  sublist = {}
963
984
  for ann in annotations:
964
- label = ann['annotation_class']['annotation_class_name']
965
- rating = ann.get('condition', {}).get('rating_name', 'default')
966
- area = ann['area']
967
- length = ann['length']
968
- ann_id = ann['id']
985
+ label = ann["annotation_class"]["annotation_class_name"]
986
+ rating = ann.get("condition", {}).get("rating_name", "default")
987
+ area = ann["area"]
988
+ length = ann["length"]
989
+ ann_id = ann["id"]
969
990
  key = (label, rating)
970
991
  if key in sublist:
971
- sublist[key]['count'] += 1
972
- sublist[key]['length'] += length
973
- sublist[key]['area'] += area
974
- sublist[key]['annotation_ids'].append(ann_id)
992
+ sublist[key]["count"] += 1
993
+ sublist[key]["length"] += length
994
+ sublist[key]["area"] += area
995
+ sublist[key]["annotation_ids"].append(ann_id)
975
996
  else:
976
997
  sublist[key] = {}
977
- sublist[key]['count'] = 1
978
- sublist[key]['length'] = length
979
- sublist[key]['area'] = area
980
- sublist[key]['annotation_ids'] = []
981
-
998
+ sublist[key]["count"] = 1
999
+ sublist[key]["length"] = length
1000
+ sublist[key]["area"] = area
1001
+ sublist[key]["annotation_ids"] = []
1002
+
982
1003
  result[reg] = sublist
983
1004
 
984
- return result
1005
+ return result
File without changes
File without changes
File without changes