Skip to content

Commit

Permalink
doc: pf validate
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotzh committed Oct 20, 2023
1 parent 8e1f786 commit 8f56ec7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
16 changes: 11 additions & 5 deletions docs/how-to-guides/use-flow-in-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ After you have developed and tested the flow in [init and test a flow](./init-an
:::{admonition} Pre-requirements
- Customer need to install the extension `ml>=2.21.0` to enable this feature in CLI and package `azure-ai-ml>=1.11.0` to enable this feature in SDK;
- Customer need to put `$schema` in the target `flow.dag.yaml` to enable this feature;
- Customer need to generate `flow.tools.json` for the target flow before below usage. Usually the generation can be done by `pf flow validate`.
- `flow.dag.yaml`: `$schema`: `https://azuremlschemas.azureedge.net/promptflow/latest/Flow.schema.json`
- `run.yaml`: `$schema`: `https://azuremlschemas.azureedge.net/promptflow/latest/Run.schema.json`
- Customer need to generate `flow.tools.json` for the target flow before below usage. The generation can be done by `pf flow validate`.
:::

For more information about AzureML and component:
Expand Down Expand Up @@ -46,16 +48,17 @@ from azure.ai.ml import MLClient, load_component
ml_client = MLClient()

# Register flow as a component
# Default component name will be the name of flow folder, which is web-classification here; default version will be "1"
flow_component = load_component("standard/web-classification/flow.dag.yaml")
# Default component name will be the name of flow folder, which is not a valid component name, so we override it here; default version will be "1"
flow_component.name = "web_classification"
ml_client.components.create_or_update(flow_component)

# Register flow as a component with parameters override
ml_client.components.create_or_update(
"standard/web-classification/flow.dag.yaml",
version="2",
params_override=[
{"name": "web-classification_updated"}
{"name": "web_classification_updated"}
]
)
```
Expand All @@ -69,5 +72,8 @@ After registered a flow as a component, they can be referred in a pipeline job l
## Directly use a flow in a pipeline job

Besides explicitly registering a flow as a component, customer can also directly use flow in a pipeline job:
- [CLI sample](https://github.com/Azure/azureml-examples/tree/zhangxingzhi/flow-in-pipeline/cli/jobs/pipelines-with-components/flow_in_pipeline/1a_flow_in_pipeline)
- [SDK sample](https://github.com/Azure/azureml-examples/blob/zhangxingzhi/flow-in-pipeline/sdk/python/jobs/pipelines/1l_flow_in_pipeline/flow_in_pipeline.ipynb)
- [CLI example](https://github.com/Azure/azureml-examples/tree/main/cli/jobs/pipelines-with-components/pipeline_job_with_flow_as_component)
- [SDK example](https://github.com/Azure/azureml-examples/tree/main/sdk/python/jobs/pipelines/1l_flow_in_pipeline)

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:
- [CLI/SDK example](../../examples/tutorials/flow-in-pipeline/pipeline.ipynb)
27 changes: 26 additions & 1 deletion docs/reference/pf-command-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Manage promptflow flow flows.
| --- | --- |
| [pf flow init](#pf-flow-init) | Initialize a prompt flow directory. |
| [pf flow test](#pf-flow-test) | Test the prompt flow or flow node. |
| [pf flow validate](#pf-flow-validate) | Validate a flow and generate `flow.tools.json` for it. |
| [pf flow build](#pf-flow-build) | Build a flow for further sharing or deployment. |
| [pf flow serve](#pf-flow-serve) | Serving a flow as an endpoint. |
| [pf flow serve](#pf-flow-serve) | Serve a flow as an endpoint. |

### pf flow init

Expand Down Expand Up @@ -167,6 +168,30 @@ Start a interactive chat session for chat flow.

Displays the output for each step in the chat flow.

### pf flow validate

Validate the prompt flow and generate a `flow.tools.json` under `.promptflow`. This file is required when using flow as a component in a Azure ML pipeline.

```bash
pf flow validate --source
[--debug]
[--verbose]
```

#### Examples

Validate the flow.

```bash
pf flow validate --source <path-to-flow>
```

#### Required Parameter

`--source`

The flow source to validate.

### pf flow build

Build a flow for further sharing or deployment.
Expand Down

0 comments on commit 8f56ec7

Please sign in to comment.