Skip to content

Commit

Permalink
[Sample]Enable automatic runtime sample (#218)
Browse files Browse the repository at this point in the history
# Description

Please add an informative description that covers that changes made by
the pull request and link all relevant issues.

# 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).**

## 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
D-W- authored Sep 6, 2023
1 parent 139190c commit cf2ef29
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 13 deletions.
20 changes: 20 additions & 0 deletions examples/flows/chat/chat-with-pdf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ fi

### CLI Example

#### Run flow

```bash
# test with default input value in flow.dag.yaml
pf flow test --flow .
Expand All @@ -47,3 +49,21 @@ pf run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --colu
# visualize run output details
pf run visualize --name $run_name
```

#### Submit run to cloud

Assume we already have a connection named `open_ai_connection` in workspace.

```bash
# set default workspace
az account set -s <your_subscription_id>
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name>
```

``` bash
# create run
pfazure run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --column-mapping question='${data.question}' pdf_url='${data.pdf_url}' chat_history='${data.chat_history}' config='{ \"EMBEDDING_MODEL_DEPLOYMENT_NAME\": \"text-embedding-ada-002\", \"CHAT_MODEL_DEPLOYMENT_NAME\": \"gpt-35-turbo\", \"PROMPT_TOKEN_LIMIT\": \"2000\", \"MAX_COMPLETION_TOKENS\": \"256\", \"VERBOSE\": \"True\", \"CHUNK_SIZE\": \"256\", \"CHUNK_OVERLAP\": \"32\" }' --name $run_name --runtime chat_with_pdf_runtime
# pfazure run create --flow . --data ./data/bert-paper-qna-3-line.jsonl --stream --column-mapping question='${data.question}' pdf_url='${data.pdf_url}' chat_history='${data.chat_history}' config='{ \"EMBEDDING_MODEL_DEPLOYMENT_NAME\": \"text-embedding-ada-002\", \"CHAT_MODEL_DEPLOYMENT_NAME\": \"gpt-35-turbo\", \"PROMPT_TOKEN_LIMIT\": \"2000\", \"MAX_COMPLETION_TOKENS\": \"256\", \"VERBOSE\": \"True\", \"CHUNK_SIZE\": \"256\", \"CHUNK_OVERLAP\": \"32\" }' --name $run_name # automatic runtime
```

Note: Click portal_url of the run to view the final snapshot.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"# Get a handle to workspace\n",
"pf = azure.PFClient.from_config(credential=credential)\n",
"runtime = \"chat_with_pdf_runtime\" # TODO add guide to create runtime\n",
"# runtime = None # serverless"
"# runtime = None # automatic runtime"
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions examples/flows/chat/chat-with-pdf/flow.dag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ nodes:
question: ${inputs.question}
history: ${inputs.chat_history}
env_ready_signal: ${setup_env.output}
environment:
python_requirements_txt: requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setUp(self):

self.pf = azure.PFClient.from_config(credential=credential)
self.runtime = "chat_with_pdf_runtime"
# self.runtime = None # serverless
# self.runtime = None # automatic runtime

def tearDown(self) -> None:
return super().tearDown()
Expand Down
18 changes: 13 additions & 5 deletions examples/flows/standard/flow-with-additional-includes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,20 @@ pf run create --file run.yml --stream

#### Submit run to cloud

Assume we already have a connection named `open_ai_connection` in workspace.

```bash
# set default workspace
az account set -s <your_subscription_id>
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name>
```

``` bash
# create run
# pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription <your_subscription_id> -g <your_resource_group_name> -w <your_workspace_name>
# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute
# pfazure run create --file run.yml --runtime demo-mir
# pfazure run create --file run.yml --stream # serverless compute
pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir
# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime
pfazure run create --file run.yml --runtime demo-mir
# pfazure run create --file run.yml --stream # automatic runtime
```

Note: Click portal_url of the run to view the final snapshot.
Note: Click portal_url of the run to view the final snapshot.
4 changes: 2 additions & 2 deletions examples/flows/standard/flow-with-symlinks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ pf run create --file run.yml --stream
``` bash
# create run
pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription <your_subscription_id> -g <your_resource_group_name> -w <your_workspace_name>
# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute
# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime

# set default workspace
az account set -s <your_subscription_id>
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name>

pfazure run create --file run.yml --runtime demo-mir --stream
# pfazure run create --file run.yml --stream # serverless compute
# pfazure run create --file run.yml --stream # automatic runtime
```
6 changes: 3 additions & 3 deletions examples/flows/standard/web-classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ az account set -s <your_subscription_id>
az configure --defaults group=<your_resource_group_name> workspace=<your_workspace_name>

# create run
pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir --subscription <your_subscription_id> -g <your_resource_group_name> -w <your_workspace_name>
# pfazure run create --flow . --data ./data.jsonl --stream # serverless compute
pfazure run create --flow . --data ./data.jsonl --stream --runtime demo-mir
# pfazure run create --flow . --data ./data.jsonl --stream # automatic runtime

# (Optional) create a new random run name for further use
run_name="web_classification_"$(openssl rand -hex 12)

# create run using yaml file, --name is optional
pfazure run create --file run.yml --runtime demo-mir --name $run_name
# pfazure run create --file run.yml --stream --name $run_name # serverless compute
# pfazure run create --file run.yml --stream --name $run_name # automatic runtime


pfazure run stream --name $run_name
Expand Down
49 changes: 48 additions & 1 deletion examples/tutorials/run-management/cloud-run-management.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"- create run which references another runs inputs\n",
"- manage runs via run.yaml\n",
"- create run with connection override\n",
"- serverless runtime\n",
"- automatic runtime\n",
"\n",
"\n",
"**Motivations** - This guide will walk you through cloud run management abilities."
Expand Down Expand Up @@ -310,6 +310,53 @@
"\n",
"pf.runs.stream(base_run)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 4 Create a flow run with uses automatic runtime\n",
"\n",
"If you don't want to create your own runtime, you can leave the `runtime` field empty to use system automatic created runtime.\n",
"To customize base image or python packages, you can add the following config in your `flow.dag.yaml`:\n",
"\n",
"```yml\n",
"environment:\n",
" image: python:3.8-slim\n",
" python_requirements_txt: requirements.txt\n",
"```\n",
"\n",
"You can also change instance type or idle time of the automatic runtime or reset the automatic runtime to clean state.\n",
"The following code cell shows how to do so."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# create run\n",
"run = Run(\n",
" # local flow file\n",
" flow=\"../../flows/standard/web-classification\",\n",
" # remote data\n",
" data=data_id,\n",
" # to customize automatic runtime instance type and idle time, you can provide them in resources\n",
" # resources={\n",
" # \"instance_type\": \"STANDARD_DS11_V2\",\n",
" # \"idle_time_before_shutdown_minutes\": 10\n",
" # }\n",
")\n",
"\n",
"base_run = pf.runs.create_or_update(\n",
" run=run,\n",
" # leave runtime None to use automatic runtime\n",
" runtime=None,\n",
" # to reset automatic runtime to clean state, set reset_runtime to True\n",
" # reset_runtime=True,\n",
")"
]
}
],
"metadata": {
Expand Down

0 comments on commit cf2ef29

Please sign in to comment.