Skip to content

Commit 8685f59

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 88e5df5 + f3ca1e0 commit 8685f59

File tree

6 files changed

+125
-1
lines changed

6 files changed

+125
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:mod:`grid_file` -- Async tools for representing files stored in GridFS
2+
=======================================================================
3+
4+
.. automodule:: gridfs.asynchronous.grid_file
5+
:synopsis: Async tools for representing files stored in GridFS
6+
7+
.. autoclass:: AsyncGridIn
8+
:members:
9+
10+
.. autoattribute:: _id
11+
12+
.. autoclass:: AsyncGridOut
13+
:members:
14+
15+
.. autoattribute:: _id
16+
.. automethod:: __aiter__
17+
18+
.. autoclass:: AsyncGridOutCursor
19+
:members:

doc/api/gridfs/asynchronous/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
:mod:`gridfs async` -- Async tools for working with GridFS
2+
==========================================================
3+
4+
.. warning:: This API is currently in beta, meaning the classes, methods,
5+
and behaviors described within may change before the full release.
6+
If you come across any bugs during your use of this API,
7+
please file a Jira ticket in the "Python Driver" project at https://jira.mongodb.org/browse/PYTHON.
8+
9+
.. automodule:: gridfs.asynchronous
10+
:synopsis: Async tools for working with GridFS
11+
:members: AsyncGridFS, AsyncGridFSBucket
12+
13+
Sub-modules:
14+
15+
.. toctree::
16+
:maxdepth: 2
17+
18+
grid_file

doc/api/gridfs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
Sub-modules:
99

1010
.. toctree::
11-
:maxdepth: 2
11+
:maxdepth: 3
1212

13+
asynchronous/index
1314
errors
1415
grid_file

gridfs/asynchronous/__init__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2009-present MongoDB, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""GridFS is a specification for storing large objects in Mongo.
16+
17+
The :mod:`gridfs` package is an implementation of GridFS on top of
18+
:mod:`pymongo`, exposing a file-like interface.
19+
20+
.. seealso:: The MongoDB documentation on `gridfs <https://dochub.mongodb.org/core/gridfs>`_.
21+
"""
22+
from __future__ import annotations
23+
24+
from gridfs.asynchronous.grid_file import (
25+
AsyncGridFS,
26+
AsyncGridFSBucket,
27+
AsyncGridIn,
28+
AsyncGridOut,
29+
AsyncGridOutCursor,
30+
)
31+
from gridfs.errors import NoFile
32+
from gridfs.grid_file_shared import DEFAULT_CHUNK_SIZE
33+
34+
__all__ = [
35+
"AsyncGridFS",
36+
"AsyncGridFSBucket",
37+
"NoFile",
38+
"DEFAULT_CHUNK_SIZE",
39+
"AsyncGridIn",
40+
"AsyncGridOut",
41+
"AsyncGridOutCursor",
42+
]

test/performance/async_perf_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,17 @@ async def do_task(self):
362362
await self.corpus.insert_many(self.documents, ordered=True)
363363

364364

365+
class TestSmallDocCollectionBulkInsert(SmallDocInsertTest, AsyncPyMongoTestCase):
366+
async def asyncSetUp(self):
367+
await super().asyncSetUp()
368+
self.models = []
369+
for doc in self.documents:
370+
self.models.append(InsertOne(namespace="perftest.corpus", document=doc))
371+
372+
async def do_task(self):
373+
await self.corpus.bulk_write(self.models, ordered=True)
374+
375+
365376
class TestSmallDocClientBulkInsert(SmallDocInsertTest, AsyncPyMongoTestCase):
366377
@async_client_context.require_version_min(8, 0, 0, -24)
367378
async def asyncSetUp(self):
@@ -412,6 +423,17 @@ async def do_task(self):
412423
await self.corpus.insert_many(self.documents, ordered=True)
413424

414425

426+
class TestLargeDocCollectionBulkInsert(LargeDocInsertTest, AsyncPyMongoTestCase):
427+
async def asyncSetUp(self):
428+
await super().asyncSetUp()
429+
self.models = []
430+
for doc in self.documents:
431+
self.models.append(InsertOne(namespace="perftest.corpus", document=doc))
432+
433+
async def do_task(self):
434+
await self.corpus.bulk_write(self.models, ordered=True)
435+
436+
415437
class TestLargeDocClientBulkInsert(LargeDocInsertTest, AsyncPyMongoTestCase):
416438
@async_client_context.require_version_min(8, 0, 0, -24)
417439
async def asyncSetUp(self):

test/performance/perf_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,17 @@ def do_task(self):
443443
self.corpus.insert_many(self.documents, ordered=True)
444444

445445

446+
class TestSmallDocCollectionBulkInsert(SmallDocInsertTest, unittest.TestCase):
447+
def setUp(self):
448+
super().setUp()
449+
self.models = []
450+
for doc in self.documents:
451+
self.models.append(InsertOne(namespace="perftest.corpus", document=doc))
452+
453+
def do_task(self):
454+
self.corpus.bulk_write(self.models, ordered=True)
455+
456+
446457
class TestSmallDocClientBulkInsert(SmallDocInsertTest, unittest.TestCase):
447458
@client_context.require_version_min(8, 0, 0, -24)
448459
def setUp(self):
@@ -493,6 +504,17 @@ def do_task(self):
493504
self.corpus.insert_many(self.documents, ordered=True)
494505

495506

507+
class TestLargeDocCollectionBulkInsert(LargeDocInsertTest, unittest.TestCase):
508+
def setUp(self):
509+
super().setUp()
510+
self.models = []
511+
for doc in self.documents:
512+
self.models.append(InsertOne(namespace="perftest.corpus", document=doc))
513+
514+
def do_task(self):
515+
self.corpus.bulk_write(self.models, ordered=True)
516+
517+
496518
class TestLargeDocClientBulkInsert(LargeDocInsertTest, unittest.TestCase):
497519
@client_context.require_version_min(8, 0, 0, -24)
498520
def setUp(self):

0 commit comments

Comments
 (0)