Navigation Menu

Skip to content

Commit

Permalink
refactor(hub): change alias to name (#3335)
Browse files Browse the repository at this point in the history
  • Loading branch information
mapleeit committed Sep 3, 2021
1 parent 7415821 commit 40416c2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion jina/hubble/__init__.py
Expand Up @@ -7,7 +7,7 @@ class HubExecutor:
"""Basic Executor Data Class from Hubble"""

uuid: str = None
alias: Optional[str] = None
name: Optional[str] = None
sn: Optional[int] = None
tag: Optional[str] = None
visibility: Optional[bool] = None
Expand Down
16 changes: 9 additions & 7 deletions jina/hubble/hubio.py
Expand Up @@ -254,9 +254,11 @@ def mustache_repl(srcs):
field_table.add_column('Field', style='cyan', no_wrap=True)
field_table.add_column('Description', no_wrap=True)
field_table.add_row('name', 'Human-readable title of the Executor')
field_table.add_row('alias', 'The unique identifier in Jina Hub')
field_table.add_row('description', 'Human-readable description of the Executor')
field_table.add_row('url', 'URL to find more information on the Executor')
field_table.add_row(
'url',
'URL to find more information on the Executor, mostly GitHub Repo URL',
)
field_table.add_row('keywords', 'Keywords that help user find the Executor')

table.add_row('', field_table)
Expand Down Expand Up @@ -441,8 +443,8 @@ def _prettyprint_result(self, console, result):
table.add_column('Key', no_wrap=True)
table.add_column('Value', style='cyan', no_wrap=True)
table.add_row(':key: ID', uuid8)
if 'alias' in image:
table.add_row(':name_badge: Alias', image['alias'])
if 'name' in image:
table.add_row(':name_badge: Name', image['name'])
table.add_row(':lock: Secret', secret)
table.add_row(
'',
Expand All @@ -452,7 +454,7 @@ def _prettyprint_result(self, console, result):
table.add_row(':whale: DockerHub', f'https://hub.docker.com/r/jinahub/{uuid8}/')
console.print(table)

presented_id = image.get('alias', uuid8)
presented_id = image.get('name', uuid8)
usage = (
f'{presented_id}' if visibility == 'public' else f'{presented_id}:{secret}'
)
Expand Down Expand Up @@ -536,7 +538,7 @@ def fetch_meta(
secret: Optional[str] = None,
) -> HubExecutor:
"""Fetch the executor meta info from Jina Hub.
:param name: the UUID/Alias of the executor
:param name: the UUID/Name of the executor
:param tag: the version tag of the executor
:param secret: the access secret of the executor
:return: meta of executor
Expand Down Expand Up @@ -564,7 +566,7 @@ def fetch_meta(

return HubExecutor(
uuid=resp['id'],
alias=resp.get('alias', None),
name=resp.get('name', None),
sn=resp.get('sn', None),
tag=resp['tag'],
visibility=resp['visibility'],
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/hub_usage/test_hub_usage.py
Expand Up @@ -76,7 +76,7 @@ def _mock_fetch(name, tag=None, secret=None):
mock(name=name)
return HubExecutor(
uuid='hello',
alias='alias_dummy',
name='alias_dummy',
tag='v0',
image_name='jinahub/pod.dummy_mwu_encoder',
md5sum=None,
Expand All @@ -101,7 +101,7 @@ def _mock_fetch(name, tag=None, secret=None):
mock(name=name)
return HubExecutor(
uuid='hello',
alias='alias_dummy',
name='alias_dummy',
tag='v0',
image_name='jinahub/pod.dummy_mwu_encoder',
md5sum=None,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/hubble/test_hubapi.py
Expand Up @@ -16,7 +16,7 @@ def executor_zip_file():

@pytest.fixture
def test_executor():
return HubExecutor(uuid='hello', alias=None, sn=0, tag='v0')
return HubExecutor(uuid='hello', name=None, sn=0, tag='v0')


@pytest.mark.parametrize('install_deps', [True, False])
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/hubble/test_hubio.py
Expand Up @@ -65,7 +65,7 @@ def json(self):
return {
'keywords': [],
'id': 'dummy_mwu_encoder',
'alias': 'alias_dummy',
'name': 'alias_dummy',
'tag': 'v0',
'versions': [],
'visibility': 'public',
Expand Down Expand Up @@ -170,7 +170,7 @@ def _mock_get(url, headers=None):
executor = HubIO(args).fetch_meta('dummy_mwu_encoder')

assert executor.uuid == 'dummy_mwu_encoder'
assert executor.alias == 'alias_dummy'
assert executor.name == 'alias_dummy'
assert executor.tag == 'v0'
assert executor.image_name == 'jinahub/pod.dummy_mwu_encoder'
assert executor.md5sum == 'ecbe3fdd9cbe25dbb85abaaf6c54ec4f'
Expand All @@ -197,7 +197,7 @@ def _mock_fetch(name, tag=None, secret=None):
mock(name=name)
return HubExecutor(
uuid='dummy_mwu_encoder',
alias='alias_dummy',
name='alias_dummy',
tag='v0',
image_name='jinahub/pod.dummy_mwu_encoder',
md5sum=None,
Expand Down Expand Up @@ -251,7 +251,7 @@ def _mock_fetch(name, tag=None, secret=None):
else:
return HubExecutor(
uuid='dummy_mwu_encoder',
alias='alias_dummy',
name='alias_dummy',
tag='v0',
image_name='jinahub/pod.dummy_mwu_encoder',
md5sum=None,
Expand Down

0 comments on commit 40416c2

Please sign in to comment.