Skip to content

Commit

Permalink
Merge pull request #3 from AbeOmor/main
Browse files Browse the repository at this point in the history
Update docs and files based on comments
  • Loading branch information
AbeOmor committed Sep 12, 2023
2 parents 10cea03 + 35cf454 commit 1284d58
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 52 deletions.
33 changes: 19 additions & 14 deletions .github/workflows/deploy-pf-online-endpoint-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,47 @@ on:
env:
GROUP: ${{secrets.GROUP}}
WORKSPACE: ${{secrets.WORKSPACE}}
SUBSCRIPTION: ${{secrets.SUBSCRIPTION}}
SUBSCRIPTION_ID: ${{secrets.SUBSCRIPTION_ID}}
RUN_NAME: web_classification_variant_1_20230816_215600_605116
EVAL_RUN_NAME: classification_accuracy_eval_default_20230821_111809_077086
ENDPOINT_NAME: web-classification
DEPLOYMENT_NAME: blue

jobs:
create-endpoint-and-deploy-pf:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: check out repo
- name: Check out repo
uses: actions/checkout@v2
- name: install az ml extension
- name: Install az ml extension
run: az extension add -n ml -y
- name: azure login
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: list current directory
- name: List current directory
run: ls
- name: set default subscription
- name: Set default subscription
run: |
az account set -s ${{env.SUBSCRIPTION}}
- name: create Hash
- name: Create Hash
run: echo "HASH=$(echo -n $RANDOM | sha1sum | cut -c 1-6)" >> "$GITHUB_ENV"
- name: create unique endpoint name
- name: Create unique endpoint name
run: echo "ENDPOINT_NAME=$(echo 'web-classification-'$HASH)" >> "$GITHUB_ENV"
- name: display endpoint name
- name: Display endpoint name
run: echo "Endpoint name is:" ${{env.ENDPOINT_NAME}}
- name: setup endpoint
- name: Setup endpoint
run: az ml online-endpoint create --file promptflow/deployment/endpoint.yaml --name ${{env.ENDPOINT_NAME}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: setup deployment
- name: Update deployment PRT_CONFIG variable
run: |
PRT_CONFIG_OVERRIDE=deployment.subscription_id=${{ env.SUBSCRIPTION }},deployment.resource_group=${{ env.GROUP }},deployment.workspace_name=${{ env.WORKSPACE }},deployment.endpoint_name=${{ env.ENDPOINT_NAME }},deployment.deployment_name=${{ env.DEPLOYMENT_NAME }}
sed -i "s/PRT_CONFIG_OVERRIDE:.*/PRT_CONFIG_OVERRIDE: $PRT_CONFIG_OVERRIDE/g" promptflow/deployment/deployment.yaml
- name: Setup deployment
run: az ml online-deployment create --file promptflow/deployment/deployment.yaml --endpoint-name ${{env.ENDPOINT_NAME}} --all-traffic -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: check the status of the endpoint
- name: Check the status of the endpoint
run: az ml online-endpoint show -n ${{env.ENDPOINT_NAME}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: check the status of the deployment
- name: Check the status of the deployment
run: az ml online-deployment get-logs --name blue --endpoint-name ${{env.ENDPOINT_NAME}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: invoke model
- name: Invoke model
run: az ml online-endpoint invoke --name ${{env.ENDPOINT_NAME}} --request-file promptflow/deployment/sample-request.json -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
48 changes: 24 additions & 24 deletions .github/workflows/run-eval-pf-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,74 @@ on:
env:
GROUP: ${{secrets.GROUP}}
WORKSPACE: ${{secrets.WORKSPACE}}
SUBSCRIPTION: ${{secrets.SUBSCRIPTION}}
SUBSCRIPTION_ID: ${{secrets.SUBSCRIPTION_ID}}
RUN_NAME: web_classification_variant_1_20230816_215600_605116
EVAL_RUN_NAME: classification_accuracy_eval_default_20230821_111809_077086

jobs:
login-and-run-and-evalpf:
runs-on: ubuntu-latest
steps:
- name: check out repo
- name: Check out repo
uses: actions/checkout@v2
- name: install az ml extension
- name: Install az ml extension
run: az extension add -n ml -y
- name: azure login
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11.4'
- name: list current directory
- name: List current directory
run: ls
- name: install promptflow
- name: Install promptflow
run: pip install -r promptflow/web-classification/requirements.txt
- name: run promptflow
- name: Run promptflow
run: |
pfazure run create -f promptflow/web-classification/run.yml --subscription ${{env.SUBSCRIPTION}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}} --stream > promptflow/llmops-helper/run_info.txt
cat promptflow/llmops-helper/run_info.txt
- name: set run name
- name: Set run name
run: |
echo "RUN_NAME=$(python promptflow/llmops-helper/parse_run_output.py run_info.txt)" >> "$GITHUB_ENV"
- name: show the current run name
- name: Show the current run name
run: echo "Run name is:" ${{env.RUN_NAME}}
- name: show promptflow results
- name: Show promptflow results
run: pfazure run show-details --name ${{env.RUN_NAME}} --subscription ${{env.SUBSCRIPTION}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: run promptflow evaluations
- name: Run promptflow evaluations
run: pfazure run create -f promptflow/web-classification/run_evaluation.yml --run ${{env.RUN_NAME}} --subscription ${{env.SUBSCRIPTION}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}} --stream > promptflow/llmops-helper/eval_info.txt
- name: get eval run name
run: export EVAL_RUN_NAME=$(python promptflow/llmops-helper/parse_run_output.py eval_info.txt)
- name: show promptflow details
- name: Get eval run name
run: echo "EVAL_RUN_NAME=$(python promptflow/llmops-helper/parse_run_output.py eval_info.txt)" >> "$GITHUB_ENV"
- name: Show promptflow details
run: pfazure run show-details --name ${{env.EVAL_RUN_NAME}} --subscription ${{env.SUBSCRIPTION}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
- name: show promptflow metrics
- name: Show promptflow metrics
run: pfazure run show-metrics --name ${{env.EVAL_RUN_NAME}} --subscription ${{env.SUBSCRIPTION}} -g ${{env.GROUP}} -w ${{env.WORKSPACE}} > promptflow/llmops-helper/eval_result.json

assert-and-register-model:
needs: login-and-run-and-evalpf
runs-on: ubuntu-latest
steps:
- name: check out repo
- name: Check out repo
uses: actions/checkout@v2
- name: install az ml extension
- name: Install az ml extension
run: az extension add -n ml -y
- name: azure login
- name: Azure login
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11.4'
- name: set default subscription
- name: Set default subscription
run: |
az account set -s ${{env.SUBSCRIPTION}}
- name: list current directory
- name: List current directory
run: ls
- name: install promptflow
- name: Install promptflow
run: pip install -r promptflow/web-classification/requirements.txt
- name: get assert eval results
- name: Get assert eval results
id: jobMetricAssert
run: |
export ASSERT=$(python promptflow/llmops-helper/assert.py result.json 0.6) # NOTE <file>.json is the file name and decimal is the threshold for the assertion
Expand All @@ -88,6 +88,6 @@ jobs:
echo "::warning::Prompt flow run didn't meet quality bar."
echo "::set-output name=result::false"
fi
- name: register promptflow model
- name: Register promptflow model
if: ${{ steps.jobMetricAssert.outputs.result == 'true' }}
run: az ml model create --file promptflow/deployment/model.yaml -g ${{env.GROUP}} -w ${{env.WORKSPACE}}
31 changes: 18 additions & 13 deletions docs/e2e_llmops_with_promptflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ Before you can set up an Prompt flow project with Machine Learning, you need to
1. Close the Cloud Shell once the service principals are created.

## Set up GitHub repo
1. Fork example repo. [LLMOps Demo Template Repo](https://github.com/Azure/llmops-gha-demo/) in your GitHub organization

1. Go to https://github.com/Azure/llmops-gha-demo/fork to fork the LLMOps demo repo into your GitHub org. This repo has reusable LLMOps code that can be used across multiple projects.
1. Fork example repo. [LLMOps Demo Template Repo](https://github.com/Azure/llmops-gha-demo/fork) in your GitHub organization. This repo has reusable LLMOps code that can be used across multiple projects.

## Add secret to GitHub Repo

Expand All @@ -103,10 +101,16 @@ Before you can set up an Prompt flow project with Machine Learning, you need to
![Screenshot of GitHub Secrets String 1.](media/e2e-llmops/github-secrets-string.png)

1. Add each of the following additional GitHub secrets using the corresponding values from the service principal output as the content of the secret:
- **GROUP**
- **WORKSPACE**
- **SUBSCRIPTION**
- **GROUP**: \<Resource Group Name\>
- **WORKSPACE**: \<Azure ML Workspace Name\>
- **SUBSCRIPTION_ID**: \<Subscription ID\>

|Variable | Description |
|---------|---------|
|GROUP | Name of resource group |
|SUBSCRIPTION_ID | Subscription ID of your workspace |
|WORKSPACE | Name of Azure Machine Learning workspace |

> [!NOTE]
> This finishes the prerequisite section and the deployment of the solution accelerator can happen accordingly.
Expand All @@ -120,6 +124,13 @@ Please go to workspace portal, click `Prompt flow` -> `Connections` -> `Create`,

![Screenshot of Prompt flow Connections](media/e2e-llmops/promptflow_connections.png)

## Setup runtime for Prompt flow
Prompt flow's runtime provides the computing resources required for the application to run, including a Docker image that contains all necessary dependency packages.

In this guide, we will use a runtime to run your prompt flow. You need to create your own [Prompt flow runtime](https://learn.microsoft.com/azure/machine-learning/prompt-flow/how-to-create-manage-runtime)

Please go to workspace portal, click `Prompt flow` -> `Runtime` -> `Add`, then follow the instruction to create your own connections

## Setup variables with for Prompt flow and GitHub Actions

1. Clone repo to your local machine
Expand All @@ -131,13 +142,7 @@ Please go to workspace portal, click `Prompt flow` -> `Connections` -> `Create`,
### Update workflow to connect to your Azure Machine Learning workspace
1. You need to update `run-eval-pf-pipeline.yml` and `deploy-pf-online-endpoint-pipeline.yml` to connect to your Azure Machine Learning workspace. You'll need to update the CLI setup file variables to match your workspace.
1. In your cloned repository, go to `.github/workflow/`.
1. Edit `env` section in the `run-eval-pf-pipeline.yml` and `deploy-pf-online-endpoint-pipeline.yml` and update these variables in the file.

|Variable | Description |
|---------|---------|
|GROUP | Name of resource group |
|SUBSCRIPTION | Subscription of your workspace |
|WORKSPACE | Name of Azure Machine Learning workspace |
1. Verify `env` section in the `run-eval-pf-pipeline.yml` and `deploy-pf-online-endpoint-pipeline.yml` refers to the workspace secrets you added in the previous step.

### Update run.yml with your connections and runtime

Expand Down
2 changes: 1 addition & 1 deletion promptflow/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ environment_variables:
PROMPTFLOW_RUN_MODE: serving

# for pulling connections from workspace
PRT_CONFIG_OVERRIDE: deployment.subscription_id=<sub-id>,deployment.resource_group=o<resource-group>,deployment.workspace_name=<workspace-name>,deployment.endpoint_name=<endpoint-name>,deployment.deployment_name=<deployment-name>
PRT_CONFIG_OVERRIDE: deployment.subscription_id=<sub-id>,deployment.resource_group=<resource-group>,deployment.workspace_name=<workspace-name>,deployment.endpoint_name=<endpoint-name>,deployment.deployment_name=<deployment-name>

# (Optional) When there are multiple fields in the response, using this env variable will filter the fields to expose in the response.
# For example, if there are 2 flow outputs: "answer", "context", and I only want to have "answer" in the endpoint response, I can set this env variable to '["answer"]'.
Expand Down
10 changes: 10 additions & 0 deletions promptflow/llmops-helper/service_principal_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
projectName="<your project name>"
roleName="Contributor"
subscriptionId="<subscription Id>"
environment="<Prod>" #First letter should be capitalized
servicePrincipalName="Azure-ARM-${environment}-${projectName}"
# Verify the ID of the active subscription
echo "Using subscription ID $subscriptionID"
echo "Creating SP for RBAC with name $servicePrincipalName, with role $roleName and in scopes /subscriptions/$subscriptionId"
az ad sp create-for-rbac --name $servicePrincipalName --role $roleName --scopes /subscriptions/$subscriptionId --sdk-auth
echo "Please ensure that the information created here is properly save for future use."

0 comments on commit 1284d58

Please sign in to comment.