Skip to content

Commit b3bd345

Browse files
authored
fix: Reverting a change from a previous context manager fix (#133)
1 parent f44be0c commit b3bd345

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/galileo/decorator.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ def call_llm(prompt, temperature=0.7):
5050
from collections.abc import AsyncGenerator, Generator
5151
from contextvars import ContextVar
5252
from functools import wraps
53-
from os import getenv
5453
from types import TracebackType
5554
from typing import Any, Callable, Literal, Optional, TypeVar, Union, cast, overload
5655

5756
from typing_extensions import ParamSpec
5857

59-
from galileo.constants import DEFAULT_LOG_STREAM_NAME, DEFAULT_PROJECT_NAME
6058
from galileo.logger import GalileoLogger
6159
from galileo.schema.datasets import DatasetRecord
6260
from galileo.schema.metrics import LocalMetricConfig
@@ -104,11 +102,6 @@ class GalileoDecorator:
104102
2. A context manager via the `__call__` method
105103
"""
106104

107-
def __init__(self):
108-
# Get default values from environment variables
109-
self.project_from_env = getenv("GALILEO_PROJECT", DEFAULT_PROJECT_NAME)
110-
self.log_stream_from_env = getenv("GALILEO_LOG_STREAM", DEFAULT_LOG_STREAM_NAME)
111-
112105
def __enter__(self) -> "GalileoDecorator":
113106
"""
114107
Entry point for the context manager.
@@ -173,13 +166,13 @@ def __call__(
173166
_trace_stack.get().append(_trace_context.get())
174167
_span_stack_stack.get().append(_span_stack_context.get().copy())
175168

176-
# Reset context values
169+
# Reset trace context values
177170
_span_stack_context.set([])
178171
_trace_context.set(None)
179172

180-
# Set context values to environment defaults
181-
_project_context.set(self.project_from_env)
182-
_log_stream_context.set(self.log_stream_from_env)
173+
# Set request context values to defaults
174+
_project_context.set(None)
175+
_log_stream_context.set(None)
183176
_experiment_id_context.set(None)
184177

185178
# Override with explicitly provided values

tests/test_galileo_context.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ def test_context_update_with_defaults(
8888
# Second level context with only project updated; log_stream should be default
8989
with galileo_context(project="project2"):
9090
assert _project_context.get() == "project2"
91-
assert _log_stream_context.get() == "test-log-stream" # use env default
91+
assert _log_stream_context.get() is None # use env default
9292
assert _experiment_id_context.get() is None
9393

9494
# Third level context with no params: should use defaults
9595
with galileo_context():
96-
assert _project_context.get() == "test-project"
97-
assert _log_stream_context.get() == "test-log-stream"
96+
assert _project_context.get() is None
97+
assert _log_stream_context.get() is None
9898
assert _experiment_id_context.get() is None
9999

100100
# After exiting third level, should restore second level context with default log_stream
101101
assert _project_context.get() == "project2"
102-
assert _log_stream_context.get() == "test-log-stream"
102+
assert _log_stream_context.get() is None
103103
assert _experiment_id_context.get() is None
104104

105105
# After exiting second level, should be back to first level

0 commit comments

Comments
 (0)