nf-core / nf-core/tools

ToDo: Refactor SyncedRepo class and its subclasses ModulesRepo and WorkflowRepo

Open
#2,940 1 comment 0 reactions 1 assignee View on GitHub

@MatthiasZepper is already working on this.

Since Mar 24, 2025.

enhancement infrastructure modules subworkflows
Dominant language
Python
Stars
322
Forks
255
Avg merge
2d 3h
Merged PRs (30d)
5

Description

This issue is a reminder that somebody (maybe at the Boston Hackathon?) should look into the three classes and check for unnecessary code duplications?

At the moment, we have two use cases of locally cached Git repositories that are cloned/updated/synced when needed:

  1. The Module repository for the nf-core modules and nf-core subworkflows functionalities.
  2. Workflow repositories if pipelines are downloaded with nf-core download as --platform downloads.

Conceptually, the idea was that most static and utility functions needed could be shared by the two and thus two subclasses ModulesRepo and WorkflowRepo were defined that inherit from their SyncedRepo superclass.

Because both subclasses define their own __init__() functions, it for example went entirely unnoticed that the __init__() function of the SyncedRepo calls self.setup_local_repo(), which is only defined for the subclasses.

Also, the SyncedRepo instances don't have a self.repo attribute, but several associated class methods use it nonetheless. This has not caused noticeable bugs yet, because the superclass is never initiated itself, but only the subclasses, which have a self.setup_local_repo() method that creates the self.repo attribute on the subclass instances.

Apart from making mypy unhappy when touching the old code and trying to commit, this is evidently far from ideal.

Hence, I think it would be good to look into those three classes. The bare minimum would be to sort out the __init__() function of the SyncedRepo class and the missing self.repo attribute, but likely this is only the tip of the iceberg.

So it would likely be required to comprehensively assess how many common and distinct methods each subclass has and either consolidate them better in the superclass or strip the superclass down in favor of the subclasses.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.