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

fixed extraction of expanded tasks #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
13 changes: 11 additions & 2 deletions rushti.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ def parse_line_arguments(line: str) -> Dict[str, Any]:
def expand_task(
tm1_services: Dict[str, TM1Service],
task: Union[Task, OptimizedTask]) -> List[Union[Task, OptimizedTask]]:

if "*" not in ",".join(task.parameters.keys()):
result = [task]
return result

tm1 = tm1_services[task.instance_name]
list_params = []
result = []
Expand Down Expand Up @@ -330,12 +335,16 @@ def extract_tasks_from_file_type_opt(
tasks[task.id].append(task)

# expand tasks
expanded_tasks = dict()
if expand:
for task_id in tasks:
for task in tasks[task_id]:
for expanded_task in expand_task(tm1_services, task):
tasks[task.id].append(expanded_task)
tasks[task.id].remove(task)
if task.id not in expanded_tasks:
expanded_tasks[task.id] = [expanded_task]
else:
expanded_tasks[task.id].append(expanded_task)
tasks = expanded_tasks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Please add a test case here. This way, we can be 100% sure that the issue is resolved and if someone accidentally breaks it in the future, we will detect it
https://github.com/cubewise-code/rushti/blob/master/tests/tests.py


# Populate the successors attribute
for task_id in tasks:
Expand Down
3 changes: 2 additions & 1 deletion tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def test_extract_lines_from_file_type_opt_happy_case(self):
def test_extract_lines_from_file_type_opt_multi_task_per_id(self):
ordered_tasks = extract_ordered_tasks_and_waits_from_file_type_opt(
5,
r"tests/resources/tasks_opt_multi_task_per_id.txt")
r"tests/resources/tasks_opt_multi_task_per_id.txt",
True)

expected_tasks = [
OptimizedTask("1", "tm1srv01", "}bedrock.server.wait", {"pWaitSec": "1"}, [], True),
Expand Down