Skip to content

Commit

Permalink
[Python] Propagate name (#934)
Browse files Browse the repository at this point in the history
Fix an issue where parent runs were being coerced to "parent" instead of the actual name
  • Loading branch information
hinthornw authored Aug 21, 2024
1 parent ce1bc34 commit 9a31d28
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions python/langsmith/run_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def from_runnable_config(
kwargs["start_time"] = run.start_time
kwargs["end_time"] = run.end_time
kwargs["tags"] = sorted(set(run.tags or [] + kwargs.get("tags", [])))
kwargs["name"] = run.name
extra_ = kwargs.setdefault("extra", {})
metadata_ = extra_.setdefault("metadata", {})
metadata_.update(run.metadata)
Expand Down
14 changes: 7 additions & 7 deletions python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.1.100"
version = "0.1.101"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <[email protected]>"]
license = "MIT"
Expand Down
10 changes: 7 additions & 3 deletions python/tests/unit_tests/test_run_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ def child(inputs: dict) -> dict:
return {**stage_added["child_output"], **inputs}

@RunnableLambda
def parent(inputs: dict) -> dict:
def the_parent(inputs: dict) -> dict:
return {
**stage_added["parent_output"],
**child.invoke({**stage_added["child_input"], **inputs}),
Expand All @@ -1167,12 +1167,14 @@ def parent(inputs: dict) -> dict:
for stage in stage_added:
current = {**current, **stage_added[stage]}
expected_at_stage[stage] = current
parent_result = parent.invoke(stage_added["parent_input"], {"callbacks": [tracer]})
parent_result = the_parent.invoke(
stage_added["parent_input"], {"callbacks": [tracer]}
)
assert parent_result == expected_at_stage["parent_output"]
mock_posts = _get_calls(tracer.client, minimum=2)
assert len(mock_posts) == 2
datas = [json.loads(mock_post.kwargs["data"]) for mock_post in mock_posts]
assert datas[0]["name"] == "parent"
assert datas[0]["name"] == "the_parent"
assert datas[0]["inputs"] == expected_at_stage["parent_input"]
assert not datas[0]["outputs"]
assert datas[1]["name"] == "child"
Expand All @@ -1188,10 +1190,12 @@ def parent(inputs: dict) -> dict:
assert child_patch["id"] == child_uid
assert child_patch["outputs"] == expected_at_stage["child_output"]
assert child_patch["inputs"] == expected_at_stage["child_input"]
assert child_patch["name"] == "child"
parent_patch = json.loads(mock_patches[1].kwargs["data"])
assert parent_patch["id"] == parent_uid
assert parent_patch["outputs"] == expected_at_stage["parent_output"]
assert parent_patch["inputs"] == expected_at_stage["parent_input"]
assert parent_patch["name"] == "the_parent"


def test_trace_respects_tracing_context():
Expand Down

0 comments on commit 9a31d28

Please sign in to comment.