judgeval 0.0.43__py3-none-any.whl → 0.0.44__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.
judgeval/common/tracer.py CHANGED
@@ -1557,7 +1557,6 @@ class _DeepTracer:
1557
1557
  # current_trace.record_output({"log": message})
1558
1558
 
1559
1559
  class Tracer:
1560
- _instance = None
1561
1560
 
1562
1561
  # Tracer.current_trace class variable is currently used in wrap()
1563
1562
  # TODO: Keep track of cross-context state for current trace and current span ID solely through class variables instead of instance variables?
@@ -1567,11 +1566,6 @@ class Tracer:
1567
1566
 
1568
1567
  trace_across_async_contexts: bool = False # BY default, we don't trace across async contexts
1569
1568
 
1570
- def __new__(cls, *args, **kwargs):
1571
- if cls._instance is None:
1572
- cls._instance = super(Tracer, cls).__new__(cls)
1573
- return cls._instance
1574
-
1575
1569
  def __init__(
1576
1570
  self,
1577
1571
  api_key: str = os.getenv("JUDGMENT_API_KEY"),
@@ -1595,66 +1589,56 @@ class Tracer:
1595
1589
  span_flush_interval: float = 1.0, # Time in seconds between automatic flushes
1596
1590
  span_num_workers: int = 10 # Number of worker threads for span processing
1597
1591
  ):
1598
- if not hasattr(self, 'initialized'):
1599
- if not api_key:
1600
- raise ValueError("Tracer must be configured with a Judgment API key")
1601
-
1602
- result, response = validate_api_key(api_key)
1603
- if not result:
1604
- raise JudgmentAPIError(f"Issue with passed in Judgment API key: {response}")
1605
-
1606
- if not organization_id:
1607
- raise ValueError("Tracer must be configured with an Organization ID")
1608
- if use_s3 and not s3_bucket_name:
1609
- raise ValueError("S3 bucket name must be provided when use_s3 is True")
1610
-
1611
- self.api_key: str = api_key
1612
- self.project_name: str = project_name or str(uuid.uuid4())
1613
- self.organization_id: str = organization_id
1614
- self.rules: List[Rule] = rules or [] # Store rules at tracer level
1615
- self.traces: List[Trace] = []
1616
- self.initialized: bool = True
1617
- self.enable_monitoring: bool = enable_monitoring
1618
- self.enable_evaluations: bool = enable_evaluations
1619
- self.class_identifiers: Dict[str, str] = {} # Dictionary to store class identifiers
1620
- self.span_id_to_previous_span_id: Dict[str, str] = {}
1621
- self.trace_id_to_previous_trace: Dict[str, TraceClient] = {}
1622
- self.current_span_id: Optional[str] = None
1623
- self.current_trace: Optional[TraceClient] = None
1624
- self.trace_across_async_contexts: bool = trace_across_async_contexts
1625
- Tracer.trace_across_async_contexts = trace_across_async_contexts
1626
-
1627
- # Initialize S3 storage if enabled
1628
- self.use_s3 = use_s3
1629
- if use_s3:
1630
- from judgeval.common.s3_storage import S3Storage
1631
- self.s3_storage = S3Storage(
1632
- bucket_name=s3_bucket_name,
1633
- aws_access_key_id=s3_aws_access_key_id,
1634
- aws_secret_access_key=s3_aws_secret_access_key,
1635
- region_name=s3_region_name
1636
- )
1637
- self.offline_mode: bool = offline_mode
1638
- self.deep_tracing: bool = deep_tracing # NEW: Store deep tracing setting
1639
-
1640
- # Initialize background span service
1641
- self.enable_background_spans: bool = enable_background_spans
1642
- self.background_span_service: Optional[BackgroundSpanService] = None
1643
- if enable_background_spans and not offline_mode:
1644
- self.background_span_service = BackgroundSpanService(
1645
- judgment_api_key=api_key,
1646
- organization_id=organization_id,
1647
- batch_size=span_batch_size,
1648
- flush_interval=span_flush_interval,
1649
- num_workers=span_num_workers
1650
- )
1651
-
1652
- elif hasattr(self, 'project_name') and self.project_name != project_name:
1653
- warnings.warn(
1654
- f"Attempting to initialize Tracer with project_name='{project_name}' but it was already initialized with "
1655
- f"project_name='{self.project_name}'. Due to the singleton pattern, the original project_name will be used. "
1656
- "To use a different project name, ensure the first Tracer initialization uses the desired project name.",
1657
- RuntimeWarning
1592
+ if not api_key:
1593
+ raise ValueError("Tracer must be configured with a Judgment API key")
1594
+
1595
+ result, response = validate_api_key(api_key)
1596
+ if not result:
1597
+ raise JudgmentAPIError(f"Issue with passed in Judgment API key: {response}")
1598
+
1599
+ if not organization_id:
1600
+ raise ValueError("Tracer must be configured with an Organization ID")
1601
+ if use_s3 and not s3_bucket_name:
1602
+ raise ValueError("S3 bucket name must be provided when use_s3 is True")
1603
+
1604
+ self.api_key: str = api_key
1605
+ self.project_name: str = project_name or str(uuid.uuid4())
1606
+ self.organization_id: str = organization_id
1607
+ self.rules: List[Rule] = rules or [] # Store rules at tracer level
1608
+ self.traces: List[Trace] = []
1609
+ self.enable_monitoring: bool = enable_monitoring
1610
+ self.enable_evaluations: bool = enable_evaluations
1611
+ self.class_identifiers: Dict[str, str] = {} # Dictionary to store class identifiers
1612
+ self.span_id_to_previous_span_id: Dict[str, str] = {}
1613
+ self.trace_id_to_previous_trace: Dict[str, TraceClient] = {}
1614
+ self.current_span_id: Optional[str] = None
1615
+ self.current_trace: Optional[TraceClient] = None
1616
+ self.trace_across_async_contexts: bool = trace_across_async_contexts
1617
+ Tracer.trace_across_async_contexts = trace_across_async_contexts
1618
+
1619
+ # Initialize S3 storage if enabled
1620
+ self.use_s3 = use_s3
1621
+ if use_s3:
1622
+ from judgeval.common.s3_storage import S3Storage
1623
+ self.s3_storage = S3Storage(
1624
+ bucket_name=s3_bucket_name,
1625
+ aws_access_key_id=s3_aws_access_key_id,
1626
+ aws_secret_access_key=s3_aws_secret_access_key,
1627
+ region_name=s3_region_name
1628
+ )
1629
+ self.offline_mode: bool = offline_mode
1630
+ self.deep_tracing: bool = deep_tracing # NEW: Store deep tracing setting
1631
+
1632
+ # Initialize background span service
1633
+ self.enable_background_spans: bool = enable_background_spans
1634
+ self.background_span_service: Optional[BackgroundSpanService] = None
1635
+ if enable_background_spans and not offline_mode:
1636
+ self.background_span_service = BackgroundSpanService(
1637
+ judgment_api_key=api_key,
1638
+ organization_id=organization_id,
1639
+ batch_size=span_batch_size,
1640
+ flush_interval=span_flush_interval,
1641
+ num_workers=span_num_workers
1658
1642
  )
1659
1643
 
1660
1644
  def set_current_span(self, span_id: str):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: judgeval
3
- Version: 0.0.43
3
+ Version: 0.0.44
4
4
  Summary: Judgeval Package
5
5
  Project-URL: Homepage, https://github.com/JudgmentLabs/judgeval
6
6
  Project-URL: Issues, https://github.com/JudgmentLabs/judgeval/issues
@@ -10,7 +10,7 @@ judgeval/common/__init__.py,sha256=7d24BRxtncpMj3AAJCj8RS7TqgjXmW777HVZH6-3sBs,2
10
10
  judgeval/common/exceptions.py,sha256=U-TxHLn7oVMezsMuoYouNDb2XuS8RCggfntYf5_6u4E,565
11
11
  judgeval/common/logger.py,sha256=KO75wWXCxhUHUMvLaTU31ZzOk6tkZBa7heQ7y0f-zFE,6062
12
12
  judgeval/common/s3_storage.py,sha256=UZZzQ8CP9_42SKDoKpPncJx8CL5Dchh4jFlKxDKi-cs,3938
13
- judgeval/common/tracer.py,sha256=jbXtgBgrfGH-zxW6Kf4VDpq8ot-yb0ggaC5isCQFGvw,128882
13
+ judgeval/common/tracer.py,sha256=I8qR6YYcjHDS5BVp9rEfGi_EOMnmcSVYk4ykHwuTBuA,127885
14
14
  judgeval/common/utils.py,sha256=l2nvm3-LeeScZ02H9TB2AcJh1gJSK1lNdi1Tu0p_fNQ,34276
15
15
  judgeval/data/__init__.py,sha256=GX_GloDtBB35mv3INWbSTP2r9cwCU2IeIYjzRT0SAd8,530
16
16
  judgeval/data/custom_example.py,sha256=QRBqiRiZS8UgVeTRHY0r1Jzm6yAYsyg6zmHxQGxdiQs,739
@@ -62,7 +62,7 @@ judgeval/scorers/judgeval_scorers/classifiers/text2sql/text2sql_scorer.py,sha256
62
62
  judgeval/tracer/__init__.py,sha256=wy3DYpH8U_z0GO_K_gOSkK0tTTD-u5eLDo0T5xIBoAc,147
63
63
  judgeval/utils/alerts.py,sha256=7HO42fEskQpwocUU-lq6EX4LGPzpxbIhaiJ5pkH31-I,3278
64
64
  judgeval/utils/data_utils.py,sha256=pB4GBWi8XoM2zSR2NlLXH5kqcQ029BVhDxaVKkdmiBY,1860
65
- judgeval-0.0.43.dist-info/METADATA,sha256=nA8kVqJDfwTJTzV31R3dbgkt4VTbcWTc_WRxyuWZZtQ,55748
66
- judgeval-0.0.43.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
67
- judgeval-0.0.43.dist-info/licenses/LICENSE.md,sha256=tKmCg7k5QOmxPK19XMfzim04QiQJPmgIm0pAn55IJwk,11352
68
- judgeval-0.0.43.dist-info/RECORD,,
65
+ judgeval-0.0.44.dist-info/METADATA,sha256=qDopKywsOERUmD2Rjy8lxSEU1C9xrRhRfiTIwN5Vi40,55748
66
+ judgeval-0.0.44.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
67
+ judgeval-0.0.44.dist-info/licenses/LICENSE.md,sha256=tKmCg7k5QOmxPK19XMfzim04QiQJPmgIm0pAn55IJwk,11352
68
+ judgeval-0.0.44.dist-info/RECORD,,