mcli-framework 7.0.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 (186) hide show
  1. mcli/app/chat_cmd.py +42 -0
  2. mcli/app/commands_cmd.py +226 -0
  3. mcli/app/completion_cmd.py +216 -0
  4. mcli/app/completion_helpers.py +288 -0
  5. mcli/app/cron_test_cmd.py +697 -0
  6. mcli/app/logs_cmd.py +419 -0
  7. mcli/app/main.py +492 -0
  8. mcli/app/model/model.py +1060 -0
  9. mcli/app/model_cmd.py +227 -0
  10. mcli/app/redis_cmd.py +269 -0
  11. mcli/app/video/video.py +1114 -0
  12. mcli/app/visual_cmd.py +303 -0
  13. mcli/chat/chat.py +2409 -0
  14. mcli/chat/command_rag.py +514 -0
  15. mcli/chat/enhanced_chat.py +652 -0
  16. mcli/chat/system_controller.py +1010 -0
  17. mcli/chat/system_integration.py +1016 -0
  18. mcli/cli.py +25 -0
  19. mcli/config.toml +20 -0
  20. mcli/lib/api/api.py +586 -0
  21. mcli/lib/api/daemon_client.py +203 -0
  22. mcli/lib/api/daemon_client_local.py +44 -0
  23. mcli/lib/api/daemon_decorator.py +217 -0
  24. mcli/lib/api/mcli_decorators.py +1032 -0
  25. mcli/lib/auth/auth.py +85 -0
  26. mcli/lib/auth/aws_manager.py +85 -0
  27. mcli/lib/auth/azure_manager.py +91 -0
  28. mcli/lib/auth/credential_manager.py +192 -0
  29. mcli/lib/auth/gcp_manager.py +93 -0
  30. mcli/lib/auth/key_manager.py +117 -0
  31. mcli/lib/auth/mcli_manager.py +93 -0
  32. mcli/lib/auth/token_manager.py +75 -0
  33. mcli/lib/auth/token_util.py +1011 -0
  34. mcli/lib/config/config.py +47 -0
  35. mcli/lib/discovery/__init__.py +1 -0
  36. mcli/lib/discovery/command_discovery.py +274 -0
  37. mcli/lib/erd/erd.py +1345 -0
  38. mcli/lib/erd/generate_graph.py +453 -0
  39. mcli/lib/files/files.py +76 -0
  40. mcli/lib/fs/fs.py +109 -0
  41. mcli/lib/lib.py +29 -0
  42. mcli/lib/logger/logger.py +611 -0
  43. mcli/lib/performance/optimizer.py +409 -0
  44. mcli/lib/performance/rust_bridge.py +502 -0
  45. mcli/lib/performance/uvloop_config.py +154 -0
  46. mcli/lib/pickles/pickles.py +50 -0
  47. mcli/lib/search/cached_vectorizer.py +479 -0
  48. mcli/lib/services/data_pipeline.py +460 -0
  49. mcli/lib/services/lsh_client.py +441 -0
  50. mcli/lib/services/redis_service.py +387 -0
  51. mcli/lib/shell/shell.py +137 -0
  52. mcli/lib/toml/toml.py +33 -0
  53. mcli/lib/ui/styling.py +47 -0
  54. mcli/lib/ui/visual_effects.py +634 -0
  55. mcli/lib/watcher/watcher.py +185 -0
  56. mcli/ml/api/app.py +215 -0
  57. mcli/ml/api/middleware.py +224 -0
  58. mcli/ml/api/routers/admin_router.py +12 -0
  59. mcli/ml/api/routers/auth_router.py +244 -0
  60. mcli/ml/api/routers/backtest_router.py +12 -0
  61. mcli/ml/api/routers/data_router.py +12 -0
  62. mcli/ml/api/routers/model_router.py +302 -0
  63. mcli/ml/api/routers/monitoring_router.py +12 -0
  64. mcli/ml/api/routers/portfolio_router.py +12 -0
  65. mcli/ml/api/routers/prediction_router.py +267 -0
  66. mcli/ml/api/routers/trade_router.py +12 -0
  67. mcli/ml/api/routers/websocket_router.py +76 -0
  68. mcli/ml/api/schemas.py +64 -0
  69. mcli/ml/auth/auth_manager.py +425 -0
  70. mcli/ml/auth/models.py +154 -0
  71. mcli/ml/auth/permissions.py +302 -0
  72. mcli/ml/backtesting/backtest_engine.py +502 -0
  73. mcli/ml/backtesting/performance_metrics.py +393 -0
  74. mcli/ml/cache.py +400 -0
  75. mcli/ml/cli/main.py +398 -0
  76. mcli/ml/config/settings.py +394 -0
  77. mcli/ml/configs/dvc_config.py +230 -0
  78. mcli/ml/configs/mlflow_config.py +131 -0
  79. mcli/ml/configs/mlops_manager.py +293 -0
  80. mcli/ml/dashboard/app.py +532 -0
  81. mcli/ml/dashboard/app_integrated.py +738 -0
  82. mcli/ml/dashboard/app_supabase.py +560 -0
  83. mcli/ml/dashboard/app_training.py +615 -0
  84. mcli/ml/dashboard/cli.py +51 -0
  85. mcli/ml/data_ingestion/api_connectors.py +501 -0
  86. mcli/ml/data_ingestion/data_pipeline.py +567 -0
  87. mcli/ml/data_ingestion/stream_processor.py +512 -0
  88. mcli/ml/database/migrations/env.py +94 -0
  89. mcli/ml/database/models.py +667 -0
  90. mcli/ml/database/session.py +200 -0
  91. mcli/ml/experimentation/ab_testing.py +845 -0
  92. mcli/ml/features/ensemble_features.py +607 -0
  93. mcli/ml/features/political_features.py +676 -0
  94. mcli/ml/features/recommendation_engine.py +809 -0
  95. mcli/ml/features/stock_features.py +573 -0
  96. mcli/ml/features/test_feature_engineering.py +346 -0
  97. mcli/ml/logging.py +85 -0
  98. mcli/ml/mlops/data_versioning.py +518 -0
  99. mcli/ml/mlops/experiment_tracker.py +377 -0
  100. mcli/ml/mlops/model_serving.py +481 -0
  101. mcli/ml/mlops/pipeline_orchestrator.py +614 -0
  102. mcli/ml/models/base_models.py +324 -0
  103. mcli/ml/models/ensemble_models.py +675 -0
  104. mcli/ml/models/recommendation_models.py +474 -0
  105. mcli/ml/models/test_models.py +487 -0
  106. mcli/ml/monitoring/drift_detection.py +676 -0
  107. mcli/ml/monitoring/metrics.py +45 -0
  108. mcli/ml/optimization/portfolio_optimizer.py +834 -0
  109. mcli/ml/preprocessing/data_cleaners.py +451 -0
  110. mcli/ml/preprocessing/feature_extractors.py +491 -0
  111. mcli/ml/preprocessing/ml_pipeline.py +382 -0
  112. mcli/ml/preprocessing/politician_trading_preprocessor.py +569 -0
  113. mcli/ml/preprocessing/test_preprocessing.py +294 -0
  114. mcli/ml/scripts/populate_sample_data.py +200 -0
  115. mcli/ml/tasks.py +400 -0
  116. mcli/ml/tests/test_integration.py +429 -0
  117. mcli/ml/tests/test_training_dashboard.py +387 -0
  118. mcli/public/oi/oi.py +15 -0
  119. mcli/public/public.py +4 -0
  120. mcli/self/self_cmd.py +1246 -0
  121. mcli/workflow/daemon/api_daemon.py +800 -0
  122. mcli/workflow/daemon/async_command_database.py +681 -0
  123. mcli/workflow/daemon/async_process_manager.py +591 -0
  124. mcli/workflow/daemon/client.py +530 -0
  125. mcli/workflow/daemon/commands.py +1196 -0
  126. mcli/workflow/daemon/daemon.py +905 -0
  127. mcli/workflow/daemon/daemon_api.py +59 -0
  128. mcli/workflow/daemon/enhanced_daemon.py +571 -0
  129. mcli/workflow/daemon/process_cli.py +244 -0
  130. mcli/workflow/daemon/process_manager.py +439 -0
  131. mcli/workflow/daemon/test_daemon.py +275 -0
  132. mcli/workflow/dashboard/dashboard_cmd.py +113 -0
  133. mcli/workflow/docker/docker.py +0 -0
  134. mcli/workflow/file/file.py +100 -0
  135. mcli/workflow/gcloud/config.toml +21 -0
  136. mcli/workflow/gcloud/gcloud.py +58 -0
  137. mcli/workflow/git_commit/ai_service.py +328 -0
  138. mcli/workflow/git_commit/commands.py +430 -0
  139. mcli/workflow/lsh_integration.py +355 -0
  140. mcli/workflow/model_service/client.py +594 -0
  141. mcli/workflow/model_service/download_and_run_efficient_models.py +288 -0
  142. mcli/workflow/model_service/lightweight_embedder.py +397 -0
  143. mcli/workflow/model_service/lightweight_model_server.py +714 -0
  144. mcli/workflow/model_service/lightweight_test.py +241 -0
  145. mcli/workflow/model_service/model_service.py +1955 -0
  146. mcli/workflow/model_service/ollama_efficient_runner.py +425 -0
  147. mcli/workflow/model_service/pdf_processor.py +386 -0
  148. mcli/workflow/model_service/test_efficient_runner.py +234 -0
  149. mcli/workflow/model_service/test_example.py +315 -0
  150. mcli/workflow/model_service/test_integration.py +131 -0
  151. mcli/workflow/model_service/test_new_features.py +149 -0
  152. mcli/workflow/openai/openai.py +99 -0
  153. mcli/workflow/politician_trading/commands.py +1790 -0
  154. mcli/workflow/politician_trading/config.py +134 -0
  155. mcli/workflow/politician_trading/connectivity.py +490 -0
  156. mcli/workflow/politician_trading/data_sources.py +395 -0
  157. mcli/workflow/politician_trading/database.py +410 -0
  158. mcli/workflow/politician_trading/demo.py +248 -0
  159. mcli/workflow/politician_trading/models.py +165 -0
  160. mcli/workflow/politician_trading/monitoring.py +413 -0
  161. mcli/workflow/politician_trading/scrapers.py +966 -0
  162. mcli/workflow/politician_trading/scrapers_california.py +412 -0
  163. mcli/workflow/politician_trading/scrapers_eu.py +377 -0
  164. mcli/workflow/politician_trading/scrapers_uk.py +350 -0
  165. mcli/workflow/politician_trading/scrapers_us_states.py +438 -0
  166. mcli/workflow/politician_trading/supabase_functions.py +354 -0
  167. mcli/workflow/politician_trading/workflow.py +852 -0
  168. mcli/workflow/registry/registry.py +180 -0
  169. mcli/workflow/repo/repo.py +223 -0
  170. mcli/workflow/scheduler/commands.py +493 -0
  171. mcli/workflow/scheduler/cron_parser.py +238 -0
  172. mcli/workflow/scheduler/job.py +182 -0
  173. mcli/workflow/scheduler/monitor.py +139 -0
  174. mcli/workflow/scheduler/persistence.py +324 -0
  175. mcli/workflow/scheduler/scheduler.py +679 -0
  176. mcli/workflow/sync/sync_cmd.py +437 -0
  177. mcli/workflow/sync/test_cmd.py +314 -0
  178. mcli/workflow/videos/videos.py +242 -0
  179. mcli/workflow/wakatime/wakatime.py +11 -0
  180. mcli/workflow/workflow.py +37 -0
  181. mcli_framework-7.0.0.dist-info/METADATA +479 -0
  182. mcli_framework-7.0.0.dist-info/RECORD +186 -0
  183. mcli_framework-7.0.0.dist-info/WHEEL +5 -0
  184. mcli_framework-7.0.0.dist-info/entry_points.txt +7 -0
  185. mcli_framework-7.0.0.dist-info/licenses/LICENSE +21 -0
  186. mcli_framework-7.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,93 @@
1
+ import base64
2
+ import json
3
+ import time
4
+ from pathlib import Path
5
+ from urllib.request import urlopen
6
+
7
+ import click
8
+
9
+ from mcli.lib.logger.logger import get_logger
10
+
11
+ logger = get_logger(__name__)
12
+
13
+
14
+ class MCLIManager:
15
+ """
16
+ Class for managing MCLI cluster connections and authentication.
17
+ """
18
+
19
+ def __init__(self, env_url: str):
20
+ self.env_url = env_url
21
+
22
+ def create_mcli_basic_auth_token(self):
23
+ """Create a basic auth token for MCLI authentication"""
24
+ basic_content_bytes = "BA:BA".encode("ASCII")
25
+ basic_token_b64 = base64.b64encode(basic_content_bytes).decode("ASCII")
26
+ return basic_token_b64
27
+
28
+ def create_mcli_basic_auth_header(self, token: str):
29
+ """Create a basic auth header for MCLI authentication"""
30
+ return "Basic " + token
31
+
32
+ def mcli_as_dev_user(self, url, authHeader):
33
+ """Connect to MCLI as a dev user"""
34
+ src = urlopen(url + "/remote/mcli.py").read()
35
+ exec_scope = {}
36
+ exec(src, exec_scope)
37
+ return exec_scope["get_mcli"](url=url, authz=authHeader)
38
+
39
+ def mcli_as_basic_user(self):
40
+ """Connect to MCLI as a BA user"""
41
+ url = self.env_url
42
+ token = self.create_mcli_basic_auth_token()
43
+ basicAuthHeader = self.create_mcli_basic_auth_header(token)
44
+ mcli = self.mcli_as_dev_user(url, basicAuthHeader)
45
+ return mcli
46
+
47
+
48
+ class MCLIConnectionParams:
49
+ """A picklable class to store MCLI connection parameters"""
50
+
51
+ def __init__(self, url, auth_token):
52
+ self.url = url
53
+ self.auth_token = auth_token
54
+
55
+
56
+ class MCLIInstance:
57
+ def __init__(self, url, auth_token):
58
+ self.url = self._normalize_url(url)
59
+ self.auth_token = auth_token
60
+ self._mcli = self._initialize_mcli()
61
+
62
+ def _normalize_url(self, url):
63
+ """Normalize URL to ensure it's properly formatted"""
64
+ if not url:
65
+ raise ValueError("URL cannot be empty")
66
+
67
+ url = url.strip()
68
+ if not url.startswith(("http://", "https://")):
69
+ url = f"https://{url}"
70
+
71
+ return url.rstrip("/")
72
+
73
+ def _initialize_mcli(self):
74
+ """Initialize the MCLI connection"""
75
+ mcli_url = f"{self.url}/remote/mcli.py"
76
+
77
+ try:
78
+ logger.info(f"Attempting to connect to: {mcli_url}")
79
+ src = urlopen(mcli_url).read()
80
+ exec_scope = {}
81
+ exec(src, exec_scope) # pylint: disable=exec-used
82
+ return exec_scope["get_mcli"](url=self.url, authz=self.auth_token)
83
+ except Exception as e:
84
+ logger.info(f"Failed to initialize MCLI connection: {str(e)}")
85
+ raise
86
+
87
+ def __getattr__(self, name):
88
+ return getattr(self._mcli, name)
89
+
90
+
91
+ def create_mcli_instance(url, token):
92
+ """Returns mcli remote type system for python."""
93
+ return MCLIInstance(url, token)
@@ -0,0 +1,75 @@
1
+ from typing import Optional
2
+
3
+ from mcli.lib.logger import get_logger
4
+
5
+ from .credential_manager import CredentialManager
6
+
7
+ logger = get_logger(__name__)
8
+
9
+
10
+ class TokenManager(CredentialManager):
11
+ """
12
+ Specialized credential manager for handling authentication tokens and environment URLs.
13
+ """
14
+
15
+ def __init__(self, app_name: str = "mcli"):
16
+ """
17
+ Initialize TokenManager with a specific configuration filename.
18
+
19
+ Args:
20
+ app_name (str, optional): Name of the application. Defaults to "mcli".
21
+ """
22
+ super().__init__(app_name, config_filename="mcli.token.config.json")
23
+
24
+ def save_token(self, token: str):
25
+ """
26
+ Save authentication token to configuration.
27
+
28
+ Args:
29
+ token (str): Authentication token to save.
30
+
31
+ Raises:
32
+ ValueError: If token is empty or not a string.
33
+ """
34
+ if not token or not isinstance(token, str):
35
+ raise ValueError("Token must be a non-empty string")
36
+
37
+ try:
38
+ self.update_config("auth_token", token)
39
+ except Exception as e:
40
+ raise Exception(f"Failed to save token: {str(e)}")
41
+
42
+ def get_token(self) -> Optional[str]:
43
+ """
44
+ Retrieve the stored authentication token.
45
+
46
+ Returns:
47
+ Optional[str]: Stored authentication token or None if not found.
48
+ """
49
+ try:
50
+ logger.info("getting token")
51
+ return self.get_config_value("auth_token")
52
+ except Exception as e:
53
+ logger.info(f"Warning: Error retrieving token: {str(e)}")
54
+ return None
55
+
56
+ def clear_token(self):
57
+ """
58
+ Clear the stored authentication token.
59
+ Uses the base class clear_config method.
60
+ """
61
+ self.clear_config()
62
+
63
+ def get_url(self) -> Optional[str]:
64
+ """
65
+ Retrieve environment URL from configuration.
66
+
67
+ Returns:
68
+ Optional[str]: Stored environment URL or None if not found.
69
+ """
70
+ try:
71
+ logger.info("getting url")
72
+ return self.get_config_value("env_url")
73
+ except Exception as e:
74
+ logger.info(f"Warning: Error retrieving environment URL: {str(e)}")
75
+ return None