Skip to content

Commit

Permalink
Add ui server support for proxied artifacts and update exception mess…
Browse files Browse the repository at this point in the history
…ages

Signed-off-by: Ben Wilson <benjamin.wilson@databricks.com>
  • Loading branch information
BenWilson2 committed Nov 15, 2021
1 parent 3f0cbb0 commit 05899d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
18 changes: 6 additions & 12 deletions mlflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,13 @@ def _validate_server_args(gunicorn_opts=None, workers=None, waitress_opts=None):
"Note that this flag does not impact already-created experiments. "
"Default: " + DEFAULT_LOCAL_FILE_AND_ARTIFACT_PATH,
)
@cli_args.SERVE_ARTIFACTS
@cli_args.ARTIFACTS_DESTINATION
@cli_args.PORT
@cli_args.HOST
def ui(backend_store_uri, default_artifact_root, artifacts_destination, port, host):
def ui(
backend_store_uri, default_artifact_root, serve_artifacts, artifacts_destination, port, host
):
"""
Launch the MLflow tracking UI for local viewing of run results. To launch a production
server, use the "mlflow server" command instead.
Expand Down Expand Up @@ -281,7 +284,7 @@ def ui(backend_store_uri, default_artifact_root, artifacts_destination, port, ho
_run_server(
backend_store_uri,
default_artifact_root,
False,
serve_artifacts,
False,
artifacts_destination,
host,
Expand Down Expand Up @@ -328,16 +331,7 @@ def _validate_static_prefix(ctx, param, value): # pylint: disable=unused-argume
"Default: Within file store, if a file:/ URI is provided. If a sql backend is"
" used, then this option is required.",
)
@click.option(
"--serve-artifacts",
is_flag=True,
help="If specified, enables serving of artifact uploads, downloads, and list requests "
"by routing these requests to the storage location that is specified by "
"'--artifact-destination' directly through a proxy. The default location that "
"these requests are served from is a local './mlartifacts' directory which can be "
"overridden via the '--artifacts-destination' argument. "
"Default: False",
)
@cli_args.SERVE_ARTIFACTS
@click.option(
"--artifacts-only",
is_flag=True,
Expand Down
6 changes: 3 additions & 3 deletions mlflow/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def wrapper(*args, **kwargs):
if os.environ.get(ARTIFACTS_ONLY_ENV_VAR):
return Response(
(
"Endpoint disabled due to the mlflow server running in `--artifacts-only` "
"mode. To enable tracking server functionality, run `mlflow server` without "
"`--artifacts-only`"
f"Endpoint: {request.url_rule} disabled due to the mlflow server running "
"in `--artifacts-only` mode. To enable tracking server functionality, run "
"`mlflow server` without `--artifacts-only`"
),
503,
)
Expand Down
11 changes: 11 additions & 0 deletions mlflow/utils/cli_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,14 @@
"artifact root location is http or mlflow-artifacts URI."
),
)

SERVE_ARTIFACTS = click.option(
"--serve-artifacts",
is_flag=True,
help="If specified, enables serving of artifact uploads, downloads, and list requests "
"by routing these requests to the storage location that is specified by "
"'--artifact-destination' directly through a proxy. The default location that "
"these requests are served from is a local './mlartifacts' directory which can be "
"overridden via the '--artifacts-destination' argument. "
"Default: False",
)
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ def test_mlflow_tracking_disabled_in_artifacts_only_mode():
_await_server_up_or_die(port, timeout=10)
resp = requests.get(f"http://localhost:{port}/api/2.0/mlflow/experiments/list")
assert (
"Endpoint disabled due to the mlflow server running in `--artifacts-only` mode."
in resp.text
"Endpoint: /api/2.0/mlflow/experiments/list disabled due to the mlflow server running "
"in `--artifacts-only` mode." in resp.text
)
process.kill()

Expand Down

0 comments on commit 05899d9

Please sign in to comment.