Skip to content

Commit

Permalink
[DOC] Supplement docs related to environment variables. (#1432)
Browse files Browse the repository at this point in the history
# Description

Supplement docs related to environment variables.

# All Promptflow Contribution checklist:
- [x] **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).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [x] 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
codingrabbitt1 authored Dec 8, 2023
1 parent 40f6f64 commit d00b7cc
Showing 1 changed file with 72 additions and 1 deletion.
73 changes: 72 additions & 1 deletion docs/how-to-guides/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,75 @@ Below is the serving logs after setting `PF_LOGGING_LEVEL` to `DEBUG`:

Compare to the serving logs with `WARNING` level:

![img](../media/how-to-guides/pf_logging_level_warning.png)
![img](../media/how-to-guides/pf_logging_level_warning.png)

### Set environment variables

Currently, promptflow supports the following environment variables:

**PF_WORKER_COUNT**

Valid for batch run only. The number of workers to use for parallel execution of the Flow.

**PF_BATCH_METHOD**

Valid for batch run only. Optional values: 'spawn', 'fork'.

**spawn**

1. The child processes will not inherit resources of the parent process, therefore, each process needs to reinitialize the resources required for the flow, which may use more system memory.

2. Starting a process is slow because it will take some time to initialize the necessary resources.

**fork**

1. Use the copy-on-write mechanism, the child processes will inherit all the resources of the parent process, thereby using less system memory.

2. The process starts faster as it doesn't need to reinitialize resources.

Note: Windows only supports spawn, Linux and macOS support both spawn and fork.


#### You can configure environment variables in the following ways

1. If you are using CLI, you can use this parameter: ```--environment-variable```. Example: ```--environment-variable PF_WORKER_COUNT="2" PF_BATCH_METHOD="spawn"```.

2. If you are using SDK, you can specify environment variables when creating run. Example:

``` python
pf = PFClient(
credential=credential,
subscription_id="<SUBSCRIPTION_ID>",
resource_group_name="<RESOURCE_GROUP>",
workspace_name="<AML_WORKSPACE_NAME>",
)

flow = "web-classification"
data = "web-classification/data.jsonl"
runtime = "example-runtime-ci"

environment_variables = {"PF_WORKER_COUNT": "2", "PF_BATCH_METHOD": "spawn"}

# create run
base_run = pf.run(
flow=flow,
data=data,
runtime=runtime,
environment_variables=environment_variables,
)
```

3. If you are using VSCode Extension to submit batch run, you can configure environment variables in the ```batch_run_create.yaml```. Example:

``` yaml
name: flow_name
display_name: display_name
flow: flow_folder
data: data_file
column_mapping:
customer_info: <Please select a data input>
history: <Please select a data input>
environment_variables:
PF_WORKER_COUNT: "2"
PF_BATCH_METHOD: "spawn"
```

0 comments on commit d00b7cc

Please sign in to comment.