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

fix(executor): override default resources to remove mem/disk (#91) #91

Merged
merged 1 commit into from
Mar 22, 2024
Merged
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
30 changes: 19 additions & 11 deletions reana_workflow_engine_snakemake/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from snakemake.common import async_lock
from snakemake.executors import ClusterExecutor, GenericClusterExecutor
from snakemake.jobs import Job
from snakemake.resources import DefaultResources

Check warning on line 24 in reana_workflow_engine_snakemake/executor.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_snakemake/executor.py#L24

Added line #L24 was not covered by tests
from snakemake import scheduler # for monkeypatch

from reana_workflow_engine_snakemake.config import (
Expand Down Expand Up @@ -250,15 +251,26 @@
operational_options={},
):
"""Run Snakemake jobs using custom REANA executor."""
workflow_file_path = os.path.join(workflow_workspace, workflow_file)
common_snakemake_args = dict(

Check warning on line 255 in reana_workflow_engine_snakemake/executor.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_snakemake/executor.py#L254-L255

Added lines #L254 - L255 were not covered by tests
snakefile=workflow_file_path,
config=workflow_parameters,
workdir=workflow_workspace,
keep_logger=True,
# Since Snakemake v7.3.0, the workflow logs include Snakemake-percieved native
# resource information on memory and storage (`mem_mb`, `disk_mb`) for each
# Snakemake rule run on cloud. However, REANA overrides these when running
# user jobs, so we should hide these in order not to present any misleading
# information to users. For this reason, the default resources are overridden
# here with the only the "bare" ones (`tmpdir`).
default_resources=DefaultResources(mode="bare"),
)

def _generate_report(workflow_file_path):
def _generate_report():

Check warning on line 269 in reana_workflow_engine_snakemake/executor.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_snakemake/executor.py#L269

Added line #L269 was not covered by tests
"""Generate HTML report."""
success = snakemake(
workflow_file_path,
config=workflow_parameters,
workdir=workflow_workspace,
**common_snakemake_args,
report=operational_options.get("report", DEFAULT_SNAKEMAKE_REPORT_FILENAME),
keep_logger=True,
)
if not success:
log.error("Error generating workflow HTML report.")
Expand All @@ -269,21 +281,17 @@
# Monkeypatch GenericClusterExecutor class in `scheduler` module
scheduler.GenericClusterExecutor = REANAClusterExecutor

workflow_file_path = os.path.join(workflow_workspace, workflow_file)
success = snakemake(
workflow_file_path,
**common_snakemake_args,
printshellcmds=True,
# FIXME: Can be anything as it's not directly used. It's supposed
# to be the shell command to submit to job e.g. `condor_q`,
# but we call RJC API client instead.
cluster="reana",
config=workflow_parameters,
workdir=workflow_workspace,
notemp=True,
nodes=SNAKEMAKE_MAX_PARALLEL_JOBS, # enables DAG parallelization
keep_logger=True,
)
# Once the workflow is finished, generate the report,
# taking into account the metadata generated.
_generate_report(workflow_file_path)
_generate_report()

Check warning on line 296 in reana_workflow_engine_snakemake/executor.py

View check run for this annotation

Codecov / codecov/patch

reana_workflow_engine_snakemake/executor.py#L296

Added line #L296 was not covered by tests
return success
Loading