MindsDB 25.8.3.0__py3-none-any.whl → 25.9.1.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.
Potentially problematic release.
This version of MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +3 -45
- mindsdb/api/a2a/__init__.py +52 -0
- mindsdb/api/a2a/agent.py +11 -12
- mindsdb/api/a2a/common/server/server.py +17 -36
- mindsdb/api/a2a/common/server/task_manager.py +14 -28
- mindsdb/api/a2a/task_manager.py +20 -21
- mindsdb/api/a2a/utils.py +1 -1
- mindsdb/api/common/middleware.py +106 -0
- mindsdb/api/executor/utilities/mysql_to_duckdb_functions.py +466 -18
- mindsdb/api/executor/utilities/sql.py +9 -31
- mindsdb/api/http/initialize.py +34 -43
- mindsdb/api/http/namespaces/auth.py +6 -14
- mindsdb/api/http/namespaces/config.py +0 -2
- mindsdb/api/http/namespaces/default.py +74 -106
- mindsdb/api/http/namespaces/file.py +9 -3
- mindsdb/api/http/namespaces/handlers.py +77 -87
- mindsdb/api/http/start.py +29 -47
- mindsdb/api/litellm/start.py +11 -10
- mindsdb/api/mcp/__init__.py +165 -0
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +33 -64
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +86 -85
- mindsdb/integrations/handlers/autogluon_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/autosklearn_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/crate_handler/crate_handler.py +3 -7
- mindsdb/integrations/handlers/derby_handler/derby_handler.py +32 -34
- mindsdb/integrations/handlers/documentdb_handler/requirements.txt +1 -0
- mindsdb/integrations/handlers/dummy_data_handler/dummy_data_handler.py +12 -13
- mindsdb/integrations/handlers/flaml_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/google_books_handler/google_books_handler.py +45 -44
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +101 -95
- mindsdb/integrations/handlers/google_content_shopping_handler/google_content_shopping_handler.py +129 -129
- mindsdb/integrations/handlers/google_fit_handler/google_fit_handler.py +59 -43
- mindsdb/integrations/handlers/google_search_handler/google_search_handler.py +38 -39
- mindsdb/integrations/handlers/informix_handler/informix_handler.py +5 -18
- mindsdb/integrations/handlers/lightfm_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/lightwood_handler/requirements.txt +4 -4
- mindsdb/integrations/handlers/maxdb_handler/maxdb_handler.py +22 -28
- mindsdb/integrations/handlers/monetdb_handler/monetdb_handler.py +3 -7
- mindsdb/integrations/handlers/mongodb_handler/mongodb_handler.py +53 -67
- mindsdb/integrations/handlers/mongodb_handler/requirements.txt +1 -0
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_ast.py +43 -68
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_parser.py +17 -25
- mindsdb/{api/mongo/utilities → integrations/handlers/mongodb_handler/utils}/mongodb_query.py +10 -16
- mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py +43 -69
- mindsdb/integrations/handlers/tpot_handler/requirements.txt +1 -1
- mindsdb/integrations/libs/base.py +1 -1
- mindsdb/integrations/libs/llm/config.py +15 -0
- mindsdb/integrations/libs/llm/utils.py +15 -0
- mindsdb/interfaces/agents/constants.py +1 -0
- mindsdb/interfaces/agents/langchain_agent.py +4 -0
- mindsdb/interfaces/agents/providers.py +20 -0
- mindsdb/interfaces/knowledge_base/controller.py +25 -7
- mindsdb/utilities/config.py +15 -158
- mindsdb/utilities/log.py +0 -25
- mindsdb/utilities/render/sqlalchemy_render.py +7 -1
- mindsdb/utilities/starters.py +0 -39
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/METADATA +269 -267
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/RECORD +62 -105
- mindsdb/api/a2a/__main__.py +0 -144
- mindsdb/api/a2a/run_a2a.py +0 -86
- mindsdb/api/common/check_auth.py +0 -42
- mindsdb/api/http/gunicorn_wrapper.py +0 -17
- mindsdb/api/mcp/start.py +0 -205
- mindsdb/api/mongo/__init__.py +0 -0
- mindsdb/api/mongo/classes/__init__.py +0 -5
- mindsdb/api/mongo/classes/query_sql.py +0 -19
- mindsdb/api/mongo/classes/responder.py +0 -45
- mindsdb/api/mongo/classes/responder_collection.py +0 -34
- mindsdb/api/mongo/classes/scram.py +0 -86
- mindsdb/api/mongo/classes/session.py +0 -23
- mindsdb/api/mongo/functions/__init__.py +0 -19
- mindsdb/api/mongo/responders/__init__.py +0 -73
- mindsdb/api/mongo/responders/add_shard.py +0 -13
- mindsdb/api/mongo/responders/aggregate.py +0 -90
- mindsdb/api/mongo/responders/buildinfo.py +0 -17
- mindsdb/api/mongo/responders/coll_stats.py +0 -63
- mindsdb/api/mongo/responders/company_id.py +0 -25
- mindsdb/api/mongo/responders/connection_status.py +0 -22
- mindsdb/api/mongo/responders/count.py +0 -21
- mindsdb/api/mongo/responders/db_stats.py +0 -32
- mindsdb/api/mongo/responders/delete.py +0 -105
- mindsdb/api/mongo/responders/describe.py +0 -23
- mindsdb/api/mongo/responders/end_sessions.py +0 -13
- mindsdb/api/mongo/responders/find.py +0 -175
- mindsdb/api/mongo/responders/get_cmd_line_opts.py +0 -18
- mindsdb/api/mongo/responders/get_free_monitoring_status.py +0 -14
- mindsdb/api/mongo/responders/get_parameter.py +0 -23
- mindsdb/api/mongo/responders/getlog.py +0 -14
- mindsdb/api/mongo/responders/host_info.py +0 -28
- mindsdb/api/mongo/responders/insert.py +0 -270
- mindsdb/api/mongo/responders/is_master.py +0 -20
- mindsdb/api/mongo/responders/is_master_lower.py +0 -13
- mindsdb/api/mongo/responders/list_collections.py +0 -55
- mindsdb/api/mongo/responders/list_databases.py +0 -37
- mindsdb/api/mongo/responders/list_indexes.py +0 -22
- mindsdb/api/mongo/responders/ping.py +0 -13
- mindsdb/api/mongo/responders/recv_chunk_start.py +0 -13
- mindsdb/api/mongo/responders/replsetgetstatus.py +0 -13
- mindsdb/api/mongo/responders/sasl_continue.py +0 -34
- mindsdb/api/mongo/responders/sasl_start.py +0 -33
- mindsdb/api/mongo/responders/update_range_deletions.py +0 -12
- mindsdb/api/mongo/responders/whatsmyuri.py +0 -18
- mindsdb/api/mongo/server.py +0 -388
- mindsdb/api/mongo/start.py +0 -15
- mindsdb/api/mongo/utilities/__init__.py +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/WHEEL +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/licenses/LICENSE +0 -0
- {mindsdb-25.8.3.0.dist-info → mindsdb-25.9.1.1.dist-info}/top_level.txt +0 -0
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
from bson.int64 import Int64
|
|
2
|
-
|
|
3
|
-
from mindsdb_sql_parser.ast import Identifier, Insert, CreateTable
|
|
4
|
-
|
|
5
|
-
from mindsdb.api.mongo.classes import Responder
|
|
6
|
-
import mindsdb.api.mongo.functions as helpers
|
|
7
|
-
from mindsdb.api.mongo.responders.find import find_to_ast
|
|
8
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
9
|
-
from mindsdb.utilities.config import config
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def aggregate_to_ast(query, database):
|
|
13
|
-
collection = query['aggregate']
|
|
14
|
-
|
|
15
|
-
save_table = None
|
|
16
|
-
is_append = False
|
|
17
|
-
first_step = query['pipeline'][0]
|
|
18
|
-
if '$match' in first_step:
|
|
19
|
-
# convert to find
|
|
20
|
-
find_query = {
|
|
21
|
-
'find': collection,
|
|
22
|
-
'filter': first_step['$match'],
|
|
23
|
-
}
|
|
24
|
-
for step in query['pipeline'][1:]:
|
|
25
|
-
if '$project' in step:
|
|
26
|
-
find_query['projection'] = step['$project']
|
|
27
|
-
if '$sort' in step:
|
|
28
|
-
find_query['sort'] = step['$sort']
|
|
29
|
-
if '$skip' in step:
|
|
30
|
-
find_query['skip'] = step['$skip']
|
|
31
|
-
if '$limit' in step:
|
|
32
|
-
find_query['limit'] = step['$limit']
|
|
33
|
-
|
|
34
|
-
if '$out' in step:
|
|
35
|
-
target = step['$out']
|
|
36
|
-
if isinstance(target, str):
|
|
37
|
-
save_table = Identifier(target)
|
|
38
|
-
else:
|
|
39
|
-
save_table = Identifier(parts=[target['db'], target['coll']])
|
|
40
|
-
if target.get('append'):
|
|
41
|
-
is_append = True
|
|
42
|
-
|
|
43
|
-
# TODO implement group
|
|
44
|
-
ast_query = find_to_ast(find_query, database)
|
|
45
|
-
if save_table is not None:
|
|
46
|
-
if is_append:
|
|
47
|
-
ast_query = Insert(save_table, from_select=ast_query)
|
|
48
|
-
else:
|
|
49
|
-
ast_query = CreateTable(save_table, from_select=ast_query, is_replace=True)
|
|
50
|
-
|
|
51
|
-
else:
|
|
52
|
-
raise NotImplementedError
|
|
53
|
-
|
|
54
|
-
return ast_query
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
class Responce(Responder):
|
|
58
|
-
when = {'aggregate': helpers.is_true}
|
|
59
|
-
|
|
60
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
61
|
-
db = query['$db']
|
|
62
|
-
collection = query['aggregate']
|
|
63
|
-
|
|
64
|
-
first_step = query['pipeline'][0]
|
|
65
|
-
if '$match' in first_step:
|
|
66
|
-
ast_query = aggregate_to_ast(query, request_env.get('database', config.get('default_project')))
|
|
67
|
-
|
|
68
|
-
data = run_sql_command(request_env, ast_query)
|
|
69
|
-
|
|
70
|
-
elif '$collStats' in first_step:
|
|
71
|
-
raise ValueError(
|
|
72
|
-
"To describe model use:"
|
|
73
|
-
" db.runCommand({describe: 'model_name.attribute'})"
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
else:
|
|
77
|
-
raise NotImplementedError
|
|
78
|
-
|
|
79
|
-
cursor = {
|
|
80
|
-
'id': Int64(0),
|
|
81
|
-
'ns': f"{db}.$cmd.{collection}",
|
|
82
|
-
'firstBatch': data
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
'cursor': cursor,
|
|
86
|
-
'ok': 1
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
responder = Responce()
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Responce(Responder):
|
|
5
|
-
def when(self, query):
|
|
6
|
-
return (
|
|
7
|
-
'buildinfo' in query or 'buildInfo' in query
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
result = {
|
|
11
|
-
'version': '3.6.8',
|
|
12
|
-
'versionArray': [3, 6, 8, 0],
|
|
13
|
-
'ok': 1
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
responder = Responce()
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
from mindsdb_sql_parser.ast import Describe, Identifier
|
|
2
|
-
|
|
3
|
-
from mindsdb.api.mongo.classes import Responder
|
|
4
|
-
import mindsdb.api.mongo.functions as helpers
|
|
5
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
6
|
-
from mindsdb.utilities.config import config
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Responce(Responder):
|
|
10
|
-
when = {'collStats': helpers.is_true}
|
|
11
|
-
|
|
12
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
13
|
-
db = query['$db']
|
|
14
|
-
collection = query['collStats']
|
|
15
|
-
|
|
16
|
-
scale = query.get('scale')
|
|
17
|
-
|
|
18
|
-
if db != config.get('default_project') or collection == 'predictors' or scale is None:
|
|
19
|
-
# old behavior
|
|
20
|
-
# NOTE real answer is huge, i removed most data from it.
|
|
21
|
-
res = {
|
|
22
|
-
'ns': "db.collection",
|
|
23
|
-
'size': 1,
|
|
24
|
-
'count': 0,
|
|
25
|
-
'avgObjSize': 1,
|
|
26
|
-
'storageSize': 16384,
|
|
27
|
-
'capped': False,
|
|
28
|
-
'wiredTiger': {
|
|
29
|
-
},
|
|
30
|
-
'nindexes': 1,
|
|
31
|
-
'indexDetails': {
|
|
32
|
-
},
|
|
33
|
-
'totalIndexSize': 16384,
|
|
34
|
-
'indexSizes': {
|
|
35
|
-
'_id_': 16384
|
|
36
|
-
},
|
|
37
|
-
'ok': 1
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
res['ns'] = f"{db}.{collection}"
|
|
41
|
-
if db == config.get('default_project') and collection == 'predictors':
|
|
42
|
-
res['count'] = len(mindsdb_env['model_controller'].get_models())
|
|
43
|
-
else:
|
|
44
|
-
|
|
45
|
-
ident_parts = [collection]
|
|
46
|
-
if scale is not None:
|
|
47
|
-
ident_parts.append(scale)
|
|
48
|
-
|
|
49
|
-
ast_query = Describe(Identifier(
|
|
50
|
-
parts=ident_parts
|
|
51
|
-
))
|
|
52
|
-
|
|
53
|
-
data = run_sql_command(request_env, ast_query)
|
|
54
|
-
res = {
|
|
55
|
-
'data': data
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
res['ns'] = f"{db}.{collection}"
|
|
59
|
-
|
|
60
|
-
return res
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
responder = Responce()
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
from mindsdb.utilities.context import context as ctx
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
def when(self, query):
|
|
7
|
-
return 'company_id' in query
|
|
8
|
-
|
|
9
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
10
|
-
company_id = query.get('company_id')
|
|
11
|
-
user_class = query.get('user_class', 0)
|
|
12
|
-
email_confirmed = query.get('email_confirmed', 1)
|
|
13
|
-
need_response = query.get('need_response', False)
|
|
14
|
-
|
|
15
|
-
ctx.company_id = company_id
|
|
16
|
-
ctx.user_class = user_class
|
|
17
|
-
ctx.email_confirmed = email_confirmed
|
|
18
|
-
|
|
19
|
-
if need_response:
|
|
20
|
-
return {'ok': 1}
|
|
21
|
-
|
|
22
|
-
return None
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
responder = Responce()
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'connectionStatus': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
res = {
|
|
10
|
-
'authInfo': {
|
|
11
|
-
'authenticatedUsers': [],
|
|
12
|
-
'authenticatedUserRoles': []
|
|
13
|
-
},
|
|
14
|
-
'ok': 1
|
|
15
|
-
}
|
|
16
|
-
if helpers.is_true(query.get('showPrivileges')):
|
|
17
|
-
res['authInfo']['authenticatedUserPrivileges'] = []
|
|
18
|
-
|
|
19
|
-
return res
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
responder = Responce()
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'count': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
collection = query['count']
|
|
10
|
-
|
|
11
|
-
count = 0
|
|
12
|
-
if collection == 'predictors':
|
|
13
|
-
count = len(mindsdb_env['model_controller'].get_models())
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
'n': count,
|
|
17
|
-
'ok': 1
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
responder = Responce()
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
from mindsdb.utilities.config import config
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class Responce(Responder):
|
|
7
|
-
when = {'dbStats': helpers.is_true}
|
|
8
|
-
|
|
9
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
10
|
-
db = query['$db']
|
|
11
|
-
collections = 0
|
|
12
|
-
if db == config.get('default_project'):
|
|
13
|
-
collections = 2 + len(mindsdb_env['model_controller'].get_models())
|
|
14
|
-
return {
|
|
15
|
-
'db': db,
|
|
16
|
-
'collections': collections,
|
|
17
|
-
'views': 0,
|
|
18
|
-
'objects': 0,
|
|
19
|
-
'avgObjSize': 0,
|
|
20
|
-
'dataSize': 0,
|
|
21
|
-
'storageSize': 0,
|
|
22
|
-
'numExtents': 0,
|
|
23
|
-
'indexes': 0,
|
|
24
|
-
'indexSize': 0,
|
|
25
|
-
'fileSize': 0,
|
|
26
|
-
'fsUsedSize': 0,
|
|
27
|
-
'fsTotalSize': 0,
|
|
28
|
-
'ok': 1
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
responder = Responce()
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
from mindsdb_sql_parser.ast import Identifier
|
|
4
|
-
from mindsdb_sql_parser.ast.mindsdb import DropPredictor, DropJob, DropMLEngine
|
|
5
|
-
from mindsdb.interfaces.jobs.jobs_controller import JobsController
|
|
6
|
-
|
|
7
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class Responce(Responder):
|
|
11
|
-
when = {'delete': helpers.is_true}
|
|
12
|
-
|
|
13
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
14
|
-
try:
|
|
15
|
-
res = self._result(query, request_env, mindsdb_env)
|
|
16
|
-
except Exception as e:
|
|
17
|
-
res = {
|
|
18
|
-
'n': 0,
|
|
19
|
-
'writeErrors': [{
|
|
20
|
-
'index': 0,
|
|
21
|
-
'code': 0,
|
|
22
|
-
'errmsg': str(e)
|
|
23
|
-
}],
|
|
24
|
-
'ok': 1
|
|
25
|
-
}
|
|
26
|
-
return res
|
|
27
|
-
|
|
28
|
-
def _result(self, query, request_env, mindsdb_env):
|
|
29
|
-
table = query['delete']
|
|
30
|
-
if table == 'predictors':
|
|
31
|
-
table = 'models'
|
|
32
|
-
|
|
33
|
-
project_name = request_env['database']
|
|
34
|
-
|
|
35
|
-
allowed_tables = ('models', 'jobs', 'ml_engines')
|
|
36
|
-
if table not in allowed_tables:
|
|
37
|
-
raise Exception(f"Only removing from this collections is supported: {', '.join(allowed_tables)}")
|
|
38
|
-
|
|
39
|
-
if len(query['deletes']) != 1:
|
|
40
|
-
raise Exception("Should be only one argument in REMOVE operation")
|
|
41
|
-
|
|
42
|
-
obj_name, obj_id = None, None
|
|
43
|
-
|
|
44
|
-
delete_filter = query['deletes'][0]['q']
|
|
45
|
-
if '_id' in delete_filter:
|
|
46
|
-
# get name of object
|
|
47
|
-
obj_id = helpers.objectid_to_int(delete_filter['_id'])
|
|
48
|
-
|
|
49
|
-
if 'name' in delete_filter:
|
|
50
|
-
obj_name = delete_filter['name']
|
|
51
|
-
|
|
52
|
-
version = None
|
|
53
|
-
if 'version' in delete_filter:
|
|
54
|
-
version = delete_filter['version']
|
|
55
|
-
|
|
56
|
-
if obj_name is None and obj_id is None:
|
|
57
|
-
raise Exception("Can't find object to delete, use filter by name or _id")
|
|
58
|
-
|
|
59
|
-
if obj_name is None:
|
|
60
|
-
if table == 'models':
|
|
61
|
-
model_id = obj_id >> 20
|
|
62
|
-
version = obj_id & (2 ** 20 - 1)
|
|
63
|
-
|
|
64
|
-
models = mindsdb_env['model_controller'].get_models(
|
|
65
|
-
ml_handler_name=None,
|
|
66
|
-
project_name=project_name
|
|
67
|
-
)
|
|
68
|
-
for model in models:
|
|
69
|
-
if model['id'] == model_id:
|
|
70
|
-
obj_name = model['name']
|
|
71
|
-
break
|
|
72
|
-
if obj_name is None:
|
|
73
|
-
raise Exception("Can't find model by _id")
|
|
74
|
-
elif table == 'jobs':
|
|
75
|
-
jobs_controller = JobsController()
|
|
76
|
-
for job in jobs_controller.get_list(project_name):
|
|
77
|
-
if job['id'] == obj_id:
|
|
78
|
-
obj_name = job['name']
|
|
79
|
-
break
|
|
80
|
-
|
|
81
|
-
# delete model
|
|
82
|
-
if table == 'models':
|
|
83
|
-
if version is None:
|
|
84
|
-
ast_query = DropPredictor(Identifier(parts=[project_name, obj_name]))
|
|
85
|
-
run_sql_command(request_env, ast_query)
|
|
86
|
-
else:
|
|
87
|
-
# delete model version
|
|
88
|
-
ast_query = DropPredictor(Identifier(parts=[project_name, obj_name, str(version)]))
|
|
89
|
-
run_sql_command(request_env, ast_query)
|
|
90
|
-
|
|
91
|
-
elif table == 'jobs':
|
|
92
|
-
ast_query = DropJob(Identifier(parts=[project_name, obj_name]))
|
|
93
|
-
run_sql_command(request_env, ast_query)
|
|
94
|
-
|
|
95
|
-
elif table == 'ml_engines':
|
|
96
|
-
ast_query = DropMLEngine(Identifier(parts=[obj_name]))
|
|
97
|
-
run_sql_command(request_env, ast_query)
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
'n': 1,
|
|
101
|
-
'ok': 1
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
responder = Responce()
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from mindsdb_sql_parser.ast import Describe, Identifier
|
|
2
|
-
|
|
3
|
-
from mindsdb.api.mongo.classes import Responder
|
|
4
|
-
import mindsdb.api.mongo.functions as helpers
|
|
5
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Responce(Responder):
|
|
9
|
-
when = {'describe': helpers.is_true}
|
|
10
|
-
|
|
11
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
12
|
-
db = query['$db']
|
|
13
|
-
model = query['describe']
|
|
14
|
-
|
|
15
|
-
ast_query = Describe(Identifier(model))
|
|
16
|
-
|
|
17
|
-
data = run_sql_command(request_env, ast_query)
|
|
18
|
-
res = {'data': data, 'ns': f"{db}.{model}"}
|
|
19
|
-
|
|
20
|
-
return res
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
responder = Responce()
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
from bson.int64 import Int64
|
|
2
|
-
|
|
3
|
-
from mindsdb_sql_parser.ast import Join, Select, Identifier, Describe, Show, Constant
|
|
4
|
-
import mindsdb.api.mongo.functions as helpers
|
|
5
|
-
from mindsdb.api.mongo.classes import Responder
|
|
6
|
-
from mindsdb.api.mongo.utilities.mongodb_ast import MongoToAst
|
|
7
|
-
from mindsdb.interfaces.jobs.jobs_controller import JobsController
|
|
8
|
-
|
|
9
|
-
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def find_to_ast(query, database):
|
|
13
|
-
mongoToAst = MongoToAst()
|
|
14
|
-
|
|
15
|
-
collection = [database, query['find']]
|
|
16
|
-
|
|
17
|
-
if not query.get('singleBatch') and 'collection' in query.get('filter'):
|
|
18
|
-
# JOIN mode
|
|
19
|
-
|
|
20
|
-
# upper query
|
|
21
|
-
ast_query = mongoToAst.find(
|
|
22
|
-
collection=collection,
|
|
23
|
-
projection=query.get('projection'),
|
|
24
|
-
sort=query.get('sort'),
|
|
25
|
-
limit=query.get('limit'),
|
|
26
|
-
skip=query.get('skip'),
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
# table_query
|
|
30
|
-
collection = query['filter']['collection']
|
|
31
|
-
filter = query['filter'].get('query', {})
|
|
32
|
-
table_select = mongoToAst.find(
|
|
33
|
-
collection=collection,
|
|
34
|
-
filter=filter,
|
|
35
|
-
)
|
|
36
|
-
table_select.parentheses = True
|
|
37
|
-
table_select.alias = Identifier(query['filter']['collection'])
|
|
38
|
-
table_select.alias.parts = [table_select.alias.parts[-1]]
|
|
39
|
-
if 'limit' in query:
|
|
40
|
-
table_select.limit = Constant(query['limit'])
|
|
41
|
-
|
|
42
|
-
modifiers = query['filter'].get('modifiers')
|
|
43
|
-
if modifiers is not None and hasattr(ast_query, 'modifiers'):
|
|
44
|
-
for modifier in modifiers:
|
|
45
|
-
table_select.modifiers.append(modifier)
|
|
46
|
-
|
|
47
|
-
# convert to join
|
|
48
|
-
right_table = ast_query.from_table
|
|
49
|
-
|
|
50
|
-
ast_join = Join(
|
|
51
|
-
left=table_select,
|
|
52
|
-
right=right_table,
|
|
53
|
-
join_type='join'
|
|
54
|
-
)
|
|
55
|
-
ast_query.from_table = ast_join
|
|
56
|
-
|
|
57
|
-
else:
|
|
58
|
-
# is single table
|
|
59
|
-
ast_query = mongoToAst.find(
|
|
60
|
-
collection=collection,
|
|
61
|
-
filter=query.get('filter'),
|
|
62
|
-
projection=query.get('projection'),
|
|
63
|
-
sort=query.get('sort'),
|
|
64
|
-
limit=query.get('limit'),
|
|
65
|
-
skip=query.get('skip'),
|
|
66
|
-
)
|
|
67
|
-
modifiers = query['filter'].get('modifiers')
|
|
68
|
-
if modifiers is not None and hasattr(ast_query, 'modifiers'):
|
|
69
|
-
for modifier in modifiers:
|
|
70
|
-
ast_query.modifiers.append(modifier)
|
|
71
|
-
return ast_query
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
class Responce(Responder):
|
|
75
|
-
when = {'find': helpers.is_true}
|
|
76
|
-
|
|
77
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
78
|
-
database = request_env['database']
|
|
79
|
-
project_name = request_env['database']
|
|
80
|
-
|
|
81
|
-
if database == 'config':
|
|
82
|
-
# return nothing
|
|
83
|
-
return {
|
|
84
|
-
'cursor': {
|
|
85
|
-
'id': Int64(0),
|
|
86
|
-
'ns': f"{database}.$cmd.{query['find']}",
|
|
87
|
-
'firstBatch': []
|
|
88
|
-
},
|
|
89
|
-
'ok': 1
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
# system queries
|
|
93
|
-
elif query['find'] == 'system.version':
|
|
94
|
-
# For studio3t
|
|
95
|
-
data = [{
|
|
96
|
-
"_id": "featureCompatibilityVersion",
|
|
97
|
-
"version": "3.6"
|
|
98
|
-
}]
|
|
99
|
-
cursor = {
|
|
100
|
-
'id': Int64(0),
|
|
101
|
-
'ns': f"system.version.$cmd.{query['find']}",
|
|
102
|
-
'firstBatch': data
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
'cursor': cursor,
|
|
106
|
-
'ok': 1
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
elif query['find'] == 'ml_engines':
|
|
110
|
-
ast_query = Show('ml_engines')
|
|
111
|
-
|
|
112
|
-
else:
|
|
113
|
-
ast_query = find_to_ast(query, database)
|
|
114
|
-
|
|
115
|
-
# add _id for objects
|
|
116
|
-
table_name = None
|
|
117
|
-
obj_idx = {}
|
|
118
|
-
if isinstance(ast_query, Select) and ast_query.from_table is not None:
|
|
119
|
-
if isinstance(ast_query.from_table, Identifier):
|
|
120
|
-
table_name = ast_query.from_table.parts[-1].lower()
|
|
121
|
-
|
|
122
|
-
if table_name == 'models':
|
|
123
|
-
|
|
124
|
-
models = mindsdb_env['model_controller'].get_models(
|
|
125
|
-
ml_handler_name=None,
|
|
126
|
-
project_name=project_name
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
for model in models:
|
|
130
|
-
obj_idx[model['name']] = model['id']
|
|
131
|
-
|
|
132
|
-
# is select from model without where
|
|
133
|
-
if table_name in obj_idx and ast_query.where is None:
|
|
134
|
-
# replace query to describe model
|
|
135
|
-
ast_query = Describe(ast_query.from_table)
|
|
136
|
-
elif table_name == 'jobs':
|
|
137
|
-
jobs_controller = JobsController()
|
|
138
|
-
for job in jobs_controller.get_list(project_name):
|
|
139
|
-
obj_idx[job['name']] = job['id']
|
|
140
|
-
|
|
141
|
-
data = run_sql_command(request_env, ast_query)
|
|
142
|
-
|
|
143
|
-
if table_name == 'models':
|
|
144
|
-
# for models and models_versions _id is:
|
|
145
|
-
# - first 20 bytes is version
|
|
146
|
-
# - next bytes is model id
|
|
147
|
-
|
|
148
|
-
for row in data:
|
|
149
|
-
model_id = obj_idx.get(row.get('NAME'))
|
|
150
|
-
if model_id is not None:
|
|
151
|
-
obj_id = model_id << 20
|
|
152
|
-
|
|
153
|
-
obj_id += row.get('VERSION', 0)
|
|
154
|
-
|
|
155
|
-
row['_id'] = helpers.int_to_objectid(obj_id)
|
|
156
|
-
elif table_name == 'jobs':
|
|
157
|
-
for row in data:
|
|
158
|
-
obj_id = obj_idx.get(row.get('NAME'))
|
|
159
|
-
if obj_id is not None:
|
|
160
|
-
row['_id'] = helpers.int_to_objectid(obj_id)
|
|
161
|
-
|
|
162
|
-
db = mindsdb_env['config']['api']['mongodb']['database']
|
|
163
|
-
|
|
164
|
-
cursor = {
|
|
165
|
-
'id': Int64(0),
|
|
166
|
-
'ns': f"{db}.$cmd.{query['find']}",
|
|
167
|
-
'firstBatch': data
|
|
168
|
-
}
|
|
169
|
-
return {
|
|
170
|
-
'cursor': cursor,
|
|
171
|
-
'ok': 1
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
responder = Responce()
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'getCmdLineOpts': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
result = {
|
|
9
|
-
'argv': [
|
|
10
|
-
'mongod'
|
|
11
|
-
],
|
|
12
|
-
'parsed': {
|
|
13
|
-
},
|
|
14
|
-
'ok': 1
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
responder = Responce()
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'getFreeMonitoringStatus': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
result = {
|
|
9
|
-
'state': 'undecided',
|
|
10
|
-
'ok': 1
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
responder = Responce()
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
from mindsdb.api.mongo.classes import Responder
|
|
2
|
-
import mindsdb.api.mongo.functions as helpers
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class Responce(Responder):
|
|
6
|
-
when = {'getParameter': helpers.is_true}
|
|
7
|
-
|
|
8
|
-
def result(self, query, request_env, mindsdb_env, session):
|
|
9
|
-
|
|
10
|
-
if query['featureCompatibilityVersion']:
|
|
11
|
-
res = {
|
|
12
|
-
"featureCompatibilityVersion":
|
|
13
|
-
{
|
|
14
|
-
"version": "3.6"
|
|
15
|
-
},
|
|
16
|
-
"ok": 1.0
|
|
17
|
-
}
|
|
18
|
-
else:
|
|
19
|
-
raise NotImplementedError(f'Unknown parameter {query}')
|
|
20
|
-
return res
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
responder = Responce()
|