Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix steps_to_run for shared config files #134

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading