Loading astrort/configure/slurmjobs.py +5 −3 Original line number Diff line number Diff line Loading @@ -11,14 +11,16 @@ from os import system from os.path import join, dirname, abspath def make_configuration(jobname_conf, configuration, node_number): # simulator configuration['simulator']['seed'] = node_number*configuration['simulator']['samples'] + 1 # logging configuration['logging']['logfile'] = join(configuration['simulator']['output'], f'job_{node_number+1}.log') configuration['logging']['datfile'] = join(configuration['simulator']['output'], f'job_{node_number+1}.dat') # write new configuration with open(jobname_conf, 'w+') as f: dump(configuration, f, default_flow_style=False) def make_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): def make_simulator_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): # write sbatch with open(jobname_sh, 'w+') as f: f.write("#!/bin/bash") Loading @@ -34,12 +36,12 @@ def make_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): f.write(f"\nsource activate {slurmconf['environment']}") f.write(f"\npython {join(dirname(abspath(__file__)).replace('configure', 'simulator'), 'base_simulator.py')} -f {jobname_conf}\n") def make_sbatch(jobname, configuration, node_number): def make_simulator_sbatch(jobname, configuration, node_number): output = configuration['simulator']['output'] jobname_sh = join(output, f"{jobname}.sh") jobname_log = join(output, f"{jobname}.slurm") jobname_conf = join(output, f"{jobname}.yml") make_configuration(jobname_conf, configuration, node_number) make_sh(jobname, configuration['slurm'], jobname_conf, jobname_sh, jobname_log) make_simulator_sh(jobname, configuration['slurm'], jobname_conf, jobname_sh, jobname_log) system(f"sbatch {jobname_sh}") No newline at end of file astrort/simulator/base_simulator.py +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from os.path import join from rtasci.lib.RTACtoolsSimulation import RTACtoolsSimulation from astrort.utils.wrap import load_yaml_conf, configure_simulator_no_visibility, write_simulation_info, set_pointing from astrort.configure.logging import set_logger, get_log_level from astrort.configure.slurmjobs import make_sbatch from astrort.configure.slurmjobs import make_simulator_sbatch def base_simulator(configuration_file): clock = time() Loading Loading @@ -57,7 +57,7 @@ def slurm_submission(configuration_file, nodes): configuration['slurm']['nodes'] = nodes for node_number in range(configuration['slurm']['nodes']): jobname = f"{configuration['slurm']['name']}_{node_number+1}" make_sbatch(jobname, configuration, node_number) make_simulator_sbatch(jobname, configuration, node_number) return def main(configuration, nodes): Loading astrort/testing/test_configure/test_slurmjobs.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ import pytest from shutil import rmtree from os import listdir, makedirs from os.path import isfile, join from astrort.configure.slurmjobs import make_configuration, make_sh, make_sbatch from astrort.configure.slurmjobs import make_configuration, make_simulator_sh, make_simulator_sbatch from astrort.utils.wrap import load_yaml_conf @pytest.mark.test_conf_file Loading @@ -34,7 +34,7 @@ def test_make_configuration(test_conf_file): assert found_configurations == expected_configurations, f"Expected {expected_configurations} simulations, found {found_configurations}" @pytest.mark.test_conf_file def test_make_sh(test_conf_file): def test_make_simulator_sh(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) Loading @@ -49,7 +49,7 @@ def test_make_sh(test_conf_file): jobname_sh = join(output, f"job_{jobname}.sh") jobname_log = join(output, f"job_{jobname}.log") jobname_conf = join(output, f"job_{jobname}.yml") make_sh(jobname, conf['slurm'], jobname_conf, jobname_sh, jobname_log) make_simulator_sh(jobname, conf['slurm'], jobname_conf, jobname_sh, jobname_log) # check output expected_sh = conf['slurm']['nodes'] Loading Loading
astrort/configure/slurmjobs.py +5 −3 Original line number Diff line number Diff line Loading @@ -11,14 +11,16 @@ from os import system from os.path import join, dirname, abspath def make_configuration(jobname_conf, configuration, node_number): # simulator configuration['simulator']['seed'] = node_number*configuration['simulator']['samples'] + 1 # logging configuration['logging']['logfile'] = join(configuration['simulator']['output'], f'job_{node_number+1}.log') configuration['logging']['datfile'] = join(configuration['simulator']['output'], f'job_{node_number+1}.dat') # write new configuration with open(jobname_conf, 'w+') as f: dump(configuration, f, default_flow_style=False) def make_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): def make_simulator_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): # write sbatch with open(jobname_sh, 'w+') as f: f.write("#!/bin/bash") Loading @@ -34,12 +36,12 @@ def make_sh(jobname, slurmconf, jobname_conf, jobname_sh, jobname_log): f.write(f"\nsource activate {slurmconf['environment']}") f.write(f"\npython {join(dirname(abspath(__file__)).replace('configure', 'simulator'), 'base_simulator.py')} -f {jobname_conf}\n") def make_sbatch(jobname, configuration, node_number): def make_simulator_sbatch(jobname, configuration, node_number): output = configuration['simulator']['output'] jobname_sh = join(output, f"{jobname}.sh") jobname_log = join(output, f"{jobname}.slurm") jobname_conf = join(output, f"{jobname}.yml") make_configuration(jobname_conf, configuration, node_number) make_sh(jobname, configuration['slurm'], jobname_conf, jobname_sh, jobname_log) make_simulator_sh(jobname, configuration['slurm'], jobname_conf, jobname_sh, jobname_log) system(f"sbatch {jobname_sh}") No newline at end of file
astrort/simulator/base_simulator.py +2 −2 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ from os.path import join from rtasci.lib.RTACtoolsSimulation import RTACtoolsSimulation from astrort.utils.wrap import load_yaml_conf, configure_simulator_no_visibility, write_simulation_info, set_pointing from astrort.configure.logging import set_logger, get_log_level from astrort.configure.slurmjobs import make_sbatch from astrort.configure.slurmjobs import make_simulator_sbatch def base_simulator(configuration_file): clock = time() Loading Loading @@ -57,7 +57,7 @@ def slurm_submission(configuration_file, nodes): configuration['slurm']['nodes'] = nodes for node_number in range(configuration['slurm']['nodes']): jobname = f"{configuration['slurm']['name']}_{node_number+1}" make_sbatch(jobname, configuration, node_number) make_simulator_sbatch(jobname, configuration, node_number) return def main(configuration, nodes): Loading
astrort/testing/test_configure/test_slurmjobs.py +3 −3 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ import pytest from shutil import rmtree from os import listdir, makedirs from os.path import isfile, join from astrort.configure.slurmjobs import make_configuration, make_sh, make_sbatch from astrort.configure.slurmjobs import make_configuration, make_simulator_sh, make_simulator_sbatch from astrort.utils.wrap import load_yaml_conf @pytest.mark.test_conf_file Loading @@ -34,7 +34,7 @@ def test_make_configuration(test_conf_file): assert found_configurations == expected_configurations, f"Expected {expected_configurations} simulations, found {found_configurations}" @pytest.mark.test_conf_file def test_make_sh(test_conf_file): def test_make_simulator_sh(test_conf_file): # clean output conf = load_yaml_conf(test_conf_file) Loading @@ -49,7 +49,7 @@ def test_make_sh(test_conf_file): jobname_sh = join(output, f"job_{jobname}.sh") jobname_log = join(output, f"job_{jobname}.log") jobname_conf = join(output, f"job_{jobname}.yml") make_sh(jobname, conf['slurm'], jobname_conf, jobname_sh, jobname_log) make_simulator_sh(jobname, conf['slurm'], jobname_conf, jobname_sh, jobname_log) # check output expected_sh = conf['slurm']['nodes'] Loading