rapidata 2.33.0__py3-none-any.whl → 2.33.1__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.
Potentially problematic release.
This version of rapidata might be problematic. Click here for more details.
- rapidata/__init__.py +1 -1
- rapidata/rapidata_client/exceptions/failed_upload_exception.py +35 -1
- rapidata/rapidata_client/order/_rapidata_order_builder.py +20 -7
- rapidata/rapidata_client/order/rapidata_order.py +4 -2
- rapidata/rapidata_client/order/rapidata_order_manager.py +14 -0
- {rapidata-2.33.0.dist-info → rapidata-2.33.1.dist-info}/METADATA +1 -1
- {rapidata-2.33.0.dist-info → rapidata-2.33.1.dist-info}/RECORD +9 -9
- {rapidata-2.33.0.dist-info → rapidata-2.33.1.dist-info}/LICENSE +0 -0
- {rapidata-2.33.0.dist-info → rapidata-2.33.1.dist-info}/WHEEL +0 -0
rapidata/__init__.py
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
from typing import cast
|
|
2
|
+
from rapidata.api_client.models.file_asset_model import FileAssetModel
|
|
3
|
+
from rapidata.api_client.models.get_failed_datapoints_result import GetFailedDatapointsResult
|
|
4
|
+
from rapidata.api_client.models.multi_asset_model import MultiAssetModel
|
|
5
|
+
from rapidata.api_client.models.original_filename_metadata_model import OriginalFilenameMetadataModel
|
|
6
|
+
from rapidata.api_client.models.source_url_metadata_model import SourceUrlMetadataModel
|
|
7
|
+
from rapidata.rapidata_client.datapoints.assets import MediaAsset, MultiAsset
|
|
1
8
|
from rapidata.rapidata_client.datapoints.datapoint import Datapoint
|
|
2
9
|
from rapidata.rapidata_client.order._rapidata_dataset import RapidataDataset
|
|
3
10
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
4
11
|
|
|
5
|
-
|
|
6
12
|
class FailedUploadException(Exception):
|
|
7
13
|
"""Custom error class for Failed Uploads to the Rapidata order."""
|
|
8
14
|
def __init__(
|
|
@@ -17,3 +23,31 @@ class FailedUploadException(Exception):
|
|
|
17
23
|
|
|
18
24
|
def __str__(self) -> str:
|
|
19
25
|
return f"Failed to upload {self.failed_uploads}"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _parse_failed_uploads(failed_uploads: GetFailedDatapointsResult) -> list[Datapoint]:
|
|
29
|
+
failed_datapoints = failed_uploads.datapoints
|
|
30
|
+
if not failed_datapoints:
|
|
31
|
+
return []
|
|
32
|
+
if isinstance(failed_datapoints[0].asset.actual_instance, FileAssetModel):
|
|
33
|
+
failed_assets = [MediaAsset(__get_asset_name(cast(FileAssetModel, datapoint.asset.actual_instance))) for datapoint in failed_datapoints]
|
|
34
|
+
elif isinstance(failed_datapoints[0].asset.actual_instance, MultiAssetModel):
|
|
35
|
+
failed_assets = []
|
|
36
|
+
backend_assets = [cast(MultiAssetModel, failed_upload.asset.actual_instance).assets for failed_upload in failed_datapoints]
|
|
37
|
+
for assets in backend_assets:
|
|
38
|
+
failed_assets.append(MultiAsset([MediaAsset(__get_asset_name(cast(FileAssetModel, asset.actual_instance))) for asset in assets if isinstance(asset.actual_instance, FileAssetModel)]))
|
|
39
|
+
else:
|
|
40
|
+
raise ValueError(f"Unsupported asset type: {type(failed_datapoints[0].asset.actual_instance)}")
|
|
41
|
+
|
|
42
|
+
return [Datapoint(asset=asset) for asset in failed_assets]
|
|
43
|
+
|
|
44
|
+
def __get_asset_name(failed_datapoint: FileAssetModel) -> str:
|
|
45
|
+
metadata = failed_datapoint.metadata
|
|
46
|
+
if "sourceUrl" in metadata:
|
|
47
|
+
return cast(SourceUrlMetadataModel, metadata["sourceUrl"].actual_instance).url
|
|
48
|
+
elif "originalFilename" in metadata:
|
|
49
|
+
return cast(OriginalFilenameMetadataModel, metadata["originalFilename"].actual_instance).original_filename
|
|
50
|
+
else:
|
|
51
|
+
return ""
|
|
52
|
+
|
|
53
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Optional, cast, Sequence
|
|
1
|
+
from typing import Literal, Optional, cast, Sequence
|
|
2
2
|
|
|
3
3
|
from rapidata.api_client.models.ab_test_selection_a_inner import AbTestSelectionAInner
|
|
4
4
|
from rapidata.api_client.models.and_user_filter_model_filters_inner import AndUserFilterModelFiltersInner
|
|
@@ -6,12 +6,10 @@ from rapidata.api_client.models.create_order_model import CreateOrderModel
|
|
|
6
6
|
from rapidata.api_client.models.create_order_model_referee import CreateOrderModelReferee
|
|
7
7
|
from rapidata.api_client.models.create_order_model_workflow import CreateOrderModelWorkflow
|
|
8
8
|
|
|
9
|
-
from rapidata.rapidata_client.datapoints.assets import MediaAsset, TextAsset, MultiAsset, BaseAsset
|
|
10
9
|
from rapidata.rapidata_client.datapoints.datapoint import Datapoint
|
|
11
|
-
from rapidata.rapidata_client.exceptions.failed_upload_exception import FailedUploadException
|
|
10
|
+
from rapidata.rapidata_client.exceptions.failed_upload_exception import FailedUploadException, _parse_failed_uploads
|
|
12
11
|
from rapidata.rapidata_client.filter import RapidataFilter
|
|
13
12
|
from rapidata.rapidata_client.logging import logger, managed_print
|
|
14
|
-
from rapidata.rapidata_client.datapoints.metadata import Metadata
|
|
15
13
|
from rapidata.rapidata_client.order._rapidata_dataset import RapidataDataset
|
|
16
14
|
from rapidata.rapidata_client.order.rapidata_order import RapidataOrder
|
|
17
15
|
from rapidata.rapidata_client.referee import Referee
|
|
@@ -19,7 +17,6 @@ from rapidata.rapidata_client.referee._naive_referee import NaiveReferee
|
|
|
19
17
|
from rapidata.rapidata_client.selection._base_selection import RapidataSelection
|
|
20
18
|
from rapidata.rapidata_client.settings import RapidataSetting
|
|
21
19
|
from rapidata.rapidata_client.workflow import Workflow
|
|
22
|
-
from rapidata.rapidata_client.workflow._compare_workflow import CompareWorkflow
|
|
23
20
|
from rapidata.service.openapi_service import OpenAPIService
|
|
24
21
|
|
|
25
22
|
|
|
@@ -50,6 +47,7 @@ class RapidataOrderBuilder:
|
|
|
50
47
|
self.__selections: list[RapidataSelection] = []
|
|
51
48
|
self.__priority: int | None = None
|
|
52
49
|
self.__datapoints: list[Datapoint] = []
|
|
50
|
+
self.__sticky_state: Literal["None", "Temporary", "Permanent"] | None = None
|
|
53
51
|
|
|
54
52
|
def _to_model(self) -> CreateOrderModel:
|
|
55
53
|
"""
|
|
@@ -92,6 +90,7 @@ class RapidataOrderBuilder:
|
|
|
92
90
|
else None
|
|
93
91
|
),
|
|
94
92
|
priority=self.__priority,
|
|
93
|
+
stickyState=self.__sticky_state,
|
|
95
94
|
)
|
|
96
95
|
|
|
97
96
|
def _create(self) -> RapidataOrder:
|
|
@@ -148,8 +147,12 @@ class RapidataOrderBuilder:
|
|
|
148
147
|
|
|
149
148
|
logger.debug("Media added to the order.")
|
|
150
149
|
logger.debug("Setting order to preview")
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
try:
|
|
151
|
+
self.__openapi_service.order_api.order_order_id_preview_post(self.order_id)
|
|
152
|
+
except Exception:
|
|
153
|
+
failed_uploads = _parse_failed_uploads(self.__openapi_service.dataset_api.dataset_dataset_id_datapoints_failed_get(self.__dataset.id))
|
|
154
|
+
logger.error(f"Internal download error for datapoints: {failed_uploads}\nWARNING: Failed Datapoints in error do not contain metadata.")
|
|
155
|
+
raise FailedUploadException(self.__dataset, order, failed_uploads)
|
|
153
156
|
return order
|
|
154
157
|
|
|
155
158
|
def _workflow(self, workflow: Workflow) -> "RapidataOrderBuilder":
|
|
@@ -315,3 +318,13 @@ class RapidataOrderBuilder:
|
|
|
315
318
|
|
|
316
319
|
self.__priority = priority
|
|
317
320
|
return self
|
|
321
|
+
|
|
322
|
+
def _sticky_state(self, sticky_state: Literal["None", "Temporary", "Permanent"] | None = None) -> "RapidataOrderBuilder":
|
|
323
|
+
"""
|
|
324
|
+
Set the sticky state for the order.
|
|
325
|
+
"""
|
|
326
|
+
if sticky_state is not None and sticky_state not in ["None", "Temporary", "Permanent"]:
|
|
327
|
+
raise TypeError("Sticky state must be of type Literal['None', 'Temporary', 'Permanent'].")
|
|
328
|
+
|
|
329
|
+
self.__sticky_state = sticky_state
|
|
330
|
+
return self
|
|
@@ -12,6 +12,8 @@ from tqdm import tqdm
|
|
|
12
12
|
from rapidata.api_client.exceptions import ApiException
|
|
13
13
|
from rapidata.api_client.models.campaign_artifact_model import CampaignArtifactModel
|
|
14
14
|
from rapidata.api_client.models.order_state import OrderState
|
|
15
|
+
from rapidata.api_client.models.preview_order_model import PreviewOrderModel
|
|
16
|
+
from rapidata.api_client.models.submit_order_model import SubmitOrderModel
|
|
15
17
|
from rapidata.api_client.models.preliminary_download_model import PreliminaryDownloadModel
|
|
16
18
|
from rapidata.api_client.models.workflow_artifact_model import WorkflowArtifactModel
|
|
17
19
|
from rapidata.rapidata_client.order.rapidata_results import RapidataResults
|
|
@@ -60,7 +62,7 @@ class RapidataOrder:
|
|
|
60
62
|
def run(self) -> "RapidataOrder":
|
|
61
63
|
"""Runs the order to start collecting responses."""
|
|
62
64
|
logger.info(f"Starting order '{self}'")
|
|
63
|
-
self.__openapi_service.order_api.order_order_id_submit_post(self.id)
|
|
65
|
+
self.__openapi_service.order_api.order_order_id_submit_post(self.id, SubmitOrderModel(ignoreFailedDatapoints=True))
|
|
64
66
|
logger.debug(f"Order '{self}' has been started.")
|
|
65
67
|
managed_print(f"Order '{self.name}' is now viewable under: {self.order_details_page}")
|
|
66
68
|
return self
|
|
@@ -203,7 +205,7 @@ class RapidataOrder:
|
|
|
203
205
|
logger.info("Opening order preview in browser...")
|
|
204
206
|
if self.get_status() == OrderState.CREATED:
|
|
205
207
|
logger.info("Order is still in state created. Setting it to preview.")
|
|
206
|
-
self.__openapi_service.order_api.order_order_id_preview_post(self.id)
|
|
208
|
+
self.__openapi_service.order_api.order_order_id_preview_post(self.id, PreviewOrderModel(ignoreFailedDatapoints=True))
|
|
207
209
|
logger.info("Order is now in preview state.")
|
|
208
210
|
|
|
209
211
|
campaign_id = self.__get_campaign_id()
|
|
@@ -51,6 +51,7 @@ class RapidataOrderManager:
|
|
|
51
51
|
self.settings = RapidataSettings
|
|
52
52
|
self.selections = RapidataSelections
|
|
53
53
|
self.__priority: int | None = None
|
|
54
|
+
self.__sticky_state: Literal["None", "Temporary", "Permanent"] | None = None
|
|
54
55
|
logger.debug("RapidataOrderManager initialized")
|
|
55
56
|
|
|
56
57
|
def _create_general_order(self,
|
|
@@ -124,13 +125,26 @@ class RapidataOrderManager:
|
|
|
124
125
|
._settings(settings)
|
|
125
126
|
._validation_set_id(validation_set_id if not selections else None)
|
|
126
127
|
._priority(self.__priority)
|
|
128
|
+
._sticky_state(self.__sticky_state)
|
|
127
129
|
._create()
|
|
128
130
|
)
|
|
129
131
|
return order
|
|
130
132
|
|
|
131
133
|
def _set_priority(self, priority: int):
|
|
134
|
+
if not isinstance(priority, int):
|
|
135
|
+
raise TypeError("Priority must be an integer")
|
|
136
|
+
|
|
137
|
+
if priority < 0:
|
|
138
|
+
raise ValueError("Priority must be greater than 0")
|
|
139
|
+
|
|
132
140
|
self.__priority = priority
|
|
133
141
|
|
|
142
|
+
def _set_sticky_state(self, sticky_state: Literal["None", "Temporary", "Permanent"]):
|
|
143
|
+
if sticky_state not in ["None", "Temporary", "Permanent"]:
|
|
144
|
+
raise ValueError("Sticky state must be one of 'None', 'Temporary', 'Permanent'")
|
|
145
|
+
|
|
146
|
+
self.__sticky_state = sticky_state
|
|
147
|
+
|
|
134
148
|
def create_classification_order(self,
|
|
135
149
|
name: str,
|
|
136
150
|
instruction: str,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
rapidata/__init__.py,sha256=
|
|
1
|
+
rapidata/__init__.py,sha256=nd-IuE9FDLGAl5tk6vhY6k8ZSxu-XK6PiMa9WY2_Buk,907
|
|
2
2
|
rapidata/api_client/__init__.py,sha256=tNSCpLEs-AyEZGCAYz9MM8gDEpA4KJKcdNL-dcvAAw0,34404
|
|
3
3
|
rapidata/api_client/api/__init__.py,sha256=qjLeeJSnuPF_ar_nLknjnOqStBQnoCiz-O_rfZUBZrE,1489
|
|
4
4
|
rapidata/api_client/api/benchmark_api.py,sha256=fr4krx4f3yN--DswD_Prpz-KU81ooG3Lcy-30_KU0dw,129751
|
|
@@ -563,7 +563,7 @@ rapidata/rapidata_client/datapoints/metadata/_select_words_metadata.py,sha256=T8
|
|
|
563
563
|
rapidata/rapidata_client/demographic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
564
564
|
rapidata/rapidata_client/demographic/demographic_manager.py,sha256=OaYrfrftU_p00X3BGlAjoky6_RPm0mhQwGnJsJSVca0,1203
|
|
565
565
|
rapidata/rapidata_client/exceptions/__init__.py,sha256=2hbWRgjlCGuoLPVDloQmmH81uzm9F2OAX2iFGCJyRu8,59
|
|
566
|
-
rapidata/rapidata_client/exceptions/failed_upload_exception.py,sha256=
|
|
566
|
+
rapidata/rapidata_client/exceptions/failed_upload_exception.py,sha256=BIG6y5TYGXz507CfH74h0H2vF6QeoB2L7VtleFqAppY,2673
|
|
567
567
|
rapidata/rapidata_client/filter/__init__.py,sha256=j_Kfz_asNVxwp56SAN2saB7ZAHg3smL5_W2sSitmuJY,548
|
|
568
568
|
rapidata/rapidata_client/filter/_base_filter.py,sha256=cPLl0ddWB8QU6Luspnub_KXiTEfEFOVBEdnxhJOjoWs,2269
|
|
569
569
|
rapidata/rapidata_client/filter/age_filter.py,sha256=oRjGY65gE_X8oa0D0XRyvKAb4_Z6XOOaGTWykRSfLFA,739
|
|
@@ -587,9 +587,9 @@ rapidata/rapidata_client/logging/logger.py,sha256=9vULXUizGObQeqMY-CryiAQsq8xDZw
|
|
|
587
587
|
rapidata/rapidata_client/logging/output_manager.py,sha256=AmSVZ2emVW5UWgOiNqkXNVRItsvd5Ox0hsIoZQhYYYo,653
|
|
588
588
|
rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
589
589
|
rapidata/rapidata_client/order/_rapidata_dataset.py,sha256=CYeDZJqHN3UWYvz5PSp8jAZ1NQIhAld467AolkVf24A,17438
|
|
590
|
-
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=
|
|
591
|
-
rapidata/rapidata_client/order/rapidata_order.py,sha256=
|
|
592
|
-
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=
|
|
590
|
+
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=W1sdPRJ_p24Skfsnv9r8zldPRjkzsJopX_dCoge5qtI,12363
|
|
591
|
+
rapidata/rapidata_client/order/rapidata_order.py,sha256=6YOAazdEk82sf8o3pal3iUqsKWN2nwy3BdNBgghkiU4,12783
|
|
592
|
+
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=vq0wG5BSGeYB2LO_fwzOrrR40mKUmkcMPeBZF1pwgoY,38055
|
|
593
593
|
rapidata/rapidata_client/order/rapidata_results.py,sha256=ZY0JyHMBZlR6-t6SqKt2OLEO6keR_KvKg9Wk6_I29x4,8653
|
|
594
594
|
rapidata/rapidata_client/rapidata_client.py,sha256=jTkpu0YcizoxAzbfNdnY1S0xXX6Q0KEMi8boo0f2F5c,4274
|
|
595
595
|
rapidata/rapidata_client/referee/__init__.py,sha256=q0Hv9nmfEpyChejtyMLT8hWKL0vTTf_UgUXPYNJ-H6M,153
|
|
@@ -643,7 +643,7 @@ rapidata/service/__init__.py,sha256=s9bS1AJZaWIhLtJX_ZA40_CK39rAAkwdAmymTMbeWl4,
|
|
|
643
643
|
rapidata/service/credential_manager.py,sha256=pUEEtp6VrFWYhfUUtyqmS0AlRqe2Y0kFkY6o22IT4KM,8682
|
|
644
644
|
rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5AnfY14BW8,877
|
|
645
645
|
rapidata/service/openapi_service.py,sha256=xoGBACpUhG0H-tadSBa8A91LHyfI7n-FCT2JlrERqco,5221
|
|
646
|
-
rapidata-2.33.
|
|
647
|
-
rapidata-2.33.
|
|
648
|
-
rapidata-2.33.
|
|
649
|
-
rapidata-2.33.
|
|
646
|
+
rapidata-2.33.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
647
|
+
rapidata-2.33.1.dist-info/METADATA,sha256=lDYoDN6gtzloaI4-8X_ifYr2RCCrHt_7LeyCi6RM_iE,1264
|
|
648
|
+
rapidata-2.33.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
649
|
+
rapidata-2.33.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|