Skip to content

Commit

Permalink
fix: do not require cores to be set for non-executing modes (#2646)
Browse files Browse the repository at this point in the history
### Description

<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).
  • Loading branch information
johanneskoester committed Jan 25, 2024
1 parent 02a7cda commit 30cf026
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions snakemake/api.py
Expand Up @@ -582,6 +582,14 @@ def execute_workflow(
updated_files=updated_files,
)

def _no_exec(method):
def _handle_no_exec(self, *args, **kwargs):
self.workflow_api.resource_settings.cores = 1
return method(self, *args, **kwargs)

return _handle_no_exec

@_no_exec
def generate_unit_tests(self, path: Path):
"""Generate unit tests for the workflow.
Expand All @@ -591,10 +599,12 @@ def generate_unit_tests(self, path: Path):
"""
self.workflow_api._workflow.generate_unit_tests(path=path)

@_no_exec
def containerize(self):
"""Containerize the workflow."""
self.workflow_api._workflow.containerize()

@_no_exec
def create_report(
self,
path: Path,
Expand All @@ -612,62 +622,74 @@ def create_report(
stylesheet=stylesheet,
)

@_no_exec
def printdag(self):
"""Print the DAG of the workflow."""
self.workflow_api._workflow.printdag()

@_no_exec
def printrulegraph(self):
"""Print the rule graph of the workflow."""
self.workflow_api._workflow.printrulegraph()

@_no_exec
def printfilegraph(self):
"""Print the file graph of the workflow."""
self.workflow_api._workflow.printfilegraph()

@_no_exec
def printd3dag(self):
"""Print the DAG of the workflow in D3.js compatible JSON."""
self.workflow_api._workflow.printd3dag()

@_no_exec
def unlock(self):
"""Unlock the workflow."""
self.workflow_api._workflow.unlock()

@_no_exec
def cleanup_metadata(self, paths: List[Path]):
"""Cleanup the metadata of the workflow."""
self.workflow_api._workflow.cleanup_metadata(paths)

@_no_exec
def conda_cleanup_envs(self):
"""Cleanup the conda environments of the workflow."""
self.workflow_api.deployment_settings.imply_deployment_method(
DeploymentMethod.CONDA
)
self.workflow_api._workflow.conda_cleanup_envs()

@_no_exec
def conda_create_envs(self):
"""Only create the conda environments of the workflow."""
self.workflow_api.deployment_settings.imply_deployment_method(
DeploymentMethod.CONDA
)
self.workflow_api._workflow.conda_create_envs()

@_no_exec
def conda_list_envs(self):
"""List the conda environments of the workflow."""
self.workflow_api.deployment_settings.imply_deployment_method(
DeploymentMethod.CONDA
)
self.workflow_api._workflow.conda_list_envs()

@_no_exec
def cleanup_shadow(self):
"""Cleanup the shadow directories of the workflow."""
self.workflow_api._workflow.cleanup_shadow()

@_no_exec
def container_cleanup_images(self):
"""Cleanup the container images of the workflow."""
self.workflow_api.deployment_settings.imply_deployment_method(
DeploymentMethod.APPTAINER
)
self.workflow_api._workflow.container_cleanup_images()

@_no_exec
def list_changes(self, change_type: ChangeType):
"""List the changes of the workflow.
Expand All @@ -677,10 +699,12 @@ def list_changes(self, change_type: ChangeType):
"""
self.workflow_api._workflow.list_changes(change_type=change_type)

@_no_exec
def list_untracked(self):
"""List the untracked files of the workflow."""
self.workflow_api._workflow.list_untracked()

@_no_exec
def summary(self, detailed: bool = False):
"""Summarize the workflow.
Expand All @@ -690,6 +714,7 @@ def summary(self, detailed: bool = False):
"""
self.workflow_api._workflow.summary(detailed=detailed)

@_no_exec
def archive(self, path: Path):
"""Archive the workflow.
Expand All @@ -699,6 +724,7 @@ def archive(self, path: Path):
"""
self.workflow_api._workflow.archive(path=path)

@_no_exec
def delete_output(self, only_temp: bool = False, dryrun: bool = False):
"""Delete the output of the workflow.
Expand Down

0 comments on commit 30cf026

Please sign in to comment.