MindsDB 25.7.4.0__py3-none-any.whl → 25.8.2.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.

Files changed (57) hide show
  1. mindsdb/__about__.py +1 -1
  2. mindsdb/__main__.py +11 -1
  3. mindsdb/api/executor/command_executor.py +9 -15
  4. mindsdb/api/executor/sql_query/steps/fetch_dataframe.py +21 -24
  5. mindsdb/api/executor/sql_query/steps/fetch_dataframe_partition.py +9 -3
  6. mindsdb/api/executor/sql_query/steps/subselect_step.py +11 -8
  7. mindsdb/api/executor/utilities/mysql_to_duckdb_functions.py +264 -0
  8. mindsdb/api/executor/utilities/sql.py +30 -0
  9. mindsdb/api/http/initialize.py +2 -1
  10. mindsdb/api/http/namespaces/views.py +56 -72
  11. mindsdb/integrations/handlers/db2_handler/db2_handler.py +19 -23
  12. mindsdb/integrations/handlers/gong_handler/__about__.py +2 -0
  13. mindsdb/integrations/handlers/gong_handler/__init__.py +30 -0
  14. mindsdb/integrations/handlers/gong_handler/connection_args.py +37 -0
  15. mindsdb/integrations/handlers/gong_handler/gong_handler.py +164 -0
  16. mindsdb/integrations/handlers/gong_handler/gong_tables.py +508 -0
  17. mindsdb/integrations/handlers/gong_handler/icon.svg +25 -0
  18. mindsdb/integrations/handlers/gong_handler/test_gong_handler.py +125 -0
  19. mindsdb/integrations/handlers/huggingface_handler/__init__.py +8 -12
  20. mindsdb/integrations/handlers/huggingface_handler/finetune.py +203 -223
  21. mindsdb/integrations/handlers/huggingface_handler/huggingface_handler.py +360 -383
  22. mindsdb/integrations/handlers/huggingface_handler/requirements.txt +7 -7
  23. mindsdb/integrations/handlers/huggingface_handler/requirements_cpu.txt +7 -7
  24. mindsdb/integrations/handlers/huggingface_handler/settings.py +25 -25
  25. mindsdb/integrations/handlers/langchain_handler/langchain_handler.py +1 -2
  26. mindsdb/integrations/handlers/openai_handler/constants.py +11 -30
  27. mindsdb/integrations/handlers/openai_handler/helpers.py +27 -34
  28. mindsdb/integrations/handlers/openai_handler/openai_handler.py +14 -12
  29. mindsdb/integrations/handlers/salesforce_handler/constants.py +9 -2
  30. mindsdb/integrations/libs/llm/config.py +0 -14
  31. mindsdb/integrations/libs/llm/utils.py +0 -15
  32. mindsdb/integrations/utilities/files/file_reader.py +5 -19
  33. mindsdb/integrations/utilities/rag/rerankers/base_reranker.py +1 -1
  34. mindsdb/interfaces/agents/agents_controller.py +83 -45
  35. mindsdb/interfaces/agents/constants.py +0 -1
  36. mindsdb/interfaces/agents/langchain_agent.py +1 -3
  37. mindsdb/interfaces/database/projects.py +111 -7
  38. mindsdb/interfaces/knowledge_base/controller.py +7 -1
  39. mindsdb/interfaces/knowledge_base/preprocessing/document_preprocessor.py +6 -10
  40. mindsdb/interfaces/knowledge_base/preprocessing/text_splitter.py +73 -0
  41. mindsdb/interfaces/query_context/context_controller.py +14 -15
  42. mindsdb/utilities/config.py +2 -0
  43. mindsdb/utilities/fs.py +54 -17
  44. {mindsdb-25.7.4.0.dist-info → mindsdb-25.8.2.0.dist-info}/METADATA +278 -263
  45. {mindsdb-25.7.4.0.dist-info → mindsdb-25.8.2.0.dist-info}/RECORD +49 -48
  46. mindsdb/integrations/handlers/anyscale_endpoints_handler/__about__.py +0 -9
  47. mindsdb/integrations/handlers/anyscale_endpoints_handler/__init__.py +0 -20
  48. mindsdb/integrations/handlers/anyscale_endpoints_handler/anyscale_endpoints_handler.py +0 -290
  49. mindsdb/integrations/handlers/anyscale_endpoints_handler/creation_args.py +0 -14
  50. mindsdb/integrations/handlers/anyscale_endpoints_handler/icon.svg +0 -4
  51. mindsdb/integrations/handlers/anyscale_endpoints_handler/requirements.txt +0 -2
  52. mindsdb/integrations/handlers/anyscale_endpoints_handler/settings.py +0 -51
  53. mindsdb/integrations/handlers/anyscale_endpoints_handler/tests/test_anyscale_endpoints_handler.py +0 -212
  54. /mindsdb/integrations/handlers/{anyscale_endpoints_handler/tests/__init__.py → gong_handler/requirements.txt} +0 -0
  55. {mindsdb-25.7.4.0.dist-info → mindsdb-25.8.2.0.dist-info}/WHEEL +0 -0
  56. {mindsdb-25.7.4.0.dist-info → mindsdb-25.8.2.0.dist-info}/licenses/LICENSE +0 -0
  57. {mindsdb-25.7.4.0.dist-info → mindsdb-25.8.2.0.dist-info}/top_level.txt +0 -0
mindsdb/utilities/fs.py CHANGED
@@ -12,6 +12,10 @@ from mindsdb.utilities import log
12
12
  logger = log.getLogger(__name__)
13
13
 
14
14
 
15
+ def get_tmp_dir() -> Path:
16
+ return Path(tempfile.gettempdir()).joinpath("mindsdb")
17
+
18
+
15
19
  def _get_process_mark_id(unified: bool = False) -> str:
16
20
  """Creates a text that can be used to identify process+thread
17
21
  Args:
@@ -26,7 +30,7 @@ def _get_process_mark_id(unified: bool = False) -> str:
26
30
 
27
31
 
28
32
  def create_process_mark(folder="learn"):
29
- p = Path(tempfile.gettempdir()).joinpath(f"mindsdb/processes/{folder}/")
33
+ p = get_tmp_dir().joinpath(f"processes/{folder}/")
30
34
  p.mkdir(parents=True, exist_ok=True)
31
35
  mark = _get_process_mark_id()
32
36
  p.joinpath(mark).touch()
@@ -43,7 +47,7 @@ def set_process_mark(folder: str, mark: str) -> None:
43
47
  Returns:
44
48
  str: process mark
45
49
  """
46
- p = Path(tempfile.gettempdir()).joinpath(f"mindsdb/processes/{folder}/")
50
+ p = get_tmp_dir().joinpath(f"processes/{folder}/")
47
51
  p.mkdir(parents=True, exist_ok=True)
48
52
  mark = f"{os.getpid()}-{threading.get_native_id()}-{mark}"
49
53
  p.joinpath(mark).touch()
@@ -53,11 +57,7 @@ def set_process_mark(folder: str, mark: str) -> None:
53
57
  def delete_process_mark(folder: str = "learn", mark: Optional[str] = None):
54
58
  if mark is None:
55
59
  mark = _get_process_mark_id()
56
- p = (
57
- Path(tempfile.gettempdir())
58
- .joinpath(f"mindsdb/processes/{folder}/")
59
- .joinpath(mark)
60
- )
60
+ p = get_tmp_dir().joinpath(f"processes/{folder}/").joinpath(mark)
61
61
  if p.exists():
62
62
  p.unlink()
63
63
 
@@ -65,7 +65,7 @@ def delete_process_mark(folder: str = "learn", mark: Optional[str] = None):
65
65
  def clean_process_marks():
66
66
  """delete all existing processes marks"""
67
67
  logger.debug("Deleting PIDs..")
68
- p = Path(tempfile.gettempdir()).joinpath("mindsdb/processes/")
68
+ p = get_tmp_dir().joinpath("processes/")
69
69
  if p.exists() is False:
70
70
  return
71
71
  for path in p.iterdir():
@@ -81,7 +81,7 @@ def get_processes_dir_files_generator() -> Tuple[Path, int, int]:
81
81
  Yields:
82
82
  Tuple[Path, int, int]: file object, process is and thread id
83
83
  """
84
- p = Path(tempfile.gettempdir()).joinpath("mindsdb/processes/")
84
+ p = get_tmp_dir().joinpath("processes/")
85
85
  if p.exists() is False:
86
86
  return
87
87
  for path in p.iterdir():
@@ -112,9 +112,7 @@ def clean_unlinked_process_marks() -> List[int]:
112
112
  try:
113
113
  next(t for t in threads if t.id == thread_id)
114
114
  except StopIteration:
115
- logger.warning(
116
- f"We have mark for process/thread {process_id}/{thread_id} but it does not exists"
117
- )
115
+ logger.warning(f"We have mark for process/thread {process_id}/{thread_id} but it does not exists")
118
116
  deleted_pids.append(process_id)
119
117
  file.unlink()
120
118
 
@@ -124,14 +122,53 @@ def clean_unlinked_process_marks() -> List[int]:
124
122
  continue
125
123
 
126
124
  except psutil.NoSuchProcess:
127
- logger.warning(
128
- f"We have mark for process/thread {process_id}/{thread_id} but it does not exists"
129
- )
125
+ logger.warning(f"We have mark for process/thread {process_id}/{thread_id} but it does not exists")
130
126
  deleted_pids.append(process_id)
131
127
  file.unlink()
132
128
  return deleted_pids
133
129
 
134
130
 
131
+ def create_pid_file():
132
+ """
133
+ Create mindsdb process pid file. Check if previous process exists and is running
134
+ """
135
+
136
+ p = get_tmp_dir()
137
+ p.mkdir(parents=True, exist_ok=True)
138
+ pid_file = p.joinpath("pid")
139
+ if pid_file.exists():
140
+ # if process exists raise exception
141
+ pid = pid_file.read_text().strip()
142
+ try:
143
+ psutil.Process(int(pid))
144
+ raise Exception(f"Found PID file with existing process: {pid}")
145
+ except (psutil.Error, ValueError):
146
+ ...
147
+
148
+ logger.warning(f"Found existing PID file ({pid}), removing")
149
+ pid_file.unlink()
150
+
151
+ pid_file.write_text(str(os.getpid()))
152
+
153
+
154
+ def delete_pid_file():
155
+ """
156
+ Remove existing process pid file if it matches current process
157
+ """
158
+ pid_file = get_tmp_dir().joinpath("pid")
159
+
160
+ if not pid_file.exists():
161
+ logger.warning("Mindsdb PID file does not exist")
162
+ return
163
+
164
+ pid = pid_file.read_text().strip()
165
+ if pid != str(os.getpid()):
166
+ logger.warning("Process id in PID file doesn't match mindsdb pid")
167
+ return
168
+
169
+ pid_file.unlink()
170
+
171
+
135
172
  def __is_within_directory(directory, target):
136
173
  abs_directory = os.path.abspath(directory)
137
174
  abs_target = os.path.abspath(target)
@@ -141,8 +178,8 @@ def __is_within_directory(directory, target):
141
178
 
142
179
  def safe_extract(tarfile, path=".", members=None, *, numeric_owner=False):
143
180
  # for py >= 3.12
144
- if hasattr(tarfile, 'data_filter'):
145
- tarfile.extractall(path, members=members, numeric_owner=numeric_owner, filter='data')
181
+ if hasattr(tarfile, "data_filter"):
182
+ tarfile.extractall(path, members=members, numeric_owner=numeric_owner, filter="data")
146
183
  return
147
184
 
148
185
  # for py < 3.12