Skip to content

Commit 354b166

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents c69de56 + 578c6c2 commit 354b166

File tree

75 files changed

+1039
-1499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1039
-1499
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 234 additions & 408 deletions
Large diffs are not rendered by default.

.evergreen/generated_configs/variants.yml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ buildvariants:
146146
COMPRESSOR: zlib
147147
- name: compression-zstd-rhel8
148148
tasks:
149-
- name: .test-standard !.server-4.0
149+
- name: .test-standard !.server-4.2
150150
display_name: Compression zstd RHEL8
151151
run_on:
152152
- rhel87-small
@@ -522,13 +522,6 @@ buildvariants:
522522
PYTHON_BINARY: /opt/python/3.9/bin/python3
523523

524524
# Server version tests
525-
- name: mongodb-v4.0
526-
tasks:
527-
- name: .server-version
528-
display_name: "* MongoDB v4.0"
529-
run_on:
530-
- rhel87-small
531-
tags: [coverage_tag]
532525
- name: mongodb-v4.2
533526
tasks:
534527
- name: .server-version
@@ -664,11 +657,3 @@ buildvariants:
664657
- rhel87-small
665658
expansions:
666659
STORAGE_ENGINE: inmemory
667-
- name: storage-mmapv1-rhel8
668-
tasks:
669-
- name: .test-standard !.sharded_cluster-auth-ssl .server-4.0
670-
display_name: Storage MMAPv1 RHEL8
671-
run_on:
672-
- rhel87-small
673-
expansions:
674-
STORAGE_ENGINE: mmapv1

.evergreen/resync-specs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ do
131131
gridfs)
132132
cpjson gridfs/tests gridfs
133133
;;
134+
handshake)
135+
cpjson mongodb-handshake/tests handshake
136+
;;
134137
index|index-management)
135138
cpjson index-management/tests index_management
136139
;;

.evergreen/scripts/generate_config.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
get_task_name,
2626
get_variant_name,
2727
get_versions_from,
28-
get_versions_until,
2928
handle_c_ext,
3029
write_functions_to_file,
3130
write_tasks_to_file,
@@ -196,7 +195,7 @@ def create_compression_variants():
196195
for compressor in "snappy", "zlib", "zstd":
197196
expansions = dict(COMPRESSOR=compressor)
198197
if compressor == "zstd":
199-
tasks = [".test-standard !.server-4.0"]
198+
tasks = [".test-standard !.server-4.2"]
200199
else:
201200
tasks = [".test-standard"]
202201
display_name = get_variant_name(f"Compression {compressor}", host)
@@ -249,16 +248,11 @@ def create_pyopenssl_variants():
249248

250249
def create_storage_engine_variants():
251250
host = DEFAULT_HOST
252-
engines = ["InMemory", "MMAPv1"]
251+
engines = ["InMemory"]
253252
variants = []
254253
for engine in engines:
255254
expansions = dict(STORAGE_ENGINE=engine.lower())
256-
if engine == engines[0]:
257-
tasks = [".test-standard .standalone-noauth-nossl"]
258-
else:
259-
# MongoDB 4.2 drops support for MMAPv1
260-
versions = get_versions_until("4.0")
261-
tasks = [f".test-standard !.sharded_cluster-auth-ssl .server-{v}" for v in versions]
255+
tasks = [".test-standard .standalone-noauth-nossl"]
262256
display_name = get_variant_name(f"Storage {engine}", host)
263257
variant = create_variant(tasks, display_name, host=host, expansions=expansions)
264258
variants.append(variant)

.evergreen/scripts/generate_config_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Globals
2222
##############
2323

24-
ALL_VERSIONS = ["4.0", "4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
24+
ALL_VERSIONS = ["4.2", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
2525
CPYTHONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
2626
PYPYS = ["pypy3.10"]
2727
ALL_PYTHONS = CPYTHONS + PYPYS

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @mongodb/dbx-python

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Initializes the CodeQL tools for scanning.
4848
- name: Initialize CodeQL
49-
uses: github/codeql-action/init@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3
49+
uses: github/codeql-action/init@39edc492dbe16b1465b0cafca41432d857bdb31a # v3
5050
with:
5151
languages: ${{ matrix.language }}
5252
build-mode: ${{ matrix.build-mode }}
@@ -63,6 +63,6 @@ jobs:
6363
pip install -e .
6464
6565
- name: Perform CodeQL Analysis
66-
uses: github/codeql-action/analyze@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3
66+
uses: github/codeql-action/analyze@39edc492dbe16b1465b0cafca41432d857bdb31a # v3
6767
with:
6868
category: "/language:${{matrix.language}}"

.github/workflows/test-python.yml

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install just
2626
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
2727
- name: Install uv
28-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
28+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
2929
with:
3030
enable-cache: true
3131
python-version: "3.9"
@@ -65,7 +65,7 @@ jobs:
6565
- name: Install just
6666
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
6767
- name: Install uv
68-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
68+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
6969
with:
7070
enable-cache: true
7171
python-version: ${{ matrix.python-version }}
@@ -88,7 +88,7 @@ jobs:
8888
- name: Install just
8989
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
9090
- name: Install uv
91-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
91+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
9292
with:
9393
enable-cache: true
9494
python-version: "3.9"
@@ -111,7 +111,7 @@ jobs:
111111
with:
112112
persist-credentials: false
113113
- name: Install uv
114-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
114+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
115115
with:
116116
enable-cache: true
117117
python-version: "3.9"
@@ -130,7 +130,7 @@ jobs:
130130
with:
131131
persist-credentials: false
132132
- name: Install uv
133-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
133+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
134134
with:
135135
enable-cache: true
136136
python-version: "3.9"
@@ -152,7 +152,7 @@ jobs:
152152
with:
153153
persist-credentials: false
154154
- name: Install uv
155-
uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v5
155+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
156156
with:
157157
enable-cache: true
158158
python-version: "${{matrix.python}}"
@@ -220,3 +220,55 @@ jobs:
220220
which python
221221
pip install -e ".[test]"
222222
PYMONGO_MUST_CONNECT=1 pytest -v -k client_context
223+
224+
test_minimum:
225+
permissions:
226+
contents: read
227+
runs-on: ubuntu-latest
228+
name: Test using minimum dependencies and supported Python
229+
steps:
230+
- uses: actions/checkout@v4
231+
with:
232+
persist-credentials: false
233+
- name: Install uv
234+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
235+
with:
236+
python-version: '3.9'
237+
- name: Start MongoDB
238+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0
239+
with:
240+
mongodb-version: 6.0
241+
# Async and our test_dns do not support dnspython 1.X, so we don't run async or dns tests here
242+
- name: Run tests
243+
shell: bash
244+
run: |
245+
uv venv
246+
source .venv/bin/activate
247+
uv pip install -e ".[test]" --resolution=lowest-direct
248+
pytest -v test/test_srv_polling.py
249+
250+
test_minimum_for_async:
251+
permissions:
252+
contents: read
253+
runs-on: ubuntu-latest
254+
name: Test async's minimum dependencies and Python
255+
steps:
256+
- uses: actions/checkout@v4
257+
with:
258+
persist-credentials: false
259+
- name: Install uv
260+
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v5
261+
with:
262+
python-version: '3.9'
263+
- name: Start MongoDB
264+
uses: supercharge/mongodb-github-action@90004df786821b6308fb02299e5835d0dae05d0d # 1.12.0
265+
with:
266+
mongodb-version: 6.0
267+
# The lifetime kwarg we use in srv resolution was added to the async resolver API in dnspython 2.1.0
268+
- name: Run tests
269+
shell: bash
270+
run: |
271+
uv venv
272+
source .venv/bin/activate
273+
uv pip install -e ".[test]" --resolution=lowest-direct dnspython==2.1.0 --force-reinstall
274+
pytest -v test/test_srv_polling.py test/test_dns.py test/asynchronous/test_srv_polling.py test/asynchronous/test_dns.py

.github/workflows/zizmor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ jobs:
1818
with:
1919
persist-credentials: false
2020
- name: Setup Rust
21-
uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1
21+
uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1
2222
- name: Get zizmor
2323
run: cargo install zizmor
2424
- name: Run zizmor 🌈
2525
run: zizmor --format sarif . > results.sarif
2626
env:
2727
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2828
- name: Upload SARIF file
29-
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3
29+
uses: github/codeql-action/upload-sarif@39edc492dbe16b1465b0cafca41432d857bdb31a # v3
3030
with:
3131
sarif_file: results.sarif
3232
category: zizmor

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,3 +460,15 @@ partially-converted asynchronous version of the same name to the `test/asynchron
460460
Use this generated file as a starting point for the completed conversion.
461461

462462
The script is used like so: `python tools/convert_test_to_async.py [test_file.py]`
463+
464+
## Generating a flame graph using py-spy
465+
To profile a test script and generate a flame graph, follow these steps:
466+
1. Install `py-spy` if you haven't already:
467+
```bash
468+
pip install py-spy
469+
```
470+
2. Inside your test script, perform any required setup and then loop over the code you want to profile for improved sampling.
471+
3. Run `py-spy record -o <output.svg> -r <sample_rate=100> -- python <path/to/script>` to generate a `.svg` file containing the flame graph.
472+
(Note: on macOS you will need to run this command using `sudo` to allow `py-spy` to attach to the Python process.)
473+
4. If you need to include native code (for example the C extensions), profiling should be done on a Linux system, as macOS and Windows do not support the `--native` option of `py-spy`.
474+
Creating an ubuntu Evergreen spawn host and using `scp` to copy the flamegraph `.svg` file back to your local machine is the best way to do this.

0 commit comments

Comments
 (0)