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.
- mcli/app/chat_cmd.py +42 -0
- mcli/app/commands_cmd.py +226 -0
- mcli/app/completion_cmd.py +216 -0
- mcli/app/completion_helpers.py +288 -0
- mcli/app/cron_test_cmd.py +697 -0
- mcli/app/logs_cmd.py +419 -0
- mcli/app/main.py +492 -0
- mcli/app/model/model.py +1060 -0
- mcli/app/model_cmd.py +227 -0
- mcli/app/redis_cmd.py +269 -0
- mcli/app/video/video.py +1114 -0
- mcli/app/visual_cmd.py +303 -0
- mcli/chat/chat.py +2409 -0
- mcli/chat/command_rag.py +514 -0
- mcli/chat/enhanced_chat.py +652 -0
- mcli/chat/system_controller.py +1010 -0
- mcli/chat/system_integration.py +1016 -0
- mcli/cli.py +25 -0
- mcli/config.toml +20 -0
- mcli/lib/api/api.py +586 -0
- mcli/lib/api/daemon_client.py +203 -0
- mcli/lib/api/daemon_client_local.py +44 -0
- mcli/lib/api/daemon_decorator.py +217 -0
- mcli/lib/api/mcli_decorators.py +1032 -0
- mcli/lib/auth/auth.py +85 -0
- mcli/lib/auth/aws_manager.py +85 -0
- mcli/lib/auth/azure_manager.py +91 -0
- mcli/lib/auth/credential_manager.py +192 -0
- mcli/lib/auth/gcp_manager.py +93 -0
- mcli/lib/auth/key_manager.py +117 -0
- mcli/lib/auth/mcli_manager.py +93 -0
- mcli/lib/auth/token_manager.py +75 -0
- mcli/lib/auth/token_util.py +1011 -0
- mcli/lib/config/config.py +47 -0
- mcli/lib/discovery/__init__.py +1 -0
- mcli/lib/discovery/command_discovery.py +274 -0
- mcli/lib/erd/erd.py +1345 -0
- mcli/lib/erd/generate_graph.py +453 -0
- mcli/lib/files/files.py +76 -0
- mcli/lib/fs/fs.py +109 -0
- mcli/lib/lib.py +29 -0
- mcli/lib/logger/logger.py +611 -0
- mcli/lib/performance/optimizer.py +409 -0
- mcli/lib/performance/rust_bridge.py +502 -0
- mcli/lib/performance/uvloop_config.py +154 -0
- mcli/lib/pickles/pickles.py +50 -0
- mcli/lib/search/cached_vectorizer.py +479 -0
- mcli/lib/services/data_pipeline.py +460 -0
- mcli/lib/services/lsh_client.py +441 -0
- mcli/lib/services/redis_service.py +387 -0
- mcli/lib/shell/shell.py +137 -0
- mcli/lib/toml/toml.py +33 -0
- mcli/lib/ui/styling.py +47 -0
- mcli/lib/ui/visual_effects.py +634 -0
- mcli/lib/watcher/watcher.py +185 -0
- mcli/ml/api/app.py +215 -0
- mcli/ml/api/middleware.py +224 -0
- mcli/ml/api/routers/admin_router.py +12 -0
- mcli/ml/api/routers/auth_router.py +244 -0
- mcli/ml/api/routers/backtest_router.py +12 -0
- mcli/ml/api/routers/data_router.py +12 -0
- mcli/ml/api/routers/model_router.py +302 -0
- mcli/ml/api/routers/monitoring_router.py +12 -0
- mcli/ml/api/routers/portfolio_router.py +12 -0
- mcli/ml/api/routers/prediction_router.py +267 -0
- mcli/ml/api/routers/trade_router.py +12 -0
- mcli/ml/api/routers/websocket_router.py +76 -0
- mcli/ml/api/schemas.py +64 -0
- mcli/ml/auth/auth_manager.py +425 -0
- mcli/ml/auth/models.py +154 -0
- mcli/ml/auth/permissions.py +302 -0
- mcli/ml/backtesting/backtest_engine.py +502 -0
- mcli/ml/backtesting/performance_metrics.py +393 -0
- mcli/ml/cache.py +400 -0
- mcli/ml/cli/main.py +398 -0
- mcli/ml/config/settings.py +394 -0
- mcli/ml/configs/dvc_config.py +230 -0
- mcli/ml/configs/mlflow_config.py +131 -0
- mcli/ml/configs/mlops_manager.py +293 -0
- mcli/ml/dashboard/app.py +532 -0
- mcli/ml/dashboard/app_integrated.py +738 -0
- mcli/ml/dashboard/app_supabase.py +560 -0
- mcli/ml/dashboard/app_training.py +615 -0
- mcli/ml/dashboard/cli.py +51 -0
- mcli/ml/data_ingestion/api_connectors.py +501 -0
- mcli/ml/data_ingestion/data_pipeline.py +567 -0
- mcli/ml/data_ingestion/stream_processor.py +512 -0
- mcli/ml/database/migrations/env.py +94 -0
- mcli/ml/database/models.py +667 -0
- mcli/ml/database/session.py +200 -0
- mcli/ml/experimentation/ab_testing.py +845 -0
- mcli/ml/features/ensemble_features.py +607 -0
- mcli/ml/features/political_features.py +676 -0
- mcli/ml/features/recommendation_engine.py +809 -0
- mcli/ml/features/stock_features.py +573 -0
- mcli/ml/features/test_feature_engineering.py +346 -0
- mcli/ml/logging.py +85 -0
- mcli/ml/mlops/data_versioning.py +518 -0
- mcli/ml/mlops/experiment_tracker.py +377 -0
- mcli/ml/mlops/model_serving.py +481 -0
- mcli/ml/mlops/pipeline_orchestrator.py +614 -0
- mcli/ml/models/base_models.py +324 -0
- mcli/ml/models/ensemble_models.py +675 -0
- mcli/ml/models/recommendation_models.py +474 -0
- mcli/ml/models/test_models.py +487 -0
- mcli/ml/monitoring/drift_detection.py +676 -0
- mcli/ml/monitoring/metrics.py +45 -0
- mcli/ml/optimization/portfolio_optimizer.py +834 -0
- mcli/ml/preprocessing/data_cleaners.py +451 -0
- mcli/ml/preprocessing/feature_extractors.py +491 -0
- mcli/ml/preprocessing/ml_pipeline.py +382 -0
- mcli/ml/preprocessing/politician_trading_preprocessor.py +569 -0
- mcli/ml/preprocessing/test_preprocessing.py +294 -0
- mcli/ml/scripts/populate_sample_data.py +200 -0
- mcli/ml/tasks.py +400 -0
- mcli/ml/tests/test_integration.py +429 -0
- mcli/ml/tests/test_training_dashboard.py +387 -0
- mcli/public/oi/oi.py +15 -0
- mcli/public/public.py +4 -0
- mcli/self/self_cmd.py +1246 -0
- mcli/workflow/daemon/api_daemon.py +800 -0
- mcli/workflow/daemon/async_command_database.py +681 -0
- mcli/workflow/daemon/async_process_manager.py +591 -0
- mcli/workflow/daemon/client.py +530 -0
- mcli/workflow/daemon/commands.py +1196 -0
- mcli/workflow/daemon/daemon.py +905 -0
- mcli/workflow/daemon/daemon_api.py +59 -0
- mcli/workflow/daemon/enhanced_daemon.py +571 -0
- mcli/workflow/daemon/process_cli.py +244 -0
- mcli/workflow/daemon/process_manager.py +439 -0
- mcli/workflow/daemon/test_daemon.py +275 -0
- mcli/workflow/dashboard/dashboard_cmd.py +113 -0
- mcli/workflow/docker/docker.py +0 -0
- mcli/workflow/file/file.py +100 -0
- mcli/workflow/gcloud/config.toml +21 -0
- mcli/workflow/gcloud/gcloud.py +58 -0
- mcli/workflow/git_commit/ai_service.py +328 -0
- mcli/workflow/git_commit/commands.py +430 -0
- mcli/workflow/lsh_integration.py +355 -0
- mcli/workflow/model_service/client.py +594 -0
- mcli/workflow/model_service/download_and_run_efficient_models.py +288 -0
- mcli/workflow/model_service/lightweight_embedder.py +397 -0
- mcli/workflow/model_service/lightweight_model_server.py +714 -0
- mcli/workflow/model_service/lightweight_test.py +241 -0
- mcli/workflow/model_service/model_service.py +1955 -0
- mcli/workflow/model_service/ollama_efficient_runner.py +425 -0
- mcli/workflow/model_service/pdf_processor.py +386 -0
- mcli/workflow/model_service/test_efficient_runner.py +234 -0
- mcli/workflow/model_service/test_example.py +315 -0
- mcli/workflow/model_service/test_integration.py +131 -0
- mcli/workflow/model_service/test_new_features.py +149 -0
- mcli/workflow/openai/openai.py +99 -0
- mcli/workflow/politician_trading/commands.py +1790 -0
- mcli/workflow/politician_trading/config.py +134 -0
- mcli/workflow/politician_trading/connectivity.py +490 -0
- mcli/workflow/politician_trading/data_sources.py +395 -0
- mcli/workflow/politician_trading/database.py +410 -0
- mcli/workflow/politician_trading/demo.py +248 -0
- mcli/workflow/politician_trading/models.py +165 -0
- mcli/workflow/politician_trading/monitoring.py +413 -0
- mcli/workflow/politician_trading/scrapers.py +966 -0
- mcli/workflow/politician_trading/scrapers_california.py +412 -0
- mcli/workflow/politician_trading/scrapers_eu.py +377 -0
- mcli/workflow/politician_trading/scrapers_uk.py +350 -0
- mcli/workflow/politician_trading/scrapers_us_states.py +438 -0
- mcli/workflow/politician_trading/supabase_functions.py +354 -0
- mcli/workflow/politician_trading/workflow.py +852 -0
- mcli/workflow/registry/registry.py +180 -0
- mcli/workflow/repo/repo.py +223 -0
- mcli/workflow/scheduler/commands.py +493 -0
- mcli/workflow/scheduler/cron_parser.py +238 -0
- mcli/workflow/scheduler/job.py +182 -0
- mcli/workflow/scheduler/monitor.py +139 -0
- mcli/workflow/scheduler/persistence.py +324 -0
- mcli/workflow/scheduler/scheduler.py +679 -0
- mcli/workflow/sync/sync_cmd.py +437 -0
- mcli/workflow/sync/test_cmd.py +314 -0
- mcli/workflow/videos/videos.py +242 -0
- mcli/workflow/wakatime/wakatime.py +11 -0
- mcli/workflow/workflow.py +37 -0
- mcli_framework-7.0.0.dist-info/METADATA +479 -0
- mcli_framework-7.0.0.dist-info/RECORD +186 -0
- mcli_framework-7.0.0.dist-info/WHEEL +5 -0
- mcli_framework-7.0.0.dist-info/entry_points.txt +7 -0
- mcli_framework-7.0.0.dist-info/licenses/LICENSE +21 -0
- 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
|