diff --git a/CLAUDE.md b/CLAUDE.md index 47dc3e3d8..c31706425 120000 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1 +1 @@ -AGENTS.md \ No newline at end of file +AGENTS.md diff --git a/kubeflow/hub/api/model_registry_client.py b/kubeflow/hub/api/model_registry_client.py index 33e5399ef..76afacce0 100644 --- a/kubeflow/hub/api/model_registry_client.py +++ b/kubeflow/hub/api/model_registry_client.py @@ -16,6 +16,7 @@ from collections.abc import Iterator, Mapping from typing import TYPE_CHECKING +from urllib.parse import urlsplit from kubeflow.hub.types.types import StorageConfig @@ -83,12 +84,13 @@ def __init__( "model-registry is not installed. Install it with:\n\n" # fmt: skip " pip install 'kubeflow[hub]'\n" ) from e + parsed_url = urlsplit(base_url if "://" in base_url else f"https://{base_url}") + is_http = parsed_url.scheme == "http" - is_http = base_url.startswith("http://") if is_secure is None: is_secure = not is_http if port is None: - port = 8080 if is_http else 443 + port = parsed_url.port or (8080 if is_http else 443) self._registry = ModelRegistry( server_address=base_url, diff --git a/kubeflow/hub/api/model_registry_client_test.py b/kubeflow/hub/api/model_registry_client_test.py index bc9cb6ce1..dfe15695f 100644 --- a/kubeflow/hub/api/model_registry_client_test.py +++ b/kubeflow/hub/api/model_registry_client_test.py @@ -147,7 +147,7 @@ def mock_import(name, *args, **kwargs): }, expected_output={ "server_address": "https://example.org:456", - "port": 443, + "port": 456, "author": "test", "is_secure": True, "user_token": None, @@ -163,7 +163,7 @@ def mock_import(name, *args, **kwargs): }, expected_output={ "server_address": "http://example.org:456", - "port": 8080, + "port": 456, "author": "test", "is_secure": False, "user_token": None,