def test_mlflow_server_command(command): port = get_safe_port() cmd = ["mlflow", command, "--port", str(port)] process = subprocess.Popen(cmd) try: _await_server_up_or_die(port, timeout=10) resp = requests.get(f"http://localhost:{port}/health") augmented_raise_for_status(resp) assert resp.text == "OK" finally: process.kill()
def test_mlflow_tracking_disabled_in_artifacts_only_mode(): port = get_safe_port() cmd = ["mlflow", "server", "--port", str(port), "--artifacts-only"] process = subprocess.Popen(cmd) _await_server_up_or_die(port, timeout=10) resp = requests.get( f"http://localhost:{port}/api/2.0/mlflow/experiments/list") assert ( "Endpoint: /api/2.0/mlflow/experiments/list disabled due to the mlflow server running " "in `--artifacts-only` mode." in resp.text) process.kill()
def test_mlflow_artifact_list_in_artifacts_only_mode(): port = get_safe_port() cmd = ["mlflow", "server", "--port", str(port), "--artifacts-only", "--serve-artifacts"] process = subprocess.Popen(cmd) try: _await_server_up_or_die(port, timeout=10) resp = requests.get(f"http://localhost:{port}/api/2.0/mlflow-artifacts/artifacts") augmented_raise_for_status(resp) assert resp.status_code == 200 assert resp.text == "{}" finally: process.kill()
def test_mlflow_artifact_service_unavailable_without_config(): port = get_safe_port() cmd = ["mlflow", "server", "--port", str(port)] process = subprocess.Popen(cmd) try: _await_server_up_or_die(port, timeout=10) endpoint = "/api/2.0/mlflow-artifacts/artifacts" resp = requests.get(f"http://localhost:{port}{endpoint}") assert ( f"Endpoint: {endpoint} disabled due to the mlflow server running without " "`--serve-artifacts`" in resp.text) finally: process.kill()
def _launch_server(host, port, backend_store_uri, default_artifact_root, artifacts_destination): extra_cmd = [] if is_windows() else [ "--gunicorn-opts", "--log-level debug" ] cmd = [ "mlflow", "server", "--host", host, "--port", str(port), "--backend-store-uri", backend_store_uri, "--serve-artifacts", "--default-artifact-root", default_artifact_root, "--artifacts-destination", artifacts_destination, *extra_cmd, ] process = subprocess.Popen(cmd) _await_server_up_or_die(port) return process