Skip to content

Commit 2aa3608

Browse files
committed
added models to create graph_template
1 parent bb58b8c commit 2aa3608

4 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from .base import BaseDatabaseModel
2+
from pydantic import Field
3+
from typing import Optional, List
4+
from ..graph_template_validation_status import GraphTemplateValidationStatus
5+
from ..node_template_model import NodeTemplate
6+
from pymongo import IndexModel
7+
8+
9+
class GraphTemplate(BaseDatabaseModel):
10+
name: str = Field(..., description="Name of the graph")
11+
namespace: str = Field(..., description="Namespace of the graph")
12+
nodes: List[NodeTemplate] = Field(..., description="Nodes of the graph")
13+
validation_status: GraphTemplateValidationStatus = Field(..., description="Validation status of the graph")
14+
validation_errors: Optional[List[str]] = Field(None, description="Validation errors of the graph")
15+
16+
class Settings:
17+
indexes = [
18+
IndexModel(
19+
keys=[("name", 1), ("namespace", 1)],
20+
unique=True,
21+
name="unique_name_namespace"
22+
)
23+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from .node_template_model import NodeTemplate
2+
from pydantic import BaseModel
3+
from typing import List
4+
from datetime import datetime
5+
6+
7+
class UpsertGraphTemplateRequest(BaseModel):
8+
name: str
9+
namespace: str
10+
nodes: List[NodeTemplate]
11+
12+
13+
class UpsertGraphTemplateResponse(BaseModel):
14+
name: str
15+
namespace: str
16+
nodes: List[NodeTemplate]
17+
created_at: datetime
18+
updated_at: datetime
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from enum import Enum
2+
3+
4+
class GraphTemplateValidationStatus(Enum):
5+
VALID = "VALID"
6+
INVALID = "INVALID"
7+
PENDING = "PENDING"
8+
ONGOING = "ONGOING"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from pydantic import Field, BaseModel
2+
from typing import Any, Optional, List
3+
4+
5+
class NodeTemplate(BaseModel):
6+
name: str = Field(..., description="Name of the node")
7+
namespace: str = Field(..., description="Namespace of the node")
8+
indentifier: str = Field(..., description="Indentifier of the node")
9+
inputs: dict[str, Any] = Field(..., description="Inputs of the node")
10+
store: dict[str, Any] = Field(..., description="Upsert data to store object for the node")
11+
next_nodes: Optional[List[str]] = Field(None, description="Next nodes to execute")

0 commit comments

Comments
 (0)