Skip to content

Commit 22de1ea

Browse files
author
wayflow-bot
committed
Merge branch 'use-stringify-for-tracing' into 'main'
Use stringify instead of str() for event tracing See merge request wayflow-dev/wayflow-public!223
2 parents 04a7df9 + 1cb0620 commit 22de1ea

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

wayflowcore/src/wayflowcore/events/event.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import TYPE_CHECKING, Any, Dict, Generic, List, Optional, TypeVar, Union
99

1010
from wayflowcore._utils.dataclass_utils import _required_attribute
11+
from wayflowcore._utils.formatting import stringify
1112
from wayflowcore.conversationalcomponent import ConversationalComponent
1213
from wayflowcore.serialization.context import SerializationContext
1314
from wayflowcore.serialization.serializer import serialize_any_to_dict, serialize_to_dict
@@ -258,7 +259,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
258259
"conversational_component.type": self.conversational_component.__class__.__name__,
259260
"conversational_component.id": self.conversational_component.id,
260261
"inputs": (
261-
{key: str(value) for key, value in (self.inputs or {}).items()}
262+
{key: stringify(value) for key, value in (self.inputs or {}).items()}
262263
if not mask_sensitive_information
263264
else _MASKING_TOKEN
264265
),
@@ -309,7 +310,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
309310
return {
310311
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
311312
"tool_request.inputs": (
312-
{key: str(value) for key, value in self.tool_request.args.items()}
313+
{key: stringify(value) for key, value in self.tool_request.args.items()}
313314
if not mask_sensitive_information
314315
else _MASKING_TOKEN
315316
),
@@ -332,7 +333,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
332333
return {
333334
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
334335
"tool_result.output": (
335-
str(self.tool_result.content) if not mask_sensitive_information else _MASKING_TOKEN
336+
stringify(self.tool_result.content)
337+
if not mask_sensitive_information
338+
else _MASKING_TOKEN
336339
),
337340
"tool_result.tool_request_id": self.tool_result.tool_request_id,
338341
}
@@ -353,7 +356,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
353356
return {
354357
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
355358
"inputs": (
356-
{key: str(value) for key, value in self.inputs.items()}
359+
{key: stringify(value) for key, value in self.inputs.items()}
357360
if not mask_sensitive_information
358361
else _MASKING_TOKEN
359362
),
@@ -372,10 +375,11 @@ class StepInvocationResultEvent(EndSpanEvent["StepInvocationSpan"]):
372375
"""Result of the step invocation"""
373376

374377
def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str, Any]:
378+
375379
return {
376380
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
377381
"step_result.outputs": (
378-
{key: str(value) for key, value in self.step_result.outputs.items()}
382+
{key: stringify(value) for key, value in self.step_result.outputs.items()}
379383
if not mask_sensitive_information
380384
else _MASKING_TOKEN
381385
),
@@ -412,7 +416,7 @@ class ContextProviderExecutionResultEvent(EndSpanEvent["ContextProviderExecution
412416
def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str, Any]:
413417
return {
414418
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
415-
"output": str(self.output) if not mask_sensitive_information else _MASKING_TOKEN,
419+
"output": stringify(self.output) if not mask_sensitive_information else _MASKING_TOKEN,
416420
}
417421

418422

@@ -520,7 +524,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
520524
else _MASKING_TOKEN
521525
),
522526
"execution_state.plan": (
523-
str(self.execution_state.plan) if not mask_sensitive_information else _MASKING_TOKEN
527+
stringify(self.execution_state.plan)
528+
if not mask_sensitive_information
529+
else _MASKING_TOKEN
524530
),
525531
"execution_state.tool_call_queue": [
526532
_serialize_tool_request(tool_request, mask_sensitive_information)
@@ -570,7 +576,9 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
570576
else _MASKING_TOKEN
571577
),
572578
"execution_state.plan": (
573-
str(self.execution_state.plan) if not mask_sensitive_information else _MASKING_TOKEN
579+
stringify(self.execution_state.plan)
580+
if not mask_sensitive_information
581+
else _MASKING_TOKEN
574582
),
575583
"execution_state.tool_call_queue": [
576584
_serialize_tool_request(tool_request, mask_sensitive_information)
@@ -610,7 +618,7 @@ def to_tracing_info(self, mask_sensitive_information: bool = True) -> Dict[str,
610618
**super().to_tracing_info(mask_sensitive_information=mask_sensitive_information),
611619
"exception.type": self.exception.__class__.__name__,
612620
"exception.message": (
613-
str(self.exception) if not mask_sensitive_information else _MASKING_TOKEN
621+
stringify(self.exception) if not mask_sensitive_information else _MASKING_TOKEN
614622
),
615623
"exception.traceback": (
616624
self.exception.__traceback__ if not mask_sensitive_information else _MASKING_TOKEN

wayflowcore/src/wayflowcore/models/ocigenaimodel.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,15 @@ def _generation_config_to_cohere_oci_parameters(
857857
_UNSUPPORTED_ARGUMENT_PATTERNS_WITH_NAMES = [
858858
"Unsupported parameter: '{param_name}'",
859859
"Unsupported value: '{param_name}'",
860-
"Argument not supported on this model: stop",
860+
"Argument not supported on this model: {param_name}",
861+
"does not support parameter {param_name}",
861862
]
862863

863864
_UNSUPPORTED_ARGUMENT_PATTERNS = [
864865
"Unsupported parameter:",
865866
"Unsupported value:",
866867
"Argument not supported on this model:",
868+
"does not support parameter",
867869
]
868870

869871

wayflowcore/tests/events/test_context_provider_execution_result_event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import pytest
77

8+
from wayflowcore._utils.formatting import stringify
89
from wayflowcore.contextproviders import ContextProvider
910
from wayflowcore.contextproviders.constantcontextprovider import ConstantContextProvider
1011
from wayflowcore.contextproviders.flowcontextprovider import FlowContextProvider
@@ -86,7 +87,7 @@ def test_correct_event_serialization_to_tracing_format(
8687
if mask_sensitive_information:
8788
assert _MASKING_TOKEN == serialized_event[attribute_name]
8889
else:
89-
assert str(attr) == serialized_event[attribute_name]
90+
assert stringify(attr) == serialized_event[attribute_name]
9091
else:
9192
assert attr == serialized_event[attribute_name]
9293

0 commit comments

Comments
 (0)