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

Files changed (97) hide show
  1. mcli/__init__.py +160 -0
  2. mcli/__main__.py +14 -0
  3. mcli/app/__init__.py +23 -0
  4. mcli/app/commands_cmd.py +741 -0
  5. mcli/app/model/__init__.py +0 -0
  6. mcli/app/video/__init__.py +5 -0
  7. mcli/chat/__init__.py +34 -0
  8. mcli/lib/__init__.py +0 -0
  9. mcli/lib/api/__init__.py +0 -0
  10. mcli/lib/auth/__init__.py +1 -0
  11. mcli/lib/config/__init__.py +1 -0
  12. mcli/lib/erd/__init__.py +25 -0
  13. mcli/lib/files/__init__.py +0 -0
  14. mcli/lib/fs/__init__.py +1 -0
  15. mcli/lib/logger/__init__.py +3 -0
  16. mcli/lib/performance/__init__.py +17 -0
  17. mcli/lib/pickles/__init__.py +1 -0
  18. mcli/lib/shell/__init__.py +0 -0
  19. mcli/lib/toml/__init__.py +1 -0
  20. mcli/lib/watcher/__init__.py +0 -0
  21. mcli/ml/__init__.py +16 -0
  22. mcli/ml/api/__init__.py +30 -0
  23. mcli/ml/api/routers/__init__.py +27 -0
  24. mcli/ml/api/schemas.py +2 -2
  25. mcli/ml/auth/__init__.py +45 -0
  26. mcli/ml/auth/models.py +2 -2
  27. mcli/ml/backtesting/__init__.py +39 -0
  28. mcli/ml/cli/__init__.py +5 -0
  29. mcli/ml/cli/main.py +1 -1
  30. mcli/ml/config/__init__.py +33 -0
  31. mcli/ml/configs/__init__.py +16 -0
  32. mcli/ml/dashboard/__init__.py +12 -0
  33. mcli/ml/dashboard/app_integrated.py +296 -30
  34. mcli/ml/dashboard/app_training.py +1 -1
  35. mcli/ml/dashboard/components/__init__.py +7 -0
  36. mcli/ml/dashboard/pages/__init__.py +6 -0
  37. mcli/ml/dashboard/pages/cicd.py +1 -1
  38. mcli/ml/dashboard/pages/debug_dependencies.py +364 -0
  39. mcli/ml/dashboard/pages/gravity_viz.py +565 -0
  40. mcli/ml/dashboard/pages/monte_carlo_predictions.py +555 -0
  41. mcli/ml/dashboard/pages/overview.py +378 -0
  42. mcli/ml/dashboard/pages/predictions_enhanced.py +20 -6
  43. mcli/ml/dashboard/pages/scrapers_and_logs.py +22 -6
  44. mcli/ml/dashboard/pages/test_portfolio.py +423 -0
  45. mcli/ml/dashboard/pages/trading.py +768 -0
  46. mcli/ml/dashboard/streamlit_extras_utils.py +297 -0
  47. mcli/ml/dashboard/utils.py +161 -0
  48. mcli/ml/dashboard/warning_suppression.py +34 -0
  49. mcli/ml/data_ingestion/__init__.py +39 -0
  50. mcli/ml/database/__init__.py +47 -0
  51. mcli/ml/database/session.py +169 -16
  52. mcli/ml/experimentation/__init__.py +29 -0
  53. mcli/ml/features/__init__.py +39 -0
  54. mcli/ml/mlops/__init__.py +33 -0
  55. mcli/ml/models/__init__.py +94 -0
  56. mcli/ml/monitoring/__init__.py +25 -0
  57. mcli/ml/optimization/__init__.py +27 -0
  58. mcli/ml/predictions/__init__.py +5 -0
  59. mcli/ml/predictions/monte_carlo.py +428 -0
  60. mcli/ml/preprocessing/__init__.py +28 -0
  61. mcli/ml/scripts/__init__.py +1 -0
  62. mcli/ml/trading/__init__.py +66 -0
  63. mcli/ml/trading/alpaca_client.py +417 -0
  64. mcli/ml/trading/migrations.py +164 -0
  65. mcli/ml/trading/models.py +418 -0
  66. mcli/ml/trading/paper_trading.py +326 -0
  67. mcli/ml/trading/risk_management.py +370 -0
  68. mcli/ml/trading/trading_service.py +480 -0
  69. mcli/ml/training/__init__.py +10 -0
  70. mcli/mygroup/__init__.py +3 -0
  71. mcli/public/__init__.py +1 -0
  72. mcli/public/commands/__init__.py +2 -0
  73. mcli/self/__init__.py +3 -0
  74. mcli/self/self_cmd.py +514 -15
  75. mcli/workflow/__init__.py +0 -0
  76. mcli/workflow/daemon/__init__.py +15 -0
  77. mcli/workflow/daemon/daemon.py +21 -3
  78. mcli/workflow/dashboard/__init__.py +5 -0
  79. mcli/workflow/docker/__init__.py +0 -0
  80. mcli/workflow/file/__init__.py +0 -0
  81. mcli/workflow/gcloud/__init__.py +1 -0
  82. mcli/workflow/git_commit/__init__.py +0 -0
  83. mcli/workflow/interview/__init__.py +0 -0
  84. mcli/workflow/politician_trading/__init__.py +4 -0
  85. mcli/workflow/registry/__init__.py +0 -0
  86. mcli/workflow/repo/__init__.py +0 -0
  87. mcli/workflow/scheduler/__init__.py +25 -0
  88. mcli/workflow/search/__init__.py +0 -0
  89. mcli/workflow/sync/__init__.py +5 -0
  90. mcli/workflow/videos/__init__.py +1 -0
  91. mcli/workflow/wakatime/__init__.py +80 -0
  92. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/METADATA +4 -1
  93. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/RECORD +97 -18
  94. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/WHEEL +0 -0
  95. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/entry_points.txt +0 -0
  96. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/licenses/LICENSE +0 -0
  97. {mcli_framework-7.2.0.dist-info → mcli_framework-7.4.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,364 @@
1
+ """Debug Dependencies - Diagnostic page for troubleshooting installation issues"""
2
+
3
+ import streamlit as st
4
+ import sys
5
+ import subprocess
6
+ from pathlib import Path
7
+ from typing import Dict, List, Tuple
8
+
9
+
10
+ def show_debug_dependencies():
11
+ """Diagnostic page for dependency debugging"""
12
+
13
+ st.title("🔍 Dependency Diagnostics")
14
+ st.markdown("""
15
+ This page helps diagnose why certain dependencies (like alpaca-py) may not be installing correctly.
16
+ """)
17
+
18
+ # Python environment info
19
+ st.header("🐍 Python Environment")
20
+
21
+ col1, col2 = st.columns(2)
22
+ with col1:
23
+ st.metric("Python Version", f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")
24
+ with col2:
25
+ st.metric("Platform", sys.platform)
26
+
27
+ with st.expander("📋 Detailed Python Info", expanded=False):
28
+ st.code(f"""
29
+ Python Version: {sys.version}
30
+ Python Path: {sys.executable}
31
+ Prefix: {sys.prefix}
32
+ Platform: {sys.platform}
33
+ """)
34
+
35
+ # Check Python paths
36
+ st.header("📁 Python Paths")
37
+ with st.expander("View all Python paths", expanded=False):
38
+ for i, path in enumerate(sys.path, 1):
39
+ st.code(f"{i}. {path}")
40
+
41
+ # Test critical imports
42
+ st.header("đŸ“Ļ Critical Import Tests")
43
+
44
+ critical_imports = [
45
+ ("streamlit", "Streamlit core"),
46
+ ("pandas", "Data processing"),
47
+ ("numpy", "Numerical computing"),
48
+ ("plotly", "Visualizations"),
49
+ ("requests", "HTTP requests"),
50
+ ("supabase", "Database client"),
51
+ ("yfinance", "Yahoo Finance API"),
52
+ ("alpaca", "Alpaca Trading API - Main module"),
53
+ ("alpaca.trading", "Alpaca Trading client"),
54
+ ("alpaca.data", "Alpaca Data client"),
55
+ ("alpaca.broker", "Alpaca Broker client"),
56
+ ]
57
+
58
+ import_results: List[Tuple[str, str, bool, str]] = []
59
+
60
+ for module_name, description in critical_imports:
61
+ try:
62
+ module = __import__(module_name)
63
+ version = getattr(module, "__version__", "Unknown")
64
+ import_results.append((module_name, description, True, version))
65
+ except ImportError as e:
66
+ import_results.append((module_name, description, False, str(e)))
67
+ except Exception as e:
68
+ import_results.append((module_name, description, False, f"Unexpected error: {str(e)}"))
69
+
70
+ # Display results in a nice table
71
+ success_count = sum(1 for _, _, success, _ in import_results if success)
72
+ fail_count = len(import_results) - success_count
73
+
74
+ col1, col2 = st.columns(2)
75
+ with col1:
76
+ st.metric("✅ Successful Imports", success_count)
77
+ with col2:
78
+ st.metric("❌ Failed Imports", fail_count)
79
+
80
+ st.markdown("---")
81
+
82
+ for module_name, description, success, info in import_results:
83
+ if success:
84
+ with st.expander(f"✅ **{module_name}** - {description}", expanded=False):
85
+ st.success(f"Successfully imported")
86
+ st.code(f"Version: {info}")
87
+ else:
88
+ with st.expander(f"❌ **{module_name}** - {description}", expanded=True):
89
+ st.error(f"Import failed")
90
+ st.code(info)
91
+
92
+ # Detailed alpaca-py investigation
93
+ st.header("đŸ”Ŧ Alpaca-py Deep Dive")
94
+
95
+ st.markdown("""
96
+ Attempting to import alpaca-py components individually to identify specific failure points.
97
+ """)
98
+
99
+ alpaca_submodules = [
100
+ "alpaca",
101
+ "alpaca.common",
102
+ "alpaca.trading",
103
+ "alpaca.trading.client",
104
+ "alpaca.trading.requests",
105
+ "alpaca.trading.models",
106
+ "alpaca.data",
107
+ "alpaca.data.historical",
108
+ "alpaca.broker",
109
+ ]
110
+
111
+ for submodule in alpaca_submodules:
112
+ try:
113
+ mod = __import__(submodule)
114
+ st.success(f"✅ {submodule}")
115
+ if hasattr(mod, "__file__"):
116
+ st.caption(f"Location: {mod.__file__}")
117
+ except ImportError as e:
118
+ st.error(f"❌ {submodule}")
119
+ with st.expander("Error details"):
120
+ st.code(str(e))
121
+ except Exception as e:
122
+ st.warning(f"âš ī¸ {submodule}")
123
+ with st.expander("Error details"):
124
+ st.code(f"Unexpected error: {str(e)}")
125
+
126
+ # List installed packages
127
+ st.header("📋 Installed Packages")
128
+
129
+ try:
130
+ result = subprocess.run(
131
+ ["pip", "list", "--format=columns"],
132
+ capture_output=True,
133
+ text=True,
134
+ timeout=10
135
+ )
136
+
137
+ if result.returncode == 0:
138
+ # Search for alpaca-related packages
139
+ alpaca_packages = [
140
+ line for line in result.stdout.split("\n")
141
+ if "alpaca" in line.lower()
142
+ ]
143
+
144
+ if alpaca_packages:
145
+ st.success("Found alpaca-related packages:")
146
+ for pkg in alpaca_packages:
147
+ st.code(pkg)
148
+ else:
149
+ st.error("âš ī¸ No alpaca-related packages found in pip list!")
150
+
151
+ with st.expander("đŸ“Ļ All Installed Packages (click to expand)"):
152
+ st.code(result.stdout)
153
+ else:
154
+ st.error("Failed to run pip list")
155
+ st.code(result.stderr)
156
+
157
+ except subprocess.TimeoutExpired:
158
+ st.error("pip list command timed out")
159
+ except Exception as e:
160
+ st.error(f"Error running pip list: {str(e)}")
161
+
162
+ # Check for specific alpaca-py installation
163
+ st.header("🔎 Alpaca-py Installation Check")
164
+
165
+ try:
166
+ result = subprocess.run(
167
+ ["pip", "show", "alpaca-py"],
168
+ capture_output=True,
169
+ text=True,
170
+ timeout=10
171
+ )
172
+
173
+ if result.returncode == 0:
174
+ st.success("✅ alpaca-py package is installed!")
175
+ st.code(result.stdout)
176
+
177
+ # Try to get the version
178
+ try:
179
+ import alpaca
180
+ if hasattr(alpaca, "__version__"):
181
+ st.info(f"Alpaca version from import: {alpaca.__version__}")
182
+ except:
183
+ pass
184
+ else:
185
+ st.error("❌ alpaca-py package NOT found!")
186
+ st.code(result.stderr)
187
+
188
+ # Suggest installation
189
+ st.markdown("### 💡 Suggested Fix")
190
+ st.code("pip install alpaca-py>=0.20.0", language="bash")
191
+
192
+ except subprocess.TimeoutExpired:
193
+ st.error("pip show command timed out")
194
+ except Exception as e:
195
+ st.error(f"Error running pip show: {str(e)}")
196
+
197
+ # Check requirements.txt
198
+ st.header("📄 Requirements.txt Check")
199
+
200
+ requirements_path = Path(__file__).parent.parent.parent.parent.parent / "requirements.txt"
201
+
202
+ if requirements_path.exists():
203
+ with open(requirements_path, "r") as f:
204
+ requirements_content = f.read()
205
+
206
+ # Check if alpaca-py is in requirements
207
+ if "alpaca-py" in requirements_content.lower():
208
+ st.success("✅ alpaca-py found in requirements.txt")
209
+ else:
210
+ st.error("❌ alpaca-py NOT found in requirements.txt!")
211
+
212
+ # Show relevant lines
213
+ st.markdown("### Alpaca-related lines:")
214
+ for line in requirements_content.split("\n"):
215
+ if "alpaca" in line.lower() and not line.strip().startswith("#"):
216
+ st.code(line)
217
+
218
+ with st.expander("📋 Full requirements.txt"):
219
+ st.code(requirements_content)
220
+ else:
221
+ st.warning(f"requirements.txt not found at {requirements_path}")
222
+
223
+ # Environment variables check
224
+ st.header("🔐 Environment Variables")
225
+
226
+ env_vars_to_check = [
227
+ "ALPACA_API_KEY",
228
+ "ALPACA_SECRET_KEY",
229
+ "ALPACA_BASE_URL",
230
+ "PYTHONPATH",
231
+ "PATH",
232
+ ]
233
+
234
+ st.markdown("Checking for relevant environment variables:")
235
+
236
+ import os
237
+ for var in env_vars_to_check:
238
+ value = os.environ.get(var)
239
+ if value:
240
+ if "KEY" in var or "SECRET" in var:
241
+ # Mask sensitive values
242
+ masked = value[:4] + "..." + value[-4:] if len(value) > 8 else "***"
243
+ st.success(f"✅ {var} = {masked}")
244
+ else:
245
+ with st.expander(f"✅ {var}", expanded=False):
246
+ st.code(value)
247
+ else:
248
+ st.info(f"â„šī¸ {var} = Not set")
249
+
250
+ # Streamlit Cloud specific checks
251
+ st.header("â˜ī¸ Streamlit Cloud Detection")
252
+
253
+ is_cloud = os.environ.get("STREAMLIT_RUNTIME_ENVIRONMENT") == "cloud"
254
+
255
+ if is_cloud:
256
+ st.success("✅ Running on Streamlit Cloud")
257
+ st.info("""
258
+ **Note:** On Streamlit Cloud, packages are installed from requirements.txt during deployment.
259
+ If alpaca-py is not installed, check:
260
+ 1. requirements.txt has correct package name and version
261
+ 2. Package has no conflicting dependencies
262
+ 3. Deployment logs for installation errors
263
+ """)
264
+ else:
265
+ st.info("â„šī¸ Running locally (not Streamlit Cloud)")
266
+
267
+ # System information
268
+ st.header("đŸ’ģ System Information")
269
+
270
+ import platform
271
+
272
+ sys_info = {
273
+ "System": platform.system(),
274
+ "Release": platform.release(),
275
+ "Version": platform.version(),
276
+ "Machine": platform.machine(),
277
+ "Processor": platform.processor(),
278
+ "Python Implementation": platform.python_implementation(),
279
+ "Python Compiler": platform.python_compiler(),
280
+ }
281
+
282
+ for key, value in sys_info.items():
283
+ st.text(f"{key}: {value}")
284
+
285
+ # Troubleshooting guide
286
+ st.header("đŸ› ī¸ Troubleshooting Guide")
287
+
288
+ with st.expander("🔧 Common Solutions", expanded=True):
289
+ st.markdown("""
290
+ ### If alpaca-py import fails:
291
+
292
+ #### 1. Check Requirements.txt
293
+ - Ensure `alpaca-py>=0.20.0` is present
294
+ - No conflicting version constraints
295
+ - No explicit sub-dependencies (websockets, msgpack, etc.)
296
+
297
+ #### 2. Check Python Version
298
+ - alpaca-py requires Python 3.8+
299
+ - Best tested on Python 3.11
300
+ - Create `.python-version` file with `3.11`
301
+
302
+ #### 3. Dependency Conflicts
303
+ - Remove explicit version pins for sub-dependencies
304
+ - Let pip resolve dependencies automatically
305
+ - Check for conflicts with other packages
306
+
307
+ #### 4. Streamlit Cloud Deployment
308
+ - Check deployment logs for installation errors
309
+ - Verify requirements.txt is in repo root
310
+ - Ensure no typos in package names
311
+ - Check for timeout during installation
312
+
313
+ #### 5. Alternative Approaches
314
+ - Try pinning to specific version: `alpaca-py==0.20.0`
315
+ - Try older stable version: `alpaca-py==0.15.0`
316
+ - Check alpaca-py GitHub issues for known problems
317
+
318
+ ### Debug Commands (local)
319
+ ```bash
320
+ # Verify installation
321
+ pip show alpaca-py
322
+
323
+ # Test import
324
+ python -c "import alpaca; print(alpaca.__version__)"
325
+
326
+ # Check for conflicts
327
+ pip check
328
+
329
+ # Reinstall clean
330
+ pip uninstall alpaca-py -y
331
+ pip install alpaca-py>=0.20.0
332
+ ```
333
+ """)
334
+
335
+ # Export diagnostics
336
+ st.header("💾 Export Diagnostics")
337
+
338
+ if st.button("📋 Copy Diagnostics to Clipboard"):
339
+ diagnostics = f"""
340
+ # Dependency Diagnostics Report
341
+ Generated: {pd.Timestamp.now()}
342
+
343
+ ## Python Environment
344
+ - Version: {sys.version}
345
+ - Platform: {sys.platform}
346
+ - Executable: {sys.executable}
347
+
348
+ ## Import Test Results
349
+ """
350
+ for module_name, description, success, info in import_results:
351
+ status = "✅ SUCCESS" if success else "❌ FAILED"
352
+ diagnostics += f"\n- {module_name}: {status}\n Info: {info}\n"
353
+
354
+ diagnostics += "\n## Installed Packages\n"
355
+ if 'result' in locals() and result.returncode == 0:
356
+ diagnostics += result.stdout
357
+
358
+ st.code(diagnostics)
359
+ st.success("Diagnostics generated! Copy the text above.")
360
+
361
+
362
+ if __name__ == "__main__":
363
+ import pandas as pd
364
+ show_debug_dependencies()