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
Show file tree
Hide file tree
Changes from 3 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
9 changes: 6 additions & 3 deletions nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,9 @@ def get_patch_fn(self, module_name, repo_url, install_dir):
)
return Path(path) if path is not None else None

def try_apply_patch_reverse(self, module, repo_name, patch_relpath, module_dir):
def try_apply_patch_reverse(
self, module: str, repo_name: str, patch_relpath: Union[Path, str], module_dir: Union[Path, str]
) -> Path:
"""
Try reverse applying a patch file to the modified module files

Expand All @@ -823,11 +825,12 @@ def try_apply_patch_reverse(self, module, repo_name, patch_relpath, module_dir):
except LookupError as e:
raise LookupError(f"Failed to apply patch in reverse for module '{module_fullname}' due to: {e}")

# Write the patched files to a temporary directory
log.debug("Writing patched files to tmpdir")
# Write the patched files and rest of the files to a temporary directory
log.info("Writing patched files to tmpdir")
asp8200 marked this conversation as resolved.
Show resolved Hide resolved
temp_dir = Path(tempfile.mkdtemp())
temp_module_dir = temp_dir / module
temp_module_dir.mkdir(parents=True, exist_ok=True)

for file, new_content in new_files.items():
fn = temp_module_dir / file
with open(fn, "w") as fh:
Expand Down
12 changes: 5 additions & 7 deletions nf_core/synced_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,14 @@ def component_files_identical(self, component_name, base_path, commit, component
self.checkout_branch()
else:
self.checkout(commit)
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 = {}
component_dir = self.get_component_dir(component_name, component_type)
component_files = [file.relative_to(component_dir) for file in Path(component_dir).rglob("*") if file.is_file()]
for file in component_files:
component_file = Path(component_dir, file)
base_file = Path(base_path, file)
if (file in optional_files) and (not component_file.exists()) and (not base_file.exists()):
log.debug(f'The optional file "{file}" was not present.')
component_file = component_dir / file
base_file = base_path / file
if not base_file.exists():
files_identical[file] = False
continue
try:
files_identical[file] = filecmp.cmp(component_file, base_file)
mashehu marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading