From 5c9a0b1e6f82a810da19855691f3357227cf855b Mon Sep 17 00:00:00 2001 From: Eric Sivonxay Date: Tue, 3 Oct 2023 17:51:27 -0700 Subject: [PATCH] Change restart behavior --- src/NanoParticleTools/flows/jobs.py | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/NanoParticleTools/flows/jobs.py b/src/NanoParticleTools/flows/jobs.py index 7c92f74..134b066 100644 --- a/src/NanoParticleTools/flows/jobs.py +++ b/src/NanoParticleTools/flows/jobs.py @@ -176,22 +176,23 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint], 'Existing run found, but some files are missing. ') fresh_start = True - if override or os.path.exists(output_dir) is False or fresh_start: - if os.path.exists(output_dir): - # delete the directory, so we can start from scratch - shutil.rmtree(output_dir) - - # Make the directory - os.mkdir(output_dir) - - npmc_input.generate_initial_state_database( - files['initial_state_db_path'], **_initial_state_db_args) - npmc_input.generate_nano_particle_database(files['np_db_path']) - with open(files['npmc_input'], 'w') as f: - json.dump(npmc_input, f, cls=MontyEncoder) - else: - raise RuntimeError( - 'Existing run found. Override is set to false, terminating') + if fresh_start: + if override or os.path.exists(output_dir) is False: + if os.path.exists(output_dir): + # delete the directory, so we can start from scratch + shutil.rmtree(output_dir) + + # Make the directory + os.mkdir(output_dir) + + npmc_input.generate_initial_state_database( + files['initial_state_db_path'], **_initial_state_db_args) + npmc_input.generate_nano_particle_database(files['np_db_path']) + with open(files['npmc_input'], 'w') as f: + json.dump(npmc_input, f, cls=MontyEncoder) + else: + raise RuntimeError( + 'Existing run found. Override is set to false, terminating') # Initialize the wrapper class to run NPMC npmc_runner = NPMCRunner(