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

[Bugfix] Fix the bug that call flow in flow function will fail #2267

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

thy09
Copy link
Contributor

@thy09 thy09 commented Mar 8, 2024

Description

Currently call a flow in a flow node will fail due to wrongly handled operation context, in this PR, we fix it by copy the original context and recover.
Issue: #2237

This pull request primarily focuses on refactoring the handling of operation contexts in the promptflow package. The most significant changes include the addition of a copy method to the OperationContext class, the introduction of a set_instance class method to the same class, and changes to the exec_line_async and _update_operation_context methods in the FlowExecutor class to utilize these new methods.

Here is a breakdown of the key changes:

Changes to OperationContext class in src/promptflow/promptflow/_core/operation_context.py:

  • A copy method has been added to the OperationContext class, which creates a copy of the current operation context and returns it. This method also ensures that a copy of the _OTEL_ATTRIBUTES is made.
  • A set_instance class method has been introduced. This method allows setting a new instance of the operation context.

Changes to FlowExecutor class in src/promptflow/promptflow/executor/flow_executor.py:

  • In the exec_line_async method, the OperationContext's new copy method is used to create a copy of the original operation context.
  • The _update_operation_context method has been significantly simplified. Instead of manually reverting changes to the operation context, it now simply restores the original context using the OperationContext's set_instance method.

These changes simplify the code and make the handling of operation contexts more robust and less error-prone.

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.
  • Create an issue and link to the pull request to get dedicated review from promptflow team. Learn more: 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.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@thy09 thy09 requested a review from a team as a code owner March 8, 2024 05:50
@github-actions github-actions bot added promptflow executor The changes related to the execution of the flow labels Mar 8, 2024
Copy link

github-actions bot commented Mar 8, 2024

promptflow-tracing unit test result heta/fix-flow-in-flow

4 files  4 suites   21s ⏱️
1 tests 1 ✅ 0 💤 0 ❌
4 runs  4 ✅ 0 💤 0 ❌

Results for commit 4cf75e8.

Copy link

github-actions bot commented Mar 8, 2024

SDK CLI Global Config Test Result heta/fix-flow-in-flow

2 tests   2 ✅  46s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 4cf75e8.

Copy link

github-actions bot commented Mar 8, 2024

Executor Unit Test Result heta/fix-flow-in-flow

754 tests   754 ✅  45s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 4cf75e8.

Copy link

github-actions bot commented Mar 8, 2024

promptflow SDK CLI Azure E2E Test Result heta/fix-flow-in-flow

  4 files    4 suites   3m 43s ⏱️
168 tests 149 ✅ 19 💤 0 ❌
672 runs  596 ✅ 76 💤 0 ❌

Results for commit 4cf75e8.

Copy link

github-actions bot commented Mar 8, 2024

Executor E2E Test Result heta/fix-flow-in-flow

211 tests   209 ✅  6m 27s ⏱️
  1 suites    2 💤
  1 files      0 ❌

Results for commit 4cf75e8.

Copy link

github-actions bot commented Mar 8, 2024

SDK CLI Test Result heta/fix-flow-in-flow

   12 files     12 suites   41m 32s ⏱️
  454 tests   437 ✅ 17 💤 0 ❌
1 816 runs  1 748 ✅ 68 💤 0 ❌

Results for commit 4cf75e8.

@thy09 thy09 merged commit bcc6af0 into main Mar 8, 2024
49 checks passed
@thy09 thy09 deleted the heta/fix-flow-in-flow branch March 8, 2024 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
executor The changes related to the execution of the flow promptflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants