Skip to content

fix: make sure each experiment run has its own id #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions literalai/evaluation/experiment_item_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ def __init__(
self,
client: "BaseLiteralClient",
):
self.id = str(uuid.uuid4())
self.client = client
EnvContextManager.__init__(self, client=client, env="experiment")
StepContextManager.__init__(
self, client=client, name="Experiment Run", type="run", id=self.id
)

def __call__(self, func):
return experiment_item_run_decorator(
Expand All @@ -30,7 +27,11 @@ def __call__(self, func):
)

async def __aenter__(self):
active_experiment_item_run_id_var.set(self.id)
id = str(uuid.uuid4())
StepContextManager.__init__(
self, client=self.client, name="Experiment Run", type="run", id=id
)
active_experiment_item_run_id_var.set(id)
await EnvContextManager.__aenter__(self)
step = await StepContextManager.__aenter__(self)
return step
Expand All @@ -42,7 +43,11 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
active_experiment_item_run_id_var.set(None)

def __enter__(self):
active_experiment_item_run_id_var.set(self.id)
id = str(uuid.uuid4())
StepContextManager.__init__(
self, client=self.client, name="Experiment Run", type="run", id=id
)
active_experiment_item_run_id_var.set(id)
EnvContextManager.__enter__(self)
step = StepContextManager.__enter__(self)
return step
Expand Down
Loading