from mlflow.server.prometheus_exporter import activate_prometheus_exporter prometheus_metrics_path = os.getenv(PROMETHEUS_EXPORTER_ENV_VAR) if not os.path.exists(prometheus_metrics_path): os.makedirs(prometheus_metrics_path) activate_prometheus_exporter(app) # Provide a health check endpoint to ensure the application is responsive @app.route("/health") def health(): return "OK", 200 # Serve the "get-artifact" route. @app.route(_add_static_prefix("/get-artifact")) def serve_artifacts(): return get_artifact_handler() # Serve the "model-versions/get-artifact" route. @app.route(_add_static_prefix("/model-versions/get-artifact")) def serve_model_version_artifact(): return get_model_version_artifact_handler() # We expect the react app to be built assuming it is hosted at /static-files, so that requests for # CSS/JS resources will be made to e.g. /static-files/main.css and we can handle them here. @app.route(_add_static_prefix("/static-files/<path:path>")) def serve_static_file(path): return send_from_directory(STATIC_DIR, path)
if os.getenv(PROMETHEUS_EXPORTER_ENV_VAR): from mlflow.server.prometheus_exporter import activate_prometheus_exporter prometheus_metrics_path = os.getenv(PROMETHEUS_EXPORTER_ENV_VAR) if not os.path.exists(prometheus_metrics_path): os.makedirs(prometheus_metrics_path) activate_prometheus_exporter(app) # Provide a health check endpoint to ensure the application is responsive @app.route("/health") def health(): return "OK", 200 # Serve the "get-artifact" route. @app.route(_add_static_prefix('/get-artifact')) def serve_artifacts(): return get_artifact_handler() # Serve the "model-versions/get-artifact" route. @app.route(_add_static_prefix('/model-versions/get-artifact')) def serve_model_version_artifact(): return get_model_version_artifact_handler() # We expect the react app to be built assuming it is hosted at /static-files, so that requests for # CSS/JS resources will be made to e.g. /static-files/main.css and we can handle them here. @app.route(_add_static_prefix('/static-files/<path:path>')) def serve_static_file(path): return send_from_directory(STATIC_DIR, path)