Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
unanao authored Nov 24, 2023
2 parents 18f4ca8 + 9781c60 commit 63324cf
Show file tree
Hide file tree
Showing 58 changed files with 1,052 additions and 767 deletions.
2 changes: 1 addition & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"llmops",
"Abhishek",
"restx",
"coreclr"
"httpx"
],
"flagWords": [
"Prompt Flow"
Expand Down
1 change: 1 addition & 0 deletions .github/actions/step_create_python_environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ runs:
- run: |
python -m pip install --upgrade pip
pip install -r ${{ inputs.pipFilePath }}
pip freeze
shell: pwsh
266 changes: 266 additions & 0 deletions .github/workflows/promptflow-release-testing-matrix-alter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
name: promptflow-release-testing-matrix
on:
workflow_call:
workflow_dispatch:
inputs:
# can leave empty when trigger manually
# GitHub Actions API for trigger does not return workflow run id
# there we reference below Stack Overflow solution:
# https://stackoverflow.com/a/69500478
# which adds an identifier in workflow run jobs and can be used for filter
id:
description: Identifier for the workflow run
required: false
type: string
env:
testWorkingDirectory: src/promptflow
PYTHONPATH: ${{ github.workspace }}/src/promptflow
IS_IN_CI_PIPELINE: "true"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: workflow run id - ${{ inputs.id }}
run: |
echo "workflow run id: ${{ inputs.id }}"
- name: checkout
uses: actions/checkout@v4
- name: Python Setup - 3.9
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: 3.9
- name: Build wheel
uses: "./.github/actions/step_sdk_setup"
with:
setupType: promptflow_with_extra
scriptPath: ${{ env.testWorkingDirectory }}
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: wheel
path: |
${{ github.workspace }}/src/promptflow/dist/*.whl
${{ github.workspace }}/src/promptflow-tools/dist/*.whl
promptflow_sdk_cli_tests:
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'pull_request' }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pythonVersion: ['3.8', '3.9', '3.10']
runs-on: ${{ matrix.os }}
steps:
- name: set test mode
shell: pwsh
run: |
# Windows support of multiprocessing is different from other platforms, mock injections is not working properly in replay mode.
if ("${{ github.event_name }}" -eq "pull_request" -and (-not "${{ matrix.os }}" -eq "windows-latest")) {
echo "PROMPT_FLOW_TEST_MODE=replay" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "PROMPT_FLOW_TEST_MODE=live" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
}
- name: checkout
uses: actions/checkout@v3
- name: Display and Set Environment Variables
run:
env | sort >> $GITHUB_OUTPUT
shell: bash -el {0}
- name: Python Env Setup - ${{ matrix.os }} - Python Version ${{ matrix.pythonVersion }}
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: ${{ matrix.pythonVersion }}
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: wheel
path: artifacts
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Generate Configs
uses: "./.github/actions/step_generate_configs"
with:
targetFolder: ${{ env.testWorkingDirectory }}
- name: Install pf
shell: pwsh
working-directory: artifacts
run: |
pip install -r ${{ github.workspace }}/src/promptflow/dev_requirements.txt
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Run SDK CLI Test
shell: pwsh
working-directory: ${{ env.testWorkingDirectory }}
run: |
python "../../scripts/building/run_coverage_tests.py" `
-p promptflow `
-t ${{ github.workspace }}/src/promptflow/tests/sdk_cli_test `
-l eastus `
-m "unittest or e2etest" `
-o "${{ github.workspace }}/test-results-sdk-cli.xml" `
--ignore-glob ${{ github.workspace }}/src/promptflow/tests/sdk_cli_test/e2etests/test_executable.py
- name: Install pf executable
shell: pwsh
working-directory: artifacts
run: |
Set-PSDebug -Trace 1
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[executable]"}}
pip freeze
- name: Run SDK CLI Executable Test
shell: pwsh
working-directory: ${{ env.testWorkingDirectory }}
run: |
python "../../scripts/building/run_coverage_tests.py" `
-p promptflow `
-t ${{ github.workspace }}/src/promptflow/tests/sdk_cli_test/e2etests/test_executable.py `
-l eastus `
-m "unittest or e2etest" `
-o "${{ github.workspace }}/test-results-sdk-cli-executable.xml"
- name: Upload pytest test results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test Results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
path: ${{ github.workspace }}/*.xml
promptflow_sdk_cli_azure_tests:
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pythonVersion: ['3.8', '3.9', '3.10']
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Display and Set Environment Variables
run:
env | sort >> $GITHUB_OUTPUT
shell: bash -el {0}
- name: Python Env Setup - ${{ matrix.os }} - Python Version ${{ matrix.pythonVersion }}
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: ${{ matrix.pythonVersion }}
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: wheel
path: artifacts
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Generate Configs
uses: "./.github/actions/step_generate_configs"
with:
targetFolder: ${{ env.testWorkingDirectory }}
- name: Install pf azure
shell: pwsh
working-directory: artifacts
run: |
pip install -r ${{ github.workspace }}/src/promptflow/dev_requirements.txt
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[azure]"}}
pip freeze
- name: Run SDK CLI Azure Test
shell: pwsh
working-directory: ${{ env.testWorkingDirectory }}
env:
PROMPT_FLOW_TEST_MODE: "live"
run: |
python "../../scripts/building/run_coverage_tests.py" `
-p promptflow `
-t ${{ github.workspace }}/src/promptflow/tests/sdk_cli_azure_test `
-l eastus `
-m "unittest or e2etest" `
-o "${{ github.workspace }}/test-results-sdk-cli-azure.xml"
- name: Upload pytest test results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test Results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
path: ${{ github.workspace }}/*.xml
promptflow_executor_tests:
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'workflow_call' || github.event_name == 'pull_request' }}
needs: build
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
pythonVersion: ['3.8', '3.9', '3.10']
runs-on: ${{ matrix.os }}
steps:
- name: checkout
uses: actions/checkout@v3
- name: Display and Set Environment Variables
run:
env | sort >> $GITHUB_OUTPUT
shell: bash -el {0}
- name: Python Env Setup - ${{ matrix.os }} - Python Version ${{ matrix.pythonVersion }}
uses: "./.github/actions/step_create_python_environment"
with:
pythonVersion: ${{ matrix.pythonVersion }}
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: wheel
path: artifacts
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Generate Configs
uses: "./.github/actions/step_generate_configs"
with:
targetFolder: ${{ env.testWorkingDirectory }}
- name: Install pf
shell: pwsh
working-directory: artifacts
run: |
pip install -r ${{ github.workspace }}/src/promptflow/dev_requirements.txt
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[azure]"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Run Executor Test
shell: pwsh
working-directory: ${{ github.workspace }}
run: |
gci env:* | sort-object name
az account show
pip install langchain
pip install numexpr
python scripts/building/run_coverage_tests.py `
-p ${{ github.workspace }}/src/promptflow/promptflow `
-t ${{ github.workspace }}/src/promptflow/tests/executor/e2etests ${{ github.workspace }}/src/promptflow/tests/executor/unittests `
-l eastus `
-m "all" `
-o "${{ github.workspace }}/test-results-executor.xml"
- name: Upload pytest test results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: Test Results (Python ${{ matrix.pythonVersion }}) (OS ${{ matrix.os }})
path: ${{ github.workspace }}/*.xml
publish-test-results:
name: "Publish Tests Results"
needs: [ promptflow_sdk_cli_tests, promptflow_sdk_cli_azure_tests, promptflow_executor_tests ]
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
contents: read
issues: read
if: always()

steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/test-*.xml"
2 changes: 1 addition & 1 deletion .github/workflows/promptflow-sdk-cli-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: |
Set-PSDebug -Trace 1
pip install -r ${{ github.workspace }}/src/promptflow/dev_requirements.txt
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)[azure]"}} # Will remove azure deps later
gci ./promptflow -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install "$($_.FullName)"}}
gci ./promptflow-tools -Recurse | % {if ($_.Name.Contains('.whl')) {python -m pip install $_.FullName}}
pip freeze
- name: Azure login (non pull_request workflow)
Expand Down
1 change: 1 addition & 0 deletions src/promptflow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Add env variable 'PF_NO_INTERACTIVE_LOGIN' to disable interactive login if using azureml connection provider in promptflow sdk.
- Improved CLI invoke time.
- Bump `pydash` upper bound to 8.0.0.
- Bump `SQLAlchemy` upper bound to 3.0.0.

## 1.0.0 (2023.11.09)

Expand Down
1 change: 1 addition & 0 deletions src/promptflow/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ setuptools_rust
twine==4.0.0
vcrpy==5.1.0 # record and replay http requests for pfazure tests
wheel
httpx
2 changes: 1 addition & 1 deletion src/promptflow/promptflow/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ class FlowLanguage:
"""The enum of tool source type."""

Python = "python"
Csharp = "csharp"
CSharp = "csharp"
8 changes: 0 additions & 8 deletions src/promptflow/promptflow/_internal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,4 @@
from promptflow.batch._batch_inputs_processor import apply_inputs_mapping
from promptflow.executor._errors import InputNotFound
from promptflow.executor._tool_invoker import DefaultToolInvoker
from promptflow.storage._cache_storage import LocalCacheStorage
from promptflow.storage._run_storage import DefaultRunStorage
from promptflow.storage._sqlite_client import (
INDEX,
PRIMARY_KEY,
DuplicatedPrimaryKeyException,
NotFoundException,
SqliteClient,
)
16 changes: 13 additions & 3 deletions src/promptflow/promptflow/_sdk/_submitter/run_submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import datetime
from pathlib import Path

from promptflow._constants import FlowLanguage
from promptflow._sdk._constants import FlowRunProperties
from promptflow._sdk._logger_factory import LoggerFactory
from promptflow._sdk._utils import parse_variant
Expand Down Expand Up @@ -63,14 +64,23 @@ def _run_bulk(self, run: Run, stream=False, **kwargs):

def _submit_bulk_run(self, flow: Flow, run: Run, local_storage: LocalStorageOperations) -> dict:
run_id = run.name
with _change_working_dir(flow.code):
connections = SubmitterHelper.resolve_connections(flow=flow)
if flow.dag.get("language", FlowLanguage.Python) == FlowLanguage.CSharp:
connections = []
else:
with _change_working_dir(flow.code):
connections = SubmitterHelper.resolve_connections(flow=flow)
column_mapping = run.column_mapping
# resolve environment variables
SubmitterHelper.resolve_environment_variables(environment_variables=run.environment_variables)
SubmitterHelper.init_env(environment_variables=run.environment_variables)

batch_engine = BatchEngine(flow.path, flow.code, connections=connections, storage=local_storage)
batch_engine = BatchEngine(
flow.path,
flow.code,
connections=connections,
storage=local_storage,
log_path=local_storage.logger.file_path,
)
# prepare data
input_dirs = self._resolve_input_dirs(run)
self._validate_column_mapping(column_mapping)
Expand Down
Loading

0 comments on commit 63324cf

Please sign in to comment.