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

Modules: Have component_files_identical check for new optional files in modules #2816

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
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
18 changes: 14 additions & 4 deletions nf_core/synced_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,25 @@ def component_files_identical(self, component_name, base_path, commit, component
self.checkout_branch()
else:
self.checkout(commit)
component_files = ["main.nf", "meta.yml"]
required_files = ["main.nf", "meta.yml"]
optional_files = ["environment.yml", "tests/main.nf.test", "tests/main.nf.test.snap", "tests/tags.yml"]
component_files = required_files + optional_files
files_identical = {file: True for file in component_files}
component_dir = self.get_component_dir(component_name, component_type)
for file in component_files:
component_file = os.path.join(component_dir, file)
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
base_file = os.path.join(base_path, file)
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
if (file in optional_files) and (not os.path.exists(component_file)) and (not os.path.exists(base_file)):
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
log.debug(f'The optional file "{file}" was not present.')
# TO-DO: Not sure we need to log this, but if we do what should the msg be?
# In this case, `files_identical[file]` will remain `True`. Is that what we want?
mashehu marked this conversation as resolved.
Show resolved Hide resolved
continue
try:
files_identical[file] = filecmp.cmp(os.path.join(component_dir, file), os.path.join(base_path, file))
files_identical[file] = filecmp.cmp(component_file, base_file)
mashehu marked this conversation as resolved.
Show resolved Hide resolved
except FileNotFoundError:
log.debug(f"Could not open file: {os.path.join(component_dir, file)}")
continue
errmsg = f"Could not open file: {os.path.join(component_dir, file)}"
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
log.error(errmsg)
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
raise UserWarning(errmsg)
self.checkout_branch()
return files_identical

Expand Down
Loading