Skip to content

Commit

Permalink
Merge pull request #2573 from mashehu/make-tests-faster
Browse files Browse the repository at this point in the history
make tests faster
  • Loading branch information
mashehu authored Dec 14, 2023
2 parents e860dc8 + 4110313 commit c025280
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
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

0 comments on commit c025280

Please sign in to comment.