Skip to content

Commit

Permalink
Propagate name
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw committed Aug 21, 2024
1 parent ce1bc34 commit 4ee786d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
2 changes: 2 additions & 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 Expand Up @@ -399,6 +400,7 @@ def from_headers(cls, headers: Dict[str, str], **kwargs: Any) -> Optional[RunTre
timezone.utc
)
init_args["run_type"] = init_args.get("run_type") or "chain"
print(init_args, flush=True)
init_args["name"] = init_args.get("name") or "parent"

baggage = _Baggage.from_header(headers.get("baggage"))
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 <support@langchain.dev>"]
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 4ee786d

Please sign in to comment.