Skip to content

Commit

Permalink
[Config] Support configuring hub url without template (#1349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedingber committed Sep 24, 2021
1 parent 536ecd4 commit 53c3f49
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mlrun/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,16 @@ def get_build_args():

return build_args

@staticmethod
def get_hub_url():
if not config.hub_url.endswith("function.yaml"):
if config.hub_url.startswith("http"):
return f"{config.hub_url}/{{tag}}/{{name}}/function.yaml"
elif config.hub_url.startswith("v3io"):
return f"{config.hub_url}/{{name}}/function.yaml"

return config.hub_url

@staticmethod
def get_default_function_node_selector():
default_function_node_selector = {}
Expand Down
19 changes: 19 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ def test_iguazio_api_url_resolution():
assert mlconf.config.iguazio_api_url == url


def test_get_hub_url():
# full path configured - no edits
mlconf.config.hub_url = (
"https://raw.githubusercontent.com/mlrun/functions/{tag}/{name}/function.yaml"
)
assert mlconf.config.get_hub_url() == mlconf.config.hub_url
# partial path configured + http - edit with tag
mlconf.config.hub_url = "https://raw.githubusercontent.com/some-fork/functions"
assert (
mlconf.config.get_hub_url()
== f"{mlconf.config.hub_url}/{{tag}}/{{name}}/function.yaml"
)
# partial path configured + http - edit without tag
mlconf.config.hub_url = "v3io://users/admin/mlrun/function-hub"
assert (
mlconf.config.get_hub_url() == f"{mlconf.config.hub_url}/{{name}}/function.yaml"
)


def test_setting_dbpath_trigger_connect(requests_mock: requests_mock_package.Mocker):
api_url = "http://mlrun-api-url:8080"
remote_host = "some-namespace"
Expand Down

0 comments on commit 53c3f49

Please sign in to comment.