MindsDB 25.2.3.0__py3-none-any.whl → 25.3.1.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.
Potentially problematic release.
This version of MindsDB might be problematic. Click here for more details.
- mindsdb/__about__.py +1 -1
- mindsdb/__main__.py +16 -11
- mindsdb/api/executor/command_executor.py +1 -1
- mindsdb/api/executor/datahub/datanodes/system_tables.py +10 -2
- mindsdb/api/executor/planner/query_planner.py +6 -2
- mindsdb/api/executor/sql_query/steps/prepare_steps.py +2 -1
- mindsdb/api/http/initialize.py +8 -5
- mindsdb/api/http/namespaces/agents.py +0 -7
- mindsdb/api/http/namespaces/config.py +0 -48
- mindsdb/api/http/namespaces/knowledge_bases.py +1 -1
- mindsdb/api/http/namespaces/util.py +0 -28
- mindsdb/api/mongo/classes/query_sql.py +2 -1
- mindsdb/api/mongo/responders/aggregate.py +2 -2
- mindsdb/api/mongo/responders/coll_stats.py +3 -2
- mindsdb/api/mongo/responders/db_stats.py +2 -1
- mindsdb/api/mongo/responders/insert.py +4 -2
- mindsdb/api/mysql/mysql_proxy/classes/fake_mysql_proxy/fake_mysql_proxy.py +2 -1
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +5 -4
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +2 -4
- mindsdb/integrations/handlers/anyscale_endpoints_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/autosklearn_handler/autosklearn_handler.py +1 -1
- mindsdb/integrations/handlers/dspy_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/gmail_handler/connection_args.py +2 -2
- mindsdb/integrations/handlers/gmail_handler/gmail_handler.py +19 -66
- mindsdb/integrations/handlers/gmail_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/google_calendar_handler/connection_args.py +15 -0
- mindsdb/integrations/handlers/google_calendar_handler/google_calendar_handler.py +31 -41
- mindsdb/integrations/handlers/google_calendar_handler/requirements.txt +0 -2
- mindsdb/integrations/handlers/langchain_embedding_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/langchain_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/llama_index_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/openai_handler/constants.py +3 -1
- mindsdb/integrations/handlers/openai_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/rag_handler/requirements.txt +0 -1
- mindsdb/integrations/handlers/ray_serve_handler/ray_serve_handler.py +33 -8
- mindsdb/integrations/handlers/web_handler/urlcrawl_helpers.py +3 -2
- mindsdb/integrations/handlers/web_handler/web_handler.py +42 -33
- mindsdb/integrations/handlers/youtube_handler/__init__.py +2 -0
- mindsdb/integrations/handlers/youtube_handler/connection_args.py +32 -0
- mindsdb/integrations/handlers/youtube_handler/youtube_handler.py +2 -38
- mindsdb/integrations/libs/llm/utils.py +7 -1
- mindsdb/integrations/libs/process_cache.py +2 -2
- mindsdb/integrations/utilities/handlers/auth_utilities/google/google_user_oauth_utilities.py +29 -38
- mindsdb/integrations/utilities/pydantic_utils.py +208 -0
- mindsdb/integrations/utilities/rag/chains/local_context_summarizer_chain.py +227 -0
- mindsdb/integrations/utilities/rag/pipelines/rag.py +11 -4
- mindsdb/integrations/utilities/rag/retrievers/sql_retriever.py +800 -135
- mindsdb/integrations/utilities/rag/settings.py +390 -152
- mindsdb/integrations/utilities/sql_utils.py +2 -1
- mindsdb/interfaces/agents/agents_controller.py +14 -10
- mindsdb/interfaces/agents/callback_handlers.py +52 -5
- mindsdb/interfaces/agents/langchain_agent.py +5 -3
- mindsdb/interfaces/agents/mindsdb_chat_model.py +4 -2
- mindsdb/interfaces/chatbot/chatbot_controller.py +9 -8
- mindsdb/interfaces/database/database.py +3 -2
- mindsdb/interfaces/database/integrations.py +1 -1
- mindsdb/interfaces/database/projects.py +28 -2
- mindsdb/interfaces/jobs/jobs_controller.py +4 -1
- mindsdb/interfaces/jobs/scheduler.py +1 -1
- mindsdb/interfaces/knowledge_base/preprocessing/constants.py +2 -2
- mindsdb/interfaces/model/model_controller.py +5 -2
- mindsdb/interfaces/skills/retrieval_tool.py +128 -39
- mindsdb/interfaces/skills/skill_tool.py +7 -7
- mindsdb/interfaces/skills/skills_controller.py +10 -6
- mindsdb/interfaces/skills/sql_agent.py +6 -1
- mindsdb/interfaces/storage/db.py +14 -12
- mindsdb/interfaces/storage/json.py +59 -0
- mindsdb/interfaces/storage/model_fs.py +85 -3
- mindsdb/interfaces/triggers/triggers_controller.py +2 -1
- mindsdb/migrations/versions/2022-10-14_43c52d23845a_projects.py +17 -3
- mindsdb/migrations/versions/2025-02-10_6ab9903fc59a_del_log_table.py +33 -0
- mindsdb/migrations/versions/2025-02-14_4521dafe89ab_added_encrypted_content_to_json_storage.py +29 -0
- mindsdb/migrations/versions/2025-02-19_11347c213b36_added_metadata_to_projects.py +41 -0
- mindsdb/utilities/config.py +6 -1
- mindsdb/utilities/functions.py +11 -0
- mindsdb/utilities/log.py +17 -2
- mindsdb/utilities/ml_task_queue/consumer.py +4 -2
- mindsdb/utilities/render/sqlalchemy_render.py +4 -0
- {MindsDB-25.2.3.0.dist-info → mindsdb-25.3.1.0.dist-info}/METADATA +226 -247
- {MindsDB-25.2.3.0.dist-info → mindsdb-25.3.1.0.dist-info}/RECORD +83 -80
- {MindsDB-25.2.3.0.dist-info → mindsdb-25.3.1.0.dist-info}/WHEEL +1 -1
- mindsdb/integrations/handlers/gmail_handler/utils.py +0 -45
- mindsdb/utilities/log_controller.py +0 -39
- mindsdb/utilities/telemetry.py +0 -44
- {MindsDB-25.2.3.0.dist-info → mindsdb-25.3.1.0.dist-info}/LICENSE +0 -0
- {MindsDB-25.2.3.0.dist-info → mindsdb-25.3.1.0.dist-info}/top_level.txt +0 -0
mindsdb/__about__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
__title__ = 'MindsDB'
|
|
2
2
|
__package_name__ = 'mindsdb'
|
|
3
|
-
__version__ = '25.
|
|
3
|
+
__version__ = '25.3.1.0'
|
|
4
4
|
__description__ = "MindsDB's AI SQL Server enables developers to build AI tools that need access to real-time data to perform their tasks"
|
|
5
5
|
__email__ = "jorge@mindsdb.com"
|
|
6
6
|
__author__ = 'MindsDB Inc'
|
mindsdb/__main__.py
CHANGED
|
@@ -22,16 +22,17 @@ logger.debug("Starting MindsDB...")
|
|
|
22
22
|
|
|
23
23
|
from mindsdb.__about__ import __version__ as mindsdb_version
|
|
24
24
|
from mindsdb.utilities.config import config
|
|
25
|
+
from mindsdb.utilities.exception import EntityNotExistsError
|
|
25
26
|
from mindsdb.utilities.starters import (
|
|
26
27
|
start_http, start_mysql, start_mongo, start_postgres, start_ml_task_queue, start_scheduler, start_tasks
|
|
27
28
|
)
|
|
28
29
|
from mindsdb.utilities.ps import is_pid_listen_port, get_child_pids
|
|
29
30
|
from mindsdb.utilities.functions import get_versions_where_predictors_become_obsolete
|
|
30
31
|
from mindsdb.interfaces.database.integrations import integration_controller
|
|
32
|
+
from mindsdb.interfaces.database.projects import ProjectController
|
|
31
33
|
import mindsdb.interfaces.storage.db as db
|
|
32
34
|
from mindsdb.integrations.utilities.install import install_dependencies
|
|
33
35
|
from mindsdb.utilities.fs import clean_process_marks, clean_unlinked_process_marks
|
|
34
|
-
from mindsdb.utilities.telemetry import telemetry_file_exists, disable_telemetry
|
|
35
36
|
from mindsdb.utilities.context import context as ctx
|
|
36
37
|
from mindsdb.utilities.auth import register_oauth_client, get_aws_meta_data
|
|
37
38
|
from mindsdb.utilities.sentry import sentry_sdk # noqa: F401
|
|
@@ -248,15 +249,6 @@ if __name__ == '__main__':
|
|
|
248
249
|
config.raise_warnings(logger=logger)
|
|
249
250
|
os.environ["MINDSDB_RUNTIME"] = "1"
|
|
250
251
|
|
|
251
|
-
if telemetry_file_exists(config.paths['root']):
|
|
252
|
-
os.environ['CHECK_FOR_UPDATES'] = '0'
|
|
253
|
-
logger.info('\n x telemetry disabled! \n')
|
|
254
|
-
elif os.getenv('CHECK_FOR_UPDATES', '1').lower() in ['0', 'false', 'False'] or config.is_cloud:
|
|
255
|
-
disable_telemetry(config.paths['root'])
|
|
256
|
-
logger.info('\n x telemetry disabled! \n')
|
|
257
|
-
else:
|
|
258
|
-
logger.info("✓ telemetry enabled")
|
|
259
|
-
|
|
260
252
|
if os.environ.get("FLASK_SECRET_KEY") is None:
|
|
261
253
|
os.environ["FLASK_SECRET_KEY"] = secrets.token_hex(32)
|
|
262
254
|
|
|
@@ -303,6 +295,19 @@ if __name__ == '__main__':
|
|
|
303
295
|
except Exception as e:
|
|
304
296
|
logger.error(f"Error! Something went wrong during DB migrations: {e}")
|
|
305
297
|
|
|
298
|
+
logger.debug(f"Checking if default project {config.get('default_project')} exists")
|
|
299
|
+
project_controller = ProjectController()
|
|
300
|
+
|
|
301
|
+
current_default_project = project_controller.get(is_default=True)
|
|
302
|
+
if current_default_project.record.name != config.get('default_project'):
|
|
303
|
+
try:
|
|
304
|
+
new_default_project = project_controller.get(name=config.get('default_project'))
|
|
305
|
+
log.critical(f"A project with the name '{config.get('default_project')}' already exists")
|
|
306
|
+
sys.exit(1)
|
|
307
|
+
except EntityNotExistsError:
|
|
308
|
+
pass
|
|
309
|
+
project_controller.update(current_default_project.record.id, new_name=config.get('default_project'))
|
|
310
|
+
|
|
306
311
|
apis = os.getenv('MINDSDB_APIS') or config.cmd_args.api
|
|
307
312
|
|
|
308
313
|
if apis is None: # If "--api" option is not specified, start the default APIs
|
|
@@ -548,7 +553,7 @@ if __name__ == '__main__':
|
|
|
548
553
|
ioloop = asyncio.new_event_loop()
|
|
549
554
|
ioloop.run_until_complete(wait_apis_start())
|
|
550
555
|
|
|
551
|
-
threading.Thread(target=do_clean_process_marks).start()
|
|
556
|
+
threading.Thread(target=do_clean_process_marks, name='clean_process_marks').start()
|
|
552
557
|
|
|
553
558
|
ioloop.run_until_complete(gather_apis())
|
|
554
559
|
ioloop.close()
|
|
@@ -1549,7 +1549,7 @@ class ExecuteCommands:
|
|
|
1549
1549
|
elif isinstance(database_name, str) and len(database_name) > 0:
|
|
1550
1550
|
db = database_name
|
|
1551
1551
|
else:
|
|
1552
|
-
db = "
|
|
1552
|
+
db = self.session.config.get("default_project")
|
|
1553
1553
|
table_name = target.parts[-1]
|
|
1554
1554
|
|
|
1555
1555
|
new_where = BinaryOperation(
|
|
@@ -8,13 +8,17 @@ from mindsdb.api.executor.datahub.classes.tables_row import (
|
|
|
8
8
|
TablesRow,
|
|
9
9
|
)
|
|
10
10
|
from mindsdb.utilities import log
|
|
11
|
+
from mindsdb.utilities.config import config
|
|
11
12
|
|
|
12
13
|
logger = log.getLogger(__name__)
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
def _get_scope(query):
|
|
16
17
|
databases, tables = None, None
|
|
17
|
-
|
|
18
|
+
try:
|
|
19
|
+
conditions = extract_comparison_conditions(query.where)
|
|
20
|
+
except NotImplementedError:
|
|
21
|
+
return databases, tables
|
|
18
22
|
for op, arg1, arg2 in conditions:
|
|
19
23
|
if op == '=':
|
|
20
24
|
scope = [arg2]
|
|
@@ -289,7 +293,11 @@ class ColumnsTable(Table):
|
|
|
289
293
|
databases, tables_names = _get_scope(query)
|
|
290
294
|
|
|
291
295
|
if databases is None:
|
|
292
|
-
databases = [
|
|
296
|
+
databases = [
|
|
297
|
+
'information_schema',
|
|
298
|
+
config.get('default_project'),
|
|
299
|
+
'files'
|
|
300
|
+
]
|
|
293
301
|
|
|
294
302
|
for db_name in databases:
|
|
295
303
|
tables = {}
|
|
@@ -25,6 +25,10 @@ from mindsdb.api.executor.planner.utils import (
|
|
|
25
25
|
)
|
|
26
26
|
from mindsdb.api.executor.planner.plan_join import PlanJoin
|
|
27
27
|
from mindsdb.api.executor.planner.query_prepare import PreparedStatementPlanner
|
|
28
|
+
from mindsdb.utilities.config import config
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
default_project = config.get('default_project')
|
|
28
32
|
|
|
29
33
|
|
|
30
34
|
class QueryPlanner:
|
|
@@ -54,12 +58,12 @@ class QueryPlanner:
|
|
|
54
58
|
self.integrations[integration_name] = integration
|
|
55
59
|
|
|
56
60
|
# allow to select from mindsdb namespace
|
|
57
|
-
_projects.add(
|
|
61
|
+
_projects.add(default_project)
|
|
58
62
|
|
|
59
63
|
self.default_namespace = default_namespace
|
|
60
64
|
|
|
61
65
|
# legacy parameter
|
|
62
|
-
self.predictor_namespace = predictor_namespace.lower() if predictor_namespace else
|
|
66
|
+
self.predictor_namespace = predictor_namespace.lower() if predictor_namespace else default_project
|
|
63
67
|
|
|
64
68
|
# map for lower names of predictors
|
|
65
69
|
|
|
@@ -10,6 +10,7 @@ from mindsdb.api.executor.planner.steps import (
|
|
|
10
10
|
)
|
|
11
11
|
|
|
12
12
|
from mindsdb.api.executor.sql_query.result_set import ResultSet, Column
|
|
13
|
+
from mindsdb.utilities.config import config
|
|
13
14
|
|
|
14
15
|
from .base import BaseStepCall
|
|
15
16
|
|
|
@@ -20,7 +21,7 @@ class GetPredictorColumnsCall(BaseStepCall):
|
|
|
20
21
|
|
|
21
22
|
def call(self, step):
|
|
22
23
|
|
|
23
|
-
mindsdb_database_name = '
|
|
24
|
+
mindsdb_database_name = config.get('default_project')
|
|
24
25
|
|
|
25
26
|
predictor_name = step.predictor.parts[-1]
|
|
26
27
|
dn = self.session.datahub.get(mindsdb_database_name)
|
mindsdb/api/http/initialize.py
CHANGED
|
@@ -48,7 +48,6 @@ from mindsdb.utilities.config import Config
|
|
|
48
48
|
from mindsdb.utilities.context import context as ctx
|
|
49
49
|
from mindsdb.utilities.json_encoder import CustomJSONProvider
|
|
50
50
|
from mindsdb.utilities.ps import is_pid_listen_port, wait_func_is_true
|
|
51
|
-
from mindsdb.utilities.telemetry import inject_telemetry_to_static
|
|
52
51
|
from mindsdb.utilities.sentry import sentry_sdk # noqa: F401
|
|
53
52
|
from mindsdb.utilities.otel import trace # noqa: F401
|
|
54
53
|
from opentelemetry.instrumentation.flask import FlaskInstrumentor # noqa: F401
|
|
@@ -200,7 +199,7 @@ def initialize_app(config, no_studio):
|
|
|
200
199
|
or gui_exists is False
|
|
201
200
|
)
|
|
202
201
|
):
|
|
203
|
-
init_static_thread = threading.Thread(target=initialize_static)
|
|
202
|
+
init_static_thread = threading.Thread(target=initialize_static, name='initialize_static')
|
|
204
203
|
init_static_thread.start()
|
|
205
204
|
|
|
206
205
|
app, api = initialize_flask(config, init_static_thread, no_studio)
|
|
@@ -420,8 +419,13 @@ def initialize_flask(config, init_static_thread, no_studio):
|
|
|
420
419
|
logger.info(f" - GUI available at {url}")
|
|
421
420
|
|
|
422
421
|
pid = os.getpid()
|
|
423
|
-
|
|
424
|
-
|
|
422
|
+
thread = threading.Thread(
|
|
423
|
+
target=_open_webbrowser,
|
|
424
|
+
args=(url, pid, port, init_static_thread, config['paths']['static']),
|
|
425
|
+
daemon=True,
|
|
426
|
+
name='open_webbrowser'
|
|
427
|
+
)
|
|
428
|
+
thread.start()
|
|
425
429
|
|
|
426
430
|
return app, api
|
|
427
431
|
|
|
@@ -441,7 +445,6 @@ def _open_webbrowser(url: str, pid: int, port: int, init_static_thread, static_f
|
|
|
441
445
|
"""
|
|
442
446
|
if init_static_thread is not None:
|
|
443
447
|
init_static_thread.join()
|
|
444
|
-
inject_telemetry_to_static(static_folder)
|
|
445
448
|
try:
|
|
446
449
|
is_http_active = wait_func_is_true(
|
|
447
450
|
func=is_pid_listen_port, timeout=15, pid=pid, port=port
|
|
@@ -293,13 +293,6 @@ def _completion_event_generator(
|
|
|
293
293
|
def json_serialize(data):
|
|
294
294
|
return f'data: {json.dumps(data)}\n\n'
|
|
295
295
|
|
|
296
|
-
quick_response_message = {
|
|
297
|
-
'role': 'assistant',
|
|
298
|
-
'content': AGENT_QUICK_RESPONSE
|
|
299
|
-
}
|
|
300
|
-
yield json_serialize({"quick_response": True, "messages": [quick_response_message]})
|
|
301
|
-
logger.info("Quick response sent")
|
|
302
|
-
|
|
303
296
|
try:
|
|
304
297
|
# Populate API key by default if not present.
|
|
305
298
|
session = SessionController()
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import os
|
|
2
1
|
import copy
|
|
3
2
|
import shutil
|
|
4
|
-
import datetime
|
|
5
3
|
import tempfile
|
|
6
4
|
from pathlib import Path
|
|
7
5
|
from http import HTTPStatus
|
|
8
6
|
|
|
9
|
-
from dateutil.tz import tzlocal
|
|
10
|
-
from dateutil.parser import parse as parse_datetime
|
|
11
7
|
from flask import request
|
|
12
8
|
from flask_restx import Resource
|
|
13
9
|
from flask import current_app as ca
|
|
@@ -17,7 +13,6 @@ from mindsdb.api.http.utils import http_error
|
|
|
17
13
|
from mindsdb.metrics.metrics import api_endpoint_metrics
|
|
18
14
|
from mindsdb.utilities import log
|
|
19
15
|
from mindsdb.utilities.functions import decrypt, encrypt
|
|
20
|
-
from mindsdb.utilities.log_controller import get_logs
|
|
21
16
|
from mindsdb.utilities.config import Config
|
|
22
17
|
from mindsdb.integrations.libs.response import HandlerStatusResponse
|
|
23
18
|
|
|
@@ -25,23 +20,6 @@ from mindsdb.integrations.libs.response import HandlerStatusResponse
|
|
|
25
20
|
logger = log.getLogger(__name__)
|
|
26
21
|
|
|
27
22
|
|
|
28
|
-
@ns_conf.route('/logs')
|
|
29
|
-
@ns_conf.param('name', 'Get logs')
|
|
30
|
-
class GetLogs(Resource):
|
|
31
|
-
@ns_conf.doc('get_integrations')
|
|
32
|
-
@api_endpoint_metrics('GET', '/config/logs')
|
|
33
|
-
def get(self):
|
|
34
|
-
min_timestamp = parse_datetime(request.args['min_timestamp'])
|
|
35
|
-
max_timestamp = request.args.get('max_timestamp', None)
|
|
36
|
-
context = request.args.get('context', None)
|
|
37
|
-
level = request.args.get('level', None)
|
|
38
|
-
log_from = request.args.get('log_from', None)
|
|
39
|
-
limit = request.args.get('limit', None)
|
|
40
|
-
|
|
41
|
-
logs = get_logs(min_timestamp, max_timestamp, context, level, log_from, limit)
|
|
42
|
-
return {'data': logs}
|
|
43
|
-
|
|
44
|
-
|
|
45
23
|
@ns_conf.route('/')
|
|
46
24
|
@ns_conf.param('name', 'Get config')
|
|
47
25
|
class GetConfig(Resource):
|
|
@@ -258,29 +236,3 @@ class Integration(Resource):
|
|
|
258
236
|
f"Error during integration modification: {str(e)}"
|
|
259
237
|
)
|
|
260
238
|
return "", 200
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
@ns_conf.route('/vars')
|
|
264
|
-
class Vars(Resource):
|
|
265
|
-
@api_endpoint_metrics('GET', '/config/vars')
|
|
266
|
-
def get(self):
|
|
267
|
-
if os.getenv('CHECK_FOR_UPDATES', '1').lower() in ['0', 'false']:
|
|
268
|
-
telemtry = False
|
|
269
|
-
else:
|
|
270
|
-
telemtry = True
|
|
271
|
-
|
|
272
|
-
if ca.config_obj.get('disable_mongo', False):
|
|
273
|
-
mongo = False
|
|
274
|
-
else:
|
|
275
|
-
mongo = True
|
|
276
|
-
|
|
277
|
-
cloud = ca.config_obj.get('cloud', False)
|
|
278
|
-
local_time = datetime.datetime.now(tzlocal())
|
|
279
|
-
local_timezone = local_time.tzname()
|
|
280
|
-
|
|
281
|
-
return {
|
|
282
|
-
'mongo': mongo,
|
|
283
|
-
'telemtry': telemtry,
|
|
284
|
-
'cloud': cloud,
|
|
285
|
-
'timezone': local_timezone,
|
|
286
|
-
}
|
|
@@ -233,7 +233,7 @@ class KnowledgeBaseResource(Resource):
|
|
|
233
233
|
if kb_data.get('urls'):
|
|
234
234
|
table.insert_web_pages(
|
|
235
235
|
urls=kb_data['urls'],
|
|
236
|
-
limit=kb_data.get('limit'
|
|
236
|
+
limit=kb_data.get('limit') or DEFAULT_WEB_CRAWL_LIMIT,
|
|
237
237
|
crawl_depth=kb_data.get('crawl_depth', DEFAULT_CRAWL_DEPTH),
|
|
238
238
|
filters=kb_data.get('filters', DEFAULT_WEB_FILTERS)
|
|
239
239
|
)
|
|
@@ -9,12 +9,6 @@ from flask import current_app as ca
|
|
|
9
9
|
|
|
10
10
|
from mindsdb.metrics.metrics import api_endpoint_metrics
|
|
11
11
|
from mindsdb.api.http.namespaces.configs.util import ns_conf
|
|
12
|
-
from mindsdb.utilities.telemetry import (
|
|
13
|
-
enable_telemetry,
|
|
14
|
-
disable_telemetry,
|
|
15
|
-
telemetry_file_exists,
|
|
16
|
-
inject_telemetry_to_static
|
|
17
|
-
)
|
|
18
12
|
from mindsdb.api.http.gui import update_static
|
|
19
13
|
from mindsdb.utilities.fs import clean_unlinked_process_marks
|
|
20
14
|
from mindsdb.api.http.utils import http_error
|
|
@@ -98,28 +92,6 @@ class PingNative(Resource):
|
|
|
98
92
|
return get_active_tasks()
|
|
99
93
|
|
|
100
94
|
|
|
101
|
-
@ns_conf.route('/telemetry')
|
|
102
|
-
class Telemetry(Resource):
|
|
103
|
-
@ns_conf.doc('get_telemetry_status')
|
|
104
|
-
@api_endpoint_metrics('GET', '/util/telemetry')
|
|
105
|
-
def get(self):
|
|
106
|
-
root_storage_path = ca.config_obj['paths']['root']
|
|
107
|
-
status = "enabled" if telemetry_file_exists(root_storage_path) else "disabled"
|
|
108
|
-
return {"status": status}
|
|
109
|
-
|
|
110
|
-
@ns_conf.doc('set_telemetry')
|
|
111
|
-
@api_endpoint_metrics('POST', '/util/telemetry')
|
|
112
|
-
def post(self):
|
|
113
|
-
data = request.json
|
|
114
|
-
action = data['action']
|
|
115
|
-
if str(action).lower() in ["true", "enable", "on"]:
|
|
116
|
-
enable_telemetry(ca.config_obj['paths']['root'])
|
|
117
|
-
else:
|
|
118
|
-
disable_telemetry(ca.config_obj['paths']['root'])
|
|
119
|
-
inject_telemetry_to_static(ca.config_obj.paths['static'])
|
|
120
|
-
return '', 200
|
|
121
|
-
|
|
122
|
-
|
|
123
95
|
@ns_conf.route('/validate_json_ai')
|
|
124
96
|
class ValidateJsonAI(Resource):
|
|
125
97
|
@api_endpoint_metrics('POST', '/util/validate_json_ai')
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from mindsdb.api.executor.controllers import SessionController
|
|
2
2
|
from mindsdb.api.executor.command_executor import ExecuteCommands
|
|
3
|
+
from mindsdb.utilities.config import config
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
def run_sql_command(request_env, ast_query):
|
|
6
7
|
sql_session = SessionController()
|
|
7
|
-
sql_session.database = request_env.get('database', '
|
|
8
|
+
sql_session.database = request_env.get('database', config.get('default_project'))
|
|
8
9
|
|
|
9
10
|
command_executor = ExecuteCommands(sql_session)
|
|
10
11
|
ret = command_executor.execute_command(ast_query)
|
|
@@ -5,8 +5,8 @@ from mindsdb_sql_parser.ast import Identifier, Insert, CreateTable
|
|
|
5
5
|
from mindsdb.api.mongo.classes import Responder
|
|
6
6
|
import mindsdb.api.mongo.functions as helpers
|
|
7
7
|
from mindsdb.api.mongo.responders.find import find_to_ast
|
|
8
|
-
|
|
9
8
|
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
9
|
+
from mindsdb.utilities.config import config
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def aggregate_to_ast(query, database):
|
|
@@ -63,7 +63,7 @@ class Responce(Responder):
|
|
|
63
63
|
|
|
64
64
|
first_step = query['pipeline'][0]
|
|
65
65
|
if '$match' in first_step:
|
|
66
|
-
ast_query = aggregate_to_ast(query, request_env.get('database', '
|
|
66
|
+
ast_query = aggregate_to_ast(query, request_env.get('database', config.get('default_project')))
|
|
67
67
|
|
|
68
68
|
data = run_sql_command(request_env, ast_query)
|
|
69
69
|
|
|
@@ -3,6 +3,7 @@ from mindsdb_sql_parser.ast import Describe, Identifier
|
|
|
3
3
|
from mindsdb.api.mongo.classes import Responder
|
|
4
4
|
import mindsdb.api.mongo.functions as helpers
|
|
5
5
|
from mindsdb.api.mongo.classes.query_sql import run_sql_command
|
|
6
|
+
from mindsdb.utilities.config import config
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class Responce(Responder):
|
|
@@ -14,7 +15,7 @@ class Responce(Responder):
|
|
|
14
15
|
|
|
15
16
|
scale = query.get('scale')
|
|
16
17
|
|
|
17
|
-
if db != '
|
|
18
|
+
if db != config.get('default_project') or collection == 'predictors' or scale is None:
|
|
18
19
|
# old behavior
|
|
19
20
|
# NOTE real answer is huge, i removed most data from it.
|
|
20
21
|
res = {
|
|
@@ -37,7 +38,7 @@ class Responce(Responder):
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
res['ns'] = f"{db}.{collection}"
|
|
40
|
-
if db == '
|
|
41
|
+
if db == config.get('default_project') and collection == 'predictors':
|
|
41
42
|
res['count'] = len(mindsdb_env['model_controller'].get_models())
|
|
42
43
|
else:
|
|
43
44
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from mindsdb.api.mongo.classes import Responder
|
|
2
2
|
import mindsdb.api.mongo.functions as helpers
|
|
3
|
+
from mindsdb.utilities.config import config
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class Responce(Responder):
|
|
@@ -8,7 +9,7 @@ class Responce(Responder):
|
|
|
8
9
|
def result(self, query, request_env, mindsdb_env, session):
|
|
9
10
|
db = query['$db']
|
|
10
11
|
collections = 0
|
|
11
|
-
if db == '
|
|
12
|
+
if db == config.get('default_project'):
|
|
12
13
|
collections = 2 + len(mindsdb_env['model_controller'].get_models())
|
|
13
14
|
return {
|
|
14
15
|
'db': db,
|
|
@@ -16,8 +16,10 @@ from mindsdb.api.mongo.responders.find import find_to_ast
|
|
|
16
16
|
from mindsdb.api.mongo.utilities.mongodb_parser import MongodbParser
|
|
17
17
|
from mindsdb.integrations.libs.response import HandlerStatusResponse
|
|
18
18
|
from mindsdb.utilities import log
|
|
19
|
+
from mindsdb.utilities.config import config
|
|
19
20
|
|
|
20
21
|
logger = log.getLogger(__name__)
|
|
22
|
+
default_project = config.get("default_project")
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
class Responce(Responder):
|
|
@@ -186,7 +188,7 @@ class Responce(Responder):
|
|
|
186
188
|
query["sort"] = step["args"][0]
|
|
187
189
|
# TODO implement group modifiers
|
|
188
190
|
ast_query = find_to_ast(
|
|
189
|
-
query, request_env.get("database",
|
|
191
|
+
query, request_env.get("database", default_project)
|
|
190
192
|
)
|
|
191
193
|
|
|
192
194
|
# to string
|
|
@@ -197,7 +199,7 @@ class Responce(Responder):
|
|
|
197
199
|
"pipeline": mql.pipeline[0]["args"][0],
|
|
198
200
|
}
|
|
199
201
|
ast_query = aggregate_to_ast(
|
|
200
|
-
query, request_env.get("database",
|
|
202
|
+
query, request_env.get("database", default_project)
|
|
201
203
|
)
|
|
202
204
|
query_str = ast_query.to_string()
|
|
203
205
|
except Exception:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from mindsdb.api.executor.controllers import SessionController
|
|
2
2
|
from mindsdb.api.mysql.mysql_proxy.libs.constants.mysql import CHARSET_NUMBERS
|
|
3
3
|
from mindsdb.api.mysql.mysql_proxy.mysql_proxy import MysqlProxy
|
|
4
|
+
from mindsdb.utilities.config import config
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def empty_fn():
|
|
@@ -29,7 +30,7 @@ class FakeMysqlProxy(MysqlProxy):
|
|
|
29
30
|
self.connection_id = None
|
|
30
31
|
|
|
31
32
|
self.session = SessionController()
|
|
32
|
-
self.session.database = '
|
|
33
|
+
self.session.database = config.get('default_project')
|
|
33
34
|
|
|
34
35
|
def is_cloud_connection(self):
|
|
35
36
|
return {
|
|
@@ -81,7 +81,7 @@ from mindsdb.api.executor import exceptions as exec_exc
|
|
|
81
81
|
from mindsdb.api.common.check_auth import check_auth
|
|
82
82
|
from mindsdb.api.mysql.mysql_proxy.utilities.lightwood_dtype import dtype
|
|
83
83
|
from mindsdb.utilities import log
|
|
84
|
-
from mindsdb.utilities.config import
|
|
84
|
+
from mindsdb.utilities.config import config
|
|
85
85
|
from mindsdb.utilities.context import context as ctx
|
|
86
86
|
from mindsdb.utilities.otel.metric_handlers import get_query_request_counter
|
|
87
87
|
from mindsdb.utilities.wizards import make_ssl_cert
|
|
@@ -448,7 +448,6 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
448
448
|
connection. '0000' selected because in real mysql connection it should be lenght of package,
|
|
449
449
|
and it can not be 0.
|
|
450
450
|
"""
|
|
451
|
-
config = Config()
|
|
452
451
|
is_cloud = config.get("cloud", False)
|
|
453
452
|
|
|
454
453
|
if sys.platform != "linux" or is_cloud is False:
|
|
@@ -746,7 +745,7 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
746
745
|
sql = SqlStatementParser.clear_sql(sql)
|
|
747
746
|
logger.debug(f'Incoming query: {sql}')
|
|
748
747
|
profiler.set_meta(
|
|
749
|
-
query=sql, api="mysql", environment=
|
|
748
|
+
query=sql, api="mysql", environment=config.get("environment")
|
|
750
749
|
)
|
|
751
750
|
with profiler.Context("mysql_query_processing"):
|
|
752
751
|
response = self.process_query(sql)
|
|
@@ -877,6 +876,9 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
877
876
|
def set_context(self, context):
|
|
878
877
|
if "db" in context:
|
|
879
878
|
self.session.database = context["db"]
|
|
879
|
+
else:
|
|
880
|
+
self.session.database = config.get('default_project')
|
|
881
|
+
|
|
880
882
|
if "profiling" in context:
|
|
881
883
|
self.session.profiling = context["profiling"]
|
|
882
884
|
if "predictor_cache" in context:
|
|
@@ -903,7 +905,6 @@ class MysqlProxy(SocketServer.BaseRequestHandler):
|
|
|
903
905
|
Create a server and wait for incoming connections until Ctrl-C
|
|
904
906
|
"""
|
|
905
907
|
global logger
|
|
906
|
-
config = Config()
|
|
907
908
|
|
|
908
909
|
cert_path = config["api"]["mysql"].get("certificate_path")
|
|
909
910
|
if cert_path is None or cert_path == "":
|
|
@@ -26,7 +26,7 @@ from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_message impor
|
|
|
26
26
|
from mindsdb.api.postgres.postgres_proxy.postgres_packets.postgres_packets import PostgresPacketReader, \
|
|
27
27
|
PostgresPacketBuilder
|
|
28
28
|
from mindsdb.api.postgres.postgres_proxy.utilities import strip_null_byte
|
|
29
|
-
from mindsdb.utilities.config import
|
|
29
|
+
from mindsdb.utilities.config import config
|
|
30
30
|
from mindsdb.utilities.context import context as ctx
|
|
31
31
|
from mindsdb.utilities import log
|
|
32
32
|
from mindsdb.api.mysql.mysql_proxy.external_libs.mysql_scramble import scramble as scramble_func
|
|
@@ -92,7 +92,6 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
92
92
|
Copied from mysql_proxy
|
|
93
93
|
TODO: Extract method into common
|
|
94
94
|
"""
|
|
95
|
-
config = Config()
|
|
96
95
|
is_cloud = config.get('cloud', False)
|
|
97
96
|
|
|
98
97
|
if sys.platform != 'linux' or is_cloud is False:
|
|
@@ -237,7 +236,7 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
237
236
|
self.server.connection_id += 1
|
|
238
237
|
self.connection_id = self.server.connection_id
|
|
239
238
|
self.session = SessionController()
|
|
240
|
-
self.session.database = '
|
|
239
|
+
self.session.database = config.get('default_project')
|
|
241
240
|
|
|
242
241
|
if hasattr(self.server, 'salt') and isinstance(self.server.salt, str):
|
|
243
242
|
self.salt = self.server.salt
|
|
@@ -461,7 +460,6 @@ class PostgresProxyHandler(socketserver.StreamRequestHandler):
|
|
|
461
460
|
|
|
462
461
|
@staticmethod
|
|
463
462
|
def startProxy():
|
|
464
|
-
config = Config()
|
|
465
463
|
host = config['api']['postgres']['host']
|
|
466
464
|
port = int(config['api']['postgres']['port'])
|
|
467
465
|
server = TcpServer((host, port), PostgresProxyHandler)
|