rapidata 2.42.5__py3-none-any.whl → 2.42.6__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/config/tracer.py +37 -3
- rapidata/rapidata_client/order/rapidata_order_manager.py +7 -2
- rapidata/rapidata_client/rapidata_client.py +6 -1
- rapidata/rapidata_client/validation/rapids/_validation_rapid_uploader.py +2 -0
- {rapidata-2.42.5.dist-info → rapidata-2.42.6.dist-info}/METADATA +1 -1
- {rapidata-2.42.5.dist-info → rapidata-2.42.6.dist-info}/RECORD +9 -9
- {rapidata-2.42.5.dist-info → rapidata-2.42.6.dist-info}/WHEEL +0 -0
- {rapidata-2.42.5.dist-info → rapidata-2.42.6.dist-info}/licenses/LICENSE +0 -0
rapidata/__init__.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
from typing import Protocol, runtime_checkable, Any
|
|
2
|
-
from opentelemetry import trace
|
|
3
2
|
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
4
3
|
from opentelemetry.sdk.trace import TracerProvider
|
|
5
4
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor
|
|
@@ -15,6 +14,7 @@ class TracerProtocol(Protocol):
|
|
|
15
14
|
|
|
16
15
|
def start_span(self, name: str, *args, **kwargs) -> Any: ...
|
|
17
16
|
def start_as_current_span(self, name: str, *args, **kwargs) -> Any: ...
|
|
17
|
+
def set_session_id(self, session_id: str) -> None: ...
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class NoOpSpan:
|
|
@@ -52,11 +52,31 @@ class NoOpTracer:
|
|
|
52
52
|
def start_as_current_span(self, name: str, *args, **kwargs) -> NoOpSpan:
|
|
53
53
|
return NoOpSpan()
|
|
54
54
|
|
|
55
|
+
def set_session_id(self, session_id: str) -> None:
|
|
56
|
+
pass
|
|
57
|
+
|
|
55
58
|
def __getattr__(self, name: str) -> Any:
|
|
56
59
|
"""Delegate to no-op behavior."""
|
|
57
60
|
return lambda *args, **kwargs: NoOpSpan()
|
|
58
61
|
|
|
59
62
|
|
|
63
|
+
class SpanContextManagerWrapper:
|
|
64
|
+
"""Wrapper for span context managers to add session_id on enter."""
|
|
65
|
+
|
|
66
|
+
def __init__(self, context_manager: Any, session_id: str | None):
|
|
67
|
+
self._context_manager = context_manager
|
|
68
|
+
self.session_id = session_id
|
|
69
|
+
|
|
70
|
+
def __enter__(self):
|
|
71
|
+
span = self._context_manager.__enter__()
|
|
72
|
+
if self.session_id and hasattr(span, "set_attribute"):
|
|
73
|
+
span.set_attribute("SDK.session.id", self.session_id)
|
|
74
|
+
return span
|
|
75
|
+
|
|
76
|
+
def __exit__(self, *args):
|
|
77
|
+
return self._context_manager.__exit__(*args)
|
|
78
|
+
|
|
79
|
+
|
|
60
80
|
class RapidataTracer:
|
|
61
81
|
"""Tracer implementation that updates when the configuration changes."""
|
|
62
82
|
|
|
@@ -67,6 +87,7 @@ class RapidataTracer:
|
|
|
67
87
|
self._real_tracer = None
|
|
68
88
|
self._no_op_tracer = NoOpTracer()
|
|
69
89
|
self._enabled = True # Default to enabled
|
|
90
|
+
self.session_id: str | None = None
|
|
70
91
|
|
|
71
92
|
# Register this tracer to receive configuration updates
|
|
72
93
|
register_config_handler(self._handle_config_update)
|
|
@@ -106,18 +127,31 @@ class RapidataTracer:
|
|
|
106
127
|
logger.warning(f"Failed to initialize tracing: {e}")
|
|
107
128
|
self._enabled = False
|
|
108
129
|
|
|
130
|
+
def _add_session_id_to_span(self, span: Any) -> Any:
|
|
131
|
+
"""Add session_id attribute to a span if session_id is set."""
|
|
132
|
+
if self.session_id and hasattr(span, "set_attribute"):
|
|
133
|
+
span.set_attribute("SDK.session.id", self.session_id)
|
|
134
|
+
return span
|
|
135
|
+
|
|
109
136
|
def start_span(self, name: str, *args, **kwargs) -> Any:
|
|
110
137
|
"""Start a span, or return a no-op span if tracing is disabled."""
|
|
111
138
|
if self._enabled and self._real_tracer:
|
|
112
|
-
|
|
139
|
+
span = self._real_tracer.start_span(name, *args, **kwargs)
|
|
140
|
+
return self._add_session_id_to_span(span)
|
|
113
141
|
return self._no_op_tracer.start_span(name, *args, **kwargs)
|
|
114
142
|
|
|
115
143
|
def start_as_current_span(self, name: str, *args, **kwargs) -> Any:
|
|
116
144
|
"""Start a span as current, or return a no-op span if tracing is disabled."""
|
|
117
145
|
if self._enabled and self._real_tracer:
|
|
118
|
-
|
|
146
|
+
context_manager = self._real_tracer.start_as_current_span(
|
|
147
|
+
name, *args, **kwargs
|
|
148
|
+
)
|
|
149
|
+
return SpanContextManagerWrapper(context_manager, self.session_id)
|
|
119
150
|
return self._no_op_tracer.start_as_current_span(name, *args, **kwargs)
|
|
120
151
|
|
|
152
|
+
def set_session_id(self, session_id: str) -> None:
|
|
153
|
+
self.session_id = session_id
|
|
154
|
+
|
|
121
155
|
def __getattr__(self, name: str) -> Any:
|
|
122
156
|
"""Delegate attribute access to the appropriate tracer."""
|
|
123
157
|
if self._enabled and self._real_tracer:
|
|
@@ -321,8 +321,10 @@ class RapidataOrderManager:
|
|
|
321
321
|
if any(not isinstance(datapoint, list) for datapoint in datapoints):
|
|
322
322
|
raise ValueError("Each datapoint must be a list of 2 paths/texts")
|
|
323
323
|
|
|
324
|
-
if any(len(datapoint) != 2 for datapoint in datapoints):
|
|
325
|
-
raise ValueError(
|
|
324
|
+
if any(len(set(datapoint)) != 2 for datapoint in datapoints):
|
|
325
|
+
raise ValueError(
|
|
326
|
+
"Each datapoint must contain exactly two unique options"
|
|
327
|
+
)
|
|
326
328
|
|
|
327
329
|
if a_b_names is not None and len(a_b_names) != 2:
|
|
328
330
|
raise ValueError(
|
|
@@ -392,6 +394,9 @@ class RapidataOrderManager:
|
|
|
392
394
|
if len(datapoints) < 2:
|
|
393
395
|
raise ValueError("At least two datapoints are required")
|
|
394
396
|
|
|
397
|
+
if len(set(datapoints)) != len(datapoints):
|
|
398
|
+
raise ValueError("Datapoints must be unique")
|
|
399
|
+
|
|
395
400
|
return self._create_general_order(
|
|
396
401
|
name=name,
|
|
397
402
|
workflow=RankingWorkflow(
|
|
@@ -3,7 +3,8 @@ from typing import Any
|
|
|
3
3
|
import requests
|
|
4
4
|
from packaging import version
|
|
5
5
|
from rapidata import __version__
|
|
6
|
-
|
|
6
|
+
import uuid
|
|
7
|
+
import random
|
|
7
8
|
from rapidata.service.openapi_service import OpenAPIService
|
|
8
9
|
|
|
9
10
|
from rapidata.rapidata_client.order.rapidata_order_manager import RapidataOrderManager
|
|
@@ -56,6 +57,10 @@ class RapidataClient:
|
|
|
56
57
|
demographic (DemographicManager): The DemographicManager instance.
|
|
57
58
|
mri (RapidataBenchmarkManager): The RapidataBenchmarkManager instance.
|
|
58
59
|
"""
|
|
60
|
+
tracer.set_session_id(
|
|
61
|
+
uuid.UUID(int=random.Random().getrandbits(128), version=4).hex
|
|
62
|
+
)
|
|
63
|
+
|
|
59
64
|
with tracer.start_as_current_span("RapidataClient.__init__"):
|
|
60
65
|
logger.debug("Checking version")
|
|
61
66
|
self._check_version()
|
|
@@ -51,6 +51,8 @@ class ValidationRapidUploader:
|
|
|
51
51
|
metadata=metadata,
|
|
52
52
|
payload=self._get_payload(rapid),
|
|
53
53
|
truth=AddValidationRapidModelTruth(actual_instance=rapid.truth),
|
|
54
|
+
randomCorrectProbability=rapid.random_correct_probability,
|
|
55
|
+
explanation=rapid.explanation,
|
|
54
56
|
featureFlags=(
|
|
55
57
|
[setting._to_feature_flag() for setting in rapid.settings]
|
|
56
58
|
if rapid.settings
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
rapidata/__init__.py,sha256=
|
|
1
|
+
rapidata/__init__.py,sha256=rsgNfH2hEqJNu89zai9F2RcA8MnUGP9XS6OX5HM3bKc,857
|
|
2
2
|
rapidata/api_client/__init__.py,sha256=Rh2aAoa6nDv09Z7cpTNdrPotXixBcNN_2VevCDD1goc,37144
|
|
3
3
|
rapidata/api_client/api/__init__.py,sha256=CaZJ54mxbAEzAFd0Cjy0mfiUabD-d_7tqVOgjU4RxZI,1749
|
|
4
4
|
rapidata/api_client/api/asset_api.py,sha256=buYMBGvg5_SLkJ7aG07c7_1rT6TXTCqoLfoV8O2nJhM,34442
|
|
@@ -616,7 +616,7 @@ rapidata/rapidata_client/config/logging_config.py,sha256=ePCh7X6v0Yzkgq1MhFNsHwL
|
|
|
616
616
|
rapidata/rapidata_client/config/managed_print.py,sha256=2T6dwgR1EZzFAdOEyPp_BBUsa-qrEuhOXgFhsSQKvRo,185
|
|
617
617
|
rapidata/rapidata_client/config/order_config.py,sha256=XxRZERzUUA9md6-PVlV__eCw8DD2kPbT_UmMwG1mAS4,615
|
|
618
618
|
rapidata/rapidata_client/config/rapidata_config.py,sha256=mURnKdl5-2sE4e_IYY9-aBkix6a12t47otEErGE_q0c,1507
|
|
619
|
-
rapidata/rapidata_client/config/tracer.py,sha256=
|
|
619
|
+
rapidata/rapidata_client/config/tracer.py,sha256=AkDcW89h5OrT1t0rk1ulidytKS4oJFG1kCLrHj8eBG4,5943
|
|
620
620
|
rapidata/rapidata_client/config/upload_config.py,sha256=hjefl-w9WaCNeCEe6hdnrAQEMjgDy-r1zgUUIFR68wk,473
|
|
621
621
|
rapidata/rapidata_client/datapoints/__init__.py,sha256=pRjH6YQLbIHOumykMgplKxFfhj6g7a2Dh2FPdFNyNsg,222
|
|
622
622
|
rapidata/rapidata_client/datapoints/_asset_uploader.py,sha256=ie9MZfzhxa0ZrRveJ516cgwvA6QIeVIxN3g5ikwLOH0,2605
|
|
@@ -658,9 +658,9 @@ rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
|
658
658
|
rapidata/rapidata_client/order/_rapidata_order_builder.py,sha256=FTJJRCW9KehIlqELOXmKeLhuGcLj9m9ImEU1agOIRa4,16915
|
|
659
659
|
rapidata/rapidata_client/order/dataset/_rapidata_dataset.py,sha256=8EhoRVBxWMbp1mtS56Uogg2dwFC2vySw5hNqTPDTHzM,6345
|
|
660
660
|
rapidata/rapidata_client/order/rapidata_order.py,sha256=w41HUWE6q9L2Stx0ScZdKb7qLjWFIUPMMDOe2fElLvM,14481
|
|
661
|
-
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=
|
|
661
|
+
rapidata/rapidata_client/order/rapidata_order_manager.py,sha256=3GafS6k815iq-s9wgS9RqUvh8OY1Kgu7LxSjLsKry5w,41197
|
|
662
662
|
rapidata/rapidata_client/order/rapidata_results.py,sha256=weL4S14fzug3ZOJbQk9Oj-4tv2jx5aZAMp7VJ-a6Qq4,8437
|
|
663
|
-
rapidata/rapidata_client/rapidata_client.py,sha256=
|
|
663
|
+
rapidata/rapidata_client/rapidata_client.py,sha256=9BgFbkPulmNNtKE7Cug7qcRQNuH-S8S8cof8NXnleuE,6004
|
|
664
664
|
rapidata/rapidata_client/referee/__init__.py,sha256=J8oZJNUduPr-Tmn8iJwR-qBiSv7owhUFcEzXTRETecw,155
|
|
665
665
|
rapidata/rapidata_client/referee/_base_referee.py,sha256=aoH3Werw-AtQo2TncG69OmCVvnbXYJBfsRCQry_Pll0,497
|
|
666
666
|
rapidata/rapidata_client/referee/_early_stopping_referee.py,sha256=_JyFcTpncI0PrLf7Ix78FtLto31sdyGDS-2QbVTuvr8,2079
|
|
@@ -694,7 +694,7 @@ rapidata/rapidata_client/settings/translation_behaviour.py,sha256=uEke2WgzrjzRlS
|
|
|
694
694
|
rapidata/rapidata_client/validation/__init__.py,sha256=s5wHVtcJkncXSFuL9I0zNwccNOKpWAqxqUjkeohzi2E,24
|
|
695
695
|
rapidata/rapidata_client/validation/rapidata_validation_set.py,sha256=eJlv0XKUC75caJKu6_kpY0EL0ZtmHpt2c3SgFjlmqRU,4666
|
|
696
696
|
rapidata/rapidata_client/validation/rapids/__init__.py,sha256=WU5PPwtTJlte6U90MDakzx4I8Y0laj7siw9teeXj5R0,21
|
|
697
|
-
rapidata/rapidata_client/validation/rapids/_validation_rapid_uploader.py,sha256=
|
|
697
|
+
rapidata/rapidata_client/validation/rapids/_validation_rapid_uploader.py,sha256=9O5kQNu9lom7x2X09sGfFFecXNO2dU4d2O1L-_n_hAw,4072
|
|
698
698
|
rapidata/rapidata_client/validation/rapids/box.py,sha256=sJbxOpz86MplXmZl6gquzgQzpFIW8fw-F0eyQY4ClDo,1486
|
|
699
699
|
rapidata/rapidata_client/validation/rapids/rapids.py,sha256=E4O4p2br0g9lgB3tOdfEBm07g8o6pCDQgQv7fi6QzF8,999
|
|
700
700
|
rapidata/rapidata_client/validation/rapids/rapids_manager.py,sha256=YqGxnqJ2vYfAywXJDujQEBrYnlf0URdLxQ7hTR1JeOI,16225
|
|
@@ -715,7 +715,7 @@ rapidata/service/credential_manager.py,sha256=T3yL4tXVnibRytxjQkOC-ex3kFGQR5KcKU
|
|
|
715
715
|
rapidata/service/local_file_service.py,sha256=0Q4LdoEtPFKzgXK2oZ1cQ-X7FipakscjGnnBH8dRFRQ,855
|
|
716
716
|
rapidata/service/openapi_service.py,sha256=E2zVagI_ri15PK06ITO_VNKYDJ0VZQG1YQ1T6bEIVsY,5566
|
|
717
717
|
rapidata/types/__init__.py,sha256=NLRuTGbTImRv3yIp8we_oqVvCuBd7TDNVlAzkVGs9oo,6056
|
|
718
|
-
rapidata-2.42.
|
|
719
|
-
rapidata-2.42.
|
|
720
|
-
rapidata-2.42.
|
|
721
|
-
rapidata-2.42.
|
|
718
|
+
rapidata-2.42.6.dist-info/METADATA,sha256=hGaKKniKHnrpgC3qBq6r1FQbzzk7af7zh9x2-1UY71g,1479
|
|
719
|
+
rapidata-2.42.6.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
720
|
+
rapidata-2.42.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
721
|
+
rapidata-2.42.6.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|