Skip to content

Commit b31a95b

Browse files
authored
Load testing for vision (#1633)
1 parent 414b1a9 commit b31a95b

File tree

3 files changed

+137
-63
lines changed

3 files changed

+137
-63
lines changed

CONTRIBUTING.md

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This project welcomes contributions and suggestions. Most contributions require you to agree to a
44
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5-
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
5+
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.
66

77
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
88
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
@@ -12,122 +12,129 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
1212
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
1313
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
1414

15-
- [Code of Conduct](#coc)
16-
- [Issues and Bugs](#issue)
17-
- [Feature Requests](#feature)
18-
- [Submitting a PR](#submit-pr)
19-
- [Running Tests](#tests)
20-
- [Code Style](#style)
15+
- [Code of Conduct](#code-of-conduct)
16+
- [Found an Issue?](#found-an-issue)
17+
- [Want a Feature?](#want-a-feature)
18+
- [Submission Guidelines](#submission-guidelines)
19+
- [Submitting an Issue](#submitting-an-issue)
20+
- [Submitting a Pull Request (PR)](#submitting-a-pull-request-pr)
21+
- [Setting up the development environment](#setting-up-the-development-environment)
22+
- [Running unit tests](#running-unit-tests)
23+
- [Running E2E tests](#running-e2e-tests)
24+
- [Code Style](#code-style)
25+
26+
## Code of Conduct
2127

22-
## <a name="coc"></a> Code of Conduct
2328
Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
2429

25-
## <a name="issue"></a> Found an Issue?
30+
## Found an Issue?
31+
2632
If you find a bug in the source code or a mistake in the documentation, you can help us by
27-
[submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can
28-
[submit a Pull Request](#submit-pr) with a fix.
33+
[submitting an issue](#submitting-an-issue) to the GitHub Repository. Even better, you can
34+
[submit a Pull Request](#submitting-a-pull-request-pr) with a fix.
35+
36+
## Want a Feature?
2937

30-
## <a name="feature"></a> Want a Feature?
31-
You can *request* a new feature by [submitting an issue](#submit-issue) to the GitHub
38+
You can *request* a new feature by [submitting an issue](#submitting-an-issue) to the GitHub
3239
Repository. If you would like to *implement* a new feature, please submit an issue with
3340
a proposal for your work first, to be sure that we can use it.
3441

35-
* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
42+
- **Small Features** can be crafted and directly [submitted as a Pull Request](#submitting-a-pull-request-pr).
3643

37-
## <a name="submit"></a> Submission Guidelines
44+
## Submission Guidelines
45+
46+
### Submitting an Issue
3847

39-
### <a name="submit-issue"></a> Submitting an Issue
4048
Before you submit an issue, search the archive, maybe your question was already answered.
4149

4250
If your issue appears to be a bug, and hasn't been reported, open a new issue.
4351
Help us to maximize the effort we can spend fixing issues and adding new
4452
features, by not reporting duplicate issues. Providing the following information will increase the
4553
chances of your issue being dealt with quickly:
4654

47-
* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
48-
* **Version** - what version is affected (e.g. 0.1.2)
49-
* **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
50-
* **Browsers and Operating System** - is this a problem with all browsers?
51-
* **Reproduce the Error** - provide a live example or a unambiguous set of steps
52-
* **Related Issues** - has a similar issue been reported before?
53-
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
55+
- **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
56+
- **Version** - what version is affected (e.g. 0.1.2)
57+
- **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
58+
- **Browsers and Operating System** - is this a problem with all browsers?
59+
- **Reproduce the Error** - provide a live example or a unambiguous set of steps
60+
- **Related Issues** - has a similar issue been reported before?
61+
- **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
5462
causing the problem (line of code or commit)
5563

56-
You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/[organization-name]/[repository-name]/issues/new].
64+
You can file new issues by providing the above information at the corresponding repository's issues link: <https://github.com/[organization-name>]/[repository-name]/issues/new].
65+
66+
### Submitting a Pull Request (PR)
5767

58-
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
5968
Before you submit your Pull Request (PR) consider the following guidelines:
6069

61-
* Search the repository (https://github.com/[organization-name]/[repository-name]/pulls) for an open or closed PR
70+
- Search the repository (<https://github.com/[organization-name>]/[repository-name]/pulls) for an open or closed PR
6271
that relates to your submission. You don't want to duplicate effort.
63-
* Make your changes in a new git fork
64-
* Follow [Code style conventions](#style)
65-
* [Run the tests](#tests) (and write new ones, if needed)
66-
* Commit your changes using a descriptive commit message
67-
* Push your fork to GitHub
68-
* In GitHub, create a pull request to the `main` branch of the repository
69-
* Ask a maintainer to review your PR and address any comments they might have
72+
- Make your changes in a new git fork
73+
- Follow [Code style conventions](#code-style)
74+
- [Run the tests](#running-unit-tests) (and write new ones, if needed)
75+
- Commit your changes using a descriptive commit message
76+
- Push your fork to GitHub
77+
- In GitHub, create a pull request to the `main` branch of the repository
78+
- Ask a maintainer to review your PR and address any comments they might have
7079

71-
## <a name="tests"></a> Setting up the development environment
80+
## Setting up the development environment
7281

7382
Install the development dependencies:
7483

75-
```
76-
python3 -m pip install -r requirements-dev.txt
84+
```shell
85+
python -m pip install -r requirements-dev.txt
7786
```
7887

7988
Install the pre-commit hooks:
8089

81-
```
90+
```shell
8291
pre-commit install
8392
```
8493

8594
Compile the JavaScript:
8695

87-
```
96+
```shell
8897
( cd ./app/frontend ; npm install ; npm run build )
8998
```
9099

91-
## <a name="unit-tests"></a> Running unit tests
100+
## Running unit tests
92101

93102
Run the tests:
94103

95-
```
96-
python3 -m pytest
104+
```shell
105+
python -m pytest
97106
```
98107

99108
Check the coverage report to make sure your changes are covered.
100109

110+
```shell
111+
python -m pytest --cov
101112
```
102-
python3 -m pytest --cov
103-
```
104-
105-
## <a name="e2e-tests"></a> Running E2E tests
106113

114+
## Running E2E tests
107115

108116
Install Playwright browser dependencies:
109117

110-
```
118+
```shell
111119
playwright install --with-deps
112120
```
113121

114122
Run the tests:
115123

116-
```
117-
python3 -m pytest tests/e2e.py --tracing=retain-on-failure
124+
```shell
125+
python -m pytest tests/e2e.py --tracing=retain-on-failure
118126
```
119127

120128
When a failure happens, the trace zip will be saved in the test-results folder.
121129
You can view that using the Playwright CLI:
122130

123-
```
131+
```shell
124132
playwright show-trace test-results/<trace-zip>
125133
```
126134

127-
You can also use the online trace viewer at https://trace.playwright.dev/
135+
You can also use the online trace viewer at <https://trace.playwright.dev/>
128136

129-
130-
## <a name="style"></a> Code Style
137+
## Code Style
131138

132139
This codebase includes several languages: TypeScript, Python, Bicep, Powershell, and Bash.
133140
Code should follow the standard conventions of each language.
@@ -136,20 +143,20 @@ For Python, you can enforce the conventions using `ruff` and `black`.
136143

137144
Install the development dependencies:
138145

139-
```
140-
python3 -m pip install -r requirements-dev.txt
146+
```shell
147+
python -m pip install -r requirements-dev.txt
141148
```
142149

143150
Run `ruff` to lint a file:
144151

145-
```
146-
python3 -m ruff <path-to-file>
152+
```shell
153+
python -m ruff <path-to-file>
147154
```
148155

149156
Run `black` to format a file:
150157

151-
```
152-
python3 -m black <path-to-file>
158+
```shell
159+
python -m black <path-to-file>
153160
```
154161

155162
If you followed the steps above to install the pre-commit hooks, then you can just wait for those hooks to run `ruff` and `black` for you.

docs/productionizing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,22 @@ or set up a loadtest with Azure Load Testing.
7373
To use locust, first install the dev requirements that includes locust:
7474

7575
```shell
76-
python3 -m pip install -r requirements-dev.txt
76+
python -m pip install -r requirements-dev.txt
7777
```
7878

7979
Or manually install locust:
8080

8181
```shell
82-
python3 -m pip install locust
82+
python -m pip install locust
8383
```
8484

85-
Then run the locust command:
85+
Then run the locust command, specifying the name of the User class to use from `locustfile.py`. We've provided a `ChatUser` class that simulates a user asking questions and receiving answers, as well as a `ChatVisionUser` to simulate a user asking questions with the [GPT-4 vision mode enabled](/docs/gpt4v.md).
8686

8787
```shell
88-
locust
88+
locust ChatUser
8989
```
9090

91-
Open the locust UI at http://localhost:8089/, the URI displayed in the terminal.
91+
Open the locust UI at [http://localhost:8089/](http://localhost:8089/), the URI displayed in the terminal.
9292

9393
Start a new test with the URI of your website, e.g. `https://my-chat-app.azurewebsites.net`.
9494
Do *not* end the URI with a slash. You can start by pointing at your localhost if you're concerned

locustfile.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,70 @@ def ask_question(self):
6161
},
6262
},
6363
)
64+
65+
66+
class ChatVisionUser(HttpUser):
67+
wait_time = between(5, 20)
68+
69+
@task
70+
def ask_question(self):
71+
self.client.get("/")
72+
time.sleep(5)
73+
self.client.post(
74+
"/chat",
75+
json={
76+
"messages": [
77+
{
78+
"content": "Can you identify any correlation between oil prices and stock market trends?",
79+
"role": "user",
80+
}
81+
],
82+
"stream": True,
83+
"context": {
84+
"overrides": {
85+
"top": 3,
86+
"temperature": 0.3,
87+
"minimum_reranker_score": 0,
88+
"minimum_search_score": 0,
89+
"retrieval_mode": "hybrid",
90+
"semantic_ranker": True,
91+
"semantic_captions": False,
92+
"suggest_followup_questions": False,
93+
"use_oid_security_filter": False,
94+
"use_groups_security_filter": False,
95+
"vector_fields": ["embedding", "imageEmbedding"],
96+
"use_gpt4v": True,
97+
"gpt4v_input": "textAndImages",
98+
}
99+
},
100+
"session_state": None,
101+
},
102+
)
103+
time.sleep(5)
104+
self.client.post(
105+
"/chat",
106+
json={
107+
"messages": [
108+
{"content": "Compare the impact of interest rates and GDP in financial markets.", "role": "user"}
109+
],
110+
"stream": True,
111+
"context": {
112+
"overrides": {
113+
"top": 3,
114+
"temperature": 0.3,
115+
"minimum_reranker_score": 0,
116+
"minimum_search_score": 0,
117+
"retrieval_mode": "hybrid",
118+
"semantic_ranker": True,
119+
"semantic_captions": False,
120+
"suggest_followup_questions": False,
121+
"use_oid_security_filter": False,
122+
"use_groups_security_filter": False,
123+
"vector_fields": ["embedding", "imageEmbedding"],
124+
"use_gpt4v": True,
125+
"gpt4v_input": "textAndImages",
126+
}
127+
},
128+
"session_state": None,
129+
},
130+
)

0 commit comments

Comments
 (0)