chore: import upstream snapshot with attribution
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# Consume connections from Azure AI
|
||||
|
||||
For a smooth development flow that transitions from cloud (Azure AI) to local environments, you can directly utilize the connection already established on the cloud by setting the connection provider to "Azure AI connections".
|
||||
|
||||
:::{note}
|
||||
Promptflow is not able to manage connections from Azure AI, please manage it in workspace portal, [Azure AI Studio](https://learn.microsoft.com/en-us/azure/ai-studio/how-to/connections-add), az ml cli or azure-ai-ml sdk.
|
||||
:::
|
||||
|
||||
You can set the connection provider using the following steps:
|
||||
|
||||
1. Navigate to the connection list in the VS Code primary sidebar.
|
||||
|
||||
1. Click on the ... (more options icon) at the top and select the `Set connection provider` option.
|
||||
|
||||

|
||||
|
||||
1. Choose one of the "Azure AI connections" provider types that you wish to use. [Click to learn more about the differences between the connection providers](#different-connection-providers).
|
||||
|
||||

|
||||
|
||||
1. If you choose "Azure AI Connections - for current working directory", then you need to specify the cloud resources in the `config.json` file within the project folder.
|
||||
|
||||

|
||||
|
||||
1. If you choose "Azure AI Connections - for this machine", specify the cloud resources in the connection string. You can do this in one of two ways:
|
||||
|
||||
(1) Input connection string in the input box above.
|
||||
For example `azureml://subscriptions/<your-subscription>/resourceGroups/<your-resourcegroup>/providers/Microsoft.MachineLearningServices/workspaces/<your-workspace>`
|
||||
|
||||

|
||||
|
||||
(2) Follow the wizard to set up your config step by step.
|
||||
|
||||

|
||||
1. Once the connection provider is set, the connection list will automatically refresh, displaying the connections retrieved from the selected provider.
|
||||
|
||||
|
||||
Note:
|
||||
1. You need to have a project folder open to use the "Azure AI connections - for current working directory" option.
|
||||
1. Once you change the connection provider, it will stay that way until you change it again and save the new setting.
|
||||
|
||||
## Different connection providers
|
||||
|
||||
Currently, we support three types of connections:
|
||||
|
||||
|Connection provider|Type|Description| Provider Specification |Use Case|
|
||||
|---|---|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
|
||||
| Local Connections| Local| Enables consume the connections created and locally and stored in local sqlite. | NA | Ideal when connections need to be stored and managed locally.|
|
||||
|Azure AI connection - For current working directory| Cloud provider| Enables the consumption of connections from a cloud provider, such as a specific Azure Machine Learning workspace or Azure AI project.| Specify the resource ID in a `config.json` file placed in the project folder. <br> [Click here for more details](../../how-to-guides/set-promptflow-configs.md#azureml) | A dynamic approach for consuming connections from different providers in specific projects. Allows for setting different provider configurations for different flows by updating the `config.json` in the project folder.|
|
||||
|Azure AI connection - For this machine| Cloud| Enables the consumption of connections from a cloud provider, such as a specific Azure Machine Learning workspace or Azure AI project. | Use a `connection string` to specify a cloud resource as the provider on your local machine. <br> [Click here for more details](../../how-to-guides/set-promptflow-configs.md#full-azure-machine-learning-workspace-resource-id) |A global provider setting that applies across all working directories on your machine.|
|
||||
|
||||
## Next steps
|
||||
|
||||
- Set global configs on [connection.provider](../../how-to-guides/set-promptflow-configs.md#connectionprovider).
|
||||
- [Manage connections on local](../../how-to-guides/manage-connections.md).
|
||||
@@ -0,0 +1,111 @@
|
||||
# Create run with compute session
|
||||
|
||||
:::{admonition} Experimental feature
|
||||
This is an experimental feature, and may change at any time. Learn [more](../../how-to-guides/faq.md#stable-vs-experimental).
|
||||
:::
|
||||
|
||||
A prompt flow compute session provides computing resources that are required for the application to run, including a Docker image that contains all necessary dependency packages. This reliable and scalable compute session environment enables prompt flow to efficiently execute its tasks and functions for a seamless user experience.
|
||||
|
||||
If you're a new user, we recommend that you use the compute session (preview). You can easily customize the environment by adding packages in the requirements.txt file in flow.dag.yaml in the flow folder.
|
||||
|
||||
## Create a run with compute session
|
||||
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
```bash
|
||||
pfazure run create --flow path/to/flow --data path/to/data --stream
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
from promptflow.azure import PFClient
|
||||
|
||||
|
||||
pf = PFClient(
|
||||
credential=credential,
|
||||
subscription_id="<SUBSCRIPTION_ID>", # this will look like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
resource_group_name="<RESOURCE_GROUP>",
|
||||
workspace_name="<AML_WORKSPACE_NAME>",
|
||||
)
|
||||
pf.run(
|
||||
flow=flow,
|
||||
data=data,
|
||||
)
|
||||
```
|
||||
|
||||
:::
|
||||
::::
|
||||
|
||||
## Specify pip requirements for compute session
|
||||
|
||||
If `requirements.txt` exists in the same folder with `flow.dag.yaml`.
|
||||
The dependencies in it will be automatically installed for compute session.
|
||||
|
||||
You can also specify which requirements file to use in `flow.dag.yaml` like this:
|
||||
|
||||
```yaml
|
||||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
|
||||
environment:
|
||||
python_requirements_txt: path/to/requirement/file
|
||||
...
|
||||
```
|
||||
|
||||
Reference [Flow YAML Schema](../../reference/flow-yaml-schema-reference.md) for details.
|
||||
|
||||
## Customize compute session
|
||||
|
||||
In compute session case, you can also specify the instance type, if you don't specify the instance type, Azure Machine Learning chooses an instance type (VM size) based on factors like quota, cost, performance and disk size, learn more about [serverless compute](https://docs.microsoft.com/en-us/azure/machine-learning/how-to-use-serverless-compute).
|
||||
|
||||
```yaml
|
||||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json
|
||||
flow: <path_to_flow>
|
||||
data: <path_to_flow>/data.jsonl
|
||||
|
||||
column_mapping:
|
||||
url: ${data.url}
|
||||
|
||||
# define instance type only work for compute session.
|
||||
resources:
|
||||
instance_type: <instance_type>
|
||||
```
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
```bash
|
||||
pfazure run create --file run.yml
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
from promptflow.client import load_run
|
||||
|
||||
run = load_run(source="run.yml")
|
||||
pf = PFClient(
|
||||
credential=credential,
|
||||
subscription_id="<SUBSCRIPTION_ID>", # this will look like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
resource_group_name="<RESOURCE_GROUP>",
|
||||
workspace_name="<AML_WORKSPACE_NAME>",
|
||||
)
|
||||
pf.runs.create_or_update(
|
||||
run=run
|
||||
)
|
||||
```
|
||||
:::
|
||||
::::
|
||||
|
||||
## Next steps
|
||||
|
||||
- Try the example [here](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/run-management/cloud-run-management.ipynb).
|
||||
@@ -0,0 +1,81 @@
|
||||
# Deploy to Azure App Service
|
||||
|
||||
[Azure App Service](https://learn.microsoft.com/azure/app-service/) is an HTTP-based service for hosting web applications, REST APIs, and mobile back ends.
|
||||
The scripts (`deploy.sh` for bash and `deploy.ps1` for powershell) under [this folder](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/flow-deploy/azure-app-service) are here to help deploy the docker image to Azure App Service.
|
||||
|
||||
This example demos how to deploy [web-classification](https://github.com/microsoft/promptflow/tree/main/examples/flows/standard/web-classification/) deploy a flow using Azure App Service.
|
||||
|
||||
## Build a flow as docker format app
|
||||
|
||||
Use the command below to build a flow as docker format app:
|
||||
|
||||
```bash
|
||||
pf flow build --source ../../flows/standard/web-classification --output dist --format docker
|
||||
```
|
||||
|
||||
Note that all dependent connections must be created before building as docker.
|
||||
|
||||
## Deploy with Azure App Service
|
||||
The two scripts will do the following things:
|
||||
1. Create a resource group if not exists.
|
||||
2. Build and push the image to docker registry.
|
||||
3. Create an app service plan with the given sku.
|
||||
4. Create an app with specified name, set the deployment container image to the pushed docker image.
|
||||
5. Set up the environment variables for the app.
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} Bash
|
||||
Example command to use bash script:
|
||||
```shell
|
||||
bash deploy.sh --path dist -i <image_tag> --name my-app-23d8m -r <docker registry> -g <resource_group>
|
||||
```
|
||||
See the full parameters by `bash deploy.sh -h`.
|
||||
:::
|
||||
:::{tab-item} PowerShell
|
||||
Example command to use powershell script:
|
||||
```powershell
|
||||
.\deploy.ps1 -Path dist -i <image_tag> -n my-app-23d8m -r <docker registry> -g <resource_group>
|
||||
```
|
||||
See the full parameters by `.\deploy.ps1 -h`.
|
||||
:::
|
||||
::::
|
||||
|
||||
Note that the `name` will produce a unique FQDN as AppName.azurewebsites.net.
|
||||
|
||||
|
||||
## View and test the web app
|
||||
The web app can be found via [azure portal](https://portal.azure.com/)
|
||||
|
||||

|
||||
|
||||
After the app created, you will need to go to https://portal.azure.com/ find the app and set up the environment variables
|
||||
at (Settings>Configuration) or (Settings>Environment variables), then restart the app.
|
||||
|
||||

|
||||
|
||||
The app can be tested by sending a POST request to the endpoint or browse the test page.
|
||||
::::{tab-set}
|
||||
:::{tab-item} Bash
|
||||
```bash
|
||||
curl https://<name>.azurewebsites.net/score --data '{"url":"https://play.google.com/store/apps/details?id=com.twitter.android"}' -X POST -H "Content-Type: application/json"
|
||||
```
|
||||
:::
|
||||
:::{tab-item} PowerShell
|
||||
```powershell
|
||||
Invoke-WebRequest -URI https://<name>.azurewebsites.net/score -Body '{"url":"https://play.google.com/store/apps/details?id=com.twitter.android"}' -Method POST -ContentType "application/json"
|
||||
```
|
||||
:::
|
||||
:::{tab-item} Test Page
|
||||
Browse the app at Overview and see the test page:
|
||||
|
||||

|
||||
:::
|
||||
::::
|
||||
|
||||
Tips:
|
||||
- Reach deployment logs at (Deployment>Deployment Central) and app logs at (Monitoring>Log stream).
|
||||
- Reach advanced deployment tools at (Development Tools>Advanced Tools).
|
||||
- Reach more details about app service at [Azure App Service](https://learn.microsoft.com/azure/app-service/).
|
||||
|
||||
## Next steps
|
||||
- Try the example [here](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/flow-deploy/azure-app-service).
|
||||
@@ -0,0 +1,15 @@
|
||||
# Frequency asked questions (FAQ)
|
||||
|
||||
|
||||
## How to create feedback for azure portal experience
|
||||
|
||||
For azure portal experience related issues, please create feedback on azure portal.
|
||||
|
||||

|
||||
|
||||
## Token expired when run pfazure cmd
|
||||
|
||||
If hit error "AADSTS700082: The refresh token has expired due to inactivity." when running pfazure cmd, it's caused by local cached token expired. Please clear the cached token under "%LOCALAPPDATA%/.IdentityService/msal.cache". Then run below command to login again:
|
||||
```sh
|
||||
az login
|
||||
```
|
||||
@@ -0,0 +1,36 @@
|
||||
# How to generate test data in cloud based on documents
|
||||
This guide will help you learn how to generate test data on Azure AI, so that you can integrate the created flow and process a large amount of data.
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. Go through [local test data generation guide](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/generate-test-data/README.md) and prepare your [test data generation flow](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/generate-test-data/example_flow).
|
||||
2. Go to the [example_gen_test_data](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/generate-test-data) folder and run command `pip install -r requirements_cloud.txt` to prepare local environment.
|
||||
3. Prepare cloud environment.
|
||||
- Navigate to file [conda.yml](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/generate-test-data/conda.yml).
|
||||
- For specific document file types, you may need to install extra packages:
|
||||
- .docx - `pip install docx2txt`
|
||||
- .pdf - `pip install pypdf`
|
||||
- .ipynb - `pip install nbconvert`
|
||||
> !Note: We use llama index `SimpleDirectoryReader` to load documents. For the latest information on required packages, please check [here](https://docs.llamaindex.ai/en/stable/examples/data_connectors/simple_directory_reader.html).
|
||||
|
||||
4. Prepare Azure AI resources in cloud.
|
||||
- An Azure AI ML workspace - [Create workspace resources you need to get started with Azure AI](https://learn.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources?view=azureml-api-2).
|
||||
- A compute target - [Learn more about compute cluster](https://learn.microsoft.com/en-us/azure/machine-learning/concept-compute-target?view=azureml-api-2).
|
||||
5. [Create cloud AzureOpenAI or OpenAI connection](https://microsoft.github.io/promptflow/cloud/azureai/run-promptflow-in-azure-ai.html#create-necessary-connections)
|
||||
|
||||
6. Prepare test data generation setting.
|
||||
- Navigate to [example_gen_test_data](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/generate-test-data) folder.
|
||||
- Prepare `config.yml` by copying [`config.yml.example`](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/generate-test-data/config.yml.example).
|
||||
- Fill in configurations in the `config.yml` by following inline comment instructions.
|
||||
|
||||
|
||||
## Generate test data at cloud
|
||||
For handling larger test data, you can leverage the PRS component to run flow in cloud.
|
||||
- Navigate to [example_gen_test_data](https://github.com/microsoft/promptflow/tree/main/examples/tutorials/generate-test-data) folder.
|
||||
- After configuration, run the following command to generate the test data set:
|
||||
```bash
|
||||
python -m generate-test-data.run --cloud
|
||||
```
|
||||
|
||||
- The generated test data will be a data asset which can be found in the output of the last node. You can register this data asset for future use.
|
||||
@@ -0,0 +1,136 @@
|
||||
# Manage flows
|
||||
|
||||
This documentation will walk you through how to manage your flow with CLI and SDK on [Azure AI](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/overview-what-is-prompt-flow?view=azureml-api-2).
|
||||
The flow examples in this guide come from [examples/flows/standard](https://github.com/microsoft/promptflow/tree/main/examples/flows/standard).
|
||||
|
||||
In general:
|
||||
- For `CLI`, you can run `pfazure flow --help` in the terminal to see help messages.
|
||||
- For `SDK`, you can refer to [Promptflow Python Library Reference](../../reference/python-library-reference/promptflow-azure/promptflow.rst) and check `promptflow.azure.PFClient.flows` for more flow operations.
|
||||
|
||||
:::{admonition} Prerequisites
|
||||
- Refer to the prerequisites in [Quick start](./run-promptflow-in-azure-ai.md#prerequisites).
|
||||
- Use the `az login` command in the command line to log in. This enables promptflow to access your credentials.
|
||||
:::
|
||||
|
||||
Let's take a look at the following topics:
|
||||
- [Manage flows](#manage-flows)
|
||||
- [Create a flow](#create-a-flow)
|
||||
- [List flows](#list-flows)
|
||||
|
||||
## Create a flow
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
To set the target workspace, you can either specify it in the CLI command or set default value in the Azure CLI.
|
||||
You can refer to [Quick start](./run-promptflow-in-azure-ai.md#submit-a-run-to-workspace) for more information.
|
||||
|
||||
To create a flow to Azure from local flow directory, you can use
|
||||
|
||||
```bash
|
||||
# create the flow
|
||||
pfazure flow create --flow <path-to-flow-folder>
|
||||
|
||||
# create the flow with metadata
|
||||
pfazure flow create --flow <path-to-flow-folder> --set display_name=<display-name> description=<description> tags.key1=value1
|
||||
```
|
||||
|
||||
After the flow is created successfully, you can see the flow summary in the command line.
|
||||
|
||||

|
||||
|
||||
|
||||
:::
|
||||
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
1. Import the required libraries
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
|
||||
# azure version promptflow apis
|
||||
from promptflow.azure import PFClient
|
||||
```
|
||||
|
||||
2. Get credential
|
||||
```python
|
||||
try:
|
||||
credential = DefaultAzureCredential()
|
||||
# Check if given credential can get token successfully.
|
||||
credential.get_token("https://management.azure.com/.default")
|
||||
except Exception as ex:
|
||||
# Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work
|
||||
credential = InteractiveBrowserCredential()
|
||||
```
|
||||
|
||||
3. Get a handle to the workspace
|
||||
```python
|
||||
# Get a handle to workspace
|
||||
pf = PFClient(
|
||||
credential=credential,
|
||||
subscription_id="<SUBSCRIPTION_ID>", # this will look like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
resource_group_name="<RESOURCE_GROUP>",
|
||||
workspace_name="<AML_WORKSPACE_NAME>",
|
||||
)
|
||||
```
|
||||
|
||||
4. Create the flow
|
||||
|
||||
```python
|
||||
|
||||
# specify flow path
|
||||
flow = "./web-classification"
|
||||
|
||||
# create flow to Azure
|
||||
flow = pf.flows.create_or_update(
|
||||
flow=flow, # path to the flow folder
|
||||
display_name="my-web-classification", # it will be "web-classification-{timestamp}" if not specified
|
||||
type="standard", # it will be "standard" if not specified
|
||||
)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
On Azure portal, you can see the created flow in the flow list.
|
||||
|
||||

|
||||
|
||||
And the flow source folder on file share is `Users/<alias>/promptflow/<flow-display-name>`:
|
||||
|
||||

|
||||
|
||||
Note that if the flow display name is not specified, it will default to the flow folder name + timestamp. (e.g. `web-classification-11-13-2023-14-19-10`)
|
||||
|
||||
## List flows
|
||||
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
List flows with default json format:
|
||||
```bash
|
||||
pfazure flow list --max-results 1
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
# reuse the pf client created in "create a flow" section
|
||||
flows = pf.flows.list(max_results=1)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
@@ -0,0 +1,155 @@
|
||||
# Run prompt flow in Azure AI
|
||||
|
||||
Assuming you have learned how to create and run a flow following [Quick start](../../how-to-guides/quick-start.md). This guide will walk you through the main process of how to submit a promptflow run to [Azure AI](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/overview-what-is-prompt-flow?view=azureml-api-2).
|
||||
|
||||
Benefits of use Azure AI comparison to just run locally:
|
||||
- **Designed for team collaboration**: Portal UI is a better fix for sharing & presentation your flow and runs. And workspace can better organize team shared resources like connections.
|
||||
- **Enterprise Readiness Solutions**: prompt flow leverages Azure AI's robust enterprise readiness solutions, providing a secure, scalable, and reliable foundation for the development, experimentation, and deployment of flows.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. An Azure account with an active subscription - [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F)
|
||||
2. An Azure AI ML workspace - [Create workspace resources you need to get started with Azure AI](https://learn.microsoft.com/en-us/azure/machine-learning/quickstart-create-resources).
|
||||
3. A python environment, `python=3.9` or higher version like 3.10 is recommended.
|
||||
4. Install `promptflow` with extra dependencies and `promptflow-tools`.
|
||||
```sh
|
||||
pip install promptflow[azure] promptflow-tools
|
||||
```
|
||||
5. Clone the sample repo and check flows in folder [examples/flows](https://github.com/microsoft/promptflow/tree/main/examples/flows).
|
||||
```sh
|
||||
git clone https://github.com/microsoft/promptflow.git
|
||||
```
|
||||
|
||||
## Create necessary connections
|
||||
Connection helps securely store and manage secret keys or other sensitive credentials required for interacting with LLM and other external tools for example Azure Content Safety.
|
||||
|
||||
In this guide, we will use flow `web-classification` which uses connection `open_ai_connection` inside, we need to set up the connection if we haven't added it before.
|
||||
|
||||
Please go to workspace portal, click `Prompt flow` -> `Connections` -> `Create`, then follow the instruction to create your own connections. Learn more on [connections](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/concept-connections?view=azureml-api-2).
|
||||
|
||||
|
||||
## Submit a run to workspace
|
||||
|
||||
Assuming you are in working directory `<path-to-the-sample-repo>/examples/flows/standard/`
|
||||
|
||||
::::{tab-set}
|
||||
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
Use `az login` to login so promptflow can get your credential.
|
||||
|
||||
```sh
|
||||
az login
|
||||
```
|
||||
|
||||
Submit a run to workspace.
|
||||
|
||||
```sh
|
||||
pfazure run create --subscription <my_sub> -g <my_resource_group> -w <my_workspace> --flow web-classification --data web-classification/data.jsonl --stream
|
||||
```
|
||||
|
||||
**Default subscription/resource-group/workspace**
|
||||
|
||||
Note `--subscription`, `-g` and `-w` can be omitted if you have installed the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) and [set the default configurations](https://learn.microsoft.com/en-us/cli/azure/azure-cli-configuration).
|
||||
|
||||
```sh
|
||||
az account set --subscription <my-sub>
|
||||
az configure --defaults group=<my_resource_group> workspace=<my_workspace>
|
||||
```
|
||||
|
||||
|
||||
**Specify run name and view a run**
|
||||
|
||||
You can also name the run by specifying `--name my_first_cloud_run` in the run create command, otherwise the run name will be generated in a certain pattern which has timestamp inside.
|
||||
|
||||
With a run name, you can easily stream or view the run details using below commands:
|
||||
|
||||
```sh
|
||||
pfazure run stream -n my_first_cloud_run # same as "--stream" in command "run create"
|
||||
pfazure run show-details -n my_first_cloud_run
|
||||
pfazure run visualize -n my_first_cloud_run
|
||||
```
|
||||
|
||||
More details can be found in [CLI reference: pfazure](../../reference/pfazure-command-reference.md)
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
1. Import the required libraries
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
|
||||
# azure version promptflow apis
|
||||
from promptflow.azure import PFClient
|
||||
```
|
||||
|
||||
2. Get credential
|
||||
```python
|
||||
try:
|
||||
credential = DefaultAzureCredential()
|
||||
# Check if given credential can get token successfully.
|
||||
credential.get_token("https://management.azure.com/.default")
|
||||
except Exception as ex:
|
||||
# Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work
|
||||
credential = InteractiveBrowserCredential()
|
||||
```
|
||||
|
||||
3. Get a handle to the workspace
|
||||
```python
|
||||
# Get a handle to workspace
|
||||
pf = PFClient(
|
||||
credential=credential,
|
||||
subscription_id="<SUBSCRIPTION_ID>", # this will look like xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
resource_group_name="<RESOURCE_GROUP>",
|
||||
workspace_name="<AML_WORKSPACE_NAME>",
|
||||
)
|
||||
```
|
||||
|
||||
4. Submit the flow run
|
||||
|
||||
```python
|
||||
|
||||
# load flow
|
||||
flow = "web-classification"
|
||||
data = "web-classification/data.jsonl"
|
||||
|
||||
# create run
|
||||
base_run = pf.run(
|
||||
flow=flow,
|
||||
data=data,
|
||||
)
|
||||
|
||||
pf.stream(base_run)
|
||||
```
|
||||
5. View the run info
|
||||
```python
|
||||
details = pf.get_details(base_run)
|
||||
details.head(10)
|
||||
|
||||
pf.visualize(base_run)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
|
||||
## View the run in workspace
|
||||
|
||||
At the end of stream logs, you can find the `portal_url` of the submitted run, click it to view the run in the workspace.
|
||||
|
||||

|
||||
|
||||
### Run snapshot of the flow with additional includes
|
||||
|
||||
Flows that enabled [additional include](../../how-to-guides/develop-a-dag-flow/referencing-external-files-or-folders-in-a-flow.md) files can also be submitted for execution in the workspace. Please note that the specific additional include files or folders will be uploaded and organized within the **Files** folder of the run snapshot in the cloud.
|
||||
|
||||

|
||||
|
||||
|
||||
## Next steps
|
||||
|
||||
Learn more about:
|
||||
- [CLI reference: pfazure](../../reference/pfazure-command-reference.md)
|
||||
@@ -0,0 +1,356 @@
|
||||
# Change log of default runtime image
|
||||
## Runtime image
|
||||
In Azure Machine Learning prompt flow, runtime provides the environment to execute flows. The default runtime includes a pre-built Docker image, which contains all necessary dependent packages.
|
||||
|
||||
### Pull image
|
||||
The image can be pulled by specifying a runtime version and executing the following command:
|
||||
```
|
||||
docker pull mcr.microsoft.com/azureml/promptflow/promptflow-runtime-stable:<runtime_version>
|
||||
```
|
||||
|
||||
### Check image version
|
||||
You can check the runtime image version from the flow execution log:
|
||||

|
||||
|
||||
## Change log
|
||||
Default runtime image is continuously updated, and here we record the new features and fixed bugs of each image version.
|
||||
|
||||
### 20251211.v2
|
||||
|
||||
#### New features
|
||||
- NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Upgrade pip==25.3 go==1.24.9 mlflow>=3.6.0 to fix vulnerabilities
|
||||
|
||||
### 20251014.v1
|
||||
|
||||
#### New features
|
||||
- NA
|
||||
|
||||
#### Bugs fixed
|
||||
- fix GNU C Library and dpkg vulnerabilities in Ubuntu Image
|
||||
|
||||
### 20250831.v1
|
||||
|
||||
#### New features
|
||||
- NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Update Ubuntu Image 22.04:latest to fix several security issues in Perl and SQLite
|
||||
|
||||
### 20250806.v3
|
||||
|
||||
#### New features
|
||||
- NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Upgrade aiohttp>=3.12.14 to fix vulnerability
|
||||
|
||||
### 20250728.v1
|
||||
|
||||
#### New features
|
||||
- NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Update Ubuntu Image 22.04 to fix several security issues in libssh and Git
|
||||
|
||||
### 20250220.v2
|
||||
|
||||
#### New features
|
||||
- Update promptflow-tools to 1.6.0
|
||||
|
||||
#### Bugs fixed
|
||||
- Pin marshmallow to ensure compatibility with older versions of promptflow for customer use.
|
||||
|
||||
### 20250131.v2
|
||||
Promptflow version 1.17.1 or higher is required due to a known issue with marshmallow.
|
||||
#### New features
|
||||
- Update promptflow-tools to 1.5.0
|
||||
- Update promptflow to 1.17.2
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20250109.v2
|
||||
|
||||
#### New features
|
||||
- Update promptflow to 1.17.0
|
||||
- PromptFlow-vectordb package update : To support langchain 0.3.x
|
||||
|
||||
#### Bugs fixed
|
||||
- Update golang crypto, net to fix vulnerabilities
|
||||
- Pin aiohttp in runtime image to fix vulnerability
|
||||
|
||||
### 20241214.v1
|
||||
Do not use this version due to known issues and bugs.
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Update langchain-community>=0.3.0 to fix vulnerability
|
||||
- Update mlflow>=2.16.0 to fix vulnerability
|
||||
|
||||
### 20241126.v3
|
||||
|
||||
#### New features
|
||||
- Upgrade promptflow version to 1.16.2
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20241114.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Update langchain-community>=0.2.19 to fix vulnerability
|
||||
|
||||
### 20241031.v1
|
||||
|
||||
#### New features
|
||||
- Upgrade promptflow version to 1.16.1
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20241021.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Upgrade langchain>=0.2.5 and langchain-community>=0.2.5,<0.3.0,!=0.2.14 to fix vulnerability
|
||||
|
||||
### 20240918.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20240909.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20240829.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Add uvicorn dependency explicitly
|
||||
|
||||
### 20240814.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix non serializable search results
|
||||
|
||||
### 20240731.v1
|
||||
|
||||
#### New features
|
||||
- Add Reranker tool with Cohere accessibility to Prompt flow
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix run id duplicate check
|
||||
- Upgrade langchain version in promptflow-vectordb-sdk
|
||||
|
||||
### 20240709.v1
|
||||
|
||||
#### New features
|
||||
- cosmos db vector db support
|
||||
- Build and publish promptflow-parallel
|
||||
|
||||
#### Bugs fixed
|
||||
- Add aad auth check
|
||||
- Fix metadata parser error
|
||||
|
||||
### 20240619.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Add @blob_error_handling_decorator for cancelling_run and get_run_status in async storage
|
||||
- Use dataplane api to list embedding deployments
|
||||
- Fix KeyError when get run meet UserAuthenticationValidationError.
|
||||
|
||||
### 20240529.v1
|
||||
|
||||
#### New features
|
||||
- [BYOI] Implement PostgreSQL
|
||||
- [Lookup tool] Implement BYO-Weaviate Index
|
||||
|
||||
#### Bugs fixed
|
||||
- The destination of _download_fileshare_directory should be str
|
||||
- Passing DefaultAzureCredential into as_langchain_vectorstore
|
||||
- Upgrade Werkzeug to 3.0.3.
|
||||
|
||||
### 20240515.v1
|
||||
|
||||
#### New features
|
||||
- runtime support batch run prompty
|
||||
- Support init_kwargs for multi-container c# batch run
|
||||
- Upgrade gunicorn and mlflow
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix and avoid FlowExecutor in PythonApiExecutorProxy
|
||||
|
||||
### 20240511.v1
|
||||
|
||||
#### New features
|
||||
- Add support for more huggingface models
|
||||
|
||||
#### Bugs fixed
|
||||
- _download_azure_file_share should return str
|
||||
- When ingress call gunicorn met timeout, we should not return 200.
|
||||
- Pin azureml-rag version to 0.2.30.2
|
||||
- Upgrade golang.org/x/net from 0.17.0 to 0.23.0 to fix vulnerability
|
||||
|
||||
### 20240429.v8
|
||||
|
||||
#### New features
|
||||
- Remove preview tag from Index Lookup
|
||||
- Support init_kwargs in c# batch run in cloud
|
||||
|
||||
#### Bugs fixed
|
||||
- Pass init_kwargs to executor in multi container case
|
||||
- Fix error of span.attributes.flow_log_path in multi-container.
|
||||
- Add duplicated key in SystemLogContext to avoid breaking when LogContext does not have it
|
||||
- Add clarification to migration notebook and small fixes
|
||||
- [Lookup tool] Update list pinecone index endpoint
|
||||
- Handle case where flow_logs_folder is None
|
||||
|
||||
### 20240424.v1
|
||||
|
||||
#### New features
|
||||
- Support download working_dir from fileshare.
|
||||
- Enable line log for batch run
|
||||
- Add prompt_tokens/completion_tokens to run properties
|
||||
- Support C# batch run in multi-container runtime
|
||||
- Implement ESIndex in common index lookup
|
||||
- Handle metadata processing better in Index Lookup
|
||||
- implement mongodb support
|
||||
|
||||
#### Bugs fixed
|
||||
- Remove Promptflow-evals publish.
|
||||
- [Lookup tool] Add workspace name in get()
|
||||
- changes to utils.py were accidentally left out of previous PR.
|
||||
|
||||
### 20240411.v4
|
||||
|
||||
#### New features
|
||||
- Add 'detail' parameter on 'Azure OpenAI GPT-4 Turbo with Vision" tool and "OpenAI GPT-4V" tool.
|
||||
|
||||
#### Bugs fixed
|
||||
- Resolve an intermittent ImportError that arose while loading the package tool.
|
||||
- Upgrade langchain>=0.1.1 and langchain-core>=0.1.30 to fix vulnerability.
|
||||
|
||||
### 20240403.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
|
||||
### 20240326.v2
|
||||
|
||||
#### New features
|
||||
- Support environment variables for C# batch run.
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
|
||||
### 20240319.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
|
||||
### 20240313.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix an issue where calling a flow with a flow function would result in failure.
|
||||
- Improve error handling by categorizing errors as user errors when a run is archived prior to being processed by the runtime.
|
||||
|
||||
|
||||
### 20240306.v5
|
||||
|
||||
#### New features
|
||||
- Support "seed" parameter for built-in LLM tools and GPT-4V tools.
|
||||
|
||||
#### Bugs fixed
|
||||
- Handle ClientAuthenticationError properly.
|
||||
- Fix appending blob exceeded size limit error by truncating debug info.
|
||||
|
||||
|
||||
### 20240228.v3
|
||||
|
||||
#### New features
|
||||
- Support async flow test for long running jobs.
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix bug when collecting package tools.
|
||||
|
||||
|
||||
### 20240222.v3
|
||||
|
||||
#### New features
|
||||
- Added support for executing C# batch runs in eager mode.
|
||||
- Introduced the ability to specify the number of workers for batch runs.
|
||||
- Implemented functionality to define a timeout for batch runs.
|
||||
|
||||
#### Bugs fixed
|
||||
NA
|
||||
|
||||
### 20240205.v2
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix the bug that deployed promptflow endpoint fails to get user assigned identity token.
|
||||
|
||||
### 20240124.v3
|
||||
|
||||
#### New features
|
||||
- Support downloading data from Azure Machine Learning registry for batch run.
|
||||
- Show node status when one line of a batch run times out.
|
||||
|
||||
#### Bugs fixed
|
||||
- Fix the bug that exception raised during preparing data is not set in run history.
|
||||
- Fix the bug that unexpected exception is raised when executor process crushes.
|
||||
|
||||
### 20240116.v1
|
||||
|
||||
#### New features
|
||||
NA
|
||||
|
||||
#### Bugs fixed
|
||||
- Add validation for wrong connection type for LLM tool.
|
||||
|
||||
### 20240111.v2
|
||||
|
||||
#### New features
|
||||
- Support error log scrubbing for heron jobs.
|
||||
|
||||
#### Bugs fixed
|
||||
- Fixed the compatibility issue between runtime and promptflow package < 1.3.0
|
||||
@@ -0,0 +1,362 @@
|
||||
# Use flow in Azure ML pipeline job
|
||||
In practical scenarios, flows fulfill various functions. For example, consider an offline flow specifically designed to assess the relevance score for communication sessions between humans and agents. This flow is triggered nightly and processes a substantial amount of session data. In such a context, Parallel component and AzureML pipeline emerge as the optimal choices for handling large-scale, highly resilient, and efficient offline batch requirements.
|
||||
|
||||
Once you’ve developed and thoroughly tested your flow, this guide will walk you through utilizing your flow as a parallel component within an AzureML pipeline job.
|
||||
|
||||
:::{admonition} Pre-requirements
|
||||
To enable this feature, customer need to:
|
||||
1. install related CLI or package:
|
||||
1. For CLI, please [install Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) first and then install the extension `ml>=2.22.0` via `az extension add -n ml`;
|
||||
2. For SDK, please install package `azure-ai-ml>=1.12.0` via `pip install azure-ai-ml>=1.12.0` or `pip install promptflow[azure]`;
|
||||
2. ensure that there is a `$schema` in the target source:
|
||||
1. `flow.dag.yaml`: `$schema`: `https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json`
|
||||
2. `run.yaml`: `$schema`: `https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json`
|
||||
3. ensure that metadata has been generated and is up-to-date:
|
||||
1. `<my-flow-directory>/.promptflow/flow.tools.json` should exist;
|
||||
2. customer may update the file via `pf flow validate --source <my-flow-directory>`.
|
||||
|
||||
:::
|
||||
|
||||
To explore an executable end-to-end example of running sample flow within Azure ML workspace, you can refer to this tutorial notebook: [run flow with pipeline](https://github.com/microsoft/promptflow/blob/main/examples/tutorials/run-flow-with-pipeline/pipeline.ipynb)
|
||||
|
||||
For more information about AzureML and component:
|
||||
- [What is Azure CLI](https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli)
|
||||
- [Install and set up the CLI(v2)](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-configure-cli)
|
||||
- [Install and set up the SDK(v2)](https://learn.microsoft.com/en-us/python/api/overview/azure/ai-ml-readme)
|
||||
- [What is a pipeline](https://learn.microsoft.com/en-us/azure/machine-learning/concept-ml-pipelines)
|
||||
- [What is a component](https://learn.microsoft.com/en-us/azure/machine-learning/concept-component)
|
||||
- [How to use parallel job in pipeline (V2)](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-parallel-job-in-pipeline)
|
||||
|
||||
## Register a flow as a component
|
||||
|
||||
Suppose there has been a flow and its `flow.dag.yaml` is as below:
|
||||
```yaml
|
||||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json
|
||||
environment:
|
||||
python_requirements_txt: requirements.txt
|
||||
inputs:
|
||||
text:
|
||||
type: string
|
||||
default: Hello World!
|
||||
outputs:
|
||||
output:
|
||||
type: string
|
||||
reference: ${llm.output}
|
||||
nodes:
|
||||
- name: hello_prompt
|
||||
type: prompt
|
||||
source:
|
||||
type: code
|
||||
path: hello.jinja2
|
||||
inputs:
|
||||
text: ${inputs.text}
|
||||
- name: llm
|
||||
type: python
|
||||
source:
|
||||
type: code
|
||||
path: hello.py
|
||||
inputs:
|
||||
prompt: ${hello_prompt.output}
|
||||
deployment_name: text-davinci-003
|
||||
max_tokens: "120"
|
||||
```
|
||||
|
||||
Customer can register a flow as a component with either CLI or SDK:
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
```bash
|
||||
# Register flow as a component
|
||||
az ml component create --file \<my-flow-directory\>/flow.dag.yaml
|
||||
|
||||
# Register flow as a component and specify its name and version
|
||||
# Default component name will be the name of flow folder, which can be invalid as a component name; default version will be "1"
|
||||
az ml component create --file \<my-flow-directory\>/flow.dag.yaml --version 3 --set name=basic_updated
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
from azure.ai.ml import MLClient, load_component
|
||||
|
||||
ml_client = MLClient()
|
||||
|
||||
# Register flow as a component
|
||||
flow_component = load_component("<my-flow-directory>/flow.dag.yaml")
|
||||
ml_client.components.create_or_update(flow_component)
|
||||
|
||||
# Register flow as a component and specify its name and version
|
||||
# Default component name will be the name of flow folder, which can be invalid as a component name; default version will be "1"
|
||||
flow_component.name = "basic_updated"
|
||||
ml_client.components.create_or_update(flow_component, version="3")
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
The generated component will be a parallel component, whose definition will be as below:
|
||||
|
||||
```yaml
|
||||
name: basic
|
||||
version: 1
|
||||
display_name: basic
|
||||
is_deterministic: True
|
||||
type: parallel
|
||||
inputs:
|
||||
data:
|
||||
type: uri_folder
|
||||
optional: False
|
||||
run_outputs:
|
||||
type: uri_folder
|
||||
optional: True
|
||||
text:
|
||||
type: string
|
||||
optional: False
|
||||
default: Hello World!
|
||||
outputs:
|
||||
flow_outputs:
|
||||
type: uri_folder
|
||||
debug_info:
|
||||
type: uri_folder
|
||||
...
|
||||
```
|
||||
|
||||
Besides the fixed input/output ports, all connections and flow inputs will be exposed as input parameters of the component. Default value can be provided in flow/run definition; they can also be set/overwrite on job submission. Full description of ports can be seen in section [Component ports and run settings](#component-ports-and-run-settings).
|
||||
|
||||
## Use a flow in a pipeline job
|
||||
|
||||
After registered a flow as a component, they can be referred in a pipeline job like [regular registered components](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/pipelines-with-components/basics/1b_e2e_registered_components). Customer may also directly use a flow in a pipeline job, then anonymous components will be created on job submission.
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
```yaml
|
||||
...
|
||||
inputs:
|
||||
basic_input:
|
||||
type: uri_file
|
||||
path: <path-to-data>
|
||||
compute: azureml:cpu-cluster
|
||||
jobs:
|
||||
flow_from_registered:
|
||||
type: parallel
|
||||
component: azureml:my_flow_component:1
|
||||
inputs:
|
||||
data: ${{parent.inputs.basic_input}}
|
||||
text: "${data.text}"
|
||||
flow_from_dag:
|
||||
type: parallel
|
||||
component: <path-to-flow-dag-yaml>
|
||||
inputs:
|
||||
data: ${{parent.inputs.basic_input}}
|
||||
text: "${data.text}"
|
||||
flow_from_run:
|
||||
type: parallel
|
||||
component: <path-to-run-yaml>
|
||||
inputs:
|
||||
data: ${{parent.inputs.basic_input}}
|
||||
text: "${data.text}"
|
||||
...
|
||||
```
|
||||
|
||||
Pipeline job can be submitted via `az ml job create --file pipeline.yml`.
|
||||
|
||||
Full example can be found [here](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/pipelines-with-components/pipeline_job_with_flow_as_component).
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.ai.ml import MLClient, load_component, Input
|
||||
from azure.ai.ml.dsl import pipeline
|
||||
|
||||
credential = DefaultAzureCredential()
|
||||
ml_client = MLClient.from_config(credential=credential)
|
||||
data_input = Input(path="<path-to-data>", type='uri_file')
|
||||
|
||||
flow_component_from_registered = ml_client.components.get("my_flow_component", "1")
|
||||
flow_component_from_dag = load_component("<path-to-flow-dag-yaml>")
|
||||
flow_component_from_run = load_component("<path-to-run-yaml>")
|
||||
|
||||
@pipeline
|
||||
def pipeline_func_with_flow(basic_input):
|
||||
flow_from_registered = flow_component_from_registered(
|
||||
data=data,
|
||||
text="${data.text}",
|
||||
)
|
||||
flow_from_dag = flow_component_from_dag(
|
||||
data=data,
|
||||
text="${data.text}",
|
||||
)
|
||||
flow_from_run = flow_component_from_run(
|
||||
data=data,
|
||||
text="${data.text}",
|
||||
)
|
||||
|
||||
pipeline_with_flow = pipeline_func_with_flow(basic_input=data_input)
|
||||
pipeline_with_flow.compute = "cpu-cluster"
|
||||
|
||||
pipeline_job = ml_client.jobs.create_or_update(pipeline_with_flow)
|
||||
ml_client.jobs.stream(pipeline_job.name)
|
||||
```
|
||||
|
||||
Full example can be found [here](https://github.com/Azure/azureml-examples/tree/main/sdk/python/jobs/pipelines/1l_flow_in_pipeline).
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
Like regular parallel components, customer may specify run settings for them in a pipeline job. Some regularly used run settings have been listed in section [Component ports and run settings](#component-ports-and-run-settings); customer may also refer to [the official document of parallel component](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-parallel-job-in-pipeline?view=azureml-api-2&tabs=cliv2) for more details:
|
||||
|
||||
::::{tab-set}
|
||||
:::{tab-item} CLI
|
||||
:sync: CLI
|
||||
|
||||
```yaml
|
||||
...
|
||||
jobs:
|
||||
flow_node:
|
||||
type: parallel
|
||||
component: <path-to-complicated-run-yaml>
|
||||
compute: azureml:cpu-cluster
|
||||
instance_count: 2
|
||||
max_concurrency_per_instance: 2
|
||||
mini_batch_error_threshold: 5
|
||||
retry_settings:
|
||||
max_retries: 3
|
||||
timeout: 30
|
||||
inputs:
|
||||
data: ${{parent.inputs.data}}
|
||||
url: "${data.url}"
|
||||
connections.summarize_text_content.connection: azure_open_ai_connection
|
||||
connections.summarize_text_content.deployment_name: text-davinci-003
|
||||
environment_variables.AZURE_OPENAI_API_KEY: ${my_connection.api_key}
|
||||
environment_variables.AZURE_OPENAI_API_BASE: ${my_connection.api_base}
|
||||
...
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
:::{tab-item} SDK
|
||||
:sync: SDK
|
||||
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.ai.ml import MLClient, load_component, Input
|
||||
from azure.ai.ml.dsl import pipeline
|
||||
from azure.ai.ml.entities import RetrySettings
|
||||
|
||||
credential = DefaultAzureCredential()
|
||||
ml_client = MLClient.from_config(credential=credential)
|
||||
data_input = Input(path="<path-to-data>", type='uri_file')
|
||||
|
||||
# Load flow as a component
|
||||
flow_component = load_component("<path-to-complicated-run-yaml>")
|
||||
|
||||
@pipeline
|
||||
def pipeline_func_with_flow(data):
|
||||
flow_node = flow_component(
|
||||
data=data,
|
||||
url="${data.url}",
|
||||
connections={
|
||||
"summarize_text_content": {
|
||||
"connection": "azure_open_ai_connection",
|
||||
"deployment_name": "text-davinci-003",
|
||||
},
|
||||
},
|
||||
environment_variables={
|
||||
"AZURE_OPENAI_API_KEY": "${my_connection.api_key}",
|
||||
"AZURE_OPENAI_API_BASE": "${my_connection.api_base}",
|
||||
}
|
||||
)
|
||||
flow_node.compute = "cpu-cluster"
|
||||
flow_node.instance_count = 2
|
||||
flow_node.max_concurrency_per_instance = 2
|
||||
flow_node.mini_batch_error_threshold = 5
|
||||
flow_node.retry_settings = RetrySettings(timeout=30, max_retries=5)
|
||||
|
||||
pipeline_with_flow = pipeline_func_with_flow(data=data_input)
|
||||
|
||||
pipeline_job = ml_client.jobs.create_or_update(pipeline_with_flow)
|
||||
ml_client.jobs.stream(pipeline_job.name)
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
::::
|
||||
|
||||
## Environment of the component
|
||||
|
||||
By default, the environment of the created component will be based on the latest promptflow runtime image. If customer has [specified python requirement file](../../reference/flow-yaml-schema-reference.md) in `flow.dag.yaml`, they will be applied to the environment automatically:
|
||||
|
||||
``` yaml
|
||||
...
|
||||
environment:
|
||||
python_requirements_txt: requirements.txt
|
||||
```
|
||||
|
||||
If customer want to use an existing Azure ML environment or define the environment in Azure ML style, they can define it in `run.yaml` like below:
|
||||
|
||||
```yaml
|
||||
$schema: https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json
|
||||
flow: <my-flow-directory>
|
||||
azureml:
|
||||
environment: azureml:my-environment:1
|
||||
```
|
||||
|
||||
For more details about the supported format of Azure ML environment, please refer to [this doc](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-manage-environments-v2?view=azureml-api-2&tabs=cli).
|
||||
|
||||
## Difference across flow in prompt flow and pipeline job
|
||||
|
||||
In prompt flow, flow runs on compute session, which is designed for prompt flow; while in pipeline job, flow runs on different types of compute, and usually compute cluster.
|
||||
|
||||
Given above, if your flow has logic relying on identity or environment variable, please be aware of this difference as you might run into some unexpected error(s) when the flow runs in pipeline job, and you might need some extra configurations to make it work.
|
||||
|
||||
## Component ports and run settings
|
||||
|
||||
### Input ports
|
||||
|
||||
| key | source | type | description |
|
||||
| ----------- | ------ | ---------------------- | ------------------------------------------------------------ |
|
||||
| data | fixed | uri_folder or uri_file | required; to pass in input data. Supported format includes [`mltable`](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-mltable?view=azureml-api-2&tabs=cli#authoring-mltable-files) and list of jsonl files. |
|
||||
| run_outputs | fixed | uri_folder | optional; to pass in output of a standard flow for [an evaluation flow](../../how-to-guides/develop-a-dag-flow/develop-evaluation-flow.md). Should be linked to a `flow_outputs` of a previous flow node in the pipeline. |
|
||||
|
||||
### Output ports
|
||||
|
||||
| key | source | type | description |
|
||||
| ------------ | ------ | ---------- | ------------------------------------------------------------ |
|
||||
| flow_outputs | fixed | uri_folder | an uri_folder with 1 or more jsonl files containing outputs of the flow runs |
|
||||
| debug_info | fixed | uri_folder | an uri_folder containing debug information of the flow run, e.g., run logs |
|
||||
|
||||
### Parameters
|
||||
|
||||
| key | source | type | description |
|
||||
| --------------------------------------------------- | ------------------------------------------------ | ------ | ------------------------------------------------------------ |
|
||||
| \<flow-input-name\> | from flow inputs | string | default value will be inherited from flow inputs; used to override [column mapping](../../how-to-guides/run-and-evaluate-a-flow/use-column-mapping.md) for flow inputs. |
|
||||
| connections.\<node-name\>.connection | from nodes of built-in LLM tools | string | default value will be current value defined in `flow.dag.yaml` or `run.yaml`; to override used connections of corresponding nodes. Connection should exist in current workspace. |
|
||||
| connections.\<node-name\>.deployment_name | from nodes of built-in LLM tools | string | default value will be current value defined in `flow.dag.yaml` or `run.yaml`; to override target deployment names of corresponding nodes. Deployment should be available with provided connection. |
|
||||
| connections.\<node-name\>.\<node-input-key\> | from nodes with `Connection` inputs | string | default value will be current value defined in `flow.dag.yaml` or `run.yaml`; to override used connections of corresponding nodes. Connection should exist in current workspace. |
|
||||
| environment_variables.\<environment-variable-name\> | from environment variables defined in `run.yaml` | string | default value will be the current value defined in `run.yaml`; to override environment variables during flow run, e.g. AZURE_OPENAI_API_KEY. Note that you can refer to workspace connections with expressions like `{my_connection.api_key}`. |
|
||||
|
||||
### Run settings
|
||||
|
||||
| key | type | Description |
|
||||
| ---------------------------- | ----------------------- | ------------------------------------------------------------ |
|
||||
| instance_count | integer | The number of nodes to use for the job. Default value is 1. |
|
||||
| max_concurrency_per_instance | integer | The number of processors on each node. |
|
||||
| mini_batch_error_threshold | integer | Define the number of failed mini batches that could be ignored in this parallel job. If the count of failed mini-batch is higher than this threshold, the parallel job will be marked as failed.<br/><br/>Mini-batch is marked as failed if:<br/>- the count of return from run() is less than mini-batch input count.<br/>- catch exceptions in custom run() code.<br/><br/>"-1" is the default number, which means to ignore all failed mini-batch during parallel job. |
|
||||
| retry_settings.max_retries | integer | Define the number of retries when mini-batch is failed or timeout. If all retries are failed, the mini-batch will be marked as failed to be counted by `mini_batch_error_threshold` calculation. |
|
||||
| retry_settings.timeout | integer | Define the timeout in seconds for executing custom run() function. If the execution time is higher than this threshold, the mini-batch will be aborted, and marked as a failed mini-batch to trigger retry. |
|
||||
| logging_level | INFO, WARNING, or DEBUG | Define which level of logs will be dumped to user log files. |
|
||||
|
||||
Check [the official document of parallel component](https://learn.microsoft.com/en-us/azure/machine-learning/how-to-use-parallel-job-in-pipeline?view=azureml-api-2&tabs=cliv2) for more run settings.
|
||||
@@ -0,0 +1,51 @@
|
||||
# Cloud
|
||||
|
||||
Prompt flow streamlines the process of developing AI applications based on LLM, easing prompt engineering, prototyping, evaluating, and fine-tuning for high-quality products.
|
||||
|
||||
Transitioning to production, however, typically requires a comprehensive **LLMOps** process, LLMOps is short for large language model operations. This can often be a complex task, demanding high availability and security, particularly vital for large-scale team collaboration and lifecycle management when deploying to production.
|
||||
|
||||
To assist in this journey, we've introduced **Azure AI**, a **cloud-based platform** tailored for executing LLMOps, focusing on boosting productivity for enterprises.
|
||||
|
||||
* Private data access and controls
|
||||
* Collaborative development
|
||||
* Automating iterative experimentation and CI/CD
|
||||
* Deployment and optimization
|
||||
* Safe and Responsible AI
|
||||
|
||||

|
||||
|
||||
## Transitioning from local to cloud (Azure AI)
|
||||
|
||||
In prompt flow, You can develop your flow locally and then seamlessly transition to Azure AI. Here are a few scenarios where this might be beneficial:
|
||||
| Scenario | Benefit | How to|
|
||||
| --- | --- |--- |
|
||||
| Collaborative development | Azure AI provides a cloud-based platform for flow development and management, facilitating sharing and collaboration across multiple teams, organizations, and tenants.| [Submit a run using pfazure](./azureai/run-promptflow-in-azure-ai.md), based on the flow file in your code base.|
|
||||
| Processing large amounts of data in parallel pipelines | Transitioning to Azure AI allows you to use your flow as a parallel component in a pipeline job, enabling you to process large amounts of data and integrate with existing pipelines. | Learn how to [Use flow in Azure ML pipeline job](./azureai/use-flow-in-azure-ml-pipeline.md).|
|
||||
| Large-scale Deployment | Azure AI allows for seamless deployment and optimization when your flow is ready for production and requires high availability and security. | Use `pf flow build` to deploy your flow to [Azure App Service](./azureai/deploy-to-azure-appservice.md).|
|
||||
| Data Security and Responsible AI Practices | If your flow handling sensitive data or requiring ethical AI practices, Azure AI offers robust security, responsible AI services, and features for data storage, identity, and access control. | Follow the steps mentioned in the above scenarios.|
|
||||
|
||||
|
||||
For more resources on Azure AI, visit the cloud documentation site: [Build AI solutions with prompt flow](https://learn.microsoft.com/en-us/azure/machine-learning/prompt-flow/get-started-prompt-flow?view=azureml-api-2).
|
||||
|
||||
```{toctree}
|
||||
:caption: Flow
|
||||
:maxdepth: 2
|
||||
azureai/manage-flows
|
||||
azureai/run-promptflow-in-azure-ai
|
||||
azureai/create-run-with-compute-session
|
||||
azureai/use-flow-in-azure-ml-pipeline
|
||||
azureai/generate-test-data-cloud.md
|
||||
```
|
||||
|
||||
```{toctree}
|
||||
:caption: Deployment
|
||||
:maxdepth: 2
|
||||
azureai/deploy-to-azure-appservice
|
||||
```
|
||||
```{toctree}
|
||||
:caption: FAQ
|
||||
:maxdepth: 2
|
||||
azureai/faq
|
||||
azureai/consume-connections-from-azure-ai
|
||||
azureai/runtime-change-log.md
|
||||
```
|
||||
Reference in New Issue
Block a user