Skip to content

Commit

Permalink
handle line run lacking main line
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengfeiwang committed Feb 6, 2024
1 parent 92fcbc7 commit 7517c51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/promptflow/promptflow/_sdk/entities/_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class LineRun:
evaluations: typing.Optional[typing.List[typing.Dict]] = None

@staticmethod
def _from_spans(spans: typing.List[Span]) -> "LineRun":
def _from_spans(spans: typing.List[Span]) -> typing.Optional["LineRun"]:
main_line_run_data: _LineRunData = None
evaluation_line_run_data_dict = dict()
for span in spans:
Expand All @@ -244,6 +244,11 @@ def _from_spans(spans: typing.List[Span]) -> "LineRun":
else:
# eager flow/arbitrary script
main_line_run_data = _LineRunData._from_root_span(span)
# main line run span is absent, ignore this line run
# this may happen when the line is still executing, or terminated
if main_line_run_data is None:
return None

evaluations = dict()
for eval_name, eval_line_run_data in evaluation_line_run_data_dict.items():
evaluations[eval_name] = eval_line_run_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ def list_line_runs(
pass
for orm_spans in grouped_orm_spans.values():
spans = [Span._from_orm_object(orm_span) for orm_span in orm_spans]
line_runs.append(LineRun._from_spans(spans))
line_run = LineRun._from_spans(spans)
if line_run is not None:
line_runs.append(line_run)
return line_runs

0 comments on commit 7517c51

Please sign in to comment.