Skip to content

Commit

Permalink
Simplify get_task_names
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Sep 19, 2024
1 parent 599beeb commit eaa1049
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
12 changes: 6 additions & 6 deletions workflow/applications/applications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

from typing import Dict, List, Tuple, Any
from typing import Dict, List, Any
from datetime import timedelta
from hosts import Host
from wxflow import Configuration, to_timedelta
Expand Down Expand Up @@ -100,8 +100,9 @@ def _init_finalize(self, conf: Configuration):
# Get a list of all possible config files that would be part of the application
self.configs_names = self._get_app_configs()

# Get task names, configs, and APPs for the application
self.runs, self.task_names = self.get_task_names()
# Get task names and runs for the application
self.task_names = self.get_task_names()
self.runs = list(self.task_names.keys())

# Initialize the configs and model_apps dictionaries
self.model_apps = dict.fromkeys(self.runs)
Expand All @@ -111,7 +112,6 @@ def _init_finalize(self, conf: Configuration):
for run in self.runs:

self.configs[run] = self._source_configs(conf, run=run, log=False)

self.model_apps[run] = self.configs[run]['base'].get('APP', 'ATM')

# Update the base config dictionary based on application and RUN
Expand Down Expand Up @@ -179,7 +179,7 @@ def _source_configs(self, conf: Configuration, run: str = "gfs", log: bool = Tru
return configs

@abstractmethod
def get_task_names(self, run: str) -> Tuple[List[str], Dict[str, List[str]]]:
def get_task_names(self, run: str) -> Dict[str, List[str]]:
'''
Create a list of valid RUNs and a dict of task names for each RUN valid for the configuation.
Expand All @@ -189,7 +189,7 @@ def get_task_names(self, run: str) -> Tuple[List[str], Dict[str, List[str]]]:
Returns
-------
Tuple[List[str], Dict[str, List[str]]]: List of valid runs and lists of all tasks for each RUN.
Dict[str, List[str]]: Lists of all tasks for each RUN.
'''
pass
Expand Down
2 changes: 1 addition & 1 deletion workflow/applications/gefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ def get_task_names(self):

tasks += ['arch', 'cleanup']

return [self.run], {f"{self.run}": tasks}
return {f"{self.run}": tasks}
9 changes: 2 additions & 7 deletions workflow/applications/gfs_cycled.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,11 @@ def _update_base(base_in):

def get_task_names(self):
"""
Get the task names in this cycled configuration and all of the valid runs.
Get the task names for each valid run in this cycled configuration.
Note that the order of the task names matters in the XML.
This is the place where that order is set.
"""

runs = ["gdas"]

gdas_gfs_common_tasks_before_fcst = ['prep']
gdas_gfs_common_cleanup_tasks = ['arch', 'cleanup']

Expand Down Expand Up @@ -295,23 +293,20 @@ def get_task_names(self):
tasks['gdas'] = gdas_tasks

if self.do_hybvar and 'gdas' in self.eupd_runs:
runs.append("enkfgdas")
enkfgdas_tasks = hybrid_tasks + hybrid_after_eupd_tasks
tasks['enkfgdas'] = enkfgdas_tasks

# Add RUN=gfs tasks if running early cycle
if self.gfs_cyc > 0:
runs.append("gfs")
tasks['gfs'] = gfs_tasks

if self.do_hybvar and 'gfs' in self.eupd_runs:
runs.append("enkfgfs")
enkfgfs_tasks = hybrid_tasks + hybrid_after_eupd_tasks
enkfgfs_tasks.remove("echgres")
enkfgfs_tasks.remove("esnowrecen")
tasks['enkfgfs'] = enkfgfs_tasks

return runs, tasks
return tasks

@staticmethod
def get_gfs_cyc_dates(base: Dict[str, Any]) -> Dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion workflow/applications/gfs_forecast_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ def get_task_names(self):

tasks += ['arch', 'cleanup'] # arch and cleanup **must** be the last tasks

return [self.run], {f"{self.run}": tasks}
return {f"{self.run}": tasks}

0 comments on commit eaa1049

Please sign in to comment.