From 40416c219cc3eece0fae9be391a4cb003a75edff Mon Sep 17 00:00:00 2001 From: Zhaofeng Miao <522856232@qq.com> Date: Fri, 3 Sep 2021 14:17:59 +0800 Subject: [PATCH] refactor(hub): change alias to name (#3335) --- jina/hubble/__init__.py | 2 +- jina/hubble/hubio.py | 16 +++++++++------- tests/integration/hub_usage/test_hub_usage.py | 4 ++-- tests/unit/hubble/test_hubapi.py | 2 +- tests/unit/hubble/test_hubio.py | 8 ++++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/jina/hubble/__init__.py b/jina/hubble/__init__.py index 19e42940b0eb5..2b79e326afa5a 100644 --- a/jina/hubble/__init__.py +++ b/jina/hubble/__init__.py @@ -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 diff --git a/jina/hubble/hubio.py b/jina/hubble/hubio.py index b6038f4e88414..237496b3480f4 100644 --- a/jina/hubble/hubio.py +++ b/jina/hubble/hubio.py @@ -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) @@ -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( '', @@ -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}' ) @@ -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 @@ -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'], diff --git a/tests/integration/hub_usage/test_hub_usage.py b/tests/integration/hub_usage/test_hub_usage.py index 37c7b6d816926..c37bb76c210d1 100644 --- a/tests/integration/hub_usage/test_hub_usage.py +++ b/tests/integration/hub_usage/test_hub_usage.py @@ -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, @@ -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, diff --git a/tests/unit/hubble/test_hubapi.py b/tests/unit/hubble/test_hubapi.py index fca71a5194a6d..f45ac8bc22f92 100644 --- a/tests/unit/hubble/test_hubapi.py +++ b/tests/unit/hubble/test_hubapi.py @@ -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]) diff --git a/tests/unit/hubble/test_hubio.py b/tests/unit/hubble/test_hubio.py index fc3143c4b55a4..9c24d860de460 100644 --- a/tests/unit/hubble/test_hubio.py +++ b/tests/unit/hubble/test_hubio.py @@ -65,7 +65,7 @@ def json(self): return { 'keywords': [], 'id': 'dummy_mwu_encoder', - 'alias': 'alias_dummy', + 'name': 'alias_dummy', 'tag': 'v0', 'versions': [], 'visibility': 'public', @@ -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' @@ -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, @@ -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,