Skip to content

Commit

Permalink
Merge pull request #134 from xylar/fix-steps-to-run-shared-config
Browse files Browse the repository at this point in the history
Fix `steps_to_run` for shared config files
  • Loading branch information
xylar authored Oct 16, 2023
2 parents 7bffbf4 + 2c6adfd commit d1db9b5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions polaris/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
"""
Expand Down
15 changes: 8 additions & 7 deletions polaris/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions polaris/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d1db9b5

Please sign in to comment.