style: apply ruff format to all files
This commit is contained in:
@@ -22,41 +22,24 @@ class MLflowConfig:
|
||||
|
||||
# Tracking server URIs
|
||||
tracking_uri: str = field(
|
||||
default_factory=lambda: os.environ.get(
|
||||
"MLFLOW_TRACKING_URI",
|
||||
"http://mlflow.mlflow.svc.cluster.local:80"
|
||||
)
|
||||
default_factory=lambda: os.environ.get("MLFLOW_TRACKING_URI", "http://mlflow.mlflow.svc.cluster.local:80")
|
||||
)
|
||||
external_uri: str = field(
|
||||
default_factory=lambda: os.environ.get(
|
||||
"MLFLOW_EXTERNAL_URI",
|
||||
"https://mlflow.lab.daviestechlabs.io"
|
||||
)
|
||||
default_factory=lambda: os.environ.get("MLFLOW_EXTERNAL_URI", "https://mlflow.lab.daviestechlabs.io")
|
||||
)
|
||||
|
||||
# Artifact storage (NFS PVC mount)
|
||||
artifact_location: str = field(
|
||||
default_factory=lambda: os.environ.get(
|
||||
"MLFLOW_ARTIFACT_LOCATION",
|
||||
"/mlflow/artifacts"
|
||||
)
|
||||
default_factory=lambda: os.environ.get("MLFLOW_ARTIFACT_LOCATION", "/mlflow/artifacts")
|
||||
)
|
||||
|
||||
# Default experiment settings
|
||||
default_experiment: str = field(
|
||||
default_factory=lambda: os.environ.get(
|
||||
"MLFLOW_DEFAULT_EXPERIMENT",
|
||||
"llm-workflows"
|
||||
)
|
||||
default_factory=lambda: os.environ.get("MLFLOW_DEFAULT_EXPERIMENT", "llm-workflows")
|
||||
)
|
||||
|
||||
# Service identification
|
||||
service_name: str = field(
|
||||
default_factory=lambda: os.environ.get(
|
||||
"OTEL_SERVICE_NAME",
|
||||
"unknown-service"
|
||||
)
|
||||
)
|
||||
service_name: str = field(default_factory=lambda: os.environ.get("OTEL_SERVICE_NAME", "unknown-service"))
|
||||
|
||||
# Additional tags to add to all runs
|
||||
default_tags: Dict[str, str] = field(default_factory=dict)
|
||||
@@ -85,10 +68,7 @@ def get_tracking_uri(external: bool = False) -> str:
|
||||
return config.external_uri if external else config.tracking_uri
|
||||
|
||||
|
||||
def get_mlflow_client(
|
||||
tracking_uri: Optional[str] = None,
|
||||
configure_global: bool = True
|
||||
) -> MlflowClient:
|
||||
def get_mlflow_client(tracking_uri: Optional[str] = None, configure_global: bool = True) -> MlflowClient:
|
||||
"""
|
||||
Get a configured MLflow client.
|
||||
|
||||
@@ -110,9 +90,7 @@ def get_mlflow_client(
|
||||
|
||||
|
||||
def ensure_experiment(
|
||||
experiment_name: str,
|
||||
artifact_location: Optional[str] = None,
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
experiment_name: str, artifact_location: Optional[str] = None, tags: Optional[Dict[str, str]] = None
|
||||
) -> str:
|
||||
"""
|
||||
Ensure an experiment exists, creating it if necessary.
|
||||
@@ -134,11 +112,7 @@ def ensure_experiment(
|
||||
if experiment is None:
|
||||
# Create the experiment
|
||||
artifact_loc = artifact_location or f"{config.artifact_location}/{experiment_name}"
|
||||
experiment_id = client.create_experiment(
|
||||
name=experiment_name,
|
||||
artifact_location=artifact_loc,
|
||||
tags=tags or {}
|
||||
)
|
||||
experiment_id = client.create_experiment(name=experiment_name, artifact_location=artifact_loc, tags=tags or {})
|
||||
logger.info(f"Created experiment '{experiment_name}' with ID: {experiment_id}")
|
||||
else:
|
||||
experiment_id = experiment.experiment_id
|
||||
@@ -148,9 +122,7 @@ def ensure_experiment(
|
||||
|
||||
|
||||
def get_or_create_registered_model(
|
||||
model_name: str,
|
||||
description: Optional[str] = None,
|
||||
tags: Optional[Dict[str, str]] = None
|
||||
model_name: str, description: Optional[str] = None, tags: Optional[Dict[str, str]] = None
|
||||
) -> str:
|
||||
"""
|
||||
Get or create a registered model in the Model Registry.
|
||||
@@ -172,9 +144,7 @@ def get_or_create_registered_model(
|
||||
except mlflow.exceptions.MlflowException:
|
||||
# Create the model
|
||||
client.create_registered_model(
|
||||
name=model_name,
|
||||
description=description or f"Model for {model_name}",
|
||||
tags=tags or {}
|
||||
name=model_name, description=description or f"Model for {model_name}", tags=tags or {}
|
||||
)
|
||||
logger.info(f"Created registered model: {model_name}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user