Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] promptflow 1.11.0 raises IndexError: list index out of range #3355

Closed
marinaby opened this issue May 29, 2024 · 2 comments
Closed

[BUG] promptflow 1.11.0 raises IndexError: list index out of range #3355

marinaby opened this issue May 29, 2024 · 2 comments
Assignees
Labels
bug Something isn't working no-recent-activity There has been no recent activity on this issue/pull request

Comments

@marinaby
Copy link

Describe the bug
When running a promptflow which calls a second promptflow as a function, we get the following error message:
IndexError: list index out of range

../..//lib/python3.9/site-packages/promptflow/_sdk/entities/_flows/base.py:239: in call
result = self.invoke(inputs=kwargs)
../..//lib/python3.9/site-packages/promptflow/_sdk/entities/_flows/dag.py:170: in invoke
return super().invoke(inputs=inputs)
../..//lib/python3.9/site-packages/promptflow/_sdk/entities/_flows/base.py:247: in invoke
result = invoker._invoke(
../..//lib/python3.9/site-packages/promptflow/core/_serving/flow_invoker.py:207: in _invoke
return self.executor.exec_line(data, run_id=run_id, allow_generator_output=self.streaming())
../..//lib/python3.9/site-packages/promptflow/executor/flow_executor.py:741: in exec_line
line_result = self._exec(
../../lib/python3.9/site-packages/promptflow/executor/flow_executor.py:1027: in _exec
output, aggregation_inputs = self._exec_inner_with_trace(
../..//lib/python3.9/site-packages/promptflow/executor/flow_executor.py:934: in _exec_inner_with_trace
self._exec_post_process(inputs, output, nodes_outputs, run_info, run_tracker, span, stream)
../..//lib/python3.9/site-packages/promptflow/executor/flow_executor.py:965: in _exec_post_process
run_tracker.update_and_persist_generator_node_runs(run_info.run_id, generator_output_nodes)


self = <promptflow._core.run_tracker.RunTracker object at 0x7fc19063ac10>
run_id = 'f5e974a5-d55f-4208-be32-502c38d1ba9e'
node_names = ['chat_with_context', 'post_process']
def update_and_persist_generator_node_runs(self, run_id: str, node_names: List[str]):
"""
Persists the node runs for nodes producing generators.

    :param run_id: The ID of the flow run.
    :type run_id: str
    :param node_names: The names of the nodes to persist.
    :type node_names: List[str]
    :returns: None
    """
    selected_node_run_info = (
        run_info for run_info in self.collect_child_node_runs(run_id) if run_info.node in node_names
    )
    for node_run_info in selected_node_run_info:
        # Update the output of the node run with the output in the trace.
        # This is because the output in the trace would includes the generated items.
      output_in_trace = node_run_info.api_calls[0]["output"]

E IndexError: list index out of range
../..//lib/python3.9/site-packages/promptflow/_core/run_tracker.py:452: IndexError

How To Reproduce the bug
Steps to reproduce the behavior, how frequent can you experience the bug:

  1. Create a promptflow which invokes a second flows like this
    second_flow = promptflow.load_flow(flow_path)
    second_flow()
  2. Invoke the (first) promptflow.

Expected behavior
The flow should succeed.

Running Information(please complete the following information):

  • Promptflow Package Version: 1.11.0
  • Operating System: macos
  • Python Version using 3.9.18

Additional context
This issue started after upgrading promptflow to 1.11.0 version, in version 1.10.0 we didn't have this problem.

@marinaby marinaby added the bug Something isn't working label May 29, 2024
@D-W- D-W- self-assigned this May 30, 2024
@D-W-
Copy link
Contributor

D-W- commented May 30, 2024

Hi @marinaby , thanks for reporting, we are fixing this bug in attached PR. I'll update here once it got released. Please pin back to 1.10.0 before next release. Thanks!

brynn-code added a commit that referenced this issue May 31, 2024
# Description

Bugfix for #3355 

This pull request includes a significant change in the
`update_and_persist_generator_node_runs` method in the
`src/promptflow-core/promptflow/_core/run_tracker.py` file. The change
primarily focuses on adding a condition to check if `api_calls` for a
`node_run_info` exists before proceeding with the update. This change is
important as it takes into account scenarios where `api_calls` for the
node run might not exist, such as in a flow as function/serving. In such
cases, the update is skipped.

Additionally, the method of accessing the `output` from `api_calls` has
been changed from direct indexing to using the `get` method, which is a
safer way to access dictionary values.

*
[`src/promptflow-core/promptflow/_core/run_tracker.py`](diffhunk://#diff-a5027d19a24cb28a68ead16dfe6c54492c78d6e0e7640e80533928808cdb3422R451-R457):
Added a condition to check if `api_calls` exists for `node_run_info`
before updating it. This accounts for scenarios where `api_calls` for
the node run might not exist. Also, changed the way `output` is accessed
from `api_calls` by using the `get` method instead of direct indexing.
# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [ ] Title of the pull request is clear and informative.
- [ ] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.

---------

Signed-off-by: Brynn Yin <biyi@microsoft.com>
Co-authored-by: Heyi <heta@microsoft.com>
Co-authored-by: Brynn Yin <biyi@microsoft.com>
Copy link

Hi, we're sending this friendly reminder because we haven't heard back from you in 30 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 7 days of this comment, the issue will be automatically closed. Thank you!

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue/pull request label Jun 29, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-recent-activity There has been no recent activity on this issue/pull request
Projects
None yet
Development

No branches or pull requests

2 participants