Commit 004a49c5 authored by Avi Vajpeyi's avatar Avi Vajpeyi 👽
Browse files

add log_directory test

parent d4a469ec
Pipeline #123992 passed with stage
in 7 minutes and 22 seconds
......@@ -1026,7 +1026,14 @@ def write_complete_config_file(parser, args, inputs):
# Verify that the written complete config is identical to the source config
complete_args = parser.parse([inputs.complete_ini_file])
complete_inputs = MainInput(complete_args, "")
ignore_keys = ["known_args", "unknown_args", "_ini", "_webdir", "_prior_dict"]
ignore_keys = [
"known_args",
"unknown_args",
"_ini",
"_webdir",
"_log_directory",
"_prior_dict",
]
differences = []
for key, val in inputs.__dict__.items():
if key in ignore_keys:
......
......@@ -29,16 +29,18 @@ This will produce a directory structure as follows:
my-run.ini
outdir/
-> data/
-> data_analysis_log/
-> data_generation_log/
-> log_data_analysis/
-> log_data_generation/
-> log_results_page/
-> result/
-> results_page_log/
-> results_page/
-> submit/
The first five of these folders will initially be empty, but as the job
The first six of these folders will initially be empty, but as the job
progresses will be populated. The :code:`data` directory will contain all the
data to be analyses while :code:`result` will contain the :code:`*result.json`
result files generated by bilby along with any plots.
result files generated by bilby along with any plots. Note that the location to the
`log` and `results_page` folders can be modified.
The final folder, :code:`submit`, contains all the of the DAG submission
scripts. To submit your job, run :code:`condor_submit_dag` giving as a
......
import glob
import os
import shutil
import unittest
import bilby_pipe
class TestCustomDir(unittest.TestCase):
def setUp(self):
self.init_dir = "tests/initdir"
self.outdir = os.path.join(self.init_dir, "outdir")
self.webdir = os.path.join(self.outdir, "results_page")
self.logdirs = os.path.join(self.outdir, "log_*")
os.makedirs(self.init_dir, exist_ok=True)
self.parser = bilby_pipe.main.create_parser()
self.ini = os.path.join(self.init_dir, "test_custom_dir.ini")
def tearDown(self):
shutil.rmtree(self.init_dir)
def generate_ini(self, extra_lines=[]):
"""Generates an ini file"""
f = open(self.ini, mode="w")
starting_lines = [
"detectors = [H1, L1]",
f"outdir = {self.outdir}",
"accounting = accounting.group",
"submit=True",
"trigger-time=0",
]
lines = starting_lines + extra_lines
for l in lines:
f.write(l + "\n")
f.close()
def test_default_dir_structure(self):
self.generate_ini()
args = self.parser.parse_args([self.ini])
inputs = bilby_pipe.main.MainInput(args, [])
bilby_pipe.main.write_complete_config_file(self.parser, args, inputs)
bilby_pipe.main.generate_dag(inputs)
for d in [self.webdir] + glob.glob(self.logdirs):
self.assertTrue(os.path.isdir(d), f"{d} is not a dir")
def test_custom_dir_structure(self):
new_logdir = os.path.join(self.init_dir, "new_logdir")
new_webdir = os.path.join(self.init_dir, "new_webdir")
self.generate_ini([f"log-directory={new_logdir}", f"webdir={new_webdir}"])
args = self.parser.parse_args([self.ini])
inputs = bilby_pipe.main.MainInput(args, [])
bilby_pipe.main.write_complete_config_file(self.parser, args, inputs)
bilby_pipe.main.generate_dag(inputs)
for d in [new_webdir] + glob.glob(new_logdir + "log_*"):
self.assertTrue(os.path.isdir(d), f"{d} is not a dir")
for d in [self.webdir] + glob.glob(self.logdirs):
self.assertFalse(os.path.isdir(d), f"{d} is a dir")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment