From 3a01cbd545556a9c6ad3032eb9b7077dde7c3f6c Mon Sep 17 00:00:00 2001 From: Andrei Ungureanu <15995496+Andrei997@users.noreply.github.com> Date: Mon, 29 Aug 2022 13:11:27 +0800 Subject: [PATCH 1/2] refactor(normalizer): check manifest cfg in both config.yml and manifest.yml --- normalizer/core.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/normalizer/core.py b/normalizer/core.py index 7377bb9..bbf4d52 100644 --- a/normalizer/core.py +++ b/normalizer/core.py @@ -405,6 +405,7 @@ def normalize( ) dockerfile_path = work_path / 'Dockerfile' + manifest_cfg = None manifest_path = work_path / 'manifest.yml' config_path = work_path / 'config.yml' readme_path = work_path / 'README.md' @@ -424,7 +425,7 @@ def normalize( if class_name is None: raise Exception('Not found jtype in config.yml') - metas_py_modules = config.get('metas', {}).get('py_modules', None); + metas_py_modules = config.get('metas', {}).get('py_modules', None) root_py_modules = config.get('py_modules', None) if metas_py_modules and root_py_modules: @@ -455,6 +456,14 @@ def normalize( py_glob.append(extended_path) break + # checking if manifest configuration is available in config + if 'manifest' in config: + manifest_cfg = config_path + + # if manifest configuration is not available, try loading from file + if manifest_cfg is None and manifest_path.exists(): + manifest_cfg = manifest_path + else: py_glob = list(work_path.glob('*.py')) + list(work_path.glob('executor/*.py')) @@ -462,7 +471,7 @@ def normalize( completeness = { 'Dockerfile': dockerfile_path, - 'manifest.yml': manifest_path, + 'manifest': manifest_cfg, 'config.yml': config_path, 'README.md': readme_path, 'requirements.txt': requirements_path, @@ -473,7 +482,7 @@ def normalize( logger.info( f'=> checking executor repository ...\n' + '\n'.join( - f'\t{colored("✓", "green") if (v if isinstance(v, list) else v.exists()) else colored("✗", "red"):>4} {k:<20} {v}' + f'\t{colored("✓", "green") if (None if v is None else v if isinstance(v, list) else v.exists()) else colored("✗", "red"):>4} {k:<20} {v}' for k, v in completeness.items() ) + '\n' @@ -481,7 +490,7 @@ def normalize( hubble_score_metrics = { 'dockerfile_exists': dockerfile_path.exists(), - 'manifest_exists': manifest_path.exists(), + 'manifest_exists': manifest_cfg is not None, 'config_exists': config_path.exists(), 'readme_exists': readme_path.exists(), 'requirements_exists': requirements_path.exists(), From 4b2f6d0f3ee38ce6a8e6109c19c30ef9e557a127 Mon Sep 17 00:00:00 2001 From: Andrei Ungureanu <15995496+Andrei997@users.noreply.github.com> Date: Wed, 31 Aug 2022 11:29:41 +0800 Subject: [PATCH 2/2] refactor(normalizer): check manifest cfg in metas field under config.yml --- normalizer/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/normalizer/core.py b/normalizer/core.py index bbf4d52..60356c2 100644 --- a/normalizer/core.py +++ b/normalizer/core.py @@ -456,11 +456,13 @@ def normalize( py_glob.append(extended_path) break - # checking if manifest configuration is available in config - if 'manifest' in config: - manifest_cfg = config_path + # checking if metas configuration is available in config + if 'metas' in config: + metas_keys = config['metas'] + if 'name' in metas_keys: + manifest_cfg = config_path - # if manifest configuration is not available, try loading from file + # if metas configuration is not available, try loading the manifest file if manifest_cfg is None and manifest_path.exists(): manifest_cfg = manifest_path