From 3239abc041700eff88daea968f096dbff52679b3 Mon Sep 17 00:00:00 2001 From: "Marcus D. Collins" Date: Wed, 4 Mar 2026 22:02:29 -0800 Subject: [PATCH 1/2] Write out job metadata to a file in the same directory as refined.cif --- src/sampleworks/utils/guidance_script_utils.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/sampleworks/utils/guidance_script_utils.py b/src/sampleworks/utils/guidance_script_utils.py index 1766f5e3..af209bc1 100644 --- a/src/sampleworks/utils/guidance_script_utils.py +++ b/src/sampleworks/utils/guidance_script_utils.py @@ -1,6 +1,7 @@ from __future__ import annotations import argparse +import json import os import pickle import traceback @@ -578,17 +579,12 @@ def run_guidance_job_queue(job_queue_path: str) -> list[JobResult]: job_results = [] for i, job in enumerate(job_queue): logger.info(f"Running job {i + 1}/{len(job_queue)}: {job}") - # TODO: I think it is safe now to re-use the wrapper, it might save us some time. - # The model wrapper can persist state across runs, so we need to re-initialize it each run. - # if job.model_checkpoint is None: - # raise ValueError( - # "Running guidance requires that you specify a model checkpoint, not None" - # ) - # device, model_wrapper = get_model_and_device( - # str(device), job.model_checkpoint, job.model, job.method, model_wrapper.model - # ) job_result = run_guidance(job, job.guidance_type, model_wrapper, device) + # write out the job parameters to a JSON file in the same directory as the refined.cif file + with open(Path(job_result.output_dir) / "job_metadata.json", "w") as fp: + json.dump(job.__dict__, fp) + job_results.append(job_result) torch.cuda.empty_cache() # just in case From d60f807463b217cc07e5e6a16a68423e4bf0778a Mon Sep 17 00:00:00 2001 From: "Marcus D. Collins" Date: Thu, 5 Mar 2026 10:08:53 -0800 Subject: [PATCH 2/2] Make sure output directory exists --- src/sampleworks/utils/guidance_script_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sampleworks/utils/guidance_script_utils.py b/src/sampleworks/utils/guidance_script_utils.py index af209bc1..5fd1aa97 100644 --- a/src/sampleworks/utils/guidance_script_utils.py +++ b/src/sampleworks/utils/guidance_script_utils.py @@ -388,6 +388,9 @@ def run_guidance( log_path = getattr(args, "log_path", None) or os.path.join(args.output_dir, "run.log") os.makedirs(os.path.dirname(log_path) or ".", exist_ok=True) + # just in case log_path does not go to args.output_dir, make sure the latter exists + os.makedirs(args.output_dir, exist_ok=True) + # separate logs for each guidance run handle = logger.add( log_path, level="INFO", filter=lambda rec: rec["extra"].get("special", False) is True