mcli-framework 7.10.0__py3-none-any.whl → 7.10.2__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 mcli-framework might be problematic. Click here for more details.

Files changed (42) hide show
  1. mcli/lib/custom_commands.py +10 -0
  2. mcli/lib/optional_deps.py +240 -0
  3. mcli/ml/backtesting/run.py +5 -3
  4. mcli/ml/models/ensemble_models.py +1 -0
  5. mcli/ml/models/recommendation_models.py +1 -0
  6. mcli/ml/optimization/optimize.py +6 -4
  7. mcli/ml/serving/serve.py +2 -2
  8. mcli/ml/training/train.py +14 -7
  9. mcli/self/completion_cmd.py +2 -2
  10. mcli/workflow/doc_convert.py +82 -112
  11. mcli/workflow/git_commit/ai_service.py +13 -2
  12. mcli/workflow/notebook/converter.py +375 -0
  13. mcli/workflow/notebook/notebook_cmd.py +441 -0
  14. mcli/workflow/notebook/schema.py +402 -0
  15. mcli/workflow/notebook/validator.py +313 -0
  16. mcli/workflow/workflow.py +14 -0
  17. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/METADATA +37 -3
  18. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/RECORD +22 -37
  19. mcli/ml/features/political_features.py +0 -677
  20. mcli/ml/preprocessing/politician_trading_preprocessor.py +0 -570
  21. mcli/workflow/politician_trading/config.py +0 -134
  22. mcli/workflow/politician_trading/connectivity.py +0 -492
  23. mcli/workflow/politician_trading/data_sources.py +0 -654
  24. mcli/workflow/politician_trading/database.py +0 -412
  25. mcli/workflow/politician_trading/demo.py +0 -249
  26. mcli/workflow/politician_trading/models.py +0 -327
  27. mcli/workflow/politician_trading/monitoring.py +0 -413
  28. mcli/workflow/politician_trading/scrapers.py +0 -1074
  29. mcli/workflow/politician_trading/scrapers_california.py +0 -434
  30. mcli/workflow/politician_trading/scrapers_corporate_registry.py +0 -797
  31. mcli/workflow/politician_trading/scrapers_eu.py +0 -376
  32. mcli/workflow/politician_trading/scrapers_free_sources.py +0 -509
  33. mcli/workflow/politician_trading/scrapers_third_party.py +0 -373
  34. mcli/workflow/politician_trading/scrapers_uk.py +0 -378
  35. mcli/workflow/politician_trading/scrapers_us_states.py +0 -471
  36. mcli/workflow/politician_trading/seed_database.py +0 -520
  37. mcli/workflow/politician_trading/supabase_functions.py +0 -354
  38. mcli/workflow/politician_trading/workflow.py +0 -879
  39. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/WHEEL +0 -0
  40. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/entry_points.txt +0 -0
  41. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/licenses/LICENSE +0 -0
  42. {mcli_framework-7.10.0.dist-info → mcli_framework-7.10.2.dist-info}/top_level.txt +0 -0
@@ -65,6 +65,7 @@ FORMAT_ALIASES = {
65
65
 
66
66
  class ConversionMethod(Enum):
67
67
  """Available conversion methods"""
68
+
68
69
  PANDOC = "pandoc"
69
70
  NBCONVERT = "nbconvert"
70
71
  PANDOC_LATEX = "pandoc_latex"
@@ -74,6 +75,7 @@ class ConversionMethod(Enum):
74
75
  @dataclass
75
76
  class ConversionStrategy:
76
77
  """Represents a conversion strategy with command and description"""
78
+
77
79
  method: ConversionMethod
78
80
  description: str
79
81
  check_command: Optional[str] = None
@@ -136,11 +138,7 @@ def cleanup_temp_conversion(temp_dir: Path, preserve_output: Optional[Path] = No
136
138
 
137
139
 
138
140
  def get_conversion_strategies(
139
- input_path: Path,
140
- output_path: Path,
141
- from_format: str,
142
- to_format: str,
143
- pandoc_args: str = ""
141
+ input_path: Path, output_path: Path, from_format: str, to_format: str, pandoc_args: str = ""
144
142
  ) -> List[ConversionStrategy]:
145
143
  """
146
144
  Get ordered list of conversion strategies to try based on input/output formats.
@@ -152,60 +150,60 @@ def get_conversion_strategies(
152
150
  # Special handling for Jupyter notebook to PDF (notoriously problematic)
153
151
  if from_format == "ipynb" and to_format == "pdf":
154
152
  # Strategy 1: nbconvert (most reliable for notebooks)
155
- strategies.append(ConversionStrategy(
156
- method=ConversionMethod.NBCONVERT,
157
- description="jupyter nbconvert (best for notebooks)",
158
- check_command="jupyter-nbconvert"
159
- ))
153
+ strategies.append(
154
+ ConversionStrategy(
155
+ method=ConversionMethod.NBCONVERT,
156
+ description="jupyter nbconvert (best for notebooks)",
157
+ check_command="jupyter-nbconvert",
158
+ )
159
+ )
160
160
 
161
161
  # Strategy 2: pandoc with pdflatex
162
- strategies.append(ConversionStrategy(
163
- method=ConversionMethod.PANDOC_LATEX,
164
- description="pandoc with pdflatex engine"
165
- ))
162
+ strategies.append(
163
+ ConversionStrategy(
164
+ method=ConversionMethod.PANDOC_LATEX, description="pandoc with pdflatex engine"
165
+ )
166
+ )
166
167
 
167
168
  # Strategy 3: pandoc via HTML intermediate
168
- strategies.append(ConversionStrategy(
169
- method=ConversionMethod.PANDOC_HTML_INTERMEDIATE,
170
- description="pandoc via HTML intermediate (wkhtmltopdf)"
171
- ))
169
+ strategies.append(
170
+ ConversionStrategy(
171
+ method=ConversionMethod.PANDOC_HTML_INTERMEDIATE,
172
+ description="pandoc via HTML intermediate (wkhtmltopdf)",
173
+ )
174
+ )
172
175
 
173
176
  # Strategy 4: standard pandoc
174
- strategies.append(ConversionStrategy(
175
- method=ConversionMethod.PANDOC,
176
- description="pandoc default method"
177
- ))
177
+ strategies.append(
178
+ ConversionStrategy(method=ConversionMethod.PANDOC, description="pandoc default method")
179
+ )
178
180
 
179
181
  # Jupyter to other formats
180
182
  elif from_format == "ipynb":
181
183
  # Try nbconvert first for notebooks
182
- strategies.append(ConversionStrategy(
183
- method=ConversionMethod.NBCONVERT,
184
- description="jupyter nbconvert",
185
- check_command="jupyter-nbconvert"
186
- ))
187
- strategies.append(ConversionStrategy(
188
- method=ConversionMethod.PANDOC,
189
- description="pandoc"
190
- ))
184
+ strategies.append(
185
+ ConversionStrategy(
186
+ method=ConversionMethod.NBCONVERT,
187
+ description="jupyter nbconvert",
188
+ check_command="jupyter-nbconvert",
189
+ )
190
+ )
191
+ strategies.append(ConversionStrategy(method=ConversionMethod.PANDOC, description="pandoc"))
191
192
 
192
193
  # PDF output (general)
193
194
  elif to_format == "pdf":
194
- strategies.append(ConversionStrategy(
195
- method=ConversionMethod.PANDOC_LATEX,
196
- description="pandoc with LaTeX"
197
- ))
198
- strategies.append(ConversionStrategy(
199
- method=ConversionMethod.PANDOC,
200
- description="pandoc default"
201
- ))
195
+ strategies.append(
196
+ ConversionStrategy(
197
+ method=ConversionMethod.PANDOC_LATEX, description="pandoc with LaTeX"
198
+ )
199
+ )
200
+ strategies.append(
201
+ ConversionStrategy(method=ConversionMethod.PANDOC, description="pandoc default")
202
+ )
202
203
 
203
204
  # Default: just use pandoc
204
205
  else:
205
- strategies.append(ConversionStrategy(
206
- method=ConversionMethod.PANDOC,
207
- description="pandoc"
208
- ))
206
+ strategies.append(ConversionStrategy(method=ConversionMethod.PANDOC, description="pandoc"))
209
207
 
210
208
  return strategies
211
209
 
@@ -216,7 +214,7 @@ def execute_conversion_strategy(
216
214
  output_path: Path,
217
215
  from_format: str,
218
216
  to_format: str,
219
- pandoc_args: str = ""
217
+ pandoc_args: str = "",
220
218
  ) -> Tuple[bool, str]:
221
219
  """
222
220
  Execute a specific conversion strategy in a temp directory.
@@ -231,29 +229,25 @@ def execute_conversion_strategy(
231
229
  if strategy.method == ConversionMethod.NBCONVERT:
232
230
  # Check if nbconvert is available
233
231
  check = subprocess.run(
234
- ["jupyter", "nbconvert", "--version"],
235
- capture_output=True,
236
- timeout=5
232
+ ["jupyter", "nbconvert", "--version"], capture_output=True, timeout=5
237
233
  )
238
234
  if check.returncode != 0:
239
235
  return False, "jupyter nbconvert not available"
240
236
 
241
237
  # Build nbconvert command (run in temp directory)
242
238
  cmd = [
243
- "jupyter", "nbconvert",
244
- "--to", to_format,
245
- "--output", str(temp_output),
246
- str(temp_input)
239
+ "jupyter",
240
+ "nbconvert",
241
+ "--to",
242
+ to_format,
243
+ "--output",
244
+ str(temp_output),
245
+ str(temp_input),
247
246
  ]
248
247
 
249
248
  # Run in temp directory
250
249
  result = subprocess.run(
251
- cmd,
252
- capture_output=True,
253
- text=True,
254
- check=True,
255
- timeout=120,
256
- cwd=str(temp_dir)
250
+ cmd, capture_output=True, text=True, check=True, timeout=120, cwd=str(temp_dir)
257
251
  )
258
252
 
259
253
  elif strategy.method == ConversionMethod.PANDOC_LATEX:
@@ -261,20 +255,17 @@ def execute_conversion_strategy(
261
255
  cmd = [
262
256
  "pandoc",
263
257
  str(temp_input),
264
- "-f", from_format,
265
- "-o", str(temp_output),
266
- "--pdf-engine=xelatex"
258
+ "-f",
259
+ from_format,
260
+ "-o",
261
+ str(temp_output),
262
+ "--pdf-engine=xelatex",
267
263
  ]
268
264
  if pandoc_args:
269
265
  cmd.extend(pandoc_args.split())
270
266
 
271
267
  result = subprocess.run(
272
- cmd,
273
- capture_output=True,
274
- text=True,
275
- check=True,
276
- timeout=120,
277
- cwd=str(temp_dir)
268
+ cmd, capture_output=True, text=True, check=True, timeout=120, cwd=str(temp_dir)
278
269
  )
279
270
 
280
271
  elif strategy.method == ConversionMethod.PANDOC_HTML_INTERMEDIATE:
@@ -285,47 +276,30 @@ def execute_conversion_strategy(
285
276
  cmd_html = [
286
277
  "pandoc",
287
278
  str(temp_input),
288
- "-f", from_format,
289
- "-t", "html",
290
- "-o", str(html_temp),
291
- "--standalone"
279
+ "-f",
280
+ from_format,
281
+ "-t",
282
+ "html",
283
+ "-o",
284
+ str(html_temp),
285
+ "--standalone",
292
286
  ]
293
287
  result = subprocess.run(
294
- cmd_html,
295
- capture_output=True,
296
- text=True,
297
- timeout=120,
298
- cwd=str(temp_dir)
288
+ cmd_html, capture_output=True, text=True, timeout=120, cwd=str(temp_dir)
299
289
  )
300
290
  if result.returncode != 0:
301
291
  return False, f"HTML intermediate failed: {result.stderr}"
302
292
 
303
293
  # Step 2: Convert HTML to PDF
304
- cmd = [
305
- "pandoc",
306
- str(html_temp),
307
- "-f", "html",
308
- "-t", "pdf",
309
- "-o", str(temp_output)
310
- ]
294
+ cmd = ["pandoc", str(html_temp), "-f", "html", "-t", "pdf", "-o", str(temp_output)]
311
295
 
312
296
  result = subprocess.run(
313
- cmd,
314
- capture_output=True,
315
- text=True,
316
- check=True,
317
- timeout=120,
318
- cwd=str(temp_dir)
297
+ cmd, capture_output=True, text=True, check=True, timeout=120, cwd=str(temp_dir)
319
298
  )
320
299
 
321
300
  else: # PANDOC
322
301
  # Standard pandoc conversion
323
- cmd = [
324
- "pandoc",
325
- str(temp_input),
326
- "-f", from_format,
327
- "-o", str(temp_output)
328
- ]
302
+ cmd = ["pandoc", str(temp_input), "-f", from_format, "-o", str(temp_output)]
329
303
  # Use xelatex for PDF conversions (better Unicode support)
330
304
  if to_format == "pdf":
331
305
  cmd.append("--pdf-engine=xelatex")
@@ -333,12 +307,7 @@ def execute_conversion_strategy(
333
307
  cmd.extend(pandoc_args.split())
334
308
 
335
309
  result = subprocess.run(
336
- cmd,
337
- capture_output=True,
338
- text=True,
339
- check=True,
340
- timeout=120,
341
- cwd=str(temp_dir)
310
+ cmd, capture_output=True, text=True, check=True, timeout=120, cwd=str(temp_dir)
342
311
  )
343
312
 
344
313
  # Copy output file to final destination
@@ -417,9 +386,7 @@ def init():
417
386
  else:
418
387
  # Try installing via pip
419
388
  result = subprocess.run(
420
- ["pip3", "install", "jupyter", "nbconvert"],
421
- capture_output=True,
422
- text=True
389
+ ["pip3", "install", "jupyter", "nbconvert"], capture_output=True, text=True
423
390
  )
424
391
  if result.returncode == 0:
425
392
  success(" ✅ jupyter & nbconvert installed successfully")
@@ -437,13 +404,13 @@ def init():
437
404
  info(" ℹ️ This is a large download (~100MB) and may take a few minutes")
438
405
  try:
439
406
  result = subprocess.run(
440
- ["brew", "install", "--cask", "basictex"],
441
- capture_output=True,
442
- text=True
407
+ ["brew", "install", "--cask", "basictex"], capture_output=True, text=True
443
408
  )
444
409
  if result.returncode == 0:
445
410
  success(" ✅ BasicTeX installed successfully")
446
- info(" ℹ️ You may need to restart your terminal or run: eval $(/usr/libexec/path_helper)")
411
+ info(
412
+ " ℹ️ You may need to restart your terminal or run: eval $(/usr/libexec/path_helper)"
413
+ )
447
414
  info("")
448
415
  info(" 📦 Installing LaTeX packages for document conversion...")
449
416
  info(" ℹ️ This requires sudo access and may take a few minutes")
@@ -512,7 +479,9 @@ def init():
512
479
  @click.argument("path")
513
480
  @click.option("--output-dir", "-o", help="Output directory (defaults to same directory as input)")
514
481
  @click.option("--pandoc-args", "-a", help="Additional pandoc arguments", default="")
515
- @click.option("--no-fallback", is_flag=True, help="Disable fallback strategies (use only primary method)")
482
+ @click.option(
483
+ "--no-fallback", is_flag=True, help="Disable fallback strategies (use only primary method)"
484
+ )
516
485
  def convert(from_format, to_format, path, output_dir, pandoc_args, no_fallback):
517
486
  """
518
487
  Convert documents with automatic fallback strategies.
@@ -626,14 +595,15 @@ def convert(from_format, to_format, path, output_dir, pandoc_args, no_fallback):
626
595
  info(f" ⚙️ Using: {strategy.description}")
627
596
 
628
597
  success_flag, error_msg = execute_conversion_strategy(
629
- strategy, input_path, output_path,
630
- from_format_mapped, to_format_mapped, pandoc_args
598
+ strategy, input_path, output_path, from_format_mapped, to_format_mapped, pandoc_args
631
599
  )
632
600
 
633
601
  if success_flag:
634
602
  conversion_succeeded = True
635
603
  method_name = strategy.description
636
- conversion_methods_used[method_name] = conversion_methods_used.get(method_name, 0) + 1
604
+ conversion_methods_used[method_name] = (
605
+ conversion_methods_used.get(method_name, 0) + 1
606
+ )
637
607
  success(f" ✅ Created: {output_path}")
638
608
  if i > 0:
639
609
  info(f" ℹ️ Succeeded with fallback method #{i + 1}")
@@ -770,7 +740,7 @@ echo ""
770
740
  commands_dir = get_custom_commands_dir()
771
741
  cleanup_path = commands_dir / "doc-convert-cleanup.sh"
772
742
 
773
- with open(cleanup_path, 'w') as f:
743
+ with open(cleanup_path, "w") as f:
774
744
  f.write(cleanup_script)
775
745
 
776
746
  # Make it executable
@@ -2,11 +2,13 @@ import json
2
2
  import logging
3
3
  from typing import Any, Dict, Optional
4
4
 
5
- import ollama
6
-
7
5
  from mcli.lib.logger.logger import get_logger
6
+ from mcli.lib.optional_deps import optional_import
8
7
  from mcli.lib.toml.toml import read_from_toml
9
8
 
9
+ # Gracefully handle optional ollama dependency
10
+ ollama, OLLAMA_AVAILABLE = optional_import("ollama")
11
+
10
12
  logger = get_logger(__name__)
11
13
 
12
14
 
@@ -204,6 +206,15 @@ Generate ONLY the commit message, nothing else:"""
204
206
  def generate_commit_message(self, changes: Dict[str, Any], diff_content: str) -> str:
205
207
  """Generate an AI-powered commit message"""
206
208
  try:
209
+ # Check if ollama is available
210
+ if not OLLAMA_AVAILABLE:
211
+ logger.warning(
212
+ "Ollama is not installed. Install it with: pip install ollama\n"
213
+ "Falling back to rule-based commit message generation."
214
+ )
215
+ analysis = self._analyze_file_patterns(changes)
216
+ return self._generate_fallback_message(changes, analysis)
217
+
207
218
  # Analyze the changes first
208
219
  analysis = self._analyze_file_patterns(changes)
209
220