Merge pull request #1282 from langchain-ai/isaac/nodelogging

add task_id to node logs
This commit is contained in:
Nuno Campos
2024-09-03 16:30:43 -07:00
committed by GitHub
5 changed files with 33 additions and 27 deletions
+3 -5
View File
@@ -108,7 +108,7 @@ def map_debug_task_results(
stream_channels_list = (
[stream_keys] if isinstance(stream_keys, str) else stream_keys
)
ts = datetime.now(timezone.utc).isoformat()
ts = datetime.now(timezone.utc)
for task, writes in tasks:
if task.config is not None and TAG_HIDDEN in task.config.get("tags", []):
continue
@@ -119,12 +119,10 @@ def map_debug_task_results(
yield {
"type": "task_result",
"timestamp": ts,
"timestamp": ts.isoformat(),
"step": step,
"payload": {
"id": str(
uuid5(TASK_NAMESPACE, json.dumps((task.name, step, metadata)))
),
"id": task.id,
"name": task.name,
"error": next((w[1] for w in writes if w[0] == ERROR), None),
"result": [w for w in writes if w[0] in stream_channels_list],
+3 -1
View File
@@ -241,7 +241,9 @@ class PregelLoop:
self.stream.extend(
(self.config["configurable"].get("checkpoint_ns", ""), "debug", v)
for v in map_debug_task_results(
self.step, [(task, writes)], self.stream_keys
self.step,
[(task, writes)],
self.stream_keys,
)
)
+6
View File
@@ -0,0 +1,6 @@
class AnyInt(int):
def __init__(self) -> None:
super().__init__()
def __eq__(self, other: object) -> bool:
return isinstance(other, int)
+10 -10
View File
@@ -1080,7 +1080,7 @@ def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 0,
"payload": {
"id": "2687f72c-e3a8-5f6f-9afa-047cbf24e923",
"id": AnyStr(),
"name": "one",
"result": [("inbox", 3)],
"error": None,
@@ -1092,7 +1092,7 @@ def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 0,
"payload": {
"id": "18f52f6a-828d-58a1-a501-53cc0c7af33e",
"id": AnyStr(),
"name": "two",
"result": [("output", 13)],
"error": None,
@@ -1115,7 +1115,7 @@ def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "871d6e74-7bb3-565f-a4fe-cef4b8f19b62",
"id": AnyStr(),
"name": "two",
"result": [("output", 4)],
"error": None,
@@ -6350,7 +6350,7 @@ def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "592f3430-c17c-5d1c-831f-fecebb2c05bf",
"id": AnyStr(),
"name": "rewrite_query",
"result": [("query", "query: what is weather in sf")],
"error": None,
@@ -6398,7 +6398,7 @@ def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "96965ed0-2c10-52a1-86eb-081ba6de73b2",
"id": AnyStr(),
"name": "retriever_two",
"result": [("docs", ["doc3", "doc4"])],
"error": None,
@@ -6417,7 +6417,7 @@ def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "7db5e9d8-e132-5079-ab99-ced15e67d48b",
"id": AnyStr(),
"name": "retriever_one",
"result": [("docs", ["doc1", "doc2"])],
"error": None,
@@ -6457,7 +6457,7 @@ def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 3,
"payload": {
"id": "8959fb57-d0f5-5725-9ac4-ec1c554fb0a0",
"id": AnyStr(),
"name": "qa",
"result": [("answer", "doc1,doc2,doc3,doc4")],
"error": None,
@@ -6874,7 +6874,7 @@ def test_branch_then(
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "7b7b0713-e958-5d07-803c-c9910a7cc162",
"id": AnyStr(),
"name": "prepare",
"result": [("my_key", " prepared")],
"error": None,
@@ -6927,7 +6927,7 @@ def test_branch_then(
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "dd9f2fa5-ccfa-5d12-81ec-942563056a08",
"id": AnyStr(),
"name": "tool_two_slow",
"result": [("my_key", " slow")],
"error": None,
@@ -6980,7 +6980,7 @@ def test_branch_then(
"timestamp": AnyStr(),
"step": 3,
"payload": {
"id": "9b590c54-15ef-54b1-83a7-140d27b0bc52",
"id": AnyStr(),
"name": "finish",
"result": [("my_key", " finished")],
"error": None,
+11 -11
View File
@@ -1327,7 +1327,7 @@ async def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 0,
"payload": {
"id": "2687f72c-e3a8-5f6f-9afa-047cbf24e923",
"id": AnyStr(),
"name": "one",
"result": [("inbox", 3)],
"error": None,
@@ -1339,7 +1339,7 @@ async def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 0,
"payload": {
"id": "18f52f6a-828d-58a1-a501-53cc0c7af33e",
"id": AnyStr(),
"name": "two",
"result": [("output", 13)],
"error": None,
@@ -1362,7 +1362,7 @@ async def test_invoke_two_processes_in_dict_out(mocker: MockerFixture) -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "871d6e74-7bb3-565f-a4fe-cef4b8f19b62",
"id": AnyStr(),
"name": "two",
"result": [("output", 4)],
"error": None,
@@ -5037,7 +5037,7 @@ async def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "592f3430-c17c-5d1c-831f-fecebb2c05bf",
"id": AnyStr(),
"name": "rewrite_query",
"result": [("query", "query: what is weather in sf")],
"error": None,
@@ -5085,7 +5085,7 @@ async def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "96965ed0-2c10-52a1-86eb-081ba6de73b2",
"id": AnyStr(),
"name": "retriever_two",
"result": [("docs", ["doc3", "doc4"])],
"error": None,
@@ -5104,7 +5104,7 @@ async def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "7db5e9d8-e132-5079-ab99-ced15e67d48b",
"id": AnyStr(),
"name": "retriever_one",
"result": [("docs", ["doc1", "doc2"])],
"error": None,
@@ -5144,7 +5144,7 @@ async def test_in_one_fan_out_out_one_graph_state() -> None:
"timestamp": AnyStr(),
"step": 3,
"payload": {
"id": "8959fb57-d0f5-5725-9ac4-ec1c554fb0a0",
"id": AnyStr(),
"name": "qa",
"result": [("answer", "doc1,doc2,doc3,doc4")],
"error": None,
@@ -5496,7 +5496,7 @@ async def test_branch_then(checkpointer_name: str) -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "7b7b0713-e958-5d07-803c-c9910a7cc162",
"id": AnyStr(),
"name": "prepare",
"result": [("my_key", " prepared")],
"error": None,
@@ -5551,7 +5551,7 @@ async def test_branch_then(checkpointer_name: str) -> None:
"timestamp": AnyStr(),
"step": 2,
"payload": {
"id": "dd9f2fa5-ccfa-5d12-81ec-942563056a08",
"id": AnyStr(),
"name": "tool_two_slow",
"result": [("my_key", " slow")],
"error": None,
@@ -5604,7 +5604,7 @@ async def test_branch_then(checkpointer_name: str) -> None:
"timestamp": AnyStr(),
"step": 3,
"payload": {
"id": "9b590c54-15ef-54b1-83a7-140d27b0bc52",
"id": AnyStr(),
"name": "finish",
"result": [("my_key", " finished")],
"error": None,
@@ -5733,7 +5733,7 @@ async def test_branch_then(checkpointer_name: str) -> None:
"timestamp": AnyStr(),
"step": 1,
"payload": {
"id": "1a591be4-f85c-558f-8d00-1ccac0d1877f",
"id": AnyStr(),
"name": "prepare",
"result": [("my_key", " prepared")],
"error": None,