Simplify MLflow auth to use native env var support
Reverted to simpler approach - MLflow natively supports MLFLOW_TRACKING_USERNAME and MLFLOW_TRACKING_PASSWORD environment variables for HTTP Basic Auth. Removed the manual URI construction since it's not needed. The workflow already sets these env vars correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a4ddfb57be
commit
22db96b3eb
@ -13,25 +13,15 @@ from sklearn.ensemble import RandomForestClassifier
|
|||||||
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score
|
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
# Configure MLflow with authentication
|
# Configure MLflow
|
||||||
|
# MLflow will automatically use MLFLOW_TRACKING_USERNAME and MLFLOW_TRACKING_PASSWORD env vars
|
||||||
tracking_uri = os.getenv("MLFLOW_TRACKING_URI", "https://mlflow.sortifal.dev")
|
tracking_uri = os.getenv("MLFLOW_TRACKING_URI", "https://mlflow.sortifal.dev")
|
||||||
username = os.getenv("MLFLOW_TRACKING_USERNAME")
|
mlflow.set_tracking_uri(tracking_uri)
|
||||||
password = os.getenv("MLFLOW_TRACKING_PASSWORD")
|
|
||||||
|
|
||||||
# Build authenticated URI if credentials are provided
|
if os.getenv("MLFLOW_TRACKING_USERNAME") and os.getenv("MLFLOW_TRACKING_PASSWORD"):
|
||||||
if username and password:
|
print(f"MLflow configured with authentication for {tracking_uri}")
|
||||||
# Extract protocol and host from URI
|
|
||||||
if tracking_uri.startswith("https://"):
|
|
||||||
auth_uri = f"https://{username}:{password}@{tracking_uri[8:]}"
|
|
||||||
elif tracking_uri.startswith("http://"):
|
|
||||||
auth_uri = f"http://{username}:{password}@{tracking_uri[7:]}"
|
|
||||||
else:
|
|
||||||
auth_uri = tracking_uri
|
|
||||||
mlflow.set_tracking_uri(auth_uri)
|
|
||||||
print(f"MLflow credentials configured for {tracking_uri}")
|
|
||||||
else:
|
else:
|
||||||
mlflow.set_tracking_uri(tracking_uri)
|
print(f"MLflow configured without authentication for {tracking_uri}")
|
||||||
print("MLflow configured without authentication")
|
|
||||||
|
|
||||||
# Try to set experiment, but handle auth errors gracefully
|
# Try to set experiment, but handle auth errors gracefully
|
||||||
USE_MLFLOW = True
|
USE_MLFLOW = True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user