-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reset user agent for each requests in local pfs (#2284)
# Description This pull request primarily involves 2 changes: 1. specifying user agent for telemetry from local PFS without touching OperationContext, which behaves as a global context and will be shared among requests; 2. support using the same port file as msi by set up environment variable. User Agent Handling: * [`src/promptflow/promptflow/_core/operation_context.py`](diffhunk://#diff-9178fcc0ca6dea0124a2a13bb8e734a77ffbc4baadfe29d18a366452ff8f865aL156-R162): The `append_user_agent` method has been refactored to handle multiple user agents. It now splits the user agent string and appends new user agents if they are not already present. Client Request Processing: * Multiple files: The `get_client_from_request` method has been replaced with `get_client_based_on_pfs_request` across several files to improve client request processing. [[1]](diffhunk://#diff-684bb9c38065c7dd14f39bceb6ed87efa1ac3a1e70329eeb617cc484297e3134L12-R12) [[2]](diffhunk://#diff-684bb9c38065c7dd14f39bceb6ed87efa1ac3a1e70329eeb617cc484297e3134L84-R84) [[3]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL17-R21) [[4]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL55-R59) [[5]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL91-R95) [[6]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL110-R128) [[7]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL133-R137) [[8]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL144-R148) [[9]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL156-R160) [[10]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL178-R182) [[11]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL189-R193) [[12]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL204-R208) [[13]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL218-R222) [[14]](diffhunk://#diff-0286484edb80bee8c05edc9c9625ac73b1504399198a518446f38406de78004fL227-R231) [[15]](diffhunk://#diff-591332c296439bb96d6a911a1d8ff539d742038b2af7fc20fb123ef74e1f4aa2L20-R20) [[16]](diffhunk://#diff-591332c296439bb96d6a911a1d8ff539d742038b2af7fc20fb123ef74e1f4aa2L111-R111) [[17]](diffhunk://#diff-8c6363e088ff6e019485525ed5392f33486bc537dc6389b19f19254d12c86a5dL27-R27) [[18]](diffhunk://#diff-8c6363e088ff6e019485525ed5392f33486bc537dc6389b19f19254d12c86a5dR234-R254) New Methods: * [`src/promptflow/promptflow/_sdk/_utils.py`](diffhunk://#diff-47208ac35b30920275fcd5e55d662647ef360129359bdc77fddd2a2157b6f47eR795-R801): A new method `pop_current_user_agent` has been introduced to handle changes in the user agent. Test Cases: * [`src/promptflow/tests/sdk_pfs_test/e2etests/test_connection_apis.py`](diffhunk://#diff-573a672b4ba71f30cd8cbc38f2b9c77640c9e276e31da5f725bb8482b793b358R35-R50): A new test case `test_list_connections_with_different_user_agent` has been added to verify the handling of different user agents. Other Changes: * [`src/promptflow/promptflow/_sdk/_service/entry.py`](diffhunk://#diff-9c01d3da61c43e2e419a02f16c2b60c345017a801b9b5e596971fb1806c44253L107-R107): The condition for using the SDK API to start pfs has been modified to also include the `args.debug` case. # 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.
- Loading branch information
Showing
13 changed files
with
153 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.