Commit 4a0a8bd8 authored by Baber's avatar Baber
Browse files

fix

parent c40a012a
...@@ -567,23 +567,27 @@ class TaskManager: ...@@ -567,23 +567,27 @@ class TaskManager:
and self.task_index[name]["type"] == "python_task" and self.task_index[name]["type"] == "python_task"
) )
def _config_is_task(self, config: dict) -> bool: @staticmethod
def _config_is_task(config: dict) -> bool:
"""Check if a config dictionary defines a single task.""" """Check if a config dictionary defines a single task."""
return "task" in config and isinstance(config["task"], str) return "task" in config and isinstance(config["task"], str)
def _config_is_group(self, config: dict) -> bool: @staticmethod
def _config_is_group(config: dict) -> bool:
"""Check if a config dictionary defines a group of tasks.""" """Check if a config dictionary defines a group of tasks."""
return "task" in config and isinstance(config["task"], list) return "task" in config and isinstance(config["task"], list)
def _config_is_python_task(self, config: dict) -> bool: @staticmethod
def _config_is_python_task(config: dict) -> bool:
"""Check if a config dictionary defines a Python class-based task.""" """Check if a config dictionary defines a Python class-based task."""
return "class" in config return "class" in config
def _config_is_task_list(self, config: dict) -> bool: @staticmethod
def _config_is_task_list(config: dict) -> bool:
"""Check if a config dictionary defines a task list.""" """Check if a config dictionary defines a task list."""
return "task_list" in config and isinstance(config["task_list"], list) return "task_list" in config and isinstance(config["task_list"], list)
def _get_yaml_path(self, name: str) -> Union[str, int]: def _get_yaml_path(self, name: str) -> Union[str, int, list[str]]:
""" """
Get the YAML file path for a registered task. Get the YAML file path for a registered task.
...@@ -645,7 +649,7 @@ class TaskManager: ...@@ -645,7 +649,7 @@ class TaskManager:
yaml_path: str, yaml_path: str,
tasks_and_groups: dict[str, dict], tasks_and_groups: dict[str, dict],
config: Optional[dict] = None, config: Optional[dict] = None,
populate_tags_fn: Optional[callable] = None, populate_tags_fn: Optional[Callable] = None,
) -> None: ) -> None:
"""Helper method to register a task in the tasks_and_groups dict""" """Helper method to register a task in the tasks_and_groups dict"""
tasks_and_groups[task_name] = { tasks_and_groups[task_name] = {
...@@ -779,11 +783,12 @@ class TaskManager: ...@@ -779,11 +783,12 @@ class TaskManager:
grp = GroupConfig(**cfg) grp = GroupConfig(**cfg)
subtasks: list[Union[str, dict]] = [] subtasks: list[Union[str, dict]] = []
for t in grp.task: if grp.task:
if isinstance(t, str) and self._name_is_tag(t): for t in grp.task:
subtasks.extend(self._get_tasklist(t)) if isinstance(t, str) and self._name_is_tag(t):
else: subtasks.extend(self._get_tasklist(t))
subtasks.append(t) else:
subtasks.append(t)
return grp, subtasks return grp, subtasks
def _load_subtasks( def _load_subtasks(
......
...@@ -173,18 +173,18 @@ class TestWalkthroughConfigs: ...@@ -173,18 +173,18 @@ class TestWalkthroughConfigs:
# Test config detection methods # Test config detection methods
assert self.tm._config_is_task(configs[0]) assert self.tm._config_is_task(configs[0])
assert not self.tm._config_is_group(configs[0]) assert not self.tm._config_is_group()
assert not self.tm._config_is_task_list(configs[0]) assert not self.tm._config_is_task_list(configs[0])
assert not self.tm._config_is_task(configs[1]) assert not self.tm._config_is_task(configs[1])
assert self.tm._config_is_group(configs[1]) assert self.tm._config_is_group()
assert not self.tm._config_is_task_list(configs[1]) assert not self.tm._config_is_task_list(configs[1])
# Test task_list detection with actual config # Test task_list detection with actual config
task_list_config = {"task_list": [{"task": "task1"}, {"task": "task2"}]} task_list_config = {"task_list": [{"task": "task1"}, {"task": "task2"}]}
assert self.tm._config_is_task_list(task_list_config) assert self.tm._config_is_task_list(task_list_config)
assert not self.tm._config_is_task(task_list_config) assert not self.tm._config_is_task(task_list_config)
assert not self.tm._config_is_group(task_list_config) assert not self.tm._config_is_group()
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment