Spaces:
Sleeping
Sleeping
update
Browse files- app.py +0 -12
- mcp_mlflow_tools.py +0 -24
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import json
|
| 2 |
import gradio as gr
|
| 3 |
from mcp_mlflow_tools import (
|
| 4 |
-
initialize_tracking,
|
| 5 |
set_tracking_uri,
|
| 6 |
get_system_info,
|
| 7 |
list_experiments,
|
|
@@ -18,17 +17,6 @@ def create_interface():
|
|
| 18 |
gr.Markdown("A service that exposes MLflow functionality through a web interface and API endpoints.")
|
| 19 |
|
| 20 |
with gr.Tab("Tracking & System Info"):
|
| 21 |
-
with gr.Group():
|
| 22 |
-
gr.Markdown("## Initialize Tracking")
|
| 23 |
-
init_output = gr.JSON(label="Initialization Status")
|
| 24 |
-
init_button = gr.Button("Initialize / Check Tracking URI")
|
| 25 |
-
init_button.click(
|
| 26 |
-
fn=initialize_tracking,
|
| 27 |
-
inputs=[],
|
| 28 |
-
outputs=init_output,
|
| 29 |
-
api_name="initialize_tracking"
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
with gr.Group():
|
| 33 |
gr.Markdown("## Set Tracking URI")
|
| 34 |
uri_input = gr.Textbox(label="MLflow Tracking URI")
|
|
|
|
| 1 |
import json
|
| 2 |
import gradio as gr
|
| 3 |
from mcp_mlflow_tools import (
|
|
|
|
| 4 |
set_tracking_uri,
|
| 5 |
get_system_info,
|
| 6 |
list_experiments,
|
|
|
|
| 17 |
gr.Markdown("A service that exposes MLflow functionality through a web interface and API endpoints.")
|
| 18 |
|
| 19 |
with gr.Tab("Tracking & System Info"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
with gr.Group():
|
| 21 |
gr.Markdown("## Set Tracking URI")
|
| 22 |
uri_input = gr.Textbox(label="MLflow Tracking URI")
|
mcp_mlflow_tools.py
CHANGED
|
@@ -8,30 +8,6 @@ from mlflow.tracking import MlflowClient
|
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
-
def initialize_tracking(default_uri: str = "http://127.0.0.1:5000") -> Dict:
|
| 12 |
-
"""
|
| 13 |
-
Checks if the MLflow tracking URI is set to a remote server.
|
| 14 |
-
If not, it sets it to a default and returns a notification message.
|
| 15 |
-
"""
|
| 16 |
-
try:
|
| 17 |
-
current_uri = mlflow.get_tracking_uri()
|
| 18 |
-
# Default local URI is 'file:///.../mlruns'. We check if it's not a remote server.
|
| 19 |
-
if current_uri and (current_uri.startswith("http://") or current_uri.startswith("https://")):
|
| 20 |
-
message = f"MLflow tracking URI is configured to: {current_uri}. You can use the interface below to change it."
|
| 21 |
-
status = "already_set"
|
| 22 |
-
else:
|
| 23 |
-
logger.info(f"Tracking URI is not set to a remote server. Defaulting to {default_uri}")
|
| 24 |
-
mlflow.set_tracking_uri(default_uri)
|
| 25 |
-
message = f"Warning: MLflow tracking URI was not set. It has been automatically set to the default: {default_uri}. You can change this below."
|
| 26 |
-
status = "defaulted"
|
| 27 |
-
|
| 28 |
-
return {"status": status, "message": message, "uri": mlflow.get_tracking_uri()}
|
| 29 |
-
|
| 30 |
-
except Exception as e:
|
| 31 |
-
error_msg = f"Failed during tracking initialization: {str(e)}"
|
| 32 |
-
logger.error(error_msg, exc_info=True)
|
| 33 |
-
return {"error": True, "message": error_msg}
|
| 34 |
-
|
| 35 |
def _format_timestamp(ts: int) -> str:
|
| 36 |
"""Convert MLflow timestamp (milliseconds since epoch) to readable string."""
|
| 37 |
dt = datetime.fromtimestamp(ts / 1000.0)
|
|
|
|
| 8 |
logging.basicConfig(level=logging.INFO)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def _format_timestamp(ts: int) -> str:
|
| 12 |
"""Convert MLflow timestamp (milliseconds since epoch) to readable string."""
|
| 13 |
dt = datetime.fromtimestamp(ts / 1000.0)
|