@@ -42,6 +42,7 @@ def create_step(
42
42
inputs : Optional [Any ] = None ,
43
43
output : Optional [Any ] = None ,
44
44
metadata : Optional [Dict [str , Any ]] = None ,
45
+ inference_pipeline_id : Optional [str ] = None ,
45
46
) -> Generator [steps .Step , None , None ]:
46
47
"""Starts a trace and yields a Step object."""
47
48
new_step : steps .Step = steps .step_factory (
@@ -99,7 +100,8 @@ def create_step(
99
100
if _publish :
100
101
try :
101
102
_client .inference_pipelines .data .stream (
102
- id = utils .get_env_variable ("OPENLAYER_INFERENCE_PIPELINE_ID" ),
103
+ inference_pipeline_id = inference_pipeline_id
104
+ or utils .get_env_variable ("OPENLAYER_INFERENCE_PIPELINE_ID" ),
103
105
rows = [trace_data ],
104
106
config = config ,
105
107
)
@@ -119,7 +121,7 @@ def add_chat_completion_step_to_trace(**kwargs) -> None:
119
121
120
122
121
123
# ----------------------------- Tracing decorator ---------------------------- #
122
- def trace (* step_args , ** step_kwargs ):
124
+ def trace (* step_args , inference_pipeline_id : Optional [ str ] = None , ** step_kwargs ):
123
125
"""Decorator to trace a function.
124
126
125
127
Examples
@@ -163,7 +165,7 @@ def decorator(func):
163
165
def wrapper (* func_args , ** func_kwargs ):
164
166
if step_kwargs .get ("name" ) is None :
165
167
step_kwargs ["name" ] = func .__name__
166
- with create_step (* step_args , ** step_kwargs ) as step :
168
+ with create_step (* step_args , inference_pipeline_id = inference_pipeline_id , ** step_kwargs ) as step :
167
169
output = exception = None
168
170
try :
169
171
output = func (* func_args , ** func_kwargs )
@@ -196,7 +198,7 @@ def wrapper(*func_args, **func_kwargs):
196
198
return decorator
197
199
198
200
199
- def trace_async (* step_args , ** step_kwargs ):
201
+ def trace_async (* step_args , inference_pipeline_id : Optional [ str ] = None , ** step_kwargs ):
200
202
"""Decorator to trace a function.
201
203
202
204
Examples
@@ -240,7 +242,7 @@ def decorator(func):
240
242
async def wrapper (* func_args , ** func_kwargs ):
241
243
if step_kwargs .get ("name" ) is None :
242
244
step_kwargs ["name" ] = func .__name__
243
- with create_step (* step_args , ** step_kwargs ) as step :
245
+ with create_step (* step_args , inference_pipeline_id = inference_pipeline_id , ** step_kwargs ) as step :
244
246
output = exception = None
245
247
try :
246
248
output = await func (* func_args , ** func_kwargs )
0 commit comments