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

Move create_cov over to submit_batch #121

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions data_files/create_cov/covmat.INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG:
BATCH_INFO: sbatch $SBATCH_TEMPLATES/SBATCH_Midway2b.TEMPLATE n

INPUT_COVMAT_FILE:

BBC_OUTDIR:

COVMATOPT:

OUTDIR:

#END_YAML
24 changes: 16 additions & 8 deletions pippin/cosmofitters/wfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
from pippin.task import Task

class WFit(ConfigBasedExecutable, CosmoFit):
def __init__(self, name, output_dir, create_cov_tasks, config, options, global_config):
def __init__(self, name, output_dir, create_cov_tasks, config, options, global_config, submit_batch_mode):
# First check if all required options exist
# In this case, WFITOPTS must exist with at least 1 entry
self.submit_batch = submit_batch_mode

self.wfitopts = options.get("WFITOPTS")
if self.wfitopts is None:
Expand All @@ -28,9 +29,15 @@ def __init__(self, name, output_dir, create_cov_tasks, config, options, global_c
self.num_jobs = len(self.wfitopts)

self.create_cov_tasks = create_cov_tasks
self.logger.debug("CreateCov tasks: {self.create_cov_tasks}")
self.create_cov_dirs = [os.path.join(t.output_dir, "output") for t in self.create_cov_tasks]
self.logger.debug("CreateCov directories: {self.create_cov_dirs}")
self.logger.debug(f"CreateCov tasks: {self.create_cov_tasks}")
if self.submit_batch:
self.create_cov_dirs = []
for t in self.create_cov_tasks:
for cov_dir in t.cov_dir:
self.create_cov_dirs.append(os.path.join(t.output_dir, "output", cov_dir))
else:
self.create_cov_dirs = [os.path.join(t.output_dir, "output") for t in self.create_cov_tasks]
self.logger.debug(f"CreateCov directories: {self.create_cov_dirs}")
self.options = options
self.global_config = global_config
self.done_file = os.path.join(self.output_dir, "output", "ALL.DONE")
Expand Down Expand Up @@ -85,13 +92,14 @@ def _run(self):

else:
self.should_be_done()
self.logger.info("Has check passed, not rerunning")
self.logger.info("Hash check passed, not rerunning")
return True

@staticmethod
def get_tasks(c, prior_tasks, base_output_dir, stage_number, prefix, global_config):

create_cov_tasks = Task.get_task_of_type(prior_tasks, CreateCov)
submit_batch_mode = False not in [t.submit_batch for t in create_cov_tasks]
Task.logger.debug(f"wfit submit_batch_mode: {submit_batch_mode}")

def _get_wfit_dir(base_output_dir, stage_number, name):
return f"{base_output_dir}/{stage_number}_COSMOFIT/WFIT/{name}"
Expand All @@ -107,8 +115,8 @@ def _get_wfit_dir(base_output_dir, stage_number, name):

ctasks = [ctask for ctask in create_cov_tasks if mask in ctask.name]

t = WFit(name, _get_wfit_dir(base_output_dir, stage_number, name), ctasks, config, options, global_config)
Task.logger.info(f"Creating WFit task {name} {t.num_jobs} jobs")
t = WFit(name, _get_wfit_dir(base_output_dir, stage_number, name), ctasks, config, options, global_config, submit_batch_mode)
Task.logger.info(f"Creating WFit task {name} with {t.num_jobs} jobs")
tasks.append(t)

if len(create_cov_tasks) == 0:
Expand Down
Loading