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

Migrate list command to components #1995

Merged
merged 16 commits into from
Nov 4, 2022
Merged

Conversation

mashehu
Copy link
Contributor

@mashehu mashehu commented Nov 3, 2022

What if we used component command classes actually? 👿

@mashehu mashehu requested review from mirpedrol and awgymer November 3, 2022 12:00
Comment on lines +37 to +45
def pattern_msg(keywords):
if len(keywords) == 0:
return ""
if len(keywords) == 1:
return f" matching pattern '{keywords[0]}'"
else:
quoted_keywords = (f"'{key}'" for key in keywords)
return f" matching patterns {', '.join(quoted_keywords)}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm never sure on when it is really necessary to have a method within a method, but this feels like it could (and should) be a standalone method outside the class. I find it particularly confusing that keywords is used in the scope of this internal method whilst being defined in the enclosing method directly above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partially fixed in 7a2fa10

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it with these levels of inheritance :)
I am not sure if this will be possible in all commands as some of them have different functionalities in ModulesCommand or SubworkflowsCommand, but we can try 💪

nf_core/__main__.py Outdated Show resolved Hide resolved
nf_core/__main__.py Outdated Show resolved Hide resolved
nf_core/__main__.py Outdated Show resolved Hide resolved
nf_core/__main__.py Outdated Show resolved Hide resolved
Copy link
Contributor

@awgymer awgymer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add tests/subworkflows/list? I didn't see it in the diff

nf_core/modules/modules_json.py Outdated Show resolved Hide resolved
@awgymer
Copy link
Contributor

awgymer commented Nov 3, 2022

I like it with these levels of inheritance :) I am not sure if this will be possible in all commands as some of them have different functionalities in ModulesCommand or SubworkflowsCommand, but we can try 💪

I just looked and I think after this only check_patch_paths will be a method on ModulesCommand and SubworkflowsCommand just sets component_type='subworkflows' in the init, so we could probably move to drop the Subworkflows/ModulesCommand classes and just use Componet<X>Command subclasses or direct subclassing of ComponentCommand where there is no shared functionality between the particular modules and subworkflows commands.

@codecov
Copy link

codecov bot commented Nov 3, 2022

Codecov Report

Merging #1995 (3f8863e) into dev (7848faa) will increase coverage by 0.87%.
The diff coverage is 54.19%.

@@            Coverage Diff             @@
##              dev    #1995      +/-   ##
==========================================
+ Coverage   62.50%   63.37%   +0.87%     
==========================================
  Files          43       44       +1     
  Lines        4902     5030     +128     
==========================================
+ Hits         3064     3188     +124     
- Misses       1838     1842       +4     
Impacted Files Coverage Δ
nf_core/components/components_command.py 67.92% <4.54%> (-16.60%) ⬇️
nf_core/__main__.py 59.59% <48.27%> (-0.41%) ⬇️
nf_core/components/list.py 69.62% <69.62%> (ø)
nf_core/subworkflows/install.py 85.00% <100.00%> (+62.50%) ⬆️
nf_core/modules/modules_repo.py 81.46% <0.00%> (+1.95%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

nf_core/components/list.py Outdated Show resolved Hide resolved
Co-authored-by: awgymer <24782660+awgymer@users.noreply.github.com>
Co-authored-by: Júlia Mir Pedrol <mirp.julia@gmail.com>
tests/test_subworkflows.py Outdated Show resolved Hide resolved
@mashehu mashehu merged commit d325e69 into nf-core:dev Nov 4, 2022
@mashehu mashehu deleted the migrate-sw-list branch November 4, 2022 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants