MindsDB 25.9.2.0a1__py3-none-any.whl → 25.10.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 +40 -29
- mindsdb/api/a2a/__init__.py +1 -1
- mindsdb/api/a2a/agent.py +16 -10
- mindsdb/api/a2a/common/server/server.py +7 -3
- mindsdb/api/a2a/common/server/task_manager.py +12 -5
- mindsdb/api/a2a/common/types.py +66 -0
- mindsdb/api/a2a/task_manager.py +65 -17
- mindsdb/api/common/middleware.py +10 -12
- mindsdb/api/executor/command_executor.py +51 -40
- mindsdb/api/executor/datahub/datanodes/datanode.py +2 -2
- mindsdb/api/executor/datahub/datanodes/information_schema_datanode.py +7 -13
- mindsdb/api/executor/datahub/datanodes/integration_datanode.py +101 -49
- mindsdb/api/executor/datahub/datanodes/project_datanode.py +8 -4
- mindsdb/api/executor/datahub/datanodes/system_tables.py +3 -2
- mindsdb/api/executor/exceptions.py +29 -10
- mindsdb/api/executor/planner/plan_join.py +17 -3
- mindsdb/api/executor/planner/query_prepare.py +2 -20
- mindsdb/api/executor/sql_query/sql_query.py +74 -74
- mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +1 -2
- mindsdb/api/executor/sql_query/steps/subselect_step.py +0 -1
- mindsdb/api/executor/utilities/functions.py +6 -6
- mindsdb/api/executor/utilities/sql.py +37 -20
- mindsdb/api/http/gui.py +5 -11
- mindsdb/api/http/initialize.py +75 -61
- mindsdb/api/http/namespaces/agents.py +10 -15
- mindsdb/api/http/namespaces/analysis.py +13 -20
- mindsdb/api/http/namespaces/auth.py +1 -1
- mindsdb/api/http/namespaces/chatbots.py +0 -5
- mindsdb/api/http/namespaces/config.py +15 -11
- mindsdb/api/http/namespaces/databases.py +140 -201
- mindsdb/api/http/namespaces/file.py +17 -4
- mindsdb/api/http/namespaces/handlers.py +17 -7
- mindsdb/api/http/namespaces/knowledge_bases.py +28 -7
- mindsdb/api/http/namespaces/models.py +94 -126
- mindsdb/api/http/namespaces/projects.py +13 -22
- mindsdb/api/http/namespaces/sql.py +33 -25
- mindsdb/api/http/namespaces/tab.py +27 -37
- mindsdb/api/http/namespaces/views.py +1 -1
- mindsdb/api/http/start.py +16 -10
- mindsdb/api/mcp/__init__.py +2 -1
- mindsdb/api/mysql/mysql_proxy/executor/mysql_executor.py +15 -20
- mindsdb/api/mysql/mysql_proxy/mysql_proxy.py +26 -50
- mindsdb/api/mysql/mysql_proxy/utilities/__init__.py +0 -1
- mindsdb/api/mysql/mysql_proxy/utilities/dump.py +8 -2
- mindsdb/integrations/handlers/byom_handler/byom_handler.py +165 -190
- mindsdb/integrations/handlers/databricks_handler/databricks_handler.py +98 -46
- mindsdb/integrations/handlers/druid_handler/druid_handler.py +32 -40
- mindsdb/integrations/handlers/file_handler/file_handler.py +7 -0
- mindsdb/integrations/handlers/gitlab_handler/gitlab_handler.py +5 -2
- mindsdb/integrations/handlers/lightwood_handler/functions.py +45 -79
- mindsdb/integrations/handlers/mssql_handler/mssql_handler.py +438 -100
- mindsdb/integrations/handlers/mssql_handler/requirements_odbc.txt +3 -0
- mindsdb/integrations/handlers/mysql_handler/mysql_handler.py +235 -3
- mindsdb/integrations/handlers/oracle_handler/__init__.py +2 -0
- mindsdb/integrations/handlers/oracle_handler/connection_args.py +7 -1
- mindsdb/integrations/handlers/oracle_handler/oracle_handler.py +321 -16
- mindsdb/integrations/handlers/oracle_handler/requirements.txt +1 -1
- mindsdb/integrations/handlers/postgres_handler/postgres_handler.py +14 -2
- mindsdb/integrations/handlers/shopify_handler/requirements.txt +1 -0
- mindsdb/integrations/handlers/shopify_handler/shopify_handler.py +80 -13
- mindsdb/integrations/handlers/snowflake_handler/snowflake_handler.py +2 -1
- mindsdb/integrations/handlers/statsforecast_handler/requirements.txt +1 -0
- mindsdb/integrations/handlers/statsforecast_handler/requirements_extra.txt +1 -0
- mindsdb/integrations/handlers/web_handler/urlcrawl_helpers.py +4 -4
- mindsdb/integrations/handlers/zendesk_handler/zendesk_tables.py +144 -111
- mindsdb/integrations/libs/api_handler.py +10 -10
- mindsdb/integrations/libs/base.py +4 -4
- mindsdb/integrations/libs/llm/utils.py +2 -2
- mindsdb/integrations/libs/ml_handler_process/create_engine_process.py +4 -7
- mindsdb/integrations/libs/ml_handler_process/func_call_process.py +2 -7
- mindsdb/integrations/libs/ml_handler_process/learn_process.py +37 -47
- mindsdb/integrations/libs/ml_handler_process/update_engine_process.py +4 -7
- mindsdb/integrations/libs/ml_handler_process/update_process.py +2 -7
- mindsdb/integrations/libs/process_cache.py +132 -140
- mindsdb/integrations/libs/response.py +18 -12
- mindsdb/integrations/libs/vectordatabase_handler.py +26 -0
- mindsdb/integrations/utilities/files/file_reader.py +6 -7
- mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/__init__.py +1 -0
- mindsdb/integrations/utilities/handlers/auth_utilities/snowflake/snowflake_jwt_gen.py +151 -0
- mindsdb/integrations/utilities/rag/config_loader.py +37 -26
- mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +83 -30
- mindsdb/integrations/utilities/rag/rerankers/reranker_compressor.py +4 -4
- mindsdb/integrations/utilities/rag/retrievers/sql_retriever.py +55 -133
- mindsdb/integrations/utilities/rag/settings.py +58 -133
- mindsdb/integrations/utilities/rag/splitters/file_splitter.py +5 -15
- mindsdb/interfaces/agents/agents_controller.py +2 -3
- mindsdb/interfaces/agents/constants.py +0 -2
- mindsdb/interfaces/agents/litellm_server.py +34 -58
- mindsdb/interfaces/agents/mcp_client_agent.py +10 -10
- mindsdb/interfaces/agents/mindsdb_database_agent.py +5 -5
- mindsdb/interfaces/agents/run_mcp_agent.py +12 -21
- mindsdb/interfaces/chatbot/chatbot_task.py +20 -23
- mindsdb/interfaces/chatbot/polling.py +30 -18
- mindsdb/interfaces/data_catalog/data_catalog_loader.py +16 -17
- mindsdb/interfaces/data_catalog/data_catalog_reader.py +15 -4
- mindsdb/interfaces/database/data_handlers_cache.py +190 -0
- mindsdb/interfaces/database/database.py +3 -3
- mindsdb/interfaces/database/integrations.py +7 -110
- mindsdb/interfaces/database/projects.py +2 -6
- mindsdb/interfaces/database/views.py +1 -4
- mindsdb/interfaces/file/file_controller.py +6 -6
- mindsdb/interfaces/functions/controller.py +1 -1
- mindsdb/interfaces/functions/to_markdown.py +2 -2
- mindsdb/interfaces/jobs/jobs_controller.py +5 -9
- mindsdb/interfaces/jobs/scheduler.py +3 -9
- mindsdb/interfaces/knowledge_base/controller.py +244 -128
- mindsdb/interfaces/knowledge_base/evaluate.py +36 -41
- mindsdb/interfaces/knowledge_base/executor.py +11 -0
- mindsdb/interfaces/knowledge_base/llm_client.py +51 -17
- mindsdb/interfaces/knowledge_base/preprocessing/json_chunker.py +40 -61
- mindsdb/interfaces/model/model_controller.py +172 -168
- mindsdb/interfaces/query_context/context_controller.py +14 -2
- mindsdb/interfaces/skills/custom/text2sql/mindsdb_sql_toolkit.py +10 -14
- mindsdb/interfaces/skills/retrieval_tool.py +43 -50
- mindsdb/interfaces/skills/skill_tool.py +2 -2
- mindsdb/interfaces/skills/skills_controller.py +1 -4
- mindsdb/interfaces/skills/sql_agent.py +25 -19
- mindsdb/interfaces/storage/db.py +16 -6
- mindsdb/interfaces/storage/fs.py +114 -169
- mindsdb/interfaces/storage/json.py +19 -18
- mindsdb/interfaces/tabs/tabs_controller.py +49 -72
- mindsdb/interfaces/tasks/task_monitor.py +3 -9
- mindsdb/interfaces/tasks/task_thread.py +7 -9
- mindsdb/interfaces/triggers/trigger_task.py +7 -13
- mindsdb/interfaces/triggers/triggers_controller.py +47 -52
- mindsdb/migrations/migrate.py +16 -16
- mindsdb/utilities/api_status.py +58 -0
- mindsdb/utilities/config.py +68 -2
- mindsdb/utilities/exception.py +40 -1
- mindsdb/utilities/fs.py +0 -1
- mindsdb/utilities/hooks/profiling.py +17 -14
- mindsdb/utilities/json_encoder.py +24 -10
- mindsdb/utilities/langfuse.py +40 -45
- mindsdb/utilities/log.py +272 -0
- mindsdb/utilities/ml_task_queue/consumer.py +52 -58
- mindsdb/utilities/ml_task_queue/producer.py +26 -30
- mindsdb/utilities/render/sqlalchemy_render.py +22 -20
- mindsdb/utilities/starters.py +0 -10
- mindsdb/utilities/utils.py +2 -2
- {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0.dist-info}/METADATA +286 -267
- {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0.dist-info}/RECORD +145 -159
- mindsdb/api/mysql/mysql_proxy/utilities/exceptions.py +0 -14
- mindsdb/api/postgres/__init__.py +0 -0
- mindsdb/api/postgres/postgres_proxy/__init__.py +0 -0
- mindsdb/api/postgres/postgres_proxy/executor/__init__.py +0 -1
- mindsdb/api/postgres/postgres_proxy/executor/executor.py +0 -189
- mindsdb/api/postgres/postgres_proxy/postgres_packets/__init__.py +0 -0
- mindsdb/api/postgres/postgres_proxy/postgres_packets/errors.py +0 -322
- mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_fields.py +0 -34
- mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message.py +0 -31
- mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_formats.py +0 -1265
- mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_message_identifiers.py +0 -31
- mindsdb/api/postgres/postgres_proxy/postgres_packets/postgres_packets.py +0 -253
- mindsdb/api/postgres/postgres_proxy/postgres_proxy.py +0 -477
- mindsdb/api/postgres/postgres_proxy/utilities/__init__.py +0 -10
- mindsdb/api/postgres/start.py +0 -11
- mindsdb/integrations/handlers/mssql_handler/tests/__init__.py +0 -0
- mindsdb/integrations/handlers/mssql_handler/tests/test_mssql_handler.py +0 -169
- mindsdb/integrations/handlers/oracle_handler/tests/__init__.py +0 -0
- mindsdb/integrations/handlers/oracle_handler/tests/test_oracle_handler.py +0 -32
- {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0.dist-info}/WHEEL +0 -0
- {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0.dist-info}/licenses/LICENSE +0 -0
- {mindsdb-25.9.2.0a1.dist-info → mindsdb-25.10.0.dist-info}/top_level.txt +0 -0
|
@@ -34,41 +34,31 @@ class ZendeskUsersTable(APITable):
|
|
|
34
34
|
If the query contains an unsupported condition
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
|
-
select_statement_parser = SELECTQueryParser(
|
|
38
|
-
query,
|
|
39
|
-
'users',
|
|
40
|
-
self.get_columns()
|
|
41
|
-
)
|
|
37
|
+
select_statement_parser = SELECTQueryParser(query, "users", self.get_columns())
|
|
42
38
|
|
|
43
|
-
selected_columns, where_conditions, order_by_conditions, result_limit = (
|
|
44
|
-
select_statement_parser.parse_query()
|
|
45
|
-
)
|
|
39
|
+
selected_columns, where_conditions, order_by_conditions, result_limit = select_statement_parser.parse_query()
|
|
46
40
|
|
|
47
|
-
subset_where_conditions =
|
|
41
|
+
subset_where_conditions = []
|
|
42
|
+
api_filters = {}
|
|
48
43
|
for op, arg1, arg2 in where_conditions:
|
|
49
44
|
if arg1 in self.get_columns():
|
|
50
|
-
if op !=
|
|
45
|
+
if op != "=":
|
|
51
46
|
raise NotImplementedError(f"Unknown op: {op}. Only '=' is supported.")
|
|
52
|
-
|
|
47
|
+
api_filters[arg1] = arg2
|
|
48
|
+
subset_where_conditions.append([op, arg1, arg2])
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
result = self.handler.zen_client.users(**subset_where_conditions)
|
|
50
|
+
result = self.handler.zen_client.users(**api_filters)
|
|
56
51
|
response = []
|
|
57
52
|
if isinstance(result, zenpy.lib.generator.BaseResultGenerator):
|
|
58
|
-
|
|
59
|
-
response.append(
|
|
60
|
-
count += 1
|
|
53
|
+
for user in result:
|
|
54
|
+
response.append(user.to_dict())
|
|
61
55
|
else:
|
|
62
56
|
response.append(result.to_dict())
|
|
63
57
|
|
|
64
58
|
df = pd.DataFrame(response, columns=self.get_columns())
|
|
65
59
|
|
|
66
60
|
select_statement_executor = SELECTQueryExecutor(
|
|
67
|
-
df,
|
|
68
|
-
selected_columns,
|
|
69
|
-
subset_where_conditions,
|
|
70
|
-
order_by_conditions,
|
|
71
|
-
result_limit
|
|
61
|
+
df, selected_columns, subset_where_conditions, order_by_conditions, result_limit
|
|
72
62
|
)
|
|
73
63
|
|
|
74
64
|
df = select_statement_executor.execute_query()
|
|
@@ -85,15 +75,43 @@ class ZendeskUsersTable(APITable):
|
|
|
85
75
|
"""
|
|
86
76
|
|
|
87
77
|
return [
|
|
88
|
-
"active",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
78
|
+
"active",
|
|
79
|
+
"alias",
|
|
80
|
+
"chat_only",
|
|
81
|
+
"created_at",
|
|
82
|
+
"custom_role_id",
|
|
83
|
+
"details",
|
|
84
|
+
"email",
|
|
85
|
+
"external_id",
|
|
86
|
+
"id",
|
|
87
|
+
"last_login_at",
|
|
88
|
+
"locale",
|
|
89
|
+
"locale_id",
|
|
90
|
+
"moderator",
|
|
91
|
+
"name",
|
|
92
|
+
"notes",
|
|
93
|
+
"only_private_comments",
|
|
94
|
+
"organization_id",
|
|
95
|
+
"phone",
|
|
96
|
+
"photo",
|
|
97
|
+
"restricted_agent",
|
|
98
|
+
"role",
|
|
99
|
+
"shared",
|
|
100
|
+
"shared_agent",
|
|
101
|
+
"signature",
|
|
102
|
+
"suspended",
|
|
103
|
+
"tags",
|
|
104
|
+
"ticket_restriction",
|
|
105
|
+
"time_zone",
|
|
106
|
+
"two_factor_auth_enabled",
|
|
107
|
+
"updated_at",
|
|
108
|
+
"url",
|
|
109
|
+
"verified",
|
|
110
|
+
"iana_time_zone",
|
|
111
|
+
"shared_phone_number",
|
|
112
|
+
"role_type",
|
|
113
|
+
"default_group_id",
|
|
114
|
+
"report_csv",
|
|
97
115
|
]
|
|
98
116
|
|
|
99
117
|
|
|
@@ -119,41 +137,31 @@ class ZendeskTicketsTable(APITable):
|
|
|
119
137
|
If the query contains an unsupported condition
|
|
120
138
|
"""
|
|
121
139
|
|
|
122
|
-
select_statement_parser = SELECTQueryParser(
|
|
123
|
-
query,
|
|
124
|
-
'tickets',
|
|
125
|
-
self.get_columns()
|
|
126
|
-
)
|
|
140
|
+
select_statement_parser = SELECTQueryParser(query, "tickets", self.get_columns())
|
|
127
141
|
|
|
128
|
-
selected_columns, where_conditions, order_by_conditions, result_limit = (
|
|
129
|
-
select_statement_parser.parse_query()
|
|
130
|
-
)
|
|
142
|
+
selected_columns, where_conditions, order_by_conditions, result_limit = select_statement_parser.parse_query()
|
|
131
143
|
|
|
132
|
-
subset_where_conditions =
|
|
144
|
+
subset_where_conditions = []
|
|
145
|
+
api_filters = {}
|
|
133
146
|
for op, arg1, arg2 in where_conditions:
|
|
134
147
|
if arg1 in self.get_columns():
|
|
135
|
-
if op !=
|
|
148
|
+
if op != "=":
|
|
136
149
|
raise NotImplementedError(f"Unknown op: {op}. Only '=' is supported.")
|
|
137
|
-
|
|
150
|
+
api_filters[arg1] = arg2
|
|
151
|
+
subset_where_conditions.append([op, arg1, arg2])
|
|
138
152
|
|
|
139
|
-
|
|
140
|
-
result = self.handler.zen_client.tickets(**subset_where_conditions)
|
|
153
|
+
result = self.handler.zen_client.tickets(**api_filters)
|
|
141
154
|
response = []
|
|
142
155
|
if isinstance(result, zenpy.lib.generator.BaseResultGenerator):
|
|
143
|
-
|
|
144
|
-
response.append(
|
|
145
|
-
count += 1
|
|
156
|
+
for ticket in result:
|
|
157
|
+
response.append(ticket.to_dict())
|
|
146
158
|
else:
|
|
147
159
|
response.append(result.to_dict())
|
|
148
160
|
|
|
149
161
|
df = pd.DataFrame(response, columns=self.get_columns())
|
|
150
162
|
|
|
151
163
|
select_statement_executor = SELECTQueryExecutor(
|
|
152
|
-
df,
|
|
153
|
-
selected_columns,
|
|
154
|
-
subset_where_conditions,
|
|
155
|
-
order_by_conditions,
|
|
156
|
-
result_limit
|
|
164
|
+
df, selected_columns, subset_where_conditions, order_by_conditions, result_limit
|
|
157
165
|
)
|
|
158
166
|
|
|
159
167
|
df = select_statement_executor.execute_query()
|
|
@@ -170,20 +178,54 @@ class ZendeskTicketsTable(APITable):
|
|
|
170
178
|
"""
|
|
171
179
|
|
|
172
180
|
return [
|
|
173
|
-
"assignee_id",
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"
|
|
181
|
+
"assignee_id",
|
|
182
|
+
"brand_id",
|
|
183
|
+
"collaborator_ids",
|
|
184
|
+
"created_at",
|
|
185
|
+
"custom_fields",
|
|
186
|
+
"description",
|
|
187
|
+
"due_at",
|
|
188
|
+
"external_id",
|
|
189
|
+
"fields",
|
|
190
|
+
"forum_topic_id",
|
|
191
|
+
"group_id",
|
|
192
|
+
"has_incidents",
|
|
193
|
+
"id",
|
|
194
|
+
"organization_id",
|
|
195
|
+
"priority",
|
|
196
|
+
"problem_id",
|
|
197
|
+
"raw_subject",
|
|
198
|
+
"recipient",
|
|
199
|
+
"requester_id",
|
|
200
|
+
"sharing_agreement_ids",
|
|
201
|
+
"status",
|
|
202
|
+
"subject",
|
|
203
|
+
"submitter_id",
|
|
204
|
+
"tags",
|
|
205
|
+
"type",
|
|
206
|
+
"updated_at",
|
|
207
|
+
"url",
|
|
208
|
+
"generated_timestamp",
|
|
209
|
+
"follower_ids",
|
|
210
|
+
"email_cc_ids",
|
|
211
|
+
"is_public",
|
|
212
|
+
"custom_status_id",
|
|
213
|
+
"followup_ids",
|
|
214
|
+
"ticket_form_id",
|
|
215
|
+
"allow_channelback",
|
|
216
|
+
"allow_attachments",
|
|
217
|
+
"from_messaging_channel",
|
|
218
|
+
"satisfaction_rating.assignee_id",
|
|
219
|
+
"satisfaction_rating.created_at",
|
|
220
|
+
"satisfaction_rating.group_id",
|
|
221
|
+
"satisfaction_rating.id",
|
|
222
|
+
"satisfaction_rating.requester_id",
|
|
223
|
+
"satisfaction_rating.score",
|
|
224
|
+
"satisfaction_rating.ticket_id",
|
|
225
|
+
"satisfaction_rating.updated_at",
|
|
226
|
+
"satisfaction_rating.url",
|
|
227
|
+
"via.channel",
|
|
228
|
+
"via.source.rel",
|
|
187
229
|
]
|
|
188
230
|
|
|
189
231
|
|
|
@@ -209,41 +251,31 @@ class ZendeskTriggersTable(APITable):
|
|
|
209
251
|
If the query contains an unsupported condition
|
|
210
252
|
"""
|
|
211
253
|
|
|
212
|
-
select_statement_parser = SELECTQueryParser(
|
|
213
|
-
query,
|
|
214
|
-
'triggers',
|
|
215
|
-
self.get_columns()
|
|
216
|
-
)
|
|
254
|
+
select_statement_parser = SELECTQueryParser(query, "triggers", self.get_columns())
|
|
217
255
|
|
|
218
|
-
selected_columns, where_conditions, order_by_conditions, result_limit = (
|
|
219
|
-
select_statement_parser.parse_query()
|
|
220
|
-
)
|
|
256
|
+
selected_columns, where_conditions, order_by_conditions, result_limit = select_statement_parser.parse_query()
|
|
221
257
|
|
|
222
|
-
subset_where_conditions =
|
|
258
|
+
subset_where_conditions = []
|
|
259
|
+
api_filters = {}
|
|
223
260
|
for op, arg1, arg2 in where_conditions:
|
|
224
261
|
if arg1 in self.get_columns():
|
|
225
|
-
if op !=
|
|
262
|
+
if op != "=":
|
|
226
263
|
raise NotImplementedError(f"Unknown op: {op}. Only '=' is supported.")
|
|
227
|
-
|
|
264
|
+
api_filters[arg1] = arg2
|
|
265
|
+
subset_where_conditions.append([op, arg1, arg2])
|
|
228
266
|
|
|
229
|
-
|
|
230
|
-
result = self.handler.zen_client.triggers(**subset_where_conditions)
|
|
267
|
+
result = self.handler.zen_client.triggers(**api_filters)
|
|
231
268
|
response = []
|
|
232
269
|
if isinstance(result, zenpy.lib.generator.BaseResultGenerator):
|
|
233
|
-
|
|
234
|
-
response.append(
|
|
235
|
-
count += 1
|
|
270
|
+
for trigger in result:
|
|
271
|
+
response.append(trigger.to_dict())
|
|
236
272
|
else:
|
|
237
273
|
response.append(result.to_dict())
|
|
238
274
|
|
|
239
275
|
df = pd.DataFrame(response, columns=self.get_columns())
|
|
240
276
|
|
|
241
277
|
select_statement_executor = SELECTQueryExecutor(
|
|
242
|
-
df,
|
|
243
|
-
selected_columns,
|
|
244
|
-
subset_where_conditions,
|
|
245
|
-
order_by_conditions,
|
|
246
|
-
result_limit
|
|
278
|
+
df, selected_columns, subset_where_conditions, order_by_conditions, result_limit
|
|
247
279
|
)
|
|
248
280
|
|
|
249
281
|
df = select_statement_executor.execute_query()
|
|
@@ -260,9 +292,20 @@ class ZendeskTriggersTable(APITable):
|
|
|
260
292
|
"""
|
|
261
293
|
|
|
262
294
|
return [
|
|
263
|
-
"actions",
|
|
264
|
-
"
|
|
265
|
-
"
|
|
295
|
+
"actions",
|
|
296
|
+
"active",
|
|
297
|
+
"description",
|
|
298
|
+
"id",
|
|
299
|
+
"position",
|
|
300
|
+
"title",
|
|
301
|
+
"url",
|
|
302
|
+
"updated_at",
|
|
303
|
+
"created_at",
|
|
304
|
+
"default",
|
|
305
|
+
"raw_title",
|
|
306
|
+
"category_id",
|
|
307
|
+
"conditions.all",
|
|
308
|
+
"conditions.any",
|
|
266
309
|
]
|
|
267
310
|
|
|
268
311
|
|
|
@@ -288,41 +331,31 @@ class ZendeskActivitiesTable(APITable):
|
|
|
288
331
|
If the query contains an unsupported condition
|
|
289
332
|
"""
|
|
290
333
|
|
|
291
|
-
select_statement_parser = SELECTQueryParser(
|
|
292
|
-
query,
|
|
293
|
-
'activities',
|
|
294
|
-
self.get_columns()
|
|
295
|
-
)
|
|
334
|
+
select_statement_parser = SELECTQueryParser(query, "activities", self.get_columns())
|
|
296
335
|
|
|
297
|
-
selected_columns, where_conditions, order_by_conditions, result_limit = (
|
|
298
|
-
select_statement_parser.parse_query()
|
|
299
|
-
)
|
|
336
|
+
selected_columns, where_conditions, order_by_conditions, result_limit = select_statement_parser.parse_query()
|
|
300
337
|
|
|
301
|
-
subset_where_conditions =
|
|
338
|
+
subset_where_conditions = []
|
|
339
|
+
api_filters = {}
|
|
302
340
|
for op, arg1, arg2 in where_conditions:
|
|
303
341
|
if arg1 in self.get_columns():
|
|
304
|
-
if op !=
|
|
342
|
+
if op != "=":
|
|
305
343
|
raise NotImplementedError(f"Unknown op: {op}. Only '=' is supported.")
|
|
306
|
-
|
|
344
|
+
api_filters[arg1] = arg2
|
|
345
|
+
subset_where_conditions.append([op, arg1, arg2])
|
|
307
346
|
|
|
308
|
-
|
|
309
|
-
result = self.handler.zen_client.activities(**subset_where_conditions)
|
|
347
|
+
result = self.handler.zen_client.activities(**api_filters)
|
|
310
348
|
response = []
|
|
311
349
|
if isinstance(result, zenpy.lib.generator.BaseResultGenerator):
|
|
312
|
-
|
|
313
|
-
response.append(
|
|
314
|
-
count += 1
|
|
350
|
+
for activity in result:
|
|
351
|
+
response.append(activity.to_dict())
|
|
315
352
|
else:
|
|
316
353
|
response.append(result.to_dict())
|
|
317
354
|
|
|
318
355
|
df = pd.DataFrame(response, columns=self.get_columns())
|
|
319
356
|
|
|
320
357
|
select_statement_executor = SELECTQueryExecutor(
|
|
321
|
-
df,
|
|
322
|
-
selected_columns,
|
|
323
|
-
subset_where_conditions,
|
|
324
|
-
order_by_conditions,
|
|
325
|
-
result_limit
|
|
358
|
+
df, selected_columns, subset_where_conditions, order_by_conditions, result_limit
|
|
326
359
|
)
|
|
327
360
|
|
|
328
361
|
df = select_statement_executor.execute_query()
|
|
@@ -459,5 +492,5 @@ class ZendeskActivitiesTable(APITable):
|
|
|
459
492
|
"target.ticket.type",
|
|
460
493
|
"target.ticket.updated_at",
|
|
461
494
|
"target.ticket.url",
|
|
462
|
-
"target.ticket.via"
|
|
495
|
+
"target.ticket.via",
|
|
463
496
|
]
|
|
@@ -550,8 +550,8 @@ class MetaAPIHandler(APIHandler):
|
|
|
550
550
|
if hasattr(table_class, "meta_get_tables"):
|
|
551
551
|
table_metadata = table_class.meta_get_tables(table_name, **kwargs)
|
|
552
552
|
df = pd.concat([df, pd.DataFrame([table_metadata])], ignore_index=True)
|
|
553
|
-
except Exception
|
|
554
|
-
logger.
|
|
553
|
+
except Exception:
|
|
554
|
+
logger.exception(f"Error retrieving metadata for table {table_name}:")
|
|
555
555
|
|
|
556
556
|
return Response(RESPONSE_TYPE.TABLE, df)
|
|
557
557
|
|
|
@@ -572,8 +572,8 @@ class MetaAPIHandler(APIHandler):
|
|
|
572
572
|
if hasattr(table_class, "meta_get_columns"):
|
|
573
573
|
column_metadata = table_class.meta_get_columns(table_name, **kwargs)
|
|
574
574
|
df = pd.concat([df, pd.DataFrame(column_metadata)], ignore_index=True)
|
|
575
|
-
except Exception
|
|
576
|
-
logger.
|
|
575
|
+
except Exception:
|
|
576
|
+
logger.exception(f"Error retrieving column metadata for table {table_name}:")
|
|
577
577
|
|
|
578
578
|
return Response(RESPONSE_TYPE.TABLE, df)
|
|
579
579
|
|
|
@@ -594,8 +594,8 @@ class MetaAPIHandler(APIHandler):
|
|
|
594
594
|
if hasattr(table_class, "meta_get_column_statistics"):
|
|
595
595
|
column_statistics = table_class.meta_get_column_statistics(table_name, **kwargs)
|
|
596
596
|
df = pd.concat([df, pd.DataFrame(column_statistics)], ignore_index=True)
|
|
597
|
-
except Exception
|
|
598
|
-
logger.
|
|
597
|
+
except Exception:
|
|
598
|
+
logger.exception(f"Error retrieving column statistics for table {table_name}:")
|
|
599
599
|
|
|
600
600
|
return Response(RESPONSE_TYPE.TABLE, df)
|
|
601
601
|
|
|
@@ -616,8 +616,8 @@ class MetaAPIHandler(APIHandler):
|
|
|
616
616
|
if hasattr(table_class, "meta_get_primary_keys"):
|
|
617
617
|
primary_key_metadata = table_class.meta_get_primary_keys(table_name, **kwargs)
|
|
618
618
|
df = pd.concat([df, pd.DataFrame(primary_key_metadata)], ignore_index=True)
|
|
619
|
-
except Exception
|
|
620
|
-
logger.
|
|
619
|
+
except Exception:
|
|
620
|
+
logger.exception(f"Error retrieving primary keys for table {table_name}:")
|
|
621
621
|
|
|
622
622
|
return Response(RESPONSE_TYPE.TABLE, df)
|
|
623
623
|
|
|
@@ -641,8 +641,8 @@ class MetaAPIHandler(APIHandler):
|
|
|
641
641
|
table_name, all_tables=table_names if table_names else all_tables, **kwargs
|
|
642
642
|
)
|
|
643
643
|
df = pd.concat([df, pd.DataFrame(foreign_key_metadata)], ignore_index=True)
|
|
644
|
-
except Exception
|
|
645
|
-
logger.
|
|
644
|
+
except Exception:
|
|
645
|
+
logger.exception(f"Error retrieving foreign keys for table {table_name}:")
|
|
646
646
|
|
|
647
647
|
return Response(RESPONSE_TYPE.TABLE, df)
|
|
648
648
|
|
|
@@ -202,8 +202,8 @@ class MetaDatabaseHandler(DatabaseHandler):
|
|
|
202
202
|
logger.error(
|
|
203
203
|
f"Error retrieving column statistics for table {table_name}: {result.error_message}"
|
|
204
204
|
)
|
|
205
|
-
except Exception
|
|
206
|
-
logger.
|
|
205
|
+
except Exception:
|
|
206
|
+
logger.exception(f"Exception occurred while retrieving column statistics for table {table_name}:")
|
|
207
207
|
|
|
208
208
|
if not results:
|
|
209
209
|
logger.warning("No column statistics could be retrieved for the specified tables.")
|
|
@@ -355,8 +355,8 @@ class ArgProbeMixin:
|
|
|
355
355
|
"""
|
|
356
356
|
try:
|
|
357
357
|
source_code = self.get_source_code(method_name)
|
|
358
|
-
except Exception
|
|
359
|
-
logger.
|
|
358
|
+
except Exception:
|
|
359
|
+
logger.exception(f"Failed to get source code of method {method_name} in {self.__class__.__name__}. Reason:")
|
|
360
360
|
return []
|
|
361
361
|
|
|
362
362
|
# parse the source code
|
|
@@ -304,10 +304,10 @@ def ft_jsonl_validation(
|
|
|
304
304
|
assistant_key=assistant_key,
|
|
305
305
|
)
|
|
306
306
|
except Exception as e:
|
|
307
|
-
raise Exception(f"{prefix}{e}")
|
|
307
|
+
raise Exception(f"{prefix}{e}") from e
|
|
308
308
|
|
|
309
309
|
except Exception as e:
|
|
310
|
-
raise Exception(f"Fine-tuning data format is not valid. Got {e}")
|
|
310
|
+
raise Exception(f"Fine-tuning data format is not valid. Got {e}") from e
|
|
311
311
|
|
|
312
312
|
|
|
313
313
|
def ft_chat_format_validation(
|
|
@@ -13,16 +13,13 @@ def create_engine_process(connection_args: dict, integration_id: int, module_pat
|
|
|
13
13
|
|
|
14
14
|
result = None
|
|
15
15
|
|
|
16
|
-
if hasattr(module.Handler,
|
|
16
|
+
if hasattr(module.Handler, "create_engine"):
|
|
17
17
|
engine_storage = HandlerStorage(integration_id)
|
|
18
18
|
try:
|
|
19
|
-
result = module.Handler(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
).create_engine(connection_args=connection_args)
|
|
19
|
+
result = module.Handler(engine_storage=engine_storage, model_storage=None).create_engine(
|
|
20
|
+
connection_args=connection_args
|
|
21
|
+
)
|
|
23
22
|
except NotImplementedError:
|
|
24
23
|
return None
|
|
25
|
-
except Exception as e:
|
|
26
|
-
raise e
|
|
27
24
|
|
|
28
25
|
return result
|
|
@@ -11,16 +11,11 @@ def func_call_process(name: str, args: dict, integration_id: int, module_path: s
|
|
|
11
11
|
|
|
12
12
|
result = None
|
|
13
13
|
|
|
14
|
-
if hasattr(module.Handler,
|
|
14
|
+
if hasattr(module.Handler, "function_call"):
|
|
15
15
|
engine_storage = HandlerStorage(integration_id)
|
|
16
16
|
try:
|
|
17
|
-
result = module.Handler(
|
|
18
|
-
engine_storage=engine_storage,
|
|
19
|
-
model_storage=None
|
|
20
|
-
).function_call(name, args)
|
|
17
|
+
result = module.Handler(engine_storage=engine_storage, model_storage=None).function_call(name, args)
|
|
21
18
|
except NotImplementedError:
|
|
22
19
|
return None
|
|
23
|
-
except Exception as e:
|
|
24
|
-
raise e
|
|
25
20
|
|
|
26
21
|
return result
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import importlib
|
|
3
|
-
import traceback
|
|
4
3
|
import datetime as dt
|
|
5
4
|
|
|
6
5
|
from sqlalchemy.orm.attributes import flag_modified
|
|
@@ -25,56 +24,52 @@ from mindsdb.integrations.libs.ml_handler_process.handlers_cacher import handler
|
|
|
25
24
|
logger = log.getLogger(__name__)
|
|
26
25
|
|
|
27
26
|
|
|
28
|
-
@mark_process(name=
|
|
29
|
-
def learn_process(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
@mark_process(name="learn")
|
|
28
|
+
def learn_process(
|
|
29
|
+
data_integration_ref: dict,
|
|
30
|
+
problem_definition: dict,
|
|
31
|
+
fetch_data_query: str,
|
|
32
|
+
project_name: str,
|
|
33
|
+
model_id: int,
|
|
34
|
+
integration_id: int,
|
|
35
|
+
base_model_id: int,
|
|
36
|
+
set_active: bool,
|
|
37
|
+
module_path: str,
|
|
38
|
+
):
|
|
39
|
+
ctx.profiling = {"level": 0, "enabled": True, "pointer": None, "tree": None}
|
|
40
|
+
profiler.set_meta(query="learn_process", api="http", environment=Config().get("environment"))
|
|
41
|
+
with profiler.Context("learn_process"):
|
|
40
42
|
from mindsdb.interfaces.database.database import DatabaseController
|
|
41
43
|
|
|
42
44
|
try:
|
|
43
45
|
predictor_record = db.Predictor.query.with_for_update().get(model_id)
|
|
44
|
-
predictor_record.training_metadata[
|
|
45
|
-
flag_modified(predictor_record,
|
|
46
|
+
predictor_record.training_metadata["process_id"] = os.getpid()
|
|
47
|
+
flag_modified(predictor_record, "training_metadata")
|
|
46
48
|
db.session.commit()
|
|
47
49
|
|
|
48
|
-
target = problem_definition.get(
|
|
50
|
+
target = problem_definition.get("target", None)
|
|
49
51
|
training_data_df = None
|
|
50
52
|
if data_integration_ref is not None:
|
|
51
53
|
database_controller = DatabaseController()
|
|
52
54
|
sql_session = make_sql_session()
|
|
53
|
-
if data_integration_ref[
|
|
54
|
-
integration_name = database_controller.get_integration(data_integration_ref[
|
|
55
|
+
if data_integration_ref["type"] == "integration":
|
|
56
|
+
integration_name = database_controller.get_integration(data_integration_ref["id"])["name"]
|
|
55
57
|
query = Select(
|
|
56
58
|
targets=[Star()],
|
|
57
|
-
from_table=NativeQuery(
|
|
58
|
-
integration=Identifier(integration_name),
|
|
59
|
-
query=fetch_data_query
|
|
60
|
-
)
|
|
59
|
+
from_table=NativeQuery(integration=Identifier(integration_name), query=fetch_data_query),
|
|
61
60
|
)
|
|
62
61
|
sqlquery = SQLQuery(query, session=sql_session)
|
|
63
|
-
if data_integration_ref[
|
|
62
|
+
if data_integration_ref["type"] == "system":
|
|
64
63
|
query = Select(
|
|
65
|
-
targets=[Star()],
|
|
66
|
-
from_table=NativeQuery(
|
|
67
|
-
integration=Identifier('log'),
|
|
68
|
-
query=fetch_data_query
|
|
69
|
-
)
|
|
64
|
+
targets=[Star()], from_table=NativeQuery(integration=Identifier("log"), query=fetch_data_query)
|
|
70
65
|
)
|
|
71
66
|
sqlquery = SQLQuery(query, session=sql_session)
|
|
72
|
-
elif data_integration_ref[
|
|
67
|
+
elif data_integration_ref["type"] == "view":
|
|
73
68
|
project = database_controller.get_project(project_name)
|
|
74
69
|
query_ast = parse_sql(fetch_data_query)
|
|
75
70
|
view_meta = project.get_view_meta(query_ast)
|
|
76
|
-
sqlquery = SQLQuery(view_meta[
|
|
77
|
-
elif data_integration_ref[
|
|
71
|
+
sqlquery = SQLQuery(view_meta["query_ast"], session=sql_session)
|
|
72
|
+
elif data_integration_ref["type"] == "project":
|
|
78
73
|
query_ast = parse_sql(fetch_data_query)
|
|
79
74
|
sqlquery = SQLQuery(query_ast, session=sql_session)
|
|
80
75
|
|
|
@@ -97,17 +92,13 @@ def learn_process(data_integration_ref: dict, problem_definition: dict, fetch_da
|
|
|
97
92
|
|
|
98
93
|
handlerStorage = HandlerStorage(integration_id)
|
|
99
94
|
modelStorage = ModelStorage(model_id)
|
|
100
|
-
modelStorage.fileStorage.push()
|
|
95
|
+
modelStorage.fileStorage.push() # FIXME
|
|
101
96
|
|
|
102
97
|
kwargs = {}
|
|
103
98
|
if base_model_id is not None:
|
|
104
|
-
kwargs[
|
|
105
|
-
kwargs[
|
|
106
|
-
ml_handler = module.Handler(
|
|
107
|
-
engine_storage=handlerStorage,
|
|
108
|
-
model_storage=modelStorage,
|
|
109
|
-
**kwargs
|
|
110
|
-
)
|
|
99
|
+
kwargs["base_model_storage"] = ModelStorage(base_model_id)
|
|
100
|
+
kwargs["base_model_storage"].fileStorage.pull()
|
|
101
|
+
ml_handler = module.Handler(engine_storage=handlerStorage, model_storage=modelStorage, **kwargs)
|
|
111
102
|
handlers_cacher[predictor_record.id] = ml_handler
|
|
112
103
|
|
|
113
104
|
if not ml_handler.generative and target is not None:
|
|
@@ -119,18 +110,19 @@ def learn_process(data_integration_ref: dict, problem_definition: dict, fetch_da
|
|
|
119
110
|
training_data_df.rename(columns={target_found: target}, inplace=True)
|
|
120
111
|
else:
|
|
121
112
|
raise Exception(
|
|
122
|
-
f'Prediction target "{target}" not found in training dataframe: {list(training_data_df.columns)}'
|
|
113
|
+
f'Prediction target "{target}" not found in training dataframe: {list(training_data_df.columns)}'
|
|
114
|
+
)
|
|
123
115
|
|
|
124
116
|
# create new model
|
|
125
117
|
if base_model_id is None:
|
|
126
|
-
with profiler.Context(
|
|
118
|
+
with profiler.Context("create"):
|
|
127
119
|
ml_handler.create(target, df=training_data_df, args=problem_definition)
|
|
128
120
|
|
|
129
121
|
# fine-tune (partially train) existing model
|
|
130
122
|
else:
|
|
131
123
|
# load model from previous version, use it as starting point
|
|
132
|
-
with profiler.Context(
|
|
133
|
-
problem_definition[
|
|
124
|
+
with profiler.Context("finetune"):
|
|
125
|
+
problem_definition["base_model_id"] = base_model_id
|
|
134
126
|
ml_handler.finetune(df=training_data_df, args=problem_definition)
|
|
135
127
|
|
|
136
128
|
predictor_record.status = PREDICTOR_STATUS.COMPLETE
|
|
@@ -139,9 +131,7 @@ def learn_process(data_integration_ref: dict, problem_definition: dict, fetch_da
|
|
|
139
131
|
# if retrain and set_active after success creation
|
|
140
132
|
if set_active is True:
|
|
141
133
|
models = get_model_records(
|
|
142
|
-
name=predictor_record.name,
|
|
143
|
-
project_id=predictor_record.project_id,
|
|
144
|
-
active=None
|
|
134
|
+
name=predictor_record.name, project_id=predictor_record.project_id, active=None
|
|
145
135
|
)
|
|
146
136
|
for model in models:
|
|
147
137
|
model.active = False
|
|
@@ -149,7 +139,7 @@ def learn_process(data_integration_ref: dict, problem_definition: dict, fetch_da
|
|
|
149
139
|
models.sort(key=lambda x: x.created_at)
|
|
150
140
|
models[-1].active = True
|
|
151
141
|
except Exception as e:
|
|
152
|
-
logger.
|
|
142
|
+
logger.exception("Error during 'learn' process:")
|
|
153
143
|
error_message = format_exception_error(e)
|
|
154
144
|
|
|
155
145
|
predictor_record = db.Predictor.query.with_for_update().get(model_id)
|