superannotate 4.6.1__tar.gz → 4.6.2__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.
Files changed (146) hide show
  1. {superannotate-4.6.1/src/superannotate.egg-info → superannotate-4.6.2}/PKG-INFO +1 -1
  2. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/__init__.py +1 -1
  3. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/helpers.py +39 -0
  4. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/base_interface.py +13 -3
  5. superannotate-4.6.2/src/superannotate/lib/app/interface/sdk/__init__.py +12 -0
  6. superannotate-4.6.2/src/superannotate/lib/app/interface/sdk/explore.py +261 -0
  7. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/sdk_interface.py +290 -8
  8. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/types.py +10 -0
  9. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/__init__.py +4 -0
  10. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/filters.py +12 -0
  11. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/work_managament.py +51 -0
  12. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/service_types.py +49 -0
  13. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/serviceproviders.py +54 -0
  14. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/items.py +89 -0
  15. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/controller.py +194 -0
  16. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/query_builder.py +33 -0
  17. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/explore.py +80 -5
  18. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/work_management.py +98 -0
  19. {superannotate-4.6.1 → superannotate-4.6.2/src/superannotate.egg-info}/PKG-INFO +1 -1
  20. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate.egg-info/SOURCES.txt +1 -2
  21. superannotate-4.6.1/src/superannotate/lib/app/interface/sdk/folders.py +0 -0
  22. superannotate-4.6.1/src/superannotate/lib/app/interface/sdk/project.py +0 -0
  23. superannotate-4.6.1/src/superannotate/lib/infrastructure/__init__.py +0 -0
  24. {superannotate-4.6.1 → superannotate-4.6.2}/LICENSE +0 -0
  25. {superannotate-4.6.1 → superannotate-4.6.2}/MANIFEST.in +0 -0
  26. {superannotate-4.6.1 → superannotate-4.6.2}/README.rst +0 -0
  27. {superannotate-4.6.1 → superannotate-4.6.2}/requirements.txt +0 -0
  28. {superannotate-4.6.1 → superannotate-4.6.2}/setup.cfg +0 -0
  29. {superannotate-4.6.1 → superannotate-4.6.2}/setup.py +0 -0
  30. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/__init__.py +0 -0
  31. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/__init__.py +0 -0
  32. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/analytics/__init__.py +0 -0
  33. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/analytics/aggregators.py +0 -0
  34. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/analytics/common.py +0 -0
  35. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/bin/__init__.py +0 -0
  36. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/bin/superannotate.py +0 -0
  37. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/common.py +0 -0
  38. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/exceptions.py +0 -0
  39. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/__init__.py +0 -0
  40. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/conversion.py +0 -0
  41. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/__init__.py +0 -0
  42. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/baseStrategy.py +0 -0
  43. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/__init__.py +0 -0
  44. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/coco_api.py +0 -0
  45. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/coco_converter.py +0 -0
  46. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/coco_strategies.py +0 -0
  47. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/coco_to_sa_vector.py +0 -0
  48. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/coco_converters/sa_vector_to_coco.py +0 -0
  49. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/converters.py +0 -0
  50. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/dataloop_converters/__init__.py +0 -0
  51. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/dataloop_converters/dataloop_helper.py +0 -0
  52. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/dataloop_converters/dataloop_strategies.py +0 -0
  53. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/dataloop_converters/dataloop_to_sa_vector.py +0 -0
  54. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/googlecloud_converters/__init__.py +0 -0
  55. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/googlecloud_converters/googlecloud_strategies.py +0 -0
  56. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/googlecloud_converters/googlecloud_to_sa_vector.py +0 -0
  57. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/labelbox_converters/__init__.py +0 -0
  58. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/labelbox_converters/labelbox_helper.py +0 -0
  59. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/labelbox_converters/labelbox_to_sa_vector.py +0 -0
  60. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/sa_json_helper.py +0 -0
  61. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/sagemaker_converters/__init__.py +0 -0
  62. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/sagemaker_converters/sagemaker_strategies.py +0 -0
  63. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/sagemaker_converters/sagemaker_to_sa_vector.py +0 -0
  64. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/supervisely_converters/__init__.py +0 -0
  65. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/supervisely_converters/supervisely_helper.py +0 -0
  66. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/supervisely_converters/supervisely_strategies.py +0 -0
  67. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/supervisely_converters/supervisely_to_sa_vector.py +0 -0
  68. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vgg_converters/__init__.py +0 -0
  69. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vgg_converters/vgg_helper.py +0 -0
  70. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vgg_converters/vgg_strategies.py +0 -0
  71. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vgg_converters/vgg_to_sa_vector.py +0 -0
  72. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/voc_converters/__init__.py +0 -0
  73. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/voc_converters/voc_helper.py +0 -0
  74. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/voc_converters/voc_strategies.py +0 -0
  75. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/voc_converters/voc_to_sa_pixel.py +0 -0
  76. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/voc_converters/voc_to_sa_vector.py +0 -0
  77. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vott_converters/__init__.py +0 -0
  78. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vott_converters/vott_strategies.py +0 -0
  79. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/vott_converters/vott_to_sa_vector.py +0 -0
  80. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/yolo_converters/__init__.py +0 -0
  81. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/yolo_converters/yolo_strategies.py +0 -0
  82. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/converters/yolo_converters/yolo_to_sa_vector.py +0 -0
  83. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/export_from_sa_conversions.py +0 -0
  84. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/input_converters/import_to_sa_conversions.py +0 -0
  85. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/__init__.py +0 -0
  86. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/cli_interface.py +0 -0
  87. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/interface/responses.py +0 -0
  88. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/app/serializers.py +0 -0
  89. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/base_usecases.py +0 -0
  90. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/conditions.py +0 -0
  91. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/config.py +0 -0
  92. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/__init__.py +0 -0
  93. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/base.py +0 -0
  94. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/classes.py +0 -0
  95. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/context.py +0 -0
  96. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/folder.py +0 -0
  97. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/integrations.py +0 -0
  98. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/items.py +0 -0
  99. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/multimodal_form.py +0 -0
  100. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/project.py +0 -0
  101. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/entities/project_entities.py +0 -0
  102. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/enums.py +0 -0
  103. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/exceptions.py +0 -0
  104. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/jsx_conditions.py +0 -0
  105. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/plugin.py +0 -0
  106. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/reporter.py +0 -0
  107. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/repositories.py +0 -0
  108. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/response.py +0 -0
  109. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/types.py +0 -0
  110. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/__init__.py +0 -0
  111. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/annotations.py +0 -0
  112. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/base.py +0 -0
  113. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/classes.py +0 -0
  114. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/custom_fields.py +0 -0
  115. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/folders.py +0 -0
  116. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/images.py +0 -0
  117. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/integrations.py +0 -0
  118. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/models.py +0 -0
  119. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/projects.py +0 -0
  120. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/usecases/work_management.py +0 -0
  121. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/utils.py +0 -0
  122. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/core/video_convertor.py +0 -0
  123. {superannotate-4.6.1/src/superannotate/lib/app/interface/sdk → superannotate-4.6.2/src/superannotate/lib/infrastructure}/__init__.py +0 -0
  124. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/annotation_adapter.py +0 -0
  125. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/custom_entities.py +0 -0
  126. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/helpers.py +0 -0
  127. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/repositories.py +0 -0
  128. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/serviceprovider.py +0 -0
  129. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/__init__.py +0 -0
  130. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/annotation.py +0 -0
  131. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/annotation_class.py +0 -0
  132. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/auth.py +0 -0
  133. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/folder.py +0 -0
  134. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/http_client.py +0 -0
  135. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/integration.py +0 -0
  136. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/item.py +0 -0
  137. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/item_service.py +0 -0
  138. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/project.py +0 -0
  139. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/services/telemetry_scoring.py +0 -0
  140. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/stream_data_handler.py +0 -0
  141. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/utils.py +0 -0
  142. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate/lib/infrastructure/validators.py +0 -0
  143. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate.egg-info/dependency_links.txt +0 -0
  144. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate.egg-info/entry_points.txt +0 -0
  145. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate.egg-info/requires.txt +0 -0
  146. {superannotate-4.6.1 → superannotate-4.6.2}/src/superannotate.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: superannotate
3
- Version: 4.6.1
3
+ Version: 4.6.2
4
4
  Summary: Python SDK to SuperAnnotate platform
5
5
  Home-page: https://github.com/superannotateai/superannotate-python-sdk
6
6
  Author: SuperAnnotate AI
@@ -2,7 +2,7 @@ import logging
2
2
  import os
3
3
  import sys
4
4
 
5
- __version__ = "4.6.1"
5
+ __version__ = "4.6.2"
6
6
 
7
7
 
8
8
  os.environ.update({"sa_version": __version__})
@@ -1,16 +1,55 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import re
5
+ import sys
4
6
  import uuid
7
+ import warnings
5
8
  from pathlib import Path
6
9
 
7
10
  import boto3
8
11
  import numpy as np
9
12
  import pandas as pd
13
+ import pydantic
10
14
  from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
11
15
  from lib.core import VECTOR_ANNOTATION_POSTFIX
12
16
  from lib.core.exceptions import AppException
13
17
 
18
+ # Frames in these directories are the SDK's own wrappers (Tracker, argument
19
+ # validation) - a deprecation warning is attributed to the first frame outside them.
20
+ _WRAPPER_DIRS = (
21
+ str(Path(__file__).resolve().parents[2]), # the superannotate package
22
+ str(Path(pydantic.__file__).resolve().parent),
23
+ )
24
+
25
+
26
+ # Python shows a DeprecationWarning by default only when it is attributed to
27
+ # __main__, so a deprecated SDK method called from any other module (a package, a
28
+ # notebook helper, a test) would be silent. Show the SDK's own deprecations wherever
29
+ # they are called from. Skipped when the user configured warnings themselves (-W or
30
+ # PYTHONWARNINGS); filters they add in code later still take precedence.
31
+ DEPRECATION_MESSAGE_PATTERN = r"This function .+ will be deprecated"
32
+ if not sys.warnoptions:
33
+ warnings.filterwarnings(
34
+ "default", message=DEPRECATION_MESSAGE_PATTERN, category=DeprecationWarning
35
+ )
36
+
37
+
38
+ def warn_deprecated(message: str):
39
+ """Emit a DeprecationWarning attributed to the user's call.
40
+
41
+ The message must match DEPRECATION_MESSAGE_PATTERN to be shown by default. The
42
+ stacklevel is computed rather than fixed: a fixed one would land inside the
43
+ wrappers every public method goes through (Tracker, argument validation).
44
+ """
45
+ assert re.match(DEPRECATION_MESSAGE_PATTERN, message), message
46
+ stacklevel = 1
47
+ frame = sys._getframe(0)
48
+ while frame is not None and frame.f_code.co_filename.startswith(_WRAPPER_DIRS):
49
+ frame = frame.f_back
50
+ stacklevel += 1
51
+ warnings.warn(message, DeprecationWarning, stacklevel=stacklevel)
52
+
14
53
 
15
54
  def get_annotation_paths(folder_path, s3_bucket=None, recursive=False):
16
55
  annotation_paths = []
@@ -230,8 +230,11 @@ class Tracker:
230
230
  "Env": os.environ.get("SA_ENV", "N/A"),
231
231
  }
232
232
 
233
- def __init__(self, function):
233
+ def __init__(self, function, event_name: str | None = None):
234
234
  self.function = function
235
+ # Reported instead of the function's own name, e.g. for a helper that stands
236
+ # in for a method the user calls on a returned object (QueryResult.count).
237
+ self.event_name = event_name
235
238
  functools.update_wrapper(self, function)
236
239
 
237
240
  @staticmethod
@@ -253,7 +256,7 @@ class Tracker:
253
256
  def default_parser(function_name: str, kwargs: dict) -> tuple:
254
257
  properties = {}
255
258
  for key, value in kwargs.items():
256
- if key == "self":
259
+ if key == "self" or key.startswith("_"):
257
260
  continue
258
261
  if key == "token":
259
262
  properties["sa_token"] = str(bool(value))
@@ -318,7 +321,14 @@ class Tracker:
318
321
  try:
319
322
  function_name = self.function.__name__ if self.function else ""
320
323
  arguments = self.extract_arguments(self.function, *args, **kwargs)
321
- event_name, properties = self.default_parser(function_name, arguments)
324
+ event_name, properties = self.default_parser(
325
+ self.event_name or function_name, arguments
326
+ )
327
+ # A namespace (e.g. SAClient.explore) reports its methods as
328
+ # "<namespace>.<method>", so they don't collide with SAClient's own.
329
+ tracking_prefix = getattr(instance, "TRACKING_PREFIX", None)
330
+ if tracking_prefix:
331
+ event_name = f"{tracking_prefix}.{event_name}"
322
332
 
323
333
  # instance is args[0] - the actual object the call was made on, captured
324
334
  # locally per call (see __call__), not shared/mutable state. It has no
@@ -0,0 +1,12 @@
1
+ class BaseNamespace:
2
+ """A group of SAClient methods exposed as an attribute, e.g. SAClient.explore.
3
+
4
+ __init__ lives here rather than on the namespace, so TrackableMeta (applied to the
5
+ namespace) does not report building one as a telemetry event.
6
+ """
7
+
8
+ #: Mixpanel events of the namespace's methods are reported as "<prefix>.<method>".
9
+ TRACKING_PREFIX: str
10
+
11
+ def __init__(self, controller):
12
+ self.controller = controller
@@ -0,0 +1,261 @@
1
+ from __future__ import annotations
2
+
3
+ from functools import partial
4
+ from typing import Annotated
5
+
6
+ from lib.app.interface.base_interface import TrackableMeta
7
+ from lib.app.interface.base_interface import Tracker
8
+ from lib.app.interface.responses import QueryResult
9
+ from lib.app.interface.sdk import BaseNamespace
10
+ from lib.app.serializers import BaseSerializer
11
+ from lib.core.exceptions import AppException
12
+ from pydantic import StringConstraints
13
+
14
+ NotEmptyStr = Annotated[str, StringConstraints(strict=True, min_length=1)]
15
+
16
+
17
+ class Explore(BaseNamespace, metaclass=TrackableMeta):
18
+ """Namespace for querying and curating project data with the Explore query language.
19
+
20
+ Accessed as ``SAClient.explore``. Groups the functions that operate on the Explore
21
+ surface of the platform. Every query in this namespace uses the SuperAnnotate query
22
+ language documented at https://doc.superannotate.com/docs/queries-beta.
23
+
24
+ Available methods:
25
+
26
+ - ``explore.query()`` - Return items that satisfy a query string. Returns a
27
+ QueryResult, which behaves like a list of dicts and exposes a ``.count()`` method.
28
+ - ``explore.query().count()`` - Returns the total number of items matching the
29
+ query, without fetching item metadata.
30
+ - ``explore.get_subsets()`` - Return the subsets that exist in a project.
31
+ - ``explore.add_items_to_subset()`` - Associate items with a subset, creating the
32
+ subset if it does not exist.
33
+ """
34
+
35
+ TRACKING_PREFIX = "explore"
36
+
37
+ def query(
38
+ self,
39
+ project: NotEmptyStr | int | tuple[int, int] | tuple[str, str],
40
+ query: NotEmptyStr | None = None,
41
+ subset: NotEmptyStr | None = None,
42
+ ) -> QueryResult:
43
+ """Return items that satisfy the given Explore query.
44
+ Query syntax should be in the SuperAnnotate query language
45
+ (https://doc.superannotate.com/docs/queries-beta).
46
+
47
+ The returned QueryResult behaves like a list of dicts, and additionally exposes a .count() method.
48
+
49
+ :param project: Accepts a project as a string ("project" or "project/folder") or as a tuple (project_id, folder_id), where the folder is optional.
50
+ :type project: Union[str, int, Tuple[int, int], Tuple[str, str]]
51
+
52
+ :param query: Explore query string.
53
+ :type query: str
54
+
55
+ :param subset: Subset name. Restricts the query to items in the given subset.
56
+ To return all the items in the specified subset, leave the query as None.
57
+ :type subset: str
58
+
59
+ :return: queried items' metadata list
60
+ :rtype: QueryResult (list of dicts with .count() method)
61
+
62
+ :raises AppException: If both query and subset are left empty, if the project,
63
+ folder or subset is not found, or with the backend's message if the query is
64
+ rejected (e.g. an invalid query string, or a project that was never resynced).
65
+
66
+ Request Example:
67
+ ::
68
+
69
+ # To query by status:
70
+ sa_client.explore.query(
71
+ project="Image Project",
72
+ query='_status = "InProgress"'
73
+ )
74
+
75
+ # To query within a subset:
76
+ sa_client.explore.query(
77
+ project="Image Project",
78
+ query='_status = "InProgress"',
79
+ subset="golden-set"
80
+ )
81
+
82
+ Response Example:
83
+ ::
84
+
85
+ [
86
+ {
87
+ "id": 196560932,
88
+ "name": "TEST_00001",
89
+ "folder_id": 867191,
90
+ "comments": [],
91
+ "annotation_status": "InProgress",
92
+ "path": "custom_llm",
93
+ "approval_status": 0,
94
+ "createdAt": "2026-08-04T03:50:53.000Z",
95
+ "updatedAt": "2026-09-02T10:37:18.000Z",
96
+ "meta": {"integration_id": None},
97
+ "instances": [],
98
+ "custom_metadata": {},
99
+ "subset_ids": [],
100
+ "category_id": [],
101
+ "category_name": None,
102
+ "assignment": [],
103
+ "last_action": {
104
+ "date": "2026-09-02T10:37:17.217Z",
105
+ "email": "test@superannotate.com"
106
+ },
107
+ "score": [],
108
+ "is_pinned": 0,
109
+ "folder_name": "root",
110
+ "is_root_folder": 1
111
+ }
112
+ ]
113
+
114
+ .. py:method:: query.count() -> int
115
+
116
+ Returns the total number of items matching the query, without fetching item metadata.
117
+
118
+ :return: total number of matching items
119
+ :rtype: int
120
+
121
+ Request Example:
122
+ ::
123
+
124
+ total = sa_client.explore.query(
125
+ project="Image Project", query='_status = "InProgress"'
126
+ ).count()
127
+ print(f"Total matching items: {total}")
128
+ """
129
+ if not any([query, subset]):
130
+ raise AppException("Provide 'query' or 'subset'")
131
+ project_entity, folder = self.controller.get_project_folder(project)
132
+ return QueryResult(
133
+ data_fetcher=lambda: [
134
+ item.model_dump()
135
+ for item in self.controller.explore_query(
136
+ project_entity, folder, query, subset
137
+ )
138
+ ],
139
+ count_fetcher=partial(
140
+ self._count,
141
+ query=query,
142
+ subset=subset,
143
+ _resolved=(project_entity, folder),
144
+ ),
145
+ )
146
+
147
+ def _count(self, query, subset, _resolved) -> int:
148
+ """Backs QueryResult.count() of explore.query().
149
+
150
+ query and subset are reported on the "explore.query.count" event; the already
151
+ resolved entities come in _resolved, which telemetry skips.
152
+ """
153
+ project_entity, folder = _resolved
154
+ return self.controller.explore_query_count(
155
+ project_entity, folder, query, subset
156
+ )
157
+
158
+ _count = Tracker(_count, event_name="query.count")
159
+
160
+ def get_subsets(self, project: NotEmptyStr | int):
161
+ """Returns the subsets that exist in the given project.
162
+
163
+ :param project: The name or ID of the project.
164
+ :type project: Union[str, int]
165
+
166
+ :return: subsets' metadata
167
+ :rtype: list of dicts
168
+
169
+ Request Example:
170
+ ::
171
+
172
+ subsets = sa_client.explore.get_subsets(project="Image Project")
173
+
174
+ Response Example:
175
+ ::
176
+
177
+ [{'name': 'test_subset'}]
178
+ """
179
+ project = self.controller.get_project(project)
180
+ response = self.controller.subsets.list(project)
181
+ if response.errors:
182
+ raise AppException(response.errors)
183
+ return BaseSerializer.serialize_iterable(response.data, ["name"])
184
+
185
+ def add_items_to_subset(
186
+ self, project: NotEmptyStr | int, subset: NotEmptyStr, items: list[dict]
187
+ ):
188
+ """Associates selected items with a given subset. Non-existing subset will be automatically created.
189
+
190
+ :param project: The name or ID of the project.
191
+ :type project: Union[str, int]
192
+
193
+ :param subset: a name of an existing/new subset to associate items with.
194
+ New subsets will be automatically created.
195
+ :type subset: str
196
+
197
+ :param items: list of items metadata.
198
+ Required keys are 'name' and 'path' if the 'id' key is not provided in the dict.
199
+ :type items: list of dicts
200
+
201
+ :return: dictionary with succeeded, skipped, and failed items lists.
202
+ :rtype: dict
203
+
204
+ Request Example:
205
+ ::
206
+
207
+ sa_client = SAClient()
208
+
209
+ # option 1
210
+ queried_items = sa_client.explore.query(
211
+ project="Image Project",
212
+ query='_status = "InProgress"'
213
+ )
214
+
215
+ sa_client.explore.add_items_to_subset(
216
+ project="Medical Annotations",
217
+ subset="Brain Study - Disapproved",
218
+ items=queried_items
219
+ )
220
+
221
+ # option 2
222
+ items_list = [
223
+ {
224
+ 'name': 'image_1.jpeg',
225
+ 'path': 'Image Project'
226
+ },
227
+ {
228
+ 'name': 'image_2.jpeg',
229
+ 'path': 'Image Project/Subfolder A'
230
+ }
231
+ ]
232
+
233
+ sa_client.explore.add_items_to_subset(
234
+ project="Image Project",
235
+ subset="Subset Name",
236
+ items=items_list
237
+ )
238
+
239
+ Response Example:
240
+ ::
241
+
242
+ {
243
+ "succeeded": [
244
+ {
245
+ 'name': 'image_1.jpeg',
246
+ 'path': 'Image Project'
247
+ },
248
+ {
249
+ 'name': 'image_2.jpeg',
250
+ 'path': 'Image Project/Subfolder A'
251
+ }
252
+ ],
253
+ "failed": [],
254
+ "skipped": []
255
+ }
256
+ """
257
+ project = self.controller.get_project(project)
258
+ response = self.controller.subsets.add_items(project, subset, items)
259
+ if response.errors:
260
+ raise AppException(response.errors)
261
+ return response.data