Skip to content

Commit bf827d7

Browse files
committed
Merge branch 'master' of github.com:MongoEngine/mongoengine into fix_performance_issue_count
2 parents 5b53314 + ff701bd commit bf827d7

Some content is hidden

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

70 files changed

+2269
-1273
lines changed

.github/workflows/github-actions.yml

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,29 @@ on:
66
push:
77
branches:
88
- master
9+
# Manual trigger from Action page
10+
workflow_dispatch:
911
# release tags
1012
create:
1113
tags:
1214
- 'v[0-9]+\.[0-9]+\.[0-9]+*'
1315
env:
14-
MONGODB_3_6: 3.6.14
15-
MONGODB_4_0: 4.0.23
16-
MONGODB_4_2: 4.2
16+
MONGODB_3_6: 3.6.23
17+
MONGODB_4_0: 4.0.28
1718
MONGODB_4_4: 4.4
19+
MONGODB_5_0: "5.0"
20+
MONGODB_6_0: "6.0"
21+
MONGODB_7_0: "7.0"
1822

1923
PYMONGO_3_4: 3.4
2024
PYMONGO_3_6: 3.6
2125
PYMONGO_3_9: 3.9
2226
PYMONGO_3_11: 3.11
27+
PYMONGO_3_12: 3.12
28+
PYMONGO_4_0: 4.0
29+
PYMONGO_4_3: 4.3.2
30+
PYMONGO_4_4: 4.4.1
31+
PYMONGO_4_6: 4.6.0
2332

2433
MAIN_PYTHON_VERSION: 3.7
2534

@@ -29,40 +38,53 @@ jobs:
2938
# which runs pre-configured linter & autoformatter
3039
runs-on: ubuntu-latest
3140
steps:
32-
- uses: actions/checkout@v2
33-
- name: Set up Python 3.7
34-
uses: actions/setup-python@v2
41+
- uses: actions/checkout@v3
42+
- uses: actions/setup-python@v4
3543
with:
36-
python-version: 3.7
44+
python-version: '3.9'
45+
check-latest: true
3746
- run: bash .github/workflows/install_ci_python_dep.sh
3847
- run: pre-commit run -a
3948

4049
test:
4150
# Test suite run against recent python versions
4251
# and against a few combination of MongoDB and pymongo
43-
runs-on: ubuntu-latest
52+
runs-on: ubuntu-20.04
4453
strategy:
4554
fail-fast: false
4655
matrix:
47-
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
56+
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9]
4857
MONGODB: [$MONGODB_4_0]
4958
PYMONGO: [$PYMONGO_3_11]
5059
include:
5160
- python-version: 3.7
5261
MONGODB: $MONGODB_3_6
5362
PYMONGO: $PYMONGO_3_9
54-
- python-version: 3.7
55-
MONGODB: $MONGODB_4_2
56-
PYMONGO: $PYMONGO_3_6
57-
- python-version: 3.7
63+
- python-version: 3.8
5864
MONGODB: $MONGODB_4_4
5965
PYMONGO: $PYMONGO_3_11
66+
- python-version: 3.9
67+
MONGODB: $MONGODB_4_4
68+
PYMONGO: $PYMONGO_3_12
69+
- python-version: "3.10"
70+
MONGODB: $MONGODB_4_4
71+
PYMONGO: $PYMONGO_4_0
72+
- python-version: "3.11"
73+
MONGODB: $MONGODB_5_0
74+
PYMONGO: $PYMONGO_4_3
75+
- python-version: "3.11"
76+
MONGODB: $MONGODB_6_0
77+
PYMONGO: $PYMONGO_4_4
78+
- python-version: "3.11"
79+
MONGODB: $MONGODB_7_0
80+
PYMONGO: $PYMONGO_4_6
6081
steps:
61-
- uses: actions/checkout@v2
82+
- uses: actions/checkout@v3
6283
- name: Set up Python ${{ matrix.python-version }}
63-
uses: actions/setup-python@v2
84+
uses: actions/setup-python@v4
6485
with:
6586
python-version: ${{ matrix.python-version }}
87+
check-latest: true
6688
- name: install mongo and ci dependencies
6789
run: |
6890
bash .github/workflows/install_mongo.sh ${{ matrix.MONGODB }}
@@ -84,11 +106,12 @@ jobs:
84106
# to avoid that it breaks when new releases are being created
85107
runs-on: ubuntu-latest
86108
steps:
87-
- uses: actions/checkout@v2
109+
- uses: actions/checkout@v3
88110
- name: Set up Python ${{ matrix.python-version }}
89-
uses: actions/setup-python@v2
111+
uses: actions/setup-python@v4
90112
with:
91113
python-version: 3.7
114+
check-latest: true
92115
- name: install python dep
93116
run: |
94117
pip install -e .
@@ -98,46 +121,38 @@ jobs:
98121
cd docs
99122
make html-readthedocs
100123
101-
build-n-publish-dummy:
124+
build-dryrun:
102125
runs-on: ubuntu-latest
103126
needs: [linting, test, build_doc_dryrun]
104-
if: github.event_name != 'pull_request'
105127
steps:
106-
- uses: actions/checkout@master
107-
- name: Set up Python 3.7
108-
uses: actions/setup-python@v1
128+
- uses: actions/checkout@v3
129+
- uses: actions/setup-python@v4
109130
with:
110-
python-version: 3.7
131+
python-version: 3.9
132+
check-latest: true
111133
- name: build dummy wheel for test-pypi
112134
run: |
113135
pip install wheel
114-
python setup.py egg_info -b ".dev`date '+%Y%m%d%H%M%S'`" build sdist bdist_wheel
115-
# - name: publish test-pypi
116-
# # Although working and recommended, test-pypi has a limit
117-
# # in the size of projects so it's better to avoid publishing
118-
# # until there is a way to garbage collect these dummy releases
119-
# uses: pypa/gh-action-pypi-publish@master
120-
# with:
121-
# password: ${{ secrets.test_pypi_token }}
122-
# repository_url: https://test.pypi.org/legacy/
136+
python setup.py sdist bdist_wheel
123137
124138
build-n-publish:
125139
runs-on: ubuntu-latest
126-
needs: [linting, test, build_doc_dryrun, build-n-publish-dummy]
140+
needs: [linting, test, build_doc_dryrun, build-dryrun]
127141
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
128142
steps:
129-
- uses: actions/checkout@master
130-
- name: Set up Python 3.7
131-
uses: actions/setup-python@v1
143+
- uses: actions/checkout@v3
144+
- name: Set up Python 3.9
145+
uses: actions/setup-python@v4
132146
with:
133-
python-version: 3.7
147+
python-version: 3.9
148+
check-latest: true
134149
# todo separate build from publish
135150
# https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have
136151
- name: build dummy wheel for test-pypi
137152
run: |
138153
pip install wheel
139154
python setup.py sdist bdist_wheel
140155
- name: publish pypi
141-
uses: pypa/gh-action-pypi-publish@master
156+
uses: pypa/gh-action-pypi-publish@release/v1
142157
with:
143158
password: ${{ secrets.pypi_token }}

.github/workflows/install_mongo.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ if [[ "$MONGODB" == *"4.2"* ]]; then
99
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
1010
elif [[ "$MONGODB" == *"4.4"* ]]; then
1111
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
12+
elif [[ "$MONGODB" == *"5.0"* ]]; then
13+
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
14+
elif [[ "$MONGODB" == *"6.0"* ]]; then
15+
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
16+
elif [[ "$MONGODB" == *"7.0"* ]]; then
17+
mongo_build=mongodb-linux-x86_64-ubuntu2004-v${MONGODB}-latest
1218
fi
1319

1420
wget http://fastdl.mongodb.org/linux/$mongo_build.tgz

.pre-commit-config.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
fail_fast: false
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v3.4.0
4+
rev: v4.4.0
55
hooks:
66
- id: check-merge-conflict
77
- id: debug-statements
88
- id: trailing-whitespace
99
- id: end-of-file-fixer
1010
- repo: https://github.com/ambv/black
11-
rev: 21.4b2
11+
rev: 23.9.1
1212
hooks:
1313
- id: black
14-
- repo: https://gitlab.com/pycqa/flake8
15-
rev: 3.9.1
14+
- repo: https://github.com/pycqa/flake8
15+
rev: 6.1.0
1616
hooks:
1717
- id: flake8
18+
additional_dependencies:
19+
- importlib_metadata<5
1820
- repo: https://github.com/asottile/pyupgrade
19-
rev: v2.14.0
21+
rev: v3.14.0
2022
hooks:
2123
- id: pyupgrade
2224
args: [--py36-plus]
2325
- repo: https://github.com/pycqa/isort
24-
rev: 5.8.0
26+
rev: 5.12.0
2527
hooks:
2628
- id: isort

AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,7 @@ that much better:
260260
* Stankiewicz Mateusz (https://github.com/mas15)
261261
* Felix Schultheiß (https://github.com/felix-smashdocs)
262262
* Jan Stein (https://github.com/janste63)
263+
* Timothé Perez (https://github.com/AchilleAsh)
264+
* oleksandr-l5 (https://github.com/oleksandr-l5)
265+
* Ido Shraga (https://github.com/idoshr)
266+
* Terence Honles (https://github.com/terencehonles)

README.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ MongoEngine
1515
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
1616
:target: https://github.com/ambv/black
1717

18+
.. image:: https://pepy.tech/badge/mongoengine/month
19+
:target: https://pepy.tech/project/mongoengine
20+
21+
.. image:: https://img.shields.io/pypi/v/mongoengine.svg
22+
:target: https://pypi.python.org/pypi/mongoengine
23+
1824
About
1925
=====
2026
MongoEngine is a Python Object-Document Mapper for working with MongoDB.
@@ -25,10 +31,10 @@ an `API reference <https://mongoengine-odm.readthedocs.io/apireference.html>`_.
2531

2632
Supported MongoDB Versions
2733
==========================
28-
MongoEngine is currently tested against MongoDB v3.4, v3.6 and v4.0. Future versions
34+
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions
2935
should be supported as well, but aren't actively tested at the moment. Make
3036
sure to open an issue or submit a pull request if you experience any problems
31-
with MongoDB version > 4.0.
37+
with a more recent MongoDB versions.
3238

3339
Installation
3440
============

benchmarks/test_basic_doc_ops.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
StringField,
1313
)
1414

15-
mongoengine.connect(db="mongoengine_benchmark_test")
15+
mongoengine.connect(db="mongoengine_benchmark_test", w=1)
1616

1717

1818
def timeit(f, n=10000):
@@ -38,34 +38,34 @@ def init_book():
3838
author_email="alec@example.com",
3939
)
4040

41-
print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10 ** 6))
41+
print("Doc initialization: %.3fus" % (timeit(init_book, 1000) * 10**6))
4242

4343
b = init_book()
44-
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10 ** 6))
44+
print("Doc getattr: %.3fus" % (timeit(lambda: b.name, 10000) * 10**6))
4545

4646
print(
4747
"Doc setattr: %.3fus"
48-
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10 ** 6) # noqa B010
48+
% (timeit(lambda: setattr(b, "name", "New name"), 10000) * 10**6) # noqa B010
4949
)
5050

51-
print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10 ** 6))
51+
print("Doc to mongo: %.3fus" % (timeit(b.to_mongo, 1000) * 10**6))
5252

53-
print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10 ** 6))
53+
print("Doc validation: %.3fus" % (timeit(b.validate, 1000) * 10**6))
5454

5555
def save_book():
5656
b._mark_as_changed("name")
5757
b._mark_as_changed("tags")
5858
b.save()
5959

60-
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10 ** 6))
60+
print("Save to database: %.3fus" % (timeit(save_book, 100) * 10**6))
6161

6262
son = b.to_mongo()
6363
print(
64-
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10 ** 6)
64+
"Load from SON: %.3fus" % (timeit(lambda: Book._from_son(son), 1000) * 10**6)
6565
)
6666

6767
print(
68-
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10 ** 6)
68+
"Load from database: %.3fus" % (timeit(lambda: Book.objects[0], 100) * 10**6)
6969
)
7070

7171
def create_and_delete_book():
@@ -75,7 +75,7 @@ def create_and_delete_book():
7575

7676
print(
7777
"Init + save to database + delete: %.3fms"
78-
% (timeit(create_and_delete_book, 10) * 10 ** 3)
78+
% (timeit(create_and_delete_book, 10) * 10**3)
7979
)
8080

8181

@@ -101,9 +101,9 @@ def init_company():
101101
)
102102

103103
company = init_company()
104-
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10 ** 3))
104+
print("Big doc to mongo: %.3fms" % (timeit(company.to_mongo, 100) * 10**3))
105105

106-
print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10 ** 3))
106+
print("Big doc validation: %.3fms" % (timeit(company.validate, 1000) * 10**3))
107107

108108
company.save()
109109

@@ -112,17 +112,17 @@ def save_company():
112112
company._mark_as_changed("contacts")
113113
company.save()
114114

115-
print("Save to database: %.3fms" % (timeit(save_company, 100) * 10 ** 3))
115+
print("Save to database: %.3fms" % (timeit(save_company, 100) * 10**3))
116116

117117
son = company.to_mongo()
118118
print(
119119
"Load from SON: %.3fms"
120-
% (timeit(lambda: Company._from_son(son), 100) * 10 ** 3)
120+
% (timeit(lambda: Company._from_son(son), 100) * 10**3)
121121
)
122122

123123
print(
124124
"Load from database: %.3fms"
125-
% (timeit(lambda: Company.objects[0], 100) * 10 ** 3)
125+
% (timeit(lambda: Company.objects[0], 100) * 10**3)
126126
)
127127

128128
def create_and_delete_company():
@@ -132,7 +132,7 @@ def create_and_delete_company():
132132

133133
print(
134134
"Init + save to database + delete: %.3fms"
135-
% (timeit(create_and_delete_company, 10) * 10 ** 3)
135+
% (timeit(create_and_delete_company, 10) * 10**3)
136136
)
137137

138138

0 commit comments

Comments
 (0)