Skip to content
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

feat: support name parameter to update_run (#927) #931

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions python/langsmith/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ def update_run(
self,
run_id: ID_TYPE,
*,
name: Optional[str] = None,
end_time: Optional[datetime.datetime] = None,
error: Optional[str] = None,
inputs: Optional[Dict] = None,
Expand All @@ -1450,6 +1451,8 @@ def update_run(
----------
run_id : str or UUID
The ID of the run to update.
name : str or None, default=None
The name of the run.
end_time : datetime or None
The end time of the run.
error : str or None, default=None
Expand All @@ -1469,6 +1472,7 @@ def update_run(
"""
data: Dict[str, Any] = {
"id": _as_uuid(run_id, "run_id"),
"name": name,
"trace_id": kwargs.pop("trace_id", None),
"parent_run_id": kwargs.pop("parent_run_id", None),
"dotted_order": kwargs.pop("dotted_order", None),
Expand Down
1 change: 1 addition & 0 deletions python/langsmith/run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def patch(self) -> None:
if not self.end_time:
self.end()
self.client.update_run(
name=self.name,
run_id=self.id,
outputs=self.outputs.copy() if self.outputs else None,
error=self.error,
Expand Down
2 changes: 2 additions & 0 deletions python/tests/integration_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,11 @@ def test_persist_update_run(langchain_client: Client) -> None:
langchain_client.create_run(**run)
run["outputs"] = {"output": ["Hi"]}
run["extra"]["foo"] = "bar"
run["name"] = "test_run_updated"
langchain_client.update_run(run["id"], **run)
wait_for(lambda: langchain_client.read_run(run["id"]).end_time is not None)
stored_run = langchain_client.read_run(run["id"])
assert stored_run.name == run["name"]
assert stored_run.id == run["id"]
assert stored_run.outputs == run["outputs"]
assert stored_run.start_time == run["start_time"]
Expand Down
Loading