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

Handle removed replisomes in superhelical density calculations #269

Merged
merged 8 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fix workflow resumption with suffix_time
  • Loading branch information
thalassemia committed Dec 17, 2024
commit b13ba46120b7ab656aa1527f249869f1cd95920b
3 changes: 2 additions & 1 deletion doc/workflows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ is a list workflow behaviors enabled in our model to handle unexpected errors.
- If you realize that a code issue is the cause of job failure(s), stop
the workflow run if it is not already (e.g. ``control + c``, ``scancel``,
etc.), make the necessary code fixes, and rerun :py:mod:`runscripts.workflow`
with the same configuration JSON and the ``--resume`` command-line argument.
with the same configuration JSON and the ``--resume`` command-line argument,
supplying the experiment ID (with time suffix if using ``suffix_time`` option).
Nextflow will intelligently resume workflow execution from the last successful
job in each chain of job dependencies (e.g. generation 7 of a cell lineage
depends on generation 6, :py:mod:`runscripts.create_variants` depends on
Expand Down
23 changes: 14 additions & 9 deletions runscripts/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,11 @@ def main():
)
parser.add_argument(
"--resume",
action="store_true",
default=False,
help="Resume last run workflow.",
type=str,
default=None,
help="Resume workflow with given experiment ID. The experiment ID must "
"match the supplied configuration file and if suffix_time was used, must "
"contain the full time suffix (suffix_time will not be applied again).",
)
args = parser.parse_args()
with open(config_file, "r") as f:
Expand All @@ -335,11 +337,14 @@ def main():
experiment_id = config["experiment_id"]
if experiment_id is None:
raise RuntimeError("No experiment ID was provided.")
if config["suffix_time"]:
if args.resume is not None:
experiment_id = args.resume
config["experiment_id"] = args.resume
elif config["suffix_time"]:
current_time = datetime.now().strftime("%Y%m%d-%H%M%S")
experiment_id = experiment_id + "_" + current_time
config["experiment_id"] = experiment_id
config["suffix_time"] = False
config["suffix_time"] = False
# Special characters are messy so do not allow them
if experiment_id != parse.quote_plus(experiment_id):
raise TypeError(
Expand Down Expand Up @@ -370,7 +375,7 @@ def main():
final_config_uri = os.path.join(out_uri, "workflow_config.json")
with open(temp_config_path, "w") as f:
json.dump(config, f)
if not args.resume:
if args.resume is None:
copy_to_filesystem(temp_config_path, final_config_path, filesystem)

nf_config = os.path.join(os.path.dirname(__file__), "nextflow", "config.template")
Expand Down Expand Up @@ -471,7 +476,7 @@ def main():
workflow_path = os.path.join(out_uri, "main.nf")

config_path = os.path.join(out_uri, "nextflow.config")
if not args.resume:
if args.resume is None:
copy_to_filesystem(local_workflow, os.path.join(outdir, "main.nf"), filesystem)
copy_to_filesystem(
local_config, os.path.join(outdir, "nextflow.config"), filesystem
Expand All @@ -497,7 +502,7 @@ def main():
report_path,
"-work-dir",
workdir,
"-resume" if args.resume else "",
"-resume" if args.resume is not None else "",
],
check=True,
)
Expand All @@ -511,7 +516,7 @@ def main():
#SBATCH --mem=4GB
#SBATCH --partition=mcovert
nextflow -C {config_path} run {workflow_path} -profile {nf_profile} \
-with-report {report_path} -work-dir {workdir} {"-resume" if args.resume else ""}
-with-report {report_path} -work-dir {workdir} {"-resume" if args.resume is not None else ""}
""")
copy_to_filesystem(
batch_script, os.path.join(outdir, "nextflow_job.sh"), filesystem
Expand Down