From 75ef3e8e608c481e5bdfd90123604bd03eb089da Mon Sep 17 00:00:00 2001 From: Heyi Tang Date: Thu, 14 Mar 2024 19:03:57 +0800 Subject: [PATCH] [Internal] Update connection not found message to make it more clear (#2350) # Description This pull request includes changes to the `src/promptflow/promptflow/executor/_tool_resolver.py` and `src/promptflow/tests/executor/e2etests/test_executor_happypath.py` files to improve error messaging and testing. The main changes are: * [`src/promptflow/promptflow/executor/_tool_resolver.py`](diffhunk://#diff-714d8202b40acb4053e3f9b366ee4972b32f98afc8a2efe8a1750842f1facc65L350-R351): The error message in the `ConnectionNotFound` exception raised in the `_get_llm_node_connection` method has been updated to include the name of the missing connection. This change will make it easier to debug issues related to missing connections. * [`src/promptflow/tests/executor/e2etests/test_executor_happypath.py`](diffhunk://#diff-44d4009e9df8029bb88432b7a843d3a887764cd6a67070afc49557334af3cbaaL182-R182): The assertion in the `test_executor_node_overrides` method has been updated to reflect the change in the error message. This ensures that the test will still pass with the updated error messaging. # 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. Co-authored-by: Heyi Co-authored-by: Brynn Yin <24237253+brynn-code@users.noreply.github.com> --- src/promptflow/promptflow/executor/_tool_resolver.py | 3 ++- .../tests/executor/e2etests/test_executor_happypath.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/promptflow/promptflow/executor/_tool_resolver.py b/src/promptflow/promptflow/executor/_tool_resolver.py index d9f7a4ba25e..d77dfcda138 100644 --- a/src/promptflow/promptflow/executor/_tool_resolver.py +++ b/src/promptflow/promptflow/executor/_tool_resolver.py @@ -347,7 +347,8 @@ def _get_llm_node_connection(self, node: Node): connection = self._connection_manager.get(node.connection) if connection is None: raise ConnectionNotFound( - message_format="Connection of LLM node '{node_name}' is not found.", + message_format="Connection '{connection}' of LLM node '{node_name}' is not found.", + connection=node.connection, node_name=node.name, target=ErrorTarget.EXECUTOR, ) diff --git a/src/promptflow/tests/executor/e2etests/test_executor_happypath.py b/src/promptflow/tests/executor/e2etests/test_executor_happypath.py index 2a4c527aa50..ed60eff72aa 100644 --- a/src/promptflow/tests/executor/e2etests/test_executor_happypath.py +++ b/src/promptflow/tests/executor/e2etests/test_executor_happypath.py @@ -179,7 +179,7 @@ def test_executor_node_overrides(self, dev_connections): raise_ex=True, ) assert isinstance(e.value.inner_exception, ConnectionNotFound) - assert "Connection of LLM node 'classify_with_llm' is not found." in str(e.value) + assert "Connection 'dummy_connection' of LLM node 'classify_with_llm' is not found." in str(e.value) @pytest.mark.parametrize( "flow_folder",