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

Enable executor recording mode #1754

Closed
wants to merge 196 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
4d7b0db
Simple Fix
crazygao Dec 1, 2023
da4d591
Fix
crazygao Dec 1, 2023
6859a25
Fix
crazygao Dec 1, 2023
bc9310f
Fix
crazygao Dec 1, 2023
2b00731
enable test_collect_package_tools_if_node_source_tool_is_legacy (#1345)
chjinche Dec 1, 2023
ab95f01
Assign promptflow-execution as Code Owner for Specific Directories (#…
liucheng-ms Dec 1, 2023
4623b31
[SDK] Add workspace info in CLI telemetry (#1349)
D-W- Dec 1, 2023
e27f8e6
Fix the gap between pf-tools and the openai api when max_tokens is 0 …
chenslucky Dec 1, 2023
c934934
Add PR check-in criteria for promptflow-tools (#1343)
chenslucky Dec 1, 2023
676795e
[SDK] Make sure we use same request id in log and when calling servic…
D-W- Dec 1, 2023
b9a56db
Verify the flow can successusfuly serve in app service (#1342)
YingChen1996 Dec 1, 2023
2881c00
revert add ua code and add test (#1341)
Stephen1993 Dec 1, 2023
92b395b
[Internal][Executor] Add e2e tests for executor proxy (#1312)
PeiwenGaoMS Dec 1, 2023
8ebdec6
Delete excess UA codes (#1356)
Stephen1993 Dec 1, 2023
c3a13a5
Fix
crazygao Dec 4, 2023
cf45fae
Fix
crazygao Dec 4, 2023
92feda7
Merge branch 'main' into yigao/executor_recording
crazygao Dec 4, 2023
7c57010
Fix
crazygao Dec 4, 2023
d3d7f4b
Fix
crazygao Dec 4, 2023
8fa4a9d
Fix
crazygao Dec 4, 2023
b8f9b13
Merge branch 'main' into yigao/executor_recording
crazygao Dec 4, 2023
d648aea
Fix
crazygao Dec 4, 2023
ee238a0
Fix metric test.
crazygao Dec 5, 2023
e3ec455
Fix
crazygao Dec 5, 2023
86f2292
Merge branch 'main' into yigao/executor_recording
crazygao Dec 6, 2023
e62d7bf
Fix
crazygao Dec 6, 2023
b4555c4
Fix
crazygao Dec 6, 2023
e7d1fc9
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 7, 2023
779ef20
remove the skip for test_executor_exec_node_with_llm_node
chw-microsoft Dec 7, 2023
8131cdb
merging with master
chw-microsoft Dec 8, 2023
64f80f4
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 11, 2023
4e1bcdd
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 13, 2023
34d36f6
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 14, 2023
fc3902c
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Dec 14, 2023
0ac1ed5
to be reverted: tempt change to verify test failure info
chw-microsoft Dec 14, 2023
18c9f4d
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Dec 14, 2023
14bf14a
to be reverted: modify the exception
chw-microsoft Dec 14, 2023
a95b3fb
adding records for test_batch_storage (#1498)
chw-microsoft Dec 15, 2023
eb9c7d9
merging with main
chw-microsoft Dec 15, 2023
50aa835
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Dec 15, 2023
d82c0b0
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 18, 2023
9f9a206
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Dec 18, 2023
57c2797
fixing tests (#1505)
chw-microsoft Dec 18, 2023
3d17574
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Dec 18, 2023
6f2976a
remove recording_injection from tests failed due to spawn/forkserver
chw-microsoft Dec 18, 2023
d73b317
revert tempt change
chw-microsoft Dec 18, 2023
1aeb9ef
remove test fixture reference to recording injection
chw-microsoft Dec 18, 2023
1677204
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Dec 18, 2023
f9acb88
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 18, 2023
b15a7d8
refine the test to make record error more clear: test_line_execution_…
chw-microsoft Dec 18, 2023
eb0da6c
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Dec 18, 2023
5d57ffc
Adding context manager into processor
chw-microsoft Dec 19, 2023
0aed7e4
adding the getInstance method
chw-microsoft Dec 19, 2023
6217139
update the records for spawn
chw-microsoft Dec 19, 2023
37dd712
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Dec 20, 2023
4ce3455
update records
chw-microsoft Dec 20, 2023
b25eac9
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Dec 20, 2023
254616a
provide solution for spawn process
chw-microsoft Dec 22, 2023
52b3719
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Dec 22, 2023
a5eec98
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 8, 2024
1824613
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 8, 2024
a3c11df
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Jan 8, 2024
0f76051
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Jan 8, 2024
4a4ad3c
[tentative] adding tag to resolve spawn process issue
chw-microsoft Jan 9, 2024
c216106
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Jan 9, 2024
85e7e49
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 9, 2024
93468b1
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Jan 9, 2024
5bd58b2
[tentative] update test_forkserver_mode_batch_run
chw-microsoft Jan 9, 2024
352bc53
Revert "[tentative] update test_forkserver_mode_batch_run"
chw-microsoft Jan 9, 2024
b6f3972
[tentative] change to all 3 start method
chw-microsoft Jan 9, 2024
60951cf
tentative change: test forkserver
chw-microsoft Jan 9, 2024
5d7a7d5
testing new change to setup_recording_injection
chw-microsoft Jan 10, 2024
d2cc99a
Revert "testing new change to setup_recording_injection"
chw-microsoft Jan 10, 2024
cff6d6a
Reapply "testing new change to setup_recording_injection"
chw-microsoft Jan 10, 2024
6227419
another try with dynamic mode
chw-microsoft Jan 10, 2024
3cd8f35
Revert "another try with dynamic mode"
chw-microsoft Jan 10, 2024
4ae10fa
Revert "Reapply "testing new change to setup_recording_injection""
chw-microsoft Jan 10, 2024
924e2dd
Revert "tentative change: test forkserver"
chw-microsoft Jan 10, 2024
0140882
Revert "[tentative] change to all 3 start method"
chw-microsoft Jan 10, 2024
e7d81e5
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 10, 2024
b5b743a
remove the bad decorator
chw-microsoft Jan 10, 2024
d362cf4
update run_batch_with_start_method
chw-microsoft Jan 10, 2024
899e22b
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Jan 10, 2024
c8d5625
try with new recording_injection
chw-microsoft Jan 10, 2024
1bdaf72
fixing several tests
chw-microsoft Jan 10, 2024
f384ef0
fixing the tests
chw-microsoft Jan 11, 2024
c93c15d
fxing tests 2
chw-microsoft Jan 11, 2024
0099ad9
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 11, 2024
783f5b5
remove useless code + skip metrics tests
chw-microsoft Jan 12, 2024
1640f99
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 12, 2024
b2ee8fc
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Jan 12, 2024
70f80aa
refine the recording mocks code
chw-microsoft Jan 13, 2024
548ba10
refine code 2
chw-microsoft Jan 13, 2024
ad92394
update the executor node cache
chw-microsoft Jan 13, 2024
27f4e82
extract process setup
chw-microsoft Jan 14, 2024
3bb4bd6
refine the process override
chw-microsoft Jan 14, 2024
e38e347
handle start_method problem
chw-microsoft Jan 14, 2024
28f5333
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Jan 15, 2024
1b1038d
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 15, 2024
aa0243e
Revert "handle start_method problem"
chw-microsoft Jan 15, 2024
1b46af9
Revert "refine the process override"
chw-microsoft Jan 15, 2024
b988d9f
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Jan 15, 2024
f81e3e9
adding more comments
chw-microsoft Jan 15, 2024
1e80e93
Update conftest.py
chw-microsoft Jan 15, 2024
bc82ecb
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 15, 2024
b1ffe86
refine the codes
chw-microsoft Jan 15, 2024
a9ea3d3
Merge branch 'chw/pf/executor_recording' of https://github.com/micros…
chw-microsoft Jan 15, 2024
310026c
fxiing tests
chw-microsoft Jan 15, 2024
42c2084
update tests
chw-microsoft Jan 15, 2024
ac949eb
fixing the test_line_execution_process_pool
chw-microsoft Jan 15, 2024
85f5574
update tests
chw-microsoft Jan 15, 2024
87a37ad
merging with main
chw-microsoft Jan 15, 2024
e79c32d
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 15, 2024
90d7798
Revert "update tests"
chw-microsoft Jan 15, 2024
48aad36
update tests
chw-microsoft Jan 15, 2024
b607426
fxing test_executor_exec_node_with_llm_node
chw-microsoft Jan 15, 2024
9bcf5ef
re_update the tests
chw-microsoft Jan 15, 2024
c9deaeb
skip one test due to trace missing
chw-microsoft Jan 15, 2024
24fd2f5
enable test_langchain recording injection
chw-microsoft Jan 15, 2024
97cfab1
adding recording injection explicitly
chw-microsoft Jan 15, 2024
12714e3
remove useless code
chw-microsoft Jan 15, 2024
906fb5d
Revert "enable test_langchain recording injection"
chw-microsoft Jan 15, 2024
f307e5b
refine the process override
chw-microsoft Jan 15, 2024
00f1c4b
tentative change
chw-microsoft Jan 15, 2024
0fce222
Revert "tentative change"
chw-microsoft Jan 15, 2024
62a69ec
remove log contesxt for test test_line_execution_process_pool
chw-microsoft Jan 16, 2024
22ea20d
refine tests
chw-microsoft Jan 16, 2024
4352edd
Merge branch 'main' into chw/pf/executor_recording
chw-microsoft Jan 16, 2024
944600f
Revert "refine tests"
chw-microsoft Jan 16, 2024
387b5a8
Revert "remove log contesxt for test test_line_execution_process_pool"
chw-microsoft Jan 16, 2024
d568764
revert tentative changes
chw-microsoft Jan 16, 2024
38664a8
update test sample
chw-microsoft Jan 16, 2024
394fa25
replace test sample again
chw-microsoft Jan 16, 2024
9c94d25
update the code
chw-microsoft Jan 16, 2024
e7128dd
fixing the timeout issue when recording enabled
chw-microsoft Jan 16, 2024
694e01c
merging with main
chw-microsoft Jan 17, 2024
b6713b0
update the mock in conftest
chw-microsoft Jan 17, 2024
ae8456b
merging with new process pool change
chw-microsoft Jan 17, 2024
4d5c004
tentative testing
chw-microsoft Jan 17, 2024
bfe57d5
Revert "tentative testing"
chw-microsoft Jan 17, 2024
b5ffd99
Revert "merging with new process pool change"
chw-microsoft Jan 17, 2024
f7f85b0
Revert "update the mock in conftest"
chw-microsoft Jan 17, 2024
03c0fec
refine config + adding more target change
chw-microsoft Jan 17, 2024
977503f
fixing TestExecutorTelemetry
chw-microsoft Jan 19, 2024
2276a33
skip test_batch_with_openai_metrics
chw-microsoft Jan 19, 2024
21fd08e
merging with main
chw-microsoft Jan 19, 2024
d3ef4d7
fixing the tests failure
chw-microsoft Jan 22, 2024
a90389c
Merge branch 'main' into chw/pf/executor_recording2
chw-microsoft Jan 22, 2024
53a792b
create override_process_target
chw-microsoft Jan 22, 2024
0a0dff8
add more comments
chw-microsoft Jan 22, 2024
b3a134e
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Jan 22, 2024
3254be8
change parameters for _create_spawned_fork_process_manager
chw-microsoft Jan 22, 2024
6ef6d16
adding records for test_batch_with_timeout
chw-microsoft Jan 22, 2024
9adba79
Merge branch 'main' into chw/pf/executor_recording2
chw-microsoft Jan 22, 2024
b0720e8
Adding more comments
chw-microsoft Jan 22, 2024
a16cd01
Merge branch 'chw/pf/executor_recording2' of https://github.com/micro…
chw-microsoft Jan 22, 2024
8d8048a
update the comments
chw-microsoft Jan 23, 2024
e1a668b
merging with master
chw-microsoft Jan 31, 2024
11e3efc
refine to the latest change
chw-microsoft Jan 31, 2024
001d7e4
record some items
chw-microsoft Feb 1, 2024
3cd290e
refine contest
chw-microsoft Feb 1, 2024
cab7907
update the data
chw-microsoft Feb 1, 2024
25137e1
update the conftest
chw-microsoft Feb 1, 2024
7b3b9a0
disable recording for one telemetry test
chw-microsoft Feb 1, 2024
70a6bff
commit session action
chw-microsoft Feb 2, 2024
cc36c92
refine conftest
chw-microsoft Feb 2, 2024
716c5ee
update conftest import
chw-microsoft Feb 2, 2024
ca0d734
update conftests
chw-microsoft Feb 2, 2024
21dfe8d
remove all the skip tag
chw-microsoft Feb 2, 2024
13a12c4
fixing some comments
chw-microsoft Feb 4, 2024
5e9306b
provide the error handling logic
chw-microsoft Feb 4, 2024
c305ede
merging with master
chw-microsoft Feb 4, 2024
a122555
fixing the bugs in error recording and fixing tests: test_executor_op…
chw-microsoft Feb 4, 2024
f04f200
remove all the skip tests
chw-microsoft Feb 4, 2024
52456e4
refactor the codes
chw-microsoft Feb 4, 2024
a3b6400
Revert "refactor the codes"
chw-microsoft Feb 5, 2024
845d519
refactor step 1
chw-microsoft Feb 5, 2024
c19d3ab
Revert "refactor step 1"
chw-microsoft Feb 5, 2024
ae15bd1
refactor 1: using contextvar to replace global variable
chw-microsoft Feb 5, 2024
789e91a
refactor conftest code 2
chw-microsoft Feb 5, 2024
81e9e45
remove useless file
chw-microsoft Feb 5, 2024
73f74c5
merging with main
chw-microsoft Feb 5, 2024
bf4cea2
refactor 3 : exact override process classs into utils
chw-microsoft Feb 5, 2024
771a3bf
update the error recording part
chw-microsoft Feb 5, 2024
e5bf37c
refine code 4
chw-microsoft Feb 5, 2024
f485d18
revert unnecessary change
chw-microsoft Feb 5, 2024
184ab28
Merge branch 'main' into chw/pf/executor_recording2
chw-microsoft Feb 5, 2024
e651b4c
replace test sample
chw-microsoft Feb 6, 2024
cd40d0d
Merge branch 'chw/pf/executor_recording2' of https://github.com/micro…
chw-microsoft Feb 6, 2024
04ae8c6
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Feb 6, 2024
c636d5a
update ci ymal
chw-microsoft Feb 6, 2024
30b4dd2
update yml + conftest
chw-microsoft Feb 6, 2024
5fe2e25
Merge branch 'main' into chw/pf/executor_recording2
chw-microsoft Feb 6, 2024
5f1d572
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Feb 6, 2024
00ef8ce
temp records refresh
chw-microsoft Feb 6, 2024
5878a22
Merge branch 'main' of https://github.com/microsoft/promptflow into c…
chw-microsoft Feb 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 16 additions & 34 deletions .github/workflows/promptflow-executor-e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: promptflow-executor-e2e-test
on:
schedule:
- cron: "40 20 * * *" # Every day starting at 4:40 BJT
pull_request_target:
- cron: "35 17 * * *" # Every day starting at 1:35 BJT
pull_request:
paths:
- src/promptflow/*
- src/promptflow/promptflow/*
Expand All @@ -26,28 +26,13 @@ env:
PYTHONPATH: ${{ github.workspace }}/src/promptflow
IS_IN_CI_PIPELINE: "true"
jobs:
authorize:
environment:
# forked prs from pull_request_target will be run in external environment, domain prs will be run in internal environment
${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
build:
needs: authorize
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
env | sort >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -78,13 +63,10 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: set test mode
run: echo "PROMPT_FLOW_TEST_MODE=$(if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo replay; else echo live; fi)" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Python Setup - ${{ matrix.os }} - Python Version 3.9
uses: "./.github/actions/step_create_python_environment"
with:
Expand All @@ -103,32 +85,36 @@ jobs:
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[executor-service]"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Azure Login
- name: Azure login (non pull_request workflow)
if: github.event_name != 'pull_request'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Generate Configs
- name: generate live test resources (non pull_request workflow)
if: github.event_name != 'pull_request'
uses: "./.github/actions/step_generate_configs"
with:
targetFolder: ${{ env.testWorkingDirectory }}
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: generate live test resources (pull_request workflow)
if: github.event_name == 'pull_request'
shell: pwsh
working-directory: ${{ env.testWorkingDirectory }}
run: |
cp ${{ github.workspace }}/src/promptflow/dev-connections.json.example ${{ github.workspace }}/src/promptflow/connections.json
- name: Run Coverage Test
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
gci env:* | sort-object name
az account show
pip install langchain

# numexpr is required by langchain in e2e tests.
pip install numexpr
python scripts/building/run_coverage_tests.py `
-p ${{ env.testWorkingDirectory }}/promptflow `
-t ${{ env.testWorkingDirectory }}/tests/executor/e2etests `
-l eastus `
-m "all" `
-n ${{ steps.cpu-cores.outputs.count }}`
--coverage-config ${{ env.testWorkingDirectory }}/tests/executor/.coveragerc `
--disable-cov-branch
- name: Upload Test Results
Expand All @@ -139,6 +125,7 @@ jobs:
path: |
${{ github.workspace }}/*.xml
${{ github.workspace }}/htmlcov/
${{ env.testWorkingDirectory }}/tests/sdk_cli_test/count.json
publish-test-results:
name: "Publish Tests Results"
needs: executor_e2e_tests
Expand All @@ -152,11 +139,6 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Publish Test Results
uses: "./.github/actions/step_publish_test_results"
with:
Expand Down
50 changes: 15 additions & 35 deletions .github/workflows/promptflow-executor-unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: promptflow-executor-unit-test
chw-microsoft marked this conversation as resolved.
Show resolved Hide resolved
on:
schedule:
- cron: "40 19 * * *" # Every day starting at 3:40 BJT
pull_request_target:
- cron: "35 18 * * *" # Every day starting at 2:35 BJT
pull_request:
paths:
- src/promptflow/*
- src/promptflow/promptflow/*
Expand All @@ -26,28 +26,13 @@ env:
PYTHONPATH: ${{ github.workspace }}/src/promptflow
IS_IN_CI_PIPELINE: "true"
jobs:
authorize:
environment:
# forked prs from pull_request_target will be run in external environment, domain prs will be run in internal environment
${{ github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
runs-on: ubuntu-latest
steps:
- run: true
build:
needs: authorize
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
env | sort >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -78,13 +63,10 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: set test mode
run: echo "PROMPT_FLOW_TEST_MODE=$(if [[ "${{ github.event_name }}" == "pull_request" ]]; then echo replay; else echo live; fi)" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Display and Set Environment Variables
run: |
env | sort >> $GITHUB_OUTPUT
Expand All @@ -108,30 +90,32 @@ jobs:
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[executor-service]"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Azure Login
- name: Azure login (non pull_request workflow)
if: github.event_name != 'pull_request'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Generate Configs
- name: generate live test resources (non pull_request workflow)
if: github.event_name != 'pull_request'
uses: "./.github/actions/step_generate_configs"
with:
targetFolder: ${{ env.testWorkingDirectory }}
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: generate live test resources (pull_request workflow)
if: github.event_name == 'pull_request'
shell: pwsh
working-directory: ${{ env.testWorkingDirectory }}
run: |
cp ${{ github.workspace }}/src/promptflow/dev-connections.json.example ${{ github.workspace }}/src/promptflow/connections.json
- name: Run Coverage Test
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
gci env:* | sort-object name
az account show
pip install langchain
python scripts/building/run_coverage_tests.py `
-p ${{ env.testWorkingDirectory }}/promptflow `
-t ${{ env.testWorkingDirectory }}/tests/executor/unittests `
-l eastus `
-m "all" `
-n ${{ steps.cpu-cores.outputs.count }} `
--coverage-config ${{ env.testWorkingDirectory }}/tests/executor/.coveragerc `
--disable-cov-branch
- name: Upload Test Results
Expand All @@ -142,6 +126,7 @@ jobs:
path: |
${{ github.workspace }}/*.xml
${{ github.workspace }}/htmlcov/
${{ env.testWorkingDirectory }}/tests/sdk_cli_test/count.json
publish-test-results:
name: "Publish Tests Results"
needs: executor_unit_tests
Expand All @@ -156,11 +141,6 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0
- name: merge main to current branch
uses: "./.github/actions/step_merge_main"
- name: Publish Test Results
uses: "./.github/actions/step_publish_test_results"
with:
Expand Down
128 changes: 126 additions & 2 deletions src/promptflow/tests/executor/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,136 @@
import multiprocessing
from pathlib import Path
from unittest.mock import patch

import pytest
from executor.process_utils import (
MockForkServerProcess,
MockSpawnProcess,
current_process_manager_var,
current_process_wrapper_var,
override_process_class,
)
from sdk_cli_test.recording_utilities import (
RecordStorage,
delete_count_lock_file,
inject_async_with_recording,
inject_sync_with_recording,
is_live,
is_record,
is_replay,
mock_tool,
recording_array_extend,
recording_array_reset,
)
from sdk_cli_test.recording_utilities.record_storage import is_recording_enabled

from promptflow._core.openai_injector import inject_openai_api
from promptflow.executor._line_execution_process_pool import _process_wrapper
from promptflow.executor._process_manager import create_spawned_fork_process_manager

PROMPTFLOW_ROOT = Path(__file__) / "../../.."
RECORDINGS_TEST_CONFIGS_ROOT = Path(PROMPTFLOW_ROOT / "tests/test_configs/node_recordings").resolve()


@pytest.fixture
def recording_setup():
patches = setup_recording()
try:
yield
finally:
for patcher in patches:
patcher.stop()


def setup_recording():
patches = []

def start_patches(patch_targets):
for target, mock_func in patch_targets.items():
patcher = patch(target, mock_func)
patches.append(patcher)
patcher.start()

if is_replay() or is_record():
file_path = RECORDINGS_TEST_CONFIGS_ROOT / "executor_node_cache.shelve"
RecordStorage.get_instance(file_path)

from promptflow._core.tool import tool as original_tool

mocked_tool = mock_tool(original_tool)
patch_targets = {
"promptflow._core.tool.tool": mocked_tool,
"promptflow._internal.tool": mocked_tool,
"promptflow.tool": mocked_tool,
"promptflow._core.openai_injector.inject_sync": inject_sync_with_recording,
"promptflow._core.openai_injector.inject_async": inject_async_with_recording,
}
start_patches(patch_targets)
inject_openai_api()

if is_live():
patch_targets = {
"promptflow._core.openai_injector.inject_sync": inject_sync_with_recording,
"promptflow._core.openai_injector.inject_async": inject_async_with_recording,
}
start_patches(patch_targets)
inject_openai_api()

return patches


def _default_mock_process_wrapper(*args, **kwargs):
# Default mock implementation of _process_wrapper in recording mode
setup_recording()
_process_wrapper(*args, **kwargs)


def _default_mock_create_spawned_fork_process_manager(*args, **kwargs):
# Default mock implementation of create_spawned_fork_process_manager in recording mode
setup_recording()
create_spawned_fork_process_manager(*args, **kwargs)


@pytest.fixture
def process_override():
# This fixture is used to override the Process class to ensure the recording mode works
chw-microsoft marked this conversation as resolved.
Show resolved Hide resolved

# Step I: set process pool targets placeholder with customized targets
current_process_wrapper_var.set(_default_mock_process_wrapper)
current_process_manager_var.set(_default_mock_create_spawned_fork_process_manager)

# Step II: override the process pool class
process_class_dict = {"spawn": MockSpawnProcess, "forkserver": MockForkServerProcess}
original_process_class = override_process_class(process_class_dict)

try:
yield
finally:
for start_method, MockProcessClass in process_class_dict.items():
if start_method in multiprocessing.get_all_start_methods():
multiprocessing.get_context(start_method).Process = original_process_class[start_method]
if start_method == multiprocessing.get_start_method():
multiprocessing.Process = original_process_class[start_method]


@pytest.fixture
def recording_injection(recording_setup, process_override):
# This fixture is used to main entry point to inject recording mode into the test
try:
yield (is_replay() or is_record(), recording_array_extend)
finally:
if is_replay() or is_record():
RecordStorage.get_instance().delete_lock_file()
if is_live():
delete_count_lock_file()
recording_array_reset()


@pytest.fixture(autouse=True, scope="session")
def inject_api_executor():
"""Inject OpenAI API during test session.
"""Inject OpenAI API during test session when recording not enabled

AOAI call in promptflow should involve trace logging and header injection. Inject
function to API call in test scenario."""
inject_openai_api()
if not is_recording_enabled():
inject_openai_api()
2 changes: 1 addition & 1 deletion src/promptflow/tests/executor/e2etests/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]


@pytest.mark.usefixtures("dev_connections")
@pytest.mark.usefixtures("dev_connections", "recording_injection")
@pytest.mark.e2etest
class TestExecutorActivate:
@pytest.mark.parametrize("flow_folder", ACTIVATE_FLOW_TEST_CASES)
Expand Down
Loading
Loading