dspy 0.27.0 → 0.27.1
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.
- checksums.yaml +4 -4
- data/lib/dspy/context.rb +24 -18
- data/lib/dspy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7962564b749798c462b3202e16153aa9e508e8d7fb10d6618c76e740ecb171d1
|
4
|
+
data.tar.gz: d81fad4637c82967745d644c291f7436e26c0c1bf06785ff56028c71d4d5f26d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ed78b62481f7267a9d1fa7157af436bdfd82d6a8281b00b9d8915fa74e7b0b5d896f8dfa9d6f4a91aa829973f7db94445d76b3cdb5e7c66800cd23f28f1fe9
|
7
|
+
data.tar.gz: 61f0ef47790c3c9aa6c6ecd1f7ee11268ac81b27ca75212af2c69b4f4b077fa07c9acb237c7d7b3f4174c85d7de415684ac9fef5c88e01d538671b93910fa889
|
data/lib/dspy/context.rb
CHANGED
@@ -6,29 +6,31 @@ module DSPy
|
|
6
6
|
class Context
|
7
7
|
class << self
|
8
8
|
def current
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
#
|
19
|
-
Fiber[:dspy_context]
|
9
|
+
# Use a combination of Thread and Fiber storage for proper context management
|
10
|
+
# Thread storage ensures thread isolation
|
11
|
+
# Fiber storage ensures OpenTelemetry context propagation
|
12
|
+
|
13
|
+
# Create a unique key for this thread to ensure isolation
|
14
|
+
thread_key = :"dspy_context_#{Thread.current.object_id}"
|
15
|
+
|
16
|
+
# Check if this thread has its own context
|
17
|
+
if Thread.current[thread_key]
|
18
|
+
# Thread has context, ensure fiber has it too for OpenTelemetry
|
19
|
+
Fiber[:dspy_context] ||= Thread.current[thread_key]
|
20
20
|
else
|
21
|
-
#
|
22
|
-
|
21
|
+
# No context for this thread - create new one
|
22
|
+
context = {
|
23
23
|
trace_id: SecureRandom.uuid,
|
24
24
|
span_stack: []
|
25
25
|
}
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Thread.current[:dspy_context]
|
26
|
+
# Set in both Thread and Fiber storage
|
27
|
+
Thread.current[thread_key] = context
|
28
|
+
Thread.current[:dspy_context] = context # Keep for backward compatibility
|
29
|
+
Fiber[:dspy_context] = context
|
31
30
|
end
|
31
|
+
|
32
|
+
# Return the context (from Fiber storage for OpenTelemetry compatibility)
|
33
|
+
Fiber[:dspy_context]
|
32
34
|
end
|
33
35
|
|
34
36
|
def with_span(operation:, **attributes)
|
@@ -65,6 +67,7 @@ module DSPy
|
|
65
67
|
# Record start time for explicit duration tracking
|
66
68
|
otel_start_time = Time.now
|
67
69
|
|
70
|
+
# Always use in_span which properly manages context internally
|
68
71
|
DSPy::Observability.tracer.in_span(
|
69
72
|
operation,
|
70
73
|
attributes: span_attributes,
|
@@ -102,6 +105,9 @@ module DSPy
|
|
102
105
|
end
|
103
106
|
|
104
107
|
def clear!
|
108
|
+
# Clear both the thread-specific key and the legacy key
|
109
|
+
thread_key = :"dspy_context_#{Thread.current.object_id}"
|
110
|
+
Thread.current[thread_key] = nil
|
105
111
|
Thread.current[:dspy_context] = nil
|
106
112
|
Fiber[:dspy_context] = nil
|
107
113
|
end
|
data/lib/dspy/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dspy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.27.
|
4
|
+
version: 0.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vicente Reig Rincón de Arellano
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-09-
|
10
|
+
date: 2025-09-14 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: dry-configurable
|