autonomous-app 0.2.24__py3-none-any.whl → 0.3.0__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 +280 -0
- autonomous/ai/oaiagent.py +24 -186
- autonomous/ai/textagent.py +35 -0
- autonomous/auth/autoauth.py +2 -2
- autonomous/auth/user.py +8 -10
- autonomous/model/autoattr.py +105 -0
- autonomous/model/automodel.py +70 -305
- autonomous/storage/imagestorage.py +9 -54
- autonomous/tasks/autotask.py +0 -25
- {autonomous_app-0.2.24.dist-info → autonomous_app-0.3.0.dist-info}/METADATA +7 -8
- autonomous_app-0.3.0.dist-info/RECORD +35 -0
- {autonomous_app-0.2.24.dist-info → autonomous_app-0.3.0.dist-info}/WHEEL +1 -1
- autonomous/db/__init__.py +0 -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 -102
- autonomous_app-0.2.24.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.24.dist-info → autonomous_app-0.3.0.dist-info}/LICENSE +0 -0
- {autonomous_app-0.2.24.dist-info → autonomous_app-0.3.0.dist-info}/top_level.txt +0 -0
autonomous/tasks/autotask.py
CHANGED
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
import importlib
|
|
2
2
|
import os
|
|
3
3
|
import subprocess
|
|
4
|
-
import time
|
|
5
4
|
|
|
6
5
|
from redis import Redis
|
|
7
6
|
from rq import Queue, Worker
|
|
8
|
-
from rq.job import Job
|
|
9
7
|
|
|
10
8
|
from autonomous import log
|
|
11
9
|
|
|
12
|
-
# class AutoJob(Job):
|
|
13
|
-
# def perform(self):
|
|
14
|
-
# start = time.time()
|
|
15
|
-
# result = super().perform()
|
|
16
|
-
# end = time.time()
|
|
17
|
-
# log.info(
|
|
18
|
-
# "Job Finished",
|
|
19
|
-
# key=self.key,
|
|
20
|
-
# seconds=(end - start),
|
|
21
|
-
# method=self.func_name,
|
|
22
|
-
# data_size=len(self._data),
|
|
23
|
-
# queue=self.origin,
|
|
24
|
-
# enqueued_at=self.enqueued_at.timestamp() if self.enqueued_at else None,
|
|
25
|
-
# started_at=self.started_at.timestamp() if self.started_at else None,
|
|
26
|
-
# )
|
|
27
|
-
# return result
|
|
28
|
-
|
|
29
10
|
|
|
30
11
|
class AutoTask:
|
|
31
12
|
def __init__(self, job):
|
|
@@ -161,9 +142,3 @@ class AutoTasks:
|
|
|
161
142
|
def clear(self):
|
|
162
143
|
AutoTasks.queue.empty()
|
|
163
144
|
AutoTasks.all_tasks = []
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# if __name__ == "__main__":
|
|
167
|
-
# autotasks = AutoTasks()
|
|
168
|
-
# for _ in range(autotasks.workers):
|
|
169
|
-
# create_worker(autotasks.queue.name)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: autonomous-app
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Containerized application framework built on Flask with additional libraries and tools for rapid development of web applications.
|
|
5
5
|
Author-email: Steven A Moore <samoore@binghamton.edu>
|
|
6
6
|
License: MIT License
|
|
@@ -25,27 +25,26 @@ License: MIT License
|
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
27
|
Project-URL: homepage, https://github.com/Sallenmoore/autonomous
|
|
28
|
-
Classifier: Programming Language :: Python :: 3.
|
|
28
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
29
29
|
Classifier: License :: OSI Approved :: MIT License
|
|
30
30
|
Classifier: Operating System :: OS Independent
|
|
31
|
-
Requires-Python: >=3.
|
|
31
|
+
Requires-Python: >=3.12
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
33
33
|
License-File: LICENSE
|
|
34
34
|
Requires-Dist: Flask
|
|
35
|
-
Requires-Dist: icecream
|
|
36
35
|
Requires-Dist: setuptools
|
|
37
36
|
Requires-Dist: python-dotenv
|
|
38
37
|
Requires-Dist: PyGithub
|
|
39
38
|
Requires-Dist: pygit2
|
|
40
|
-
Requires-Dist:
|
|
39
|
+
Requires-Dist: mongoengine
|
|
41
40
|
Requires-Dist: pillow
|
|
42
|
-
Requires-Dist:
|
|
41
|
+
Requires-Dist: redis
|
|
43
42
|
Requires-Dist: jsmin
|
|
44
43
|
Requires-Dist: requests
|
|
45
44
|
Requires-Dist: gunicorn
|
|
46
45
|
Requires-Dist: Authlib
|
|
47
|
-
Requires-Dist:
|
|
48
|
-
Requires-Dist:
|
|
46
|
+
Requires-Dist: rq
|
|
47
|
+
Requires-Dist: openai>=1.42
|
|
49
48
|
Requires-Dist: dateparser
|
|
50
49
|
Requires-Dist: python-slugify
|
|
51
50
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
autonomous/__init__.py,sha256=SRUR0ydj_pjN9Q_N-39Nhb4_1VcqnvPVEQ5gtV4VWUQ,95
|
|
2
|
+
autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
|
|
3
|
+
autonomous/logger.py,sha256=jePQ4kTtECTwGtIcDmpLSE6rSwhaUEiQe2vK06h5XIg,1915
|
|
4
|
+
autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
autonomous/ai/audioagent.py,sha256=ZGiT7uCrjwMMB5czGrMG9XEn7LcaeT5my6hyh4MVddk,1019
|
|
6
|
+
autonomous/ai/imageagent.py,sha256=HlmKb8f5r8SSwm-M22ZvTYtyF4IN0VDZXSiHZjcfqNI,960
|
|
7
|
+
autonomous/ai/jsonagent.py,sha256=l-DHdDuedEoR99pSHvaN2iV-1JicSoZhlkfqlc2Jgro,1300
|
|
8
|
+
autonomous/ai/oaiagent.py,sha256=wSD0Ct1XAuheS8x9ALCc_aw1fdTZTkZadgryRcxCHTU,1580
|
|
9
|
+
autonomous/ai/textagent.py,sha256=Mq10S2QJS-JPStVmbWCjn_JvS7hBlw-0puQnkTqrs7k,1199
|
|
10
|
+
autonomous/ai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
autonomous/ai/models/openai.py,sha256=CrSQc_9iAW3dqrpaF-Vi3Ia0arlamKQlPJiKVKWfKSs,10499
|
|
12
|
+
autonomous/apis/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
|
|
13
|
+
autonomous/apis/version_control/GHOrganization.py,sha256=mi2livdsGurKiifbvuLwiFbdDzL77IlEfhwEa-tG77I,1155
|
|
14
|
+
autonomous/apis/version_control/GHRepo.py,sha256=hTFHMkxSbSlVELfh8S6mq6ijkIKPRQO-Q5775ZjRKD4,4622
|
|
15
|
+
autonomous/apis/version_control/GHVersionControl.py,sha256=VIhVRxe6gJgozFWyhyKIu4spgSJI-GChiVJudnSyggI,196
|
|
16
|
+
autonomous/apis/version_control/__init__.py,sha256=tP0bAWYl1RwBRi62HsIidmgyqHuSlCUqwGuKUKKRugc,117
|
|
17
|
+
autonomous/auth/__init__.py,sha256=IW5tQ8VYwHIbDfMYA0wYgx4PprwcjUWV4EoIJ8HTlMU,161
|
|
18
|
+
autonomous/auth/autoauth.py,sha256=LSJuopTyVxyvktzea0h450UvfW8sOHnG6apxfmn7SJo,3718
|
|
19
|
+
autonomous/auth/github.py,sha256=dHf84bJdV9rXGcvRLzWCPW9CvuA-VEmqYi_QQFwd2kY,886
|
|
20
|
+
autonomous/auth/google.py,sha256=cHmqbyNEPTKipc3WkYcD1XPOyqcWEFW0Ks4qJYmGvPw,1049
|
|
21
|
+
autonomous/auth/user.py,sha256=2euce_Fe_iEMUgoPIH4J8m_MBtZ2hdaDnAL-zHL6LlM,2404
|
|
22
|
+
autonomous/model/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
23
|
+
autonomous/model/autoattr.py,sha256=Pb6Fk-yvrw2LxqmvS3PftkcUGdJF6sdM6f_vpX9YMg0,2223
|
|
24
|
+
autonomous/model/automodel.py,sha256=WJ3pwJiYP2PNRXC6rculpB9QXMOVwPPDLmdeJ83At9I,4664
|
|
25
|
+
autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
autonomous/storage/imagestorage.py,sha256=xxMu9gXZ3nGU9xsXNmHtk_9RtrALZ2QlX5XsR4SL7xc,4589
|
|
27
|
+
autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
|
|
28
|
+
autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
|
|
29
|
+
autonomous/tasks/autotask.py,sha256=aK5iapDhgcAic3F5ZYMAhNKJkOepj8yWwbMizKDzUwQ,4153
|
|
30
|
+
autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
|
|
31
|
+
autonomous_app-0.3.0.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
|
|
32
|
+
autonomous_app-0.3.0.dist-info/METADATA,sha256=1UzOoW2CSVG7OEySyRXEBCOof-R4E3YaAlr7MUJdSOE,4192
|
|
33
|
+
autonomous_app-0.3.0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
34
|
+
autonomous_app-0.3.0.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
|
|
35
|
+
autonomous_app-0.3.0.dist-info/RECORD,,
|
autonomous/db/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
autonomous/db/autodb.py
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
_summary_
|
|
3
|
-
|
|
4
|
-
_extended_summary_
|
|
5
|
-
|
|
6
|
-
:return: _description_
|
|
7
|
-
:rtype: _type_
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import glob
|
|
11
|
-
import os
|
|
12
|
-
import subprocess
|
|
13
|
-
import urllib.parse
|
|
14
|
-
from datetime import datetime
|
|
15
|
-
|
|
16
|
-
import pymongo
|
|
17
|
-
|
|
18
|
-
from autonomous import log
|
|
19
|
-
|
|
20
|
-
from .table import Table
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class Database:
|
|
24
|
-
"""
|
|
25
|
-
_summary_
|
|
26
|
-
|
|
27
|
-
_extended_summary_
|
|
28
|
-
|
|
29
|
-
:return: _description_
|
|
30
|
-
:rtype: _type_
|
|
31
|
-
"""
|
|
32
|
-
|
|
33
|
-
def __init__(
|
|
34
|
-
self,
|
|
35
|
-
host=os.getenv("DB_HOST", "db"),
|
|
36
|
-
port=os.getenv("DB_PORT", 27017),
|
|
37
|
-
password=os.getenv("DB_PASSWORD"),
|
|
38
|
-
username=os.getenv("DB_USERNAME"),
|
|
39
|
-
db=os.getenv("DB_DB"),
|
|
40
|
-
):
|
|
41
|
-
"""
|
|
42
|
-
create an interface for your database
|
|
43
|
-
"""
|
|
44
|
-
# log(self.username, self.password)
|
|
45
|
-
username = urllib.parse.quote_plus(str(username))
|
|
46
|
-
password = urllib.parse.quote_plus(str(password))
|
|
47
|
-
self.connect_str = f"mongodb://{username}:{password}@{host}:{port}"
|
|
48
|
-
# log(f"mongodb://{username}:{password}@{host}", port=int(port))
|
|
49
|
-
self.db = pymongo.MongoClient(
|
|
50
|
-
f"mongodb://{username}:{password}@{host}", port=int(port)
|
|
51
|
-
)[db]
|
|
52
|
-
self.tables = {}
|
|
53
|
-
|
|
54
|
-
def get_table(self, table="default", schema=None):
|
|
55
|
-
"""
|
|
56
|
-
opens the table from the file, which clears any changed data
|
|
57
|
-
"""
|
|
58
|
-
if not self.tables.get(table):
|
|
59
|
-
self.tables[table] = Table(table, schema, self.db)
|
|
60
|
-
return self.tables[table]
|
|
61
|
-
|
|
62
|
-
def dbdump(self, directory):
|
|
63
|
-
"""
|
|
64
|
-
dumps the database to a json file
|
|
65
|
-
"""
|
|
66
|
-
datetime_string = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
|
67
|
-
command_str = f'mongodump --uri="{self.connect_str}" --archive="{directory}/dbbackup-{datetime_string}.archive"'
|
|
68
|
-
result = subprocess.Popen(command_str, shell=True).wait()
|
|
69
|
-
log(result, command_str)
|
|
70
|
-
|
|
71
|
-
def dbload(self, directory):
|
|
72
|
-
"""
|
|
73
|
-
loads the database from a json file
|
|
74
|
-
"""
|
|
75
|
-
files = glob.glob(
|
|
76
|
-
f"{directory}/dbbackup-*.archive"
|
|
77
|
-
) # replace with your directory path
|
|
78
|
-
|
|
79
|
-
# Find the file with the most recent timestamp
|
|
80
|
-
latest_file = max(files, key=os.path.getctime)
|
|
81
|
-
log(latest_file)
|
|
82
|
-
command_str = (
|
|
83
|
-
f'mongorestore --uri="{self.connect_str}" --archive="{latest_file}"'
|
|
84
|
-
)
|
|
85
|
-
result = subprocess.Popen(command_str, shell=True).wait()
|
|
86
|
-
log(result, command_str)
|
autonomous/db/table.py
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
_summary_
|
|
3
|
-
|
|
4
|
-
_extended_summary_
|
|
5
|
-
|
|
6
|
-
:return: _description_
|
|
7
|
-
:rtype: _type_
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import json
|
|
11
|
-
import random
|
|
12
|
-
|
|
13
|
-
from bson.objectid import ObjectId
|
|
14
|
-
|
|
15
|
-
from autonomous import log
|
|
16
|
-
from autonomous.model.autoattribute import AutoAttribute
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class Table:
|
|
20
|
-
def __init__(self, name, attributes, db):
|
|
21
|
-
self._db = db[name]
|
|
22
|
-
self.name = name
|
|
23
|
-
# log(attributes)
|
|
24
|
-
self._rules = {}
|
|
25
|
-
|
|
26
|
-
for k, v in attributes.items():
|
|
27
|
-
if isinstance(v, AutoAttribute):
|
|
28
|
-
self._rules[k] = v
|
|
29
|
-
elif isinstance(v, str):
|
|
30
|
-
self._rules[k] = AutoAttribute("TEXT", default=v)
|
|
31
|
-
elif isinstance(v, (int, float)):
|
|
32
|
-
self._rules[k] = AutoAttribute("NUMERIC", default=v)
|
|
33
|
-
else:
|
|
34
|
-
self._rules[k] = None
|
|
35
|
-
self._index = self._get_index(f"idx:{name}")
|
|
36
|
-
|
|
37
|
-
def __str__(self):
|
|
38
|
-
return json.dumps(self.all(), indent=4)
|
|
39
|
-
|
|
40
|
-
def _get_index(self, name):
|
|
41
|
-
pass
|
|
42
|
-
|
|
43
|
-
def _validate(self, k, v):
|
|
44
|
-
# log(k, v, self._rules)
|
|
45
|
-
if rule := self._rules.get(k):
|
|
46
|
-
if rule.type == "NUMERIC":
|
|
47
|
-
if v:
|
|
48
|
-
try:
|
|
49
|
-
float(v)
|
|
50
|
-
except TypeError:
|
|
51
|
-
raise Exception(
|
|
52
|
-
f"VALIDATION ERROR: Invalid attribute value. Must be a number: {k}:{v}"
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
if rule.required:
|
|
56
|
-
try:
|
|
57
|
-
assert v is not None
|
|
58
|
-
except AssertionError:
|
|
59
|
-
raise Exception(
|
|
60
|
-
f"VALIDATION ERROR: Attribute Required. Must not be 'None': {k}:{v}"
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
def save(self, obj):
|
|
64
|
-
for k, v in obj.items():
|
|
65
|
-
try:
|
|
66
|
-
self._validate(k, v)
|
|
67
|
-
except Exception as e:
|
|
68
|
-
# log(e)
|
|
69
|
-
raise e
|
|
70
|
-
|
|
71
|
-
if obj_id := obj.get("_id"):
|
|
72
|
-
obj["_id"] = ObjectId(obj_id)
|
|
73
|
-
self._db.replace_one({"_id": obj["_id"]}, obj, True)
|
|
74
|
-
else:
|
|
75
|
-
obj.pop("_id", None)
|
|
76
|
-
obj["_id"] = self._db.insert_one(obj).inserted_id
|
|
77
|
-
return str(obj["_id"])
|
|
78
|
-
|
|
79
|
-
def count(self):
|
|
80
|
-
return self._db.count_documents({})
|
|
81
|
-
|
|
82
|
-
def delete(self, _id):
|
|
83
|
-
try:
|
|
84
|
-
return self._db.delete_one({"_id": ObjectId(_id)}).acknowledged
|
|
85
|
-
except Exception as e:
|
|
86
|
-
log(e)
|
|
87
|
-
|
|
88
|
-
def _convert_to_dot_notation(self, search_terms, fuzzy_search=False, prefix=""):
|
|
89
|
-
dot_notation = {}
|
|
90
|
-
for key, value in search_terms.items():
|
|
91
|
-
if isinstance(value, dict):
|
|
92
|
-
dot_notation.update(
|
|
93
|
-
self._convert_to_dot_notation(
|
|
94
|
-
value, fuzzy_search=fuzzy_search, prefix=f"{prefix}{key}."
|
|
95
|
-
)
|
|
96
|
-
)
|
|
97
|
-
else:
|
|
98
|
-
if fuzzy_search and isinstance(value, str):
|
|
99
|
-
dot_notation[f"{prefix}{key}"] = {"$regex": value, "$options": "i"}
|
|
100
|
-
else:
|
|
101
|
-
dot_notation[f"{prefix}{key}"] = value
|
|
102
|
-
return dot_notation
|
|
103
|
-
|
|
104
|
-
def find(self, **search_terms):
|
|
105
|
-
search_terms = self._convert_to_dot_notation(search_terms)
|
|
106
|
-
result = self._db.find_one(search_terms)
|
|
107
|
-
if result:
|
|
108
|
-
result["_id"] = str(result["_id"])
|
|
109
|
-
return result
|
|
110
|
-
|
|
111
|
-
def search(self, **search_terms):
|
|
112
|
-
fuzzy_search = search_terms.pop("_FUZZY_SEARCH", False)
|
|
113
|
-
search_terms = self._convert_to_dot_notation(
|
|
114
|
-
search_terms, fuzzy_search=fuzzy_search
|
|
115
|
-
)
|
|
116
|
-
result = self._db.find(search_terms) or []
|
|
117
|
-
|
|
118
|
-
objs = []
|
|
119
|
-
for o in result:
|
|
120
|
-
o["_id"] = str(o["_id"])
|
|
121
|
-
objs.append(o)
|
|
122
|
-
# log(search_terms, fuzzy_search, objs)
|
|
123
|
-
return objs
|
|
124
|
-
|
|
125
|
-
def get(self, _id):
|
|
126
|
-
try:
|
|
127
|
-
if o := self._db.find_one({"_id": ObjectId(_id)}):
|
|
128
|
-
o["_id"] = str(o["_id"])
|
|
129
|
-
except Exception as e:
|
|
130
|
-
return None
|
|
131
|
-
# log(e, f"Object '{_id}' not found in '{self.name}'")
|
|
132
|
-
return o
|
|
133
|
-
|
|
134
|
-
def all(self):
|
|
135
|
-
objs = []
|
|
136
|
-
for o in self._db.find():
|
|
137
|
-
o["_id"] = str(o["_id"])
|
|
138
|
-
objs.append(o)
|
|
139
|
-
return objs
|
|
140
|
-
|
|
141
|
-
def random(self):
|
|
142
|
-
keys = [o for o in self._db.find({}, projection=["_id"])]
|
|
143
|
-
# log(keys)
|
|
144
|
-
try:
|
|
145
|
-
key = random.choice(keys)
|
|
146
|
-
except Exception as e:
|
|
147
|
-
# log(e, f"Table '{self.name}' is empty.")
|
|
148
|
-
return None
|
|
149
|
-
else:
|
|
150
|
-
result = self.get(str(key["_id"]))
|
|
151
|
-
# log(result)
|
|
152
|
-
return result
|
|
153
|
-
|
|
154
|
-
def clear(self):
|
|
155
|
-
# breakpoint()
|
|
156
|
-
return self._db.drop()
|
autonomous/errors/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .danglingreferenceerror import DanglingReferenceError
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
class AutoAttribute:
|
|
2
|
-
def __init__(
|
|
3
|
-
self, type, default=None, required=False, unique=False, primary_key=False
|
|
4
|
-
):
|
|
5
|
-
if type in [
|
|
6
|
-
"TEXT",
|
|
7
|
-
"NUMERIC",
|
|
8
|
-
"MODEL",
|
|
9
|
-
]:
|
|
10
|
-
self.type = type
|
|
11
|
-
else:
|
|
12
|
-
raise ValueError(f"Invalid type {type}")
|
|
13
|
-
|
|
14
|
-
self.default = default
|
|
15
|
-
self.required = required
|
|
16
|
-
self.unique = unique
|
|
17
|
-
self.primary_key = primary_key
|
|
18
|
-
|
|
19
|
-
def __repr__(self):
|
|
20
|
-
return f"<AutoAttribute {self.type} {self.default} {self.required} {self.unique} {self.primary_key}>"
|
autonomous/model/orm.py
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
|
-
from autonomous import log
|
|
4
|
-
from autonomous.db.autodb import Database
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class ORM:
|
|
8
|
-
_database = Database()
|
|
9
|
-
|
|
10
|
-
def __init__(self, name, attributes):
|
|
11
|
-
self.table = self._database.get_table(table=name, schema=attributes)
|
|
12
|
-
self.name = name
|
|
13
|
-
|
|
14
|
-
def _replace_pk_with_id(self, data):
|
|
15
|
-
if isinstance(data, dict):
|
|
16
|
-
for key in list(data.keys()):
|
|
17
|
-
if key == "pk":
|
|
18
|
-
data["_id"] = data.pop("pk")
|
|
19
|
-
else:
|
|
20
|
-
self._replace_pk_with_id(data[key])
|
|
21
|
-
# breakpoint()
|
|
22
|
-
elif isinstance(data, list):
|
|
23
|
-
for item in data:
|
|
24
|
-
self._replace_pk_with_id(item)
|
|
25
|
-
|
|
26
|
-
def _replace_id_with_pk(self, data):
|
|
27
|
-
if isinstance(data, dict):
|
|
28
|
-
for key in list(data.keys()):
|
|
29
|
-
if key == "_id":
|
|
30
|
-
data["pk"] = data.pop("_id")
|
|
31
|
-
else:
|
|
32
|
-
self._replace_id_with_pk(data[key])
|
|
33
|
-
# breakpoint()
|
|
34
|
-
elif isinstance(data, list):
|
|
35
|
-
for item in data:
|
|
36
|
-
self._replace_id_with_pk(item)
|
|
37
|
-
|
|
38
|
-
def save(self, data):
|
|
39
|
-
self._replace_pk_with_id(data)
|
|
40
|
-
if result := self.table.save(data):
|
|
41
|
-
self._replace_id_with_pk(result)
|
|
42
|
-
return result
|
|
43
|
-
|
|
44
|
-
def get(self, pk):
|
|
45
|
-
pk = str(pk)
|
|
46
|
-
if result := self.table.get(pk):
|
|
47
|
-
self._replace_id_with_pk(result)
|
|
48
|
-
return result
|
|
49
|
-
|
|
50
|
-
def all(self):
|
|
51
|
-
if results := self.table.all():
|
|
52
|
-
self._replace_id_with_pk(results)
|
|
53
|
-
return results
|
|
54
|
-
|
|
55
|
-
def search(self, **kwargs):
|
|
56
|
-
self._replace_pk_with_id(kwargs)
|
|
57
|
-
if results := self.table.search(**kwargs):
|
|
58
|
-
self._replace_id_with_pk(results)
|
|
59
|
-
return results
|
|
60
|
-
|
|
61
|
-
def find(self, **kwargs):
|
|
62
|
-
# log(kwargs)
|
|
63
|
-
self._replace_pk_with_id(kwargs)
|
|
64
|
-
# log(kwargs)
|
|
65
|
-
if result := self.table.find(**kwargs):
|
|
66
|
-
self._replace_id_with_pk(result)
|
|
67
|
-
# log(result)
|
|
68
|
-
return result
|
|
69
|
-
|
|
70
|
-
def random(self):
|
|
71
|
-
if result := self.table.random():
|
|
72
|
-
self._replace_id_with_pk(result)
|
|
73
|
-
return result
|
|
74
|
-
|
|
75
|
-
def delete(self, pk):
|
|
76
|
-
pk = str(pk)
|
|
77
|
-
return self.table.delete(_id=pk)
|
|
78
|
-
|
|
79
|
-
def flush_table(self):
|
|
80
|
-
return self.table.clear()
|
|
81
|
-
|
|
82
|
-
def dbdump(self, directory="./dbbackups"):
|
|
83
|
-
return self._database.dbdump(directory)
|
|
84
|
-
|
|
85
|
-
def dbload(self, directory="./dbbackups"):
|
|
86
|
-
return self._database.dbload(directory)
|
autonomous/model/serializer.py
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
|
-
|
|
3
|
-
from autonomous import log
|
|
4
|
-
from autonomous.errors import DanglingReferenceError
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class AutoEncoder:
|
|
8
|
-
@classmethod
|
|
9
|
-
def encode(cls, objs):
|
|
10
|
-
try:
|
|
11
|
-
if isinstance(objs, dict):
|
|
12
|
-
obj_copy = {k: cls.encode(v) for k, v in objs.items()}
|
|
13
|
-
elif isinstance(objs, list):
|
|
14
|
-
obj_copy = [cls.encode(v) for v in objs]
|
|
15
|
-
else:
|
|
16
|
-
obj_copy = cls().default(objs)
|
|
17
|
-
return obj_copy
|
|
18
|
-
except DanglingReferenceError as e:
|
|
19
|
-
log(e)
|
|
20
|
-
return None
|
|
21
|
-
|
|
22
|
-
def default(self, o):
|
|
23
|
-
from autonomous.model.automodel import AutoModel, DelayedModel
|
|
24
|
-
|
|
25
|
-
if issubclass(type(o), (AutoModel, DelayedModel)):
|
|
26
|
-
name = "AutoModel"
|
|
27
|
-
else:
|
|
28
|
-
name = type(o).__name__
|
|
29
|
-
|
|
30
|
-
encoder_name = f"encode_{name}"
|
|
31
|
-
|
|
32
|
-
try:
|
|
33
|
-
encoder = getattr(self, encoder_name)
|
|
34
|
-
except AttributeError:
|
|
35
|
-
return o
|
|
36
|
-
else:
|
|
37
|
-
encoded = {"__extended_json_type__": name, "value": encoder(o)}
|
|
38
|
-
|
|
39
|
-
return encoded
|
|
40
|
-
|
|
41
|
-
def encode_datetime(self, o):
|
|
42
|
-
return o.isoformat()
|
|
43
|
-
|
|
44
|
-
def encode_AutoModel(self, o):
|
|
45
|
-
if o.pk:
|
|
46
|
-
return {
|
|
47
|
-
"pk": o.pk,
|
|
48
|
-
"_automodel": o.model_name(qualified=True),
|
|
49
|
-
}
|
|
50
|
-
else:
|
|
51
|
-
log(
|
|
52
|
-
o,
|
|
53
|
-
"The above object was not been saved. You must save subobjects if you want them to persist.",
|
|
54
|
-
)
|
|
55
|
-
raise ValueError(f"Cannot encode unsaved {o.model_name(qualified=True)}")
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
class AutoDecoder:
|
|
59
|
-
@classmethod
|
|
60
|
-
def decode(cls, objs):
|
|
61
|
-
decoder = cls()
|
|
62
|
-
if isinstance(objs, dict):
|
|
63
|
-
if "__extended_json_type__" in objs:
|
|
64
|
-
objs = decoder.default(objs)
|
|
65
|
-
else:
|
|
66
|
-
for k, v in objs.items():
|
|
67
|
-
objs[k] = cls.decode(v)
|
|
68
|
-
elif isinstance(objs, list):
|
|
69
|
-
for i, v in enumerate(objs):
|
|
70
|
-
objs[i] = cls.decode(v)
|
|
71
|
-
return objs
|
|
72
|
-
|
|
73
|
-
def default(self, obj):
|
|
74
|
-
try:
|
|
75
|
-
name = obj["__extended_json_type__"]
|
|
76
|
-
decoder_name = f"decode_{name}"
|
|
77
|
-
decoder = getattr(self, decoder_name)
|
|
78
|
-
except (KeyError, AttributeError, TypeError):
|
|
79
|
-
return obj
|
|
80
|
-
else:
|
|
81
|
-
return decoder(obj)
|
|
82
|
-
|
|
83
|
-
def decode_datetime(self, o):
|
|
84
|
-
return datetime.fromisoformat(o["value"])
|
|
85
|
-
|
|
86
|
-
def decode_AutoModel(self, o):
|
|
87
|
-
obj = o["value"]
|
|
88
|
-
try:
|
|
89
|
-
from autonomous.model.automodel import DelayedModel
|
|
90
|
-
|
|
91
|
-
if not obj["pk"]:
|
|
92
|
-
raise KeyError
|
|
93
|
-
return DelayedModel(obj["_automodel"], obj["pk"])
|
|
94
|
-
except DanglingReferenceError as e:
|
|
95
|
-
log(e)
|
|
96
|
-
return None
|
|
97
|
-
except KeyError:
|
|
98
|
-
log(
|
|
99
|
-
"AutoModel",
|
|
100
|
-
"The above object was not been saved. You must save subobjects if you want them to persist.",
|
|
101
|
-
)
|
|
102
|
-
raise ValueError("Cannot decode unsaved AutoModel")
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
autonomous/__init__.py,sha256=xlnCuJvSnIv1ZWLEaEt30t7aS6_2owEjBUePCe75JiY,87
|
|
2
|
-
autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
|
|
3
|
-
autonomous/logger.py,sha256=jePQ4kTtECTwGtIcDmpLSE6rSwhaUEiQe2vK06h5XIg,1915
|
|
4
|
-
autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
autonomous/ai/oaiagent.py,sha256=73gBZqlYTL8i7WuUrhu-G4JflzBDVdhragj9PvBkyKM,7697
|
|
6
|
-
autonomous/auth/__init__.py,sha256=IW5tQ8VYwHIbDfMYA0wYgx4PprwcjUWV4EoIJ8HTlMU,161
|
|
7
|
-
autonomous/auth/autoauth.py,sha256=Q2DfcWjh0vTSSpf5SqyK4SElVDcxu8435GhLSPqTYco,3724
|
|
8
|
-
autonomous/auth/github.py,sha256=dHf84bJdV9rXGcvRLzWCPW9CvuA-VEmqYi_QQFwd2kY,886
|
|
9
|
-
autonomous/auth/google.py,sha256=cHmqbyNEPTKipc3WkYcD1XPOyqcWEFW0Ks4qJYmGvPw,1049
|
|
10
|
-
autonomous/auth/user.py,sha256=eDOIhGuWjzhyAxlZkt6lw74Ykxt2TluDanW17D-eZmc,2389
|
|
11
|
-
autonomous/db/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
12
|
-
autonomous/db/autodb.py,sha256=GifrahGJ2dAi8jQOiMIh0pgktcbuKt_1kAXIjKlKVZY,2376
|
|
13
|
-
autonomous/db/table.py,sha256=eigar6_jxAZxYoh3mzHH1__QNyuh11LFAzOTEzCBHzo,4660
|
|
14
|
-
autonomous/errors/__init__.py,sha256=OruWG9IkAF4LN-OAo5c2K9Dnds4oZFJJQHKaXbQaWnA,59
|
|
15
|
-
autonomous/errors/danglingreferenceerror.py,sha256=obfNjpn2vsyK4ak-UuuwFTMVzecs1SaeFPshOvnukS8,275
|
|
16
|
-
autonomous/model/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
17
|
-
autonomous/model/autoattribute.py,sha256=q09cORKC6-LpoZ3Ez-lRkd5kxuSFQrB2nA2f9_8k2c8,588
|
|
18
|
-
autonomous/model/automodel.py,sha256=BT6Uj-GXTAxvvZg69vMjn40gb5taNXXyxfUUpAV2KUU,12690
|
|
19
|
-
autonomous/model/orm.py,sha256=IJrbp15RmBgF61vLsqcS_VdnAnw9736sLW75_xFYE9Y,2521
|
|
20
|
-
autonomous/model/serializer.py,sha256=ixJ5LZ0sicv49WIaPKSzNX0IFy0InlHYv9X-uG8Pi5Y,3048
|
|
21
|
-
autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
autonomous/storage/imagestorage.py,sha256=azV594Z_v-wf3W8lUtgLIb5q5O5VrAtqE2kxGtSIUKA,6250
|
|
23
|
-
autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
|
|
24
|
-
autonomous/storage/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
|
|
25
|
-
autonomous/storage/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
|
|
26
|
-
autonomous/storage/version_control/GHOrganization.py,sha256=mi2livdsGurKiifbvuLwiFbdDzL77IlEfhwEa-tG77I,1155
|
|
27
|
-
autonomous/storage/version_control/GHRepo.py,sha256=hTFHMkxSbSlVELfh8S6mq6ijkIKPRQO-Q5775ZjRKD4,4622
|
|
28
|
-
autonomous/storage/version_control/GHVersionControl.py,sha256=VIhVRxe6gJgozFWyhyKIu4spgSJI-GChiVJudnSyggI,196
|
|
29
|
-
autonomous/storage/version_control/__init__.py,sha256=tP0bAWYl1RwBRi62HsIidmgyqHuSlCUqwGuKUKKRugc,117
|
|
30
|
-
autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
|
|
31
|
-
autonomous/tasks/autotask.py,sha256=_WQ8w1LyV2FVJ0Ct0FoF9q1W8ClXfS57-omnBb0LNWE,4910
|
|
32
|
-
autonomous_app-0.2.24.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
|
|
33
|
-
autonomous_app-0.2.24.dist-info/METADATA,sha256=gTY0P7KKNU5SUsi77hjgaUdAOHhBkDdV2a09HrIHHXM,4228
|
|
34
|
-
autonomous_app-0.2.24.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
|
|
35
|
-
autonomous_app-0.2.24.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
|
|
36
|
-
autonomous_app-0.2.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|