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

Log error when multiple remotes have the same org name #2228

Merged
merged 19 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Add the Nextflow version to Gitpod container matching the minimal Nextflow version for nf-core (according to `nextflow.config`) ([#2196](https://github.com/nf-core/tools/pull/2196))
- Use `nfcore/gitpod:dev` container in the dev branch ([#2196](https://github.com/nf-core/tools/pull/2196))
- Replace requests_mock with responses in test mocks ([#2165](https://github.com/nf-core/tools/pull/2165)).
- Add warning when installing a module from an `org_path` that exists in multiple remotes in `modules.json` ([#2228](https://github.com/nf-core/tools/pull/2228)).

## [v2.7.2 - Mercury Eagle Patch](https://github.com/nf-core/tools/releases/tag/2.7.2) - [2022-12-19]

Expand Down
25 changes: 25 additions & 0 deletions nf_core/components/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def install(self, component, silent=False):
if not silent:
modules_json.check_up_to_date()

# Verify that the remote repo's org_path does not match the org_path of any alternate repo among the installed modules
self.check_alternate_remotes(modules_json)
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved

# Verify SHA
if not self.modules_repo.verify_sha(self.prompt, self.sha):
return False
Expand Down Expand Up @@ -264,3 +267,25 @@ def clean_modules_json(self, component, modules_repo, modules_json):
self.component_type, component, repo_to_remove, modules_repo.repo_path
)
return component_values["installed_by"]

def check_alternate_remotes(self, modules_json):
"""
Check whether there are previously installed components with the same org_path but different remote urls
Log warning if multiple remotes exist.

Return:
True: if problematic components are found
False: if problematic components are not found
"""
alternate_remotes = False
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved
modules_json.load()
for repo_url, repo_content in modules_json.modules_json.get("repos", dict()).items():
for dir in repo_content.get(self.component_type, dict()).keys():
if dir == self.org and repo_url != self.modules_repo.remote_url:
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved
alternate_remotes = True
if alternate_remotes:
warn_msg = f"Multiple module remotes are used with the same org_path '{self.org}': {', '.join(alternate_remotes)}. This may result in reinstalled modules from the wrong remote."
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved
log.warning(warn_msg)
return True
else:
return False
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved