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 8 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
21 changes: 21 additions & 0 deletions nf_core/components/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ 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
if self.check_alternate_remotes(modules_json):
err_msg = f"You are trying to install {self.component_type} from different repositories with the same organization name '{self.org}' (set in the `.nf-core.yml` file in the `org_path` field).\nThis is not supported, and will likely cause problems. org_path should be set to the github account/organization name."
anoronh4 marked this conversation as resolved.
Show resolved Hide resolved
log.err(err_msg)
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 +269,19 @@ 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 error if multiple remotes exist.

Return:
True: if problematic components are found
False: if problematic components are not found
"""
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
return True
return False