Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 45
Fixes #206#209
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Fixes #206 #209
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d729cda
added code to check for dependency and fan-in
NiveditJain 854ab02
removed redefination of state
NiveditJain c4a0b5c
fixed comments by @gemni
NiveditJain 5b08c6c
fixed comments
NiveditJain 4bef305
fixed ruff
NiveditJain 3887cf9
depends -> unites
NiveditJain 0c131ce
verify_unites
NiveditJain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -6,9 +6,13 @@ | ||
| from app.models.graph_template_validation_status import GraphTemplateValidationStatus | ||
| from app.models.db.registered_node import RegisteredNode | ||
| from app.models.state_status_enum import StateStatusEnum | ||
| from beanie.operators import NE | ||
| from app.singletons.logs_manager import LogsManager | ||
| from json_schema_to_pydantic import create_model | ||
NiveditJain marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| logger = LogsManager().get_logger() | ||
| async def create_next_state(state: State): | ||
| graph_template = None | ||
| @@ -50,6 +54,32 @@ async def create_next_state(state: State): | ||
| if not next_node_template: | ||
| continue | ||
| depends_satisfied = True | ||
| if next_node_template.unites is not None and len(next_node_template.unites) > 0: | ||
| pending_count = 0 | ||
| for depend in next_node_template.unites: | ||
| if depend.identifier == state.identifier: | ||
| continue | ||
| else: | ||
| root_parent = state.parents.get(depend.identifier) | ||
| if root_parent is None: | ||
| raise Exception(f"Root parent of {depend.identifier} not found") | ||
| pending_count = await State.find( | ||
| State.identifier == depend.identifier, | ||
| State.namespace_name == state.namespace_name, | ||
| State.graph_name == state.graph_name, | ||
| NE(State.status, StateStatusEnum.SUCCESS), | ||
| {f"parents.{depend.identifier}": parents[depend.identifier]} | ||
| ).count() | ||
| if pending_count > 0: | ||
| logger.info(f"Node {next_node_template.identifier} depends on {depend.identifier} but it is not satisfied") | ||
| depends_satisfied = False | ||
| break | ||
| if not depends_satisfied: | ||
| continue | ||
NiveditJain marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| registered_node = await RegisteredNode.find_one(RegisteredNode.name == next_node_template.node_name, RegisteredNode.namespace == next_node_template.namespace) | ||
| if not registered_node: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -219,6 +219,18 @@ def dfs_visit(current_node: str, parent_node: str | None = None, current_path: l | ||
| return dependency_graph | ||
| async def verify_unites(graph_nodes: list[NodeTemplate], dependency_graph: dict | None, errors: list[str]): | ||
| if dependency_graph is None: | ||
| return | ||
| for node in graph_nodes: | ||
| if node.unites is None or len(node.unites) == 0: | ||
| continue | ||
| for depend in node.unites: | ||
| if depend.identifier not in dependency_graph[node.identifier]: | ||
| errors.append(f"Node {node.identifier} depends on {depend.identifier} which is not a dependency of {node.identifier}") | ||
NiveditJain marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| async def verify_graph(graph_template: GraphTemplate): | ||
| try: | ||
| errors = [] | ||
| @@ -229,16 +241,19 @@ async def verify_graph(graph_template: GraphTemplate): | ||
| await verify_node_exists(graph_template.nodes, database_nodes, errors) | ||
| await verify_node_identifiers(graph_template.nodes, errors) | ||
| await verify_secrets(graph_template, database_nodes, errors) | ||
| dependency_graph = await verify_topology(graph_template.nodes, errors) | ||
| dependency_graph = await verify_topology(graph_template.nodes, errors) | ||
| if dependency_graph is not None and len(errors) == 0: | ||
| await verify_inputs(graph_template.nodes, database_nodes, dependency_graph, errors) | ||
| await verify_unites(graph_template.nodes, dependency_graph, errors) | ||
| if errors or dependency_graph is None: | ||
| graph_template.validation_status = GraphTemplateValidationStatus.INVALID | ||
| graph_template.validation_errors = errors | ||
| await graph_template.save() | ||
| return | ||
| graph_template.validation_status = GraphTemplateValidationStatus.VALID | ||
| graph_template.validation_errors = None | ||
| await graph_template.save() | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.