t2d2-sdk 1.4.20.dev1__tar.gz → 1.4.20.dev2__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.
@@ -17,7 +17,6 @@ jobs:
17
17
  id: version
18
18
  with:
19
19
  scheme: semver
20
- increment: patch
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.dev2
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.dev2'
16
+ __version_tuple__ = version_tuple = (1, 4, 20, 'dev2')
@@ -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.dev2
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
  ################################################################################################
@@ -929,14 +949,14 @@ class T2D2(object):
929
949
  defaultdict(int),
930
950
  )
931
951
  for img in images:
932
- img_region = img["region"]['name']
933
- img_date = ts2date(img["captured_date"]).split(' ')[0]
952
+ img_region = img["region"]["name"]
953
+ img_date = ts2date(img["captured_date"]).split(" ")[0]
934
954
  img_tags = img["tags"]
935
955
 
936
956
  region_group[img_region] += 1
937
957
  date_group[img_date] += 1
938
958
  for img_tag in img_tags:
939
- tag_group[img_tag['name']] += 1
959
+ tag_group[img_tag["name"]] += 1
940
960
 
941
961
  return {
942
962
  "region_group": region_group,
@@ -953,32 +973,32 @@ class T2D2(object):
953
973
 
954
974
  anns = defaultdict(list)
955
975
  for img in imgs:
956
- reg = img['region']['name']
957
- anns_img = self.get_annotations(image_id=img['id'])
976
+ reg = img["region"]["name"]
977
+ anns_img = self.get_annotations(image_id=img["id"])
958
978
  anns[reg] += anns_img
959
979
 
960
980
  result = {}
961
981
  for reg, annotations in anns.items():
962
982
  sublist = {}
963
983
  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']
984
+ label = ann["annotation_class"]["annotation_class_name"]
985
+ rating = ann.get("condition", {}).get("rating_name", "default")
986
+ area = ann["area"]
987
+ length = ann["length"]
988
+ ann_id = ann["id"]
969
989
  key = (label, rating)
970
990
  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)
991
+ sublist[key]["count"] += 1
992
+ sublist[key]["length"] += length
993
+ sublist[key]["area"] += area
994
+ sublist[key]["annotation_ids"].append(ann_id)
975
995
  else:
976
996
  sublist[key] = {}
977
- sublist[key]['count'] = 1
978
- sublist[key]['length'] = length
979
- sublist[key]['area'] = area
980
- sublist[key]['annotation_ids'] = []
981
-
997
+ sublist[key]["count"] = 1
998
+ sublist[key]["length"] = length
999
+ sublist[key]["area"] = area
1000
+ sublist[key]["annotation_ids"] = []
1001
+
982
1002
  result[reg] = sublist
983
1003
 
984
- return result
1004
+ return result
File without changes
File without changes
File without changes