diff --git a/nsrdb/create_configs.py b/nsrdb/create_configs.py index 8ba54753..38d2a024 100755 --- a/nsrdb/create_configs.py +++ b/nsrdb/create_configs.py @@ -5,7 +5,7 @@ @author: gbuster -TODO: Clean up create_config_files, blend_files, aggregate_files +TODO: Clean up main, blend_files, aggregate_files """ import calendar @@ -219,9 +219,9 @@ def main_all_domains(cls, kwargs): 'satellite': 'east', } ) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update({'satellite': 'west'}) - cls.create_config_files(kwargs) + cls.main(kwargs) elif kwargs['year'] == 2018: kwargs.update( { @@ -231,9 +231,9 @@ def main_all_domains(cls, kwargs): 'satellite': 'east', } ) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update({'extent': 'conus', 'freq': '5min'}) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update( { 'spatial': '4km', @@ -242,7 +242,7 @@ def main_all_domains(cls, kwargs): 'satellite': 'west', } ) - cls.create_config_files(kwargs) + cls.main(kwargs) else: kwargs.update( { @@ -252,15 +252,15 @@ def main_all_domains(cls, kwargs): 'satellite': 'east', } ) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update({'satellite': 'west'}) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update( {'extent': 'conus', 'freq': '5min', 'satellite': 'east'} ) - cls.create_config_files(kwargs) + cls.main(kwargs) kwargs.update({'satellite': 'west'}) - cls.create_config_files(kwargs) + cls.main(kwargs) @staticmethod def _update_run_templates(user_input): @@ -369,6 +369,11 @@ def main(cls, kwargs): cls._update_run_templates(user_input) + with open( + os.path.join(user_input['out_dir'], 'run.sh'), mode='w' + ) as f: + f.write('python -m nsrdb.cli pipeline -c config_pipeline.json') + @classmethod def collect_blend(cls, kwargs): """Create blend collect config files. diff --git a/nsrdb/nsrdb.py b/nsrdb/nsrdb.py index 697bf25f..ccf40feb 100755 --- a/nsrdb/nsrdb.py +++ b/nsrdb/nsrdb.py @@ -1,12 +1,4 @@ -# -*- coding: utf-8 -*- -"""Entry point for NSRDB data pipeline execution. - -Created on Thu Apr 25 15:47:53 2019 - -@author: gbuster - -TODO: Clean up create_config_files, blend_files, aggregate_files -""" +"""Entry point for NSRDB data pipeline execution.""" import datetime import json diff --git a/nsrdb/utilities/file_utils.py b/nsrdb/utilities/file_utils.py index 9759a6ac..ea80d18c 100755 --- a/nsrdb/utilities/file_utils.py +++ b/nsrdb/utilities/file_utils.py @@ -34,7 +34,7 @@ def str_replace_dict(string_rep, user_input): """Replace keys in string representation of a dictionary with user input values. This is used to update config templates in - :meth:`NSRDB.create_config_files`""" + :meth:`CreateConfigs.main()`""" for k, v in user_input.items(): if isinstance(v, int): string_rep = string_rep.replace(f'"%{k}%"', str(v)) diff --git a/tests/cli/test_nsrdb_cli.py b/tests/cli/test_nsrdb_cli.py index 4a147416..5ebcb2cf 100755 --- a/tests/cli/test_nsrdb_cli.py +++ b/tests/cli/test_nsrdb_cli.py @@ -167,7 +167,7 @@ def test_cli_create_main_configs(runner): assert os.path.exists(os.path.join(out_dir, 'config_pipeline.json')) assert os.path.exists(os.path.join(out_dir, 'run.sh')) - kwargs = {'year': 2020} + kwargs = {'year': 2020, 'out_dir': td} result = runner.invoke( cli.create_configs, ['-c', kwargs, '--all_domains'] ) @@ -179,8 +179,8 @@ def test_cli_create_main_configs(runner): out_dirs = [ f'{td}/nsrdb_east_conus_2020_2km_5min', f'{td}/nsrdb_west_conus_2020_2km_5min', - f'{td}/nsrdb_east_full_2020_4km_10min', - f'{td}/nsrdb_east_full_2020_4km_10min', + f'{td}/nsrdb_east_full_2020_2km_10min', + f'{td}/nsrdb_west_full_2020_2km_10min', ] for out_dir in out_dirs: assert os.path.exists(os.path.join(out_dir, 'config_nsrdb.json'))