forked from microsoft/promptflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Description Copy the setup doc from azure devops to github repo # 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
1 parent
9306494
commit 1da0b56
Showing
11 changed files
with
161 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,120 @@ | ||
# Dev Steup | ||
WIP | ||
|
||
## Set up process | ||
|
||
- First create a new [conda](https://conda.io/projects/conda/en/latest/user-guide/getting-started.html) environment. Please specify python version as 3.9. | ||
`conda create -n <envname> python=3.9`. | ||
- Activate the env you created. | ||
- Set environment variable `PYTHONPATH` in your new conda environment. | ||
`conda env config vars set PYTHONPATH=<path-to-src\promptflow>`. | ||
Once you have set the environment variable, you have to reactivate your environment. | ||
`conda activate <envname>`. | ||
- In root folder, run `python scripts/building/dev_setup.py --promptflow-extra-deps azure` to install the package and dependencies. | ||
|
||
## How to run tests | ||
|
||
### Set up your secrets | ||
|
||
`dev-connections.json.example` is a template about connections provided in `src/promptflow`. You can follow these steps to refer to this template to configure your connection for the test cases: | ||
1. `cd ./src/promptflow` | ||
2. Run the command `cp dev-connections.json.example connections.json`; | ||
3. Replace the values in the json file with your connection info; | ||
4. Set the environment `PROMPTFLOW_CONNECTIONS='connections.json'`; | ||
|
||
After above setup process is finished. You can use `pytest` command to run test, for example in root folder you can: | ||
|
||
### Run tests via command | ||
|
||
- Run all tests under a folder: `pytest src/promptflow/tests -v` | ||
- Run a single test: ` pytest src/promptflow/tests/promptflow_test/e2etests/test_executor.py::TestExecutor::test_executor_basic_flow -v` | ||
|
||
### Run tests in VSCode | ||
|
||
1. Set up your python interperter | ||
|
||
- Open the Command Palette (Ctrl+Shift+P) and select `Python: Select Interpreter`. | ||
|
||
 | ||
|
||
- Select existing conda env which you created previously. | ||
|
||
 | ||
|
||
2. Set up your test framework and directory | ||
|
||
- Open the Command Palette (Ctrl+Shift+P) and select `Python: Configure Tests`. | ||
|
||
 | ||
|
||
- Select `pytest` as test framework. | ||
|
||
 | ||
|
||
- Select `Root directory` as test directory. | ||
|
||
 | ||
|
||
3. Click the `Run Test` button on the left | ||
|
||
 | ||
|
||
### Run tests in pycharm | ||
|
||
1. Set up your pycharm python interpreter | ||
|
||
 | ||
|
||
2. Select existing conda env which you created previously | ||
|
||
 | ||
|
||
3. Run test, right-click the test name to run, or click the green arrow button on the left. | ||
|
||
 | ||
|
||
## How to write tests | ||
|
||
- Put all test data/configs under `src/promptflow/tests/test_configs`. | ||
- Write unit tests: | ||
- Flow run in local: `src/promptflow/tests/sdk_cli_test/unittest/` | ||
- Flow run in azure: `src/promptflow/tests/sdk_cli_azure_test/unittest/` | ||
- Write e2e tests: | ||
- Flow run in local: `src/promptflow/tests/sdk_cli_test/e2etests/` | ||
- Flow run in azure: `src/promptflow/tests/sdk_cli_azure_test/e2etests/` | ||
- Test file name and the test case name all start with `test_`. | ||
- A basic test example, see [test_connection.py](../../src/promptflow/tests/sdk_cli_test/e2etests/test_connection.py). | ||
|
||
### Test structure | ||
|
||
Currently all tests are under `src/promptflow/tests/` folder: | ||
|
||
- tests/ | ||
- promptflow/ | ||
- sdk_cli_test/ | ||
- e2etests/ | ||
- unittests/ | ||
- sdk_cli_azure_test/ | ||
- e2etests/ | ||
- unittests/ | ||
- test_configs/ | ||
- connections/ | ||
- datas/ | ||
- flows/ | ||
- runs/ | ||
- wrong_flows/ | ||
- wrong_tools/ | ||
|
||
When you want to add tests for a new feature, you can add new test file let's say a e2e test file `test_construction.py` | ||
under `tests/promptflow/**/e2etests/`. | ||
|
||
Once the project gets more complicated or anytime you find it necessary to add new test folder and test configs for | ||
a specific feature, feel free to split the `promptflow` to more folders, for example: | ||
|
||
- tests/ | ||
- <Test folder name>/ | ||
- e2etests/ | ||
- test_xxx.py | ||
- unittests/ | ||
- test_xxx.py | ||
- test_configs/ | ||
- <Data or config folder name>/ |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import argparse | ||
from pathlib import Path | ||
from platform import system | ||
|
||
from utils import print_blue, run_command | ||
|
||
|
||
def setup_promptflow(extra_deps: list, command_args: dict) -> None: | ||
print_blue("- Setting up the promptflow SDK ") | ||
print_blue("- Installing promptflow Python SDK from local directory") | ||
package_location = f"{Path('./src/promptflow/').absolute()}" | ||
if extra_deps: | ||
print_blue(f"- Installing with extra dependencies: {extra_deps}") | ||
extra_deps = ",".join(extra_deps) | ||
package_location = f"{package_location}[{extra_deps}]" | ||
cmds = ["pip", "install", "-e", package_location] | ||
print_blue(f"Running {cmds}") | ||
run_command(commands=cmds, **command_args) | ||
run_command( | ||
commands=["pip", "install", "-r", str(Path("./src/promptflow/dev_requirements.txt").absolute())], | ||
**command_args, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
epilog = """ | ||
Sample Usages: | ||
python scripts/building/dev_setup.py | ||
python scripts/building/dev_setup.py --promptflow-extra-deps azure | ||
""" | ||
parser = argparse.ArgumentParser( | ||
description="Welcome to promptflow dev setup!", | ||
epilog=epilog, | ||
) | ||
parser.add_argument( | ||
"--promptflow-extra-deps", required=False, nargs="+", type=str, help="extra dependencies for promptflow" | ||
) | ||
parser.add_argument("-v", "--verbose", action="store_true", required=False, help="turn on verbose output") | ||
args = parser.parse_args() | ||
|
||
command_args = {"shell": system() == "Windows", "stream_stdout": args.verbose} | ||
setup_promptflow(extra_deps=args.promptflow_extra_deps, command_args=command_args) |