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

make tests faster #2573

Merged
merged 15 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions nf_core/components/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def install(self, component, silent=False):
self.install_included_components(component_dir)

if not silent:
modules_json.load()
modules_json.dump(run_prettier=True)
# Print include statement
component_name = "_".join(component.upper().split("/"))
log.info(f"Use the following statement to include this {self.component_type[:-1]}:")
Expand Down
33 changes: 19 additions & 14 deletions nf_core/components/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,21 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
updated.append(component)
recursive_update = True
modules_to_update, subworkflows_to_update = self.get_components_to_update(component)
if not silent and not self.update_all and len(modules_to_update + subworkflows_to_update) > 0:
log.warning(
f"All modules and subworkflows linked to the updated {self.component_type[:-1]} will be {'asked for update' if self.show_diff else 'automatically updated'}.\n"
"It is advised to keep all your modules and subworkflows up to date.\n"
"It is not guaranteed that a subworkflow will continue working as expected if all modules/subworkflows used in it are not up to date.\n"
)
if self.update_deps:
recursive_update = True
else:
recursive_update = questionary.confirm(
"Would you like to continue updating all modules and subworkflows?",
default=True,
style=nf_core.utils.nfcore_question_style,
).unsafe_ask()
if not silent and len(modules_to_update + subworkflows_to_update) > 0:
if not self.update_all:
log.warning(
f"All modules and subworkflows linked to the updated {self.component_type[:-1]} will be {'asked for update' if self.show_diff else 'automatically updated'}.\n"
"It is advised to keep all your modules and subworkflows up to date.\n"
"It is not guaranteed that a subworkflow will continue working as expected if all modules/subworkflows used in it are not up to date.\n"
)
if self.update_deps:
recursive_update = True
else:
recursive_update = questionary.confirm(
"Would you like to continue updating all modules and subworkflows?",
default=True,
style=nf_core.utils.nfcore_question_style,
).unsafe_ask()
if recursive_update and len(modules_to_update + subworkflows_to_update) > 0:
# Update linked components
self.update_linked_components(modules_to_update, subworkflows_to_update, updated)
Expand All @@ -323,8 +324,12 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
)
elif not all_patches_successful and not silent:
log.info(f"Updates complete. Please apply failed patch{plural_es(components_info)} manually.")
self.modules_json.load()
self.modules_json.dump(run_prettier=True)
elif not silent:
log.info("Updates complete :sparkles:")
self.modules_json.load()
self.modules_json.dump(run_prettier=True)

return exit_value

Expand Down
11 changes: 8 additions & 3 deletions nf_core/modules/modules_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import shutil
import tempfile
from pathlib import Path
from typing import Union

import git
import questionary
Expand Down Expand Up @@ -41,7 +42,7 @@ def __init__(self, pipeline_dir):
self.modules_dir = Path(self.dir, "modules")
self.subworkflows_dir = Path(self.dir, "subworkflows")
self.modules_json_path = Path(self.dir, "modules.json")
self.modules_json = None
self.modules_json: Union(dict, None) = None
self.pipeline_modules = None
self.pipeline_subworkflows = None
self.pipeline_components = None
Expand Down Expand Up @@ -1035,13 +1036,17 @@ def get_component_branch(self, component_type, component, repo_url, install_dir)
)
return branch

def dump(self):
def dump(self, run_prettier: bool = False):
"""
Sort the modules.json, and write it to file
"""
# Sort the modules.json
self.modules_json["repos"] = nf_core.utils.sort_dictionary(self.modules_json["repos"])
dump_json_with_prettier(self.modules_json_path, self.modules_json)
if run_prettier:
dump_json_with_prettier(self.modules_json_path, self.modules_json)
else:
with open(self.modules_json_path, "w") as fh:
json.dump(self.modules_json, fh, indent=4)

def resolve_missing_installation(self, missing_installation, component_type):
missing_but_in_mod_json = [
Expand Down
Loading