diff --git a/polaris/config.py b/polaris/config.py index 49ad726d9..f176c8790 100644 --- a/polaris/config.py +++ b/polaris/config.py @@ -25,6 +25,8 @@ class PolarisConfigParser(MpasConfigParser): A list of filepaths within the component's work directory where symlinks to ``filepath`` will be created + symlinks : set of polaris.Task + A list of tasks that use this config """ def __init__(self, filepath=None): @@ -40,6 +42,7 @@ def __init__(self, filepath=None): super().__init__() self.filepath: Union[str, None] = filepath self.symlinks = list() + self.tasks = set() def setup(self): """ diff --git a/polaris/setup.py b/polaris/setup.py index 0db8c0395..3d6ed288c 100644 --- a/polaris/setup.py +++ b/polaris/setup.py @@ -370,13 +370,14 @@ def _configure_tasks_and_add_step_configs(tasks, component, initial_configs, Call the configure() method for each task and add configs to "owned" steps """ - for task in tasks.values(): - task.configure() - task.config.set(section=f'{task.name}', - option='steps_to_run', - value=' '.join(task.steps_to_run), - comment=f'A list of steps to include when running the ' - f'{task.name} task') + for config in initial_configs.values(): + for task in config.tasks: + task.configure() + task.config.set(section=f'{task.name}', + option='steps_to_run', + value=' '.join(task.steps_to_run), + comment=f'A list of steps to include when running ' + f'the {task.name} task') # add configs to steps after calling task.configure() on all tasks in case # new steps were added diff --git a/polaris/task.py b/polaris/task.py index 2f2cfdc84..a55c99b70 100644 --- a/polaris/task.py +++ b/polaris/task.py @@ -100,6 +100,7 @@ def __init__(self, component, name, subdir=None, indir=None): self.path = os.path.join(self.component.name, self.subdir) self.config = PolarisConfigParser() self.config_filename = '' + self.config.tasks.add(self) # steps will be added by calling add_step() self.steps = dict() @@ -219,6 +220,7 @@ def set_shared_config(self, config, link=None): self.component.add_config(config) self.config = config + config.tasks.add(self) if link is None: directory, basename = os.path.split(config.filepath) if directory != self.subdir: