Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb32 committed Jul 5, 2024
1 parent 7a0180e commit 2bfeb35
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
25 changes: 15 additions & 10 deletions nsrdb/create_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
{
Expand All @@ -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',
Expand All @@ -242,7 +242,7 @@ def main_all_domains(cls, kwargs):
'satellite': 'west',
}
)
cls.create_config_files(kwargs)
cls.main(kwargs)
else:
kwargs.update(
{
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 1 addition & 9 deletions nsrdb/nsrdb.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion nsrdb/utilities/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_nsrdb_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
)
Expand All @@ -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'))
Expand Down

0 comments on commit 2bfeb35

Please sign in to comment.