Skip to content

Commit d61888c

Browse files
viniciusdsmellogustavocidornelas
authored andcommitted
refactor(tracer): simplify async step creation by consolidating functions
- Replaced `_create_step_for_async_generator` with a direct call to `_create_and_initialize_step` to streamline async step creation. - Updated the parameters for step initialization to enhance clarity and maintainability. - Improved overall code readability by reducing function complexity.
1 parent 16429ac commit d61888c

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/openlayer/lib/tracing/tracer.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ async def __anext__(self):
251251
# Initialize tracing on first iteration only
252252
if not self._trace_initialized:
253253
self._original_gen = func(*func_args, **func_kwargs)
254-
self._step, self._is_root_step, self._token = (
255-
_create_step_for_async_generator(
256-
step_name=step_name,
257-
inference_pipeline_id=inference_pipeline_id,
258-
**step_kwargs,
259-
)
254+
self._step, self._is_root_step, self._token = _create_and_initialize_step(
255+
step_name=step_name,
256+
step_type=enums.StepType.USER_CALL,
257+
inputs=None,
258+
output=None,
259+
metadata=None,
260260
)
261261
self._inputs = _extract_function_inputs(
262262
func_signature=func_signature,
@@ -557,18 +557,6 @@ def _finalize_step_logging(
557557
# ----------------------------- Async generator specific functions ----------------------------- #
558558

559559

560-
def _create_step_for_async_generator(
561-
step_name: str, inference_pipeline_id: Optional[str] = None, **step_kwargs
562-
) -> Tuple[steps.Step, bool, Any]:
563-
"""Create and initialize step for async generators - no context manager."""
564-
return _create_and_initialize_step(
565-
step_name=step_name,
566-
step_type=enums.StepType.USER_CALL,
567-
inputs=None,
568-
output=None,
569-
metadata=None,
570-
)
571-
572560

573561
def _finalize_async_generator_step(
574562
step: steps.Step,

0 commit comments

Comments
 (0)