autonomous-app 0.2.25__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autonomous/__init__.py +5 -2
- autonomous/ai/audioagent.py +32 -0
- autonomous/ai/imageagent.py +31 -0
- autonomous/ai/jsonagent.py +40 -0
- autonomous/ai/models/__init__.py +0 -0
- autonomous/ai/models/openai.py +308 -0
- autonomous/ai/oaiagent.py +20 -194
- autonomous/ai/textagent.py +35 -0
- autonomous/auth/autoauth.py +11 -11
- autonomous/auth/user.py +24 -11
- autonomous/db/__init__.py +41 -0
- autonomous/db/base/__init__.py +33 -0
- autonomous/db/base/common.py +62 -0
- autonomous/db/base/datastructures.py +476 -0
- autonomous/db/base/document.py +1230 -0
- autonomous/db/base/fields.py +767 -0
- autonomous/db/base/metaclasses.py +468 -0
- autonomous/db/base/utils.py +22 -0
- autonomous/db/common.py +79 -0
- autonomous/db/connection.py +472 -0
- autonomous/db/context_managers.py +313 -0
- autonomous/db/dereference.py +291 -0
- autonomous/db/document.py +1141 -0
- autonomous/db/errors.py +165 -0
- autonomous/db/fields.py +2732 -0
- autonomous/db/mongodb_support.py +24 -0
- autonomous/db/pymongo_support.py +80 -0
- autonomous/db/queryset/__init__.py +28 -0
- autonomous/db/queryset/base.py +2033 -0
- autonomous/db/queryset/field_list.py +88 -0
- autonomous/db/queryset/manager.py +58 -0
- autonomous/db/queryset/queryset.py +189 -0
- autonomous/db/queryset/transform.py +527 -0
- autonomous/db/queryset/visitor.py +189 -0
- autonomous/db/signals.py +59 -0
- autonomous/logger.py +3 -0
- autonomous/model/autoattr.py +120 -0
- autonomous/model/automodel.py +121 -308
- autonomous/storage/imagestorage.py +9 -54
- autonomous/tasks/autotask.py +0 -25
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/METADATA +7 -8
- autonomous_app-0.3.1.dist-info/RECORD +60 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/WHEEL +1 -1
- autonomous/db/autodb.py +0 -86
- autonomous/db/table.py +0 -156
- autonomous/errors/__init__.py +0 -1
- autonomous/errors/danglingreferenceerror.py +0 -8
- autonomous/model/autoattribute.py +0 -20
- autonomous/model/orm.py +0 -86
- autonomous/model/serializer.py +0 -110
- autonomous_app-0.2.25.dist-info/RECORD +0 -36
- /autonomous/{storage → apis}/version_control/GHCallbacks.py +0 -0
- /autonomous/{storage → apis}/version_control/GHOrganization.py +0 -0
- /autonomous/{storage → apis}/version_control/GHRepo.py +0 -0
- /autonomous/{storage → apis}/version_control/GHVersionControl.py +0 -0
- /autonomous/{storage → apis}/version_control/__init__.py +0 -0
- /autonomous/{storage → utils}/markdown.py +0 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/LICENSE +0 -0
- {autonomous_app-0.2.25.dist-info → autonomous_app-0.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Helper functions, constants, and types to aid with MongoDB version support
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from autonomous.db.connection import get_connection
|
|
6
|
+
|
|
7
|
+
# Constant that can be used to compare the version retrieved with
|
|
8
|
+
# get_mongodb_version()
|
|
9
|
+
MONGODB_34 = (3, 4)
|
|
10
|
+
MONGODB_36 = (3, 6)
|
|
11
|
+
MONGODB_42 = (4, 2)
|
|
12
|
+
MONGODB_44 = (4, 4)
|
|
13
|
+
MONGODB_50 = (5, 0)
|
|
14
|
+
MONGODB_60 = (6, 0)
|
|
15
|
+
MONGODB_70 = (7, 0)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_mongodb_version():
|
|
19
|
+
"""Return the version of the default connected mongoDB (first 2 digits)
|
|
20
|
+
|
|
21
|
+
:return: tuple(int, int)
|
|
22
|
+
"""
|
|
23
|
+
version_list = get_connection().server_info()["versionArray"][:2] # e.g: (3, 2)
|
|
24
|
+
return tuple(version_list)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Helper functions, constants, and types to aid with PyMongo support.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import pymongo
|
|
6
|
+
from bson import binary, json_util
|
|
7
|
+
from pymongo.errors import OperationFailure
|
|
8
|
+
|
|
9
|
+
PYMONGO_VERSION = tuple(pymongo.version_tuple[:2])
|
|
10
|
+
|
|
11
|
+
# This will be changed to UuidRepresentation.UNSPECIFIED in a future
|
|
12
|
+
# (breaking) release.
|
|
13
|
+
if PYMONGO_VERSION >= (4,):
|
|
14
|
+
LEGACY_JSON_OPTIONS = json_util.LEGACY_JSON_OPTIONS.with_options(
|
|
15
|
+
uuid_representation=binary.UuidRepresentation.PYTHON_LEGACY,
|
|
16
|
+
)
|
|
17
|
+
else:
|
|
18
|
+
LEGACY_JSON_OPTIONS = json_util.DEFAULT_JSON_OPTIONS
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def count_documents(
|
|
22
|
+
collection, filter, skip=None, limit=None, hint=None, collation=None
|
|
23
|
+
):
|
|
24
|
+
"""Pymongo>3.7 deprecates count in favour of count_documents"""
|
|
25
|
+
if limit == 0:
|
|
26
|
+
return 0 # Pymongo raises an OperationFailure if called with limit=0
|
|
27
|
+
|
|
28
|
+
kwargs = {}
|
|
29
|
+
if skip is not None:
|
|
30
|
+
kwargs["skip"] = skip
|
|
31
|
+
if limit is not None:
|
|
32
|
+
kwargs["limit"] = limit
|
|
33
|
+
if hint not in (-1, None):
|
|
34
|
+
kwargs["hint"] = hint
|
|
35
|
+
if collation is not None:
|
|
36
|
+
kwargs["collation"] = collation
|
|
37
|
+
|
|
38
|
+
# count_documents appeared in pymongo 3.7
|
|
39
|
+
if PYMONGO_VERSION >= (3, 7):
|
|
40
|
+
try:
|
|
41
|
+
if not filter and set(kwargs) <= {"max_time_ms"}:
|
|
42
|
+
# when no filter is provided, estimated_document_count
|
|
43
|
+
# is a lot faster as it uses the collection metadata
|
|
44
|
+
return collection.estimated_document_count(**kwargs)
|
|
45
|
+
else:
|
|
46
|
+
return collection.count_documents(filter=filter, **kwargs)
|
|
47
|
+
except OperationFailure as err:
|
|
48
|
+
if PYMONGO_VERSION >= (4,):
|
|
49
|
+
raise
|
|
50
|
+
|
|
51
|
+
# OperationFailure - accounts for some operators that used to work
|
|
52
|
+
# with .count but are no longer working with count_documents (i.e $geoNear, $near, and $nearSphere)
|
|
53
|
+
# fallback to deprecated Cursor.count
|
|
54
|
+
# Keeping this should be reevaluated the day pymongo removes .count entirely
|
|
55
|
+
if (
|
|
56
|
+
"$geoNear, $near, and $nearSphere are not allowed in this context"
|
|
57
|
+
not in str(err)
|
|
58
|
+
and "$where is not allowed in this context" not in str(err)
|
|
59
|
+
):
|
|
60
|
+
raise
|
|
61
|
+
|
|
62
|
+
cursor = collection.find(filter)
|
|
63
|
+
for option, option_value in kwargs.items():
|
|
64
|
+
cursor_method = getattr(cursor, option)
|
|
65
|
+
cursor = cursor_method(option_value)
|
|
66
|
+
with_limit_and_skip = "skip" in kwargs or "limit" in kwargs
|
|
67
|
+
return cursor.count(with_limit_and_skip=with_limit_and_skip)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def list_collection_names(db, include_system_collections=False):
|
|
71
|
+
"""Pymongo>3.7 deprecates collection_names in favour of list_collection_names"""
|
|
72
|
+
if PYMONGO_VERSION >= (3, 7):
|
|
73
|
+
collections = db.list_collection_names()
|
|
74
|
+
else:
|
|
75
|
+
collections = db.collection_names()
|
|
76
|
+
|
|
77
|
+
if not include_system_collections:
|
|
78
|
+
collections = [c for c in collections if not c.startswith("system.")]
|
|
79
|
+
|
|
80
|
+
return collections
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from autonomous.db.errors import *
|
|
2
|
+
from autonomous.db.queryset.field_list import *
|
|
3
|
+
from autonomous.db.queryset.manager import *
|
|
4
|
+
from autonomous.db.queryset.queryset import *
|
|
5
|
+
from autonomous.db.queryset.transform import *
|
|
6
|
+
from autonomous.db.queryset.visitor import *
|
|
7
|
+
|
|
8
|
+
# Expose just the public subset of all imported objects and constants.
|
|
9
|
+
__all__ = (
|
|
10
|
+
"QuerySet",
|
|
11
|
+
"QuerySetNoCache",
|
|
12
|
+
"Q",
|
|
13
|
+
"queryset_manager",
|
|
14
|
+
"QuerySetManager",
|
|
15
|
+
"QueryFieldList",
|
|
16
|
+
"DO_NOTHING",
|
|
17
|
+
"NULLIFY",
|
|
18
|
+
"CASCADE",
|
|
19
|
+
"DENY",
|
|
20
|
+
"PULL",
|
|
21
|
+
# Errors that might be related to a queryset, mostly here for backward
|
|
22
|
+
# compatibility
|
|
23
|
+
"DoesNotExist",
|
|
24
|
+
"InvalidQueryError",
|
|
25
|
+
"MultipleObjectsReturned",
|
|
26
|
+
"NotUniqueError",
|
|
27
|
+
"OperationError",
|
|
28
|
+
)
|