create dependency_rules
This commit is contained in:
parent
65f1238916
commit
978a37ca30
2 changed files with 9 additions and 4 deletions
|
|
@ -47,13 +47,18 @@ class Coordinator:
|
||||||
env_files.append(EnvFile(env_path=env_path, config=config, env_type=env_type))
|
env_files.append(EnvFile(env_path=env_path, config=config, env_type=env_type))
|
||||||
return env_files
|
return env_files
|
||||||
|
|
||||||
def _get_dependency_rules(self, env_files: list[EnvFile]):
|
def _get_dependency_rules(self, env_files: list[EnvFile]) -> list[DependencyRule]:
|
||||||
|
dependency_rules: list[DependencyRule] = []
|
||||||
for env_file in env_files:
|
for env_file in env_files:
|
||||||
child_runner_class = RUNNER_DICT[env_file.env_type]
|
child_runner_class = RUNNER_DICT[env_file.env_type]
|
||||||
print(child_runner_class.name)
|
print(child_runner_class.name)
|
||||||
for dependency in child_runner_class.dependencies:
|
for dependency in child_runner_class.dependencies:
|
||||||
print("dependency", dependency.name)
|
print("dependency", dependency.name)
|
||||||
|
dependency_rule = DependencyRule(child=child_runner_class.name, dependency=dependency.name)
|
||||||
|
dependency_rules.append(dependency_rule)
|
||||||
|
print(dependency_rules)
|
||||||
exit()
|
exit()
|
||||||
|
return dependency_rules
|
||||||
|
|
||||||
def setup_test(self) -> None:
|
def setup_test(self) -> None:
|
||||||
logger.info("calling setup_test()")
|
logger.info("calling setup_test()")
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ class EnvFile(NamedTuple):
|
||||||
|
|
||||||
class DependencyRule(NamedTuple):
|
class DependencyRule(NamedTuple):
|
||||||
child: str
|
child: str
|
||||||
parent: str
|
dependency: str
|
||||||
|
|
||||||
|
|
||||||
def _is_rule_satisfied(in_list: list, rule: DependencyRule) -> bool:
|
def _is_rule_satisfied(in_list: list, rule: DependencyRule) -> bool:
|
||||||
child_index = in_list.index(rule.child)
|
child_index = in_list.index(rule.child)
|
||||||
parent_index = in_list.index(rule.parent)
|
parent_index = in_list.index(rule.dependency)
|
||||||
return parent_index < child_index
|
return parent_index < child_index
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ def sort_env_files_by_rule(env_list: list, rules: list[DependencyRule]) -> list:
|
||||||
rule_satisfied.append(True)
|
rule_satisfied.append(True)
|
||||||
else:
|
else:
|
||||||
rule_satisfied.append(False)
|
rule_satisfied.append(False)
|
||||||
parent_index = in_list.index(rule.parent)
|
parent_index = in_list.index(rule.dependency)
|
||||||
swap_item_with_previous(in_list, parent_index)
|
swap_item_with_previous(in_list, parent_index)
|
||||||
if all(rule_satisfied):
|
if all(rule_satisfied):
|
||||||
return in_list
|
return in_list
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue