Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(normalizer): check manifest cfg in both config.yml and manifest.yml #52

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions normalizer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand Down Expand Up @@ -455,14 +456,24 @@ def normalize(
py_glob.append(extended_path)
break

# 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 metas configuration is not available, try loading the manifest 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'))

py_glob = list(set(py_glob))

completeness = {
'Dockerfile': dockerfile_path,
'manifest.yml': manifest_path,
'manifest': manifest_cfg,
'config.yml': config_path,
'README.md': readme_path,
'requirements.txt': requirements_path,
Expand All @@ -473,15 +484,15 @@ 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'
)

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(),
Expand Down