Skip to content

Commit

Permalink
major addition of obj factories for MGraph models and domains, and MG…
Browse files Browse the repository at this point in the history
…raph_Json schemas, models and domains
  • Loading branch information
DinisCruz committed Jan 21, 2025
1 parent 348456a commit 1c28eca
Show file tree
Hide file tree
Showing 13 changed files with 986 additions and 5 deletions.
41 changes: 41 additions & 0 deletions mgraph_ai/mgraph/actions/MGraph__Obj_Factory__Domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from mgraph_ai.mgraph.domain.Domain__MGraph__Edge import Domain__MGraph__Edge
from mgraph_ai.mgraph.domain.Domain__MGraph__Graph import Domain__MGraph__Graph
from mgraph_ai.mgraph.domain.Domain__MGraph__Node import Domain__MGraph__Node
from mgraph_ai.mgraph.domain.Domain__MGraph__Types import Domain__MGraph__Types
from mgraph_ai.mgraph.actions.MGraph__Obj_Factory__Models import MGraph__Obj_Factory__Models
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Obj_Factory__Domain(Type_Safe):
models_factory: MGraph__Obj_Factory__Models

def __init__(self):
super().__init__()
self.models_factory = MGraph__Obj_Factory__Models()

def create__Domain__MGraph__Types(self):
types = object.__new__(Domain__MGraph__Types)
types_dict = dict(node_domain_type = Domain__MGraph__Node,
edge_domain_type = Domain__MGraph__Edge)
object.__setattr__(types, '__dict__', types_dict)
return types

def create__Domain__MGraph__Node(self):
node = object.__new__(Domain__MGraph__Node)
node_dict = dict(node = self.models_factory.create__Model__MGraph__Node(),
graph = self.models_factory.create__Model__MGraph__Graph())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Domain__MGraph__Edge(self):
edge = object.__new__(Domain__MGraph__Edge)
edge_dict = dict(edge = self.models_factory.create__Model__MGraph__Edge(),
graph = self.models_factory.create__Model__MGraph__Graph())
object.__setattr__(edge, '__dict__', edge_dict)
return edge

def create__Domain__MGraph__Graph(self):
graph = object.__new__(Domain__MGraph__Graph)
graph_dict = dict(domain_types = self.create__Domain__MGraph__Types(),
model = self.models_factory.create__Model__MGraph__Graph())
object.__setattr__(graph, '__dict__', graph_dict)
return graph
39 changes: 39 additions & 0 deletions mgraph_ai/mgraph/actions/MGraph__Obj_Factory__Models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from mgraph_ai.mgraph.actions.MGraph__Obj_Factory__Schemas import MGraph__Obj_Factory__Schemas
from mgraph_ai.mgraph.models.Model__MGraph__Edge import Model__MGraph__Edge
from mgraph_ai.mgraph.models.Model__MGraph__Graph import Model__MGraph__Graph
from mgraph_ai.mgraph.models.Model__MGraph__Node import Model__MGraph__Node
from mgraph_ai.mgraph.models.Model__MGraph__Types import Model__MGraph__Types
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Obj_Factory__Models(Type_Safe):
schema_factory: MGraph__Obj_Factory__Schemas

def __init__(self):
super().__init__()
self.schema_factory = MGraph__Obj_Factory__Schemas()

def create__Model__MGraph__Types(self):
types = object.__new__(Model__MGraph__Types)
types_dict = dict(node_model_type = Model__MGraph__Node,
edge_model_type = Model__MGraph__Edge)
object.__setattr__(types, '__dict__', types_dict)
return types

def create__Model__MGraph__Node(self):
node = object.__new__(Model__MGraph__Node)
node_dict = dict(data = self.schema_factory.create__Schema__MGraph__Node())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Model__MGraph__Edge(self):
edge = object.__new__(Model__MGraph__Edge)
edge_dict = dict(data = self.schema_factory.create__Schema__MGraph__Edge())
object.__setattr__(edge, '__dict__', edge_dict)
return edge

def create__Model__MGraph__Graph(self):
graph = object.__new__(Model__MGraph__Graph)
graph_dict = dict(data = self.schema_factory.create__Schema__MGraph__Graph(),
model_types = self.create__Model__MGraph__Types())
object.__setattr__(graph, '__dict__', graph_dict)
return graph
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from mgraph_ai.mgraph.schemas.Schema__MGraph__Types import Schema__MGraph__Types
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Obj_Factory(Type_Safe):
class MGraph__Obj_Factory__Schemas(Type_Safe):

def create__Schema__MGraph__Node__Data(self):
node_data = object.__new__(Schema__MGraph__Node__Data)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Edge import Domain__MGraph__Json__Edge
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Graph import Domain__MGraph__Json__Graph
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Node import Domain__MGraph__Json__Node
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Node__Dict import Domain__MGraph__Json__Node__Dict
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Node__List import Domain__MGraph__Json__Node__List
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Node__Property import Domain__MGraph__Json__Node__Property
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Node__Value import Domain__MGraph__Json__Node__Value
from mgraph_ai.providers.json.domain.Domain__MGraph__Json__Types import Domain__MGraph__Json__Types
from mgraph_ai.providers.json.actions.MGraph__Json__Obj_Factory__Models import MGraph__Json__Obj_Factory__Models
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Json__Obj_Factory__Domain(Type_Safe):
json_models_factory: MGraph__Json__Obj_Factory__Models

def __init__(self):
super().__init__()
self.json_models_factory = MGraph__Json__Obj_Factory__Models()

def create__Domain__MGraph__Json__Types(self):
types = object.__new__(Domain__MGraph__Json__Types)
types_dict = dict(node_domain_type = Domain__MGraph__Json__Node,
edge_domain_type = Domain__MGraph__Json__Edge)
object.__setattr__(types, '__dict__', types_dict)
return types

def create__Domain__MGraph__Json__Node__Value(self):
node = object.__new__(Domain__MGraph__Json__Node__Value)
node_dict = dict(node = self.json_models_factory.create__Model__MGraph__Json__Node__Value(),
graph = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Domain__MGraph__Json__Node__Property(self):
node = object.__new__(Domain__MGraph__Json__Node__Property)
node_dict = dict(node = self.json_models_factory.create__Model__MGraph__Json__Node__Property(),
graph = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Domain__MGraph__Json__Node__Dict(self):
node = object.__new__(Domain__MGraph__Json__Node__Dict)
node_dict = dict(node = self.json_models_factory.create__Model__MGraph__Json__Node__Dict(),
graph = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Domain__MGraph__Json__Node__List(self):
node = object.__new__(Domain__MGraph__Json__Node__List)
node_dict = dict(node = self.json_models_factory.create__Model__MGraph__Json__Node__List(),
graph = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Domain__MGraph__Json__Edge(self):
edge = object.__new__(Domain__MGraph__Json__Edge)
edge_dict = dict(edge = self.json_models_factory.create__Model__MGraph__Json__Edge(),
graph = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(edge, '__dict__', edge_dict)
return edge

def create__Domain__MGraph__Json__Graph(self):
graph = object.__new__(Domain__MGraph__Json__Graph)
graph_dict = dict(domain_types = self.create__Domain__MGraph__Json__Types(),
model = self.json_models_factory.create__Model__MGraph__Json__Graph())
object.__setattr__(graph, '__dict__', graph_dict)
return graph
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from mgraph_ai.providers.json.models.Model__MGraph__Json__Edge import Model__MGraph__Json__Edge
from mgraph_ai.providers.json.models.Model__MGraph__Json__Graph import Model__MGraph__Json__Graph
from mgraph_ai.providers.json.models.Model__MGraph__Json__Node import Model__MGraph__Json__Node
from mgraph_ai.providers.json.models.Model__MGraph__Json__Node__Dict import Model__MGraph__Json__Node__Dict
from mgraph_ai.providers.json.models.Model__MGraph__Json__Node__List import Model__MGraph__Json__Node__List
from mgraph_ai.providers.json.models.Model__MGraph__Json__Node__Property import Model__MGraph__Json__Node__Property
from mgraph_ai.providers.json.models.Model__MGraph__Json__Node__Value import Model__MGraph__Json__Node__Value
from mgraph_ai.providers.json.models.Model__MGraph__Json__Types import Model__MGraph__Json__Types
from mgraph_ai.providers.json.actions.MGraph__Json__Obj_Factory__Schemas import MGraph__Json__Obj_Factory__Schemas
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Json__Obj_Factory__Models(Type_Safe):
json_schema_factory: MGraph__Json__Obj_Factory__Schemas

def __init__(self):
super().__init__()
self.json_schema_factory = MGraph__Json__Obj_Factory__Schemas()

def create__Model__MGraph__Json__Types(self):
types = object.__new__(Model__MGraph__Json__Types)
types_dict = dict(node_model_type = Model__MGraph__Json__Node,
edge_model_type = Model__MGraph__Json__Edge)
object.__setattr__(types, '__dict__', types_dict)
return types

def create__Model__MGraph__Json__Node__Value(self):
node = object.__new__(Model__MGraph__Json__Node__Value)
node_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Node__Value())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Model__MGraph__Json__Node__Property(self):
node = object.__new__(Model__MGraph__Json__Node__Property)
node_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Node__Property())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Model__MGraph__Json__Node__Dict(self):
node = object.__new__(Model__MGraph__Json__Node__Dict)
node_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Node__Dict())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Model__MGraph__Json__Node__List(self):
node = object.__new__(Model__MGraph__Json__Node__List)
node_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Node__List())
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Model__MGraph__Json__Edge(self):
edge = object.__new__(Model__MGraph__Json__Edge)
edge_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Edge())
object.__setattr__(edge, '__dict__', edge_dict)
return edge

def create__Model__MGraph__Json__Graph(self):
graph = object.__new__(Model__MGraph__Json__Graph)
graph_dict = dict(data = self.json_schema_factory.create__Schema__MGraph__Json__Graph(),
model_types = self.create__Model__MGraph__Json__Types())
object.__setattr__(graph, '__dict__', graph_dict)
return graph
106 changes: 106 additions & 0 deletions mgraph_ai/providers/json/actions/MGraph__Json__Obj_Factory__Schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from mgraph_ai.mgraph.actions.MGraph__Obj_Factory__Schemas import MGraph__Obj_Factory__Schemas
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Edge import Schema__MGraph__Json__Edge
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Graph import Schema__MGraph__Json__Graph
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Graph__Data import Schema__MGraph__Json__Graph__Data
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node import Schema__MGraph__Json__Node
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__Dict import Schema__MGraph__Json__Node__Dict
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__List import Schema__MGraph__Json__Node__List
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__Property import Schema__MGraph__Json__Node__Property
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__Property__Data import Schema__MGraph__Json__Node__Property__Data
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__Value import Schema__MGraph__Json__Node__Value
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Node__Value__Data import Schema__MGraph__Json__Node__Value__Data
from mgraph_ai.providers.json.schemas.Schema__MGraph__Json__Types import Schema__MGraph__Json__Types
from osbot_utils.type_safe.Type_Safe import Type_Safe

class MGraph__Json__Obj_Factory__Schemas(Type_Safe):
schema_factory: MGraph__Obj_Factory__Schemas

def __init__(self):
super().__init__()
self.schema_factory = MGraph__Obj_Factory__Schemas()

def create__Schema__MGraph__Json__Node__Value__Data(self):
data = object.__new__(Schema__MGraph__Json__Node__Value__Data)
data_dict = dict(value = None,
value_type = str)
object.__setattr__(data, '__dict__', data_dict)
return data

def create__Schema__MGraph__Json__Node__Property__Data(self):
data = object.__new__(Schema__MGraph__Json__Node__Property__Data)
data_dict = dict(name = '')
object.__setattr__(data, '__dict__', data_dict)
return data

def create__Schema__MGraph__Json__Node__Value(self):
node = object.__new__(Schema__MGraph__Json__Node__Value)
node_dict = dict(node_data = self.create__Schema__MGraph__Json__Node__Value__Data(),
node_id = self.schema_factory.create__Schema__MGraph__Node().node_id,
node_type = Schema__MGraph__Json__Node__Value)
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Schema__MGraph__Json__Node__Property(self):
node = object.__new__(Schema__MGraph__Json__Node__Property)
node_dict = dict(node_data = self.create__Schema__MGraph__Json__Node__Property__Data(),
node_id = self.schema_factory.create__Schema__MGraph__Node().node_id,
node_type = Schema__MGraph__Json__Node__Property)
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Schema__MGraph__Json__Node__Dict(self):
node = object.__new__(Schema__MGraph__Json__Node__Dict)
base_node = self.schema_factory.create__Schema__MGraph__Node()
node_dict = dict(node_data = base_node.node_data,
node_id = base_node.node_id,
node_type = Schema__MGraph__Json__Node__Dict)
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Schema__MGraph__Json__Node__List(self):
node = object.__new__(Schema__MGraph__Json__Node__List)
base_node = self.schema_factory.create__Schema__MGraph__Node()
node_dict = dict(node_data = base_node.node_data,
node_id = base_node.node_id,
node_type = Schema__MGraph__Json__Node__List)
object.__setattr__(node, '__dict__', node_dict)
return node

def create__Schema__MGraph__Json__Edge(self):
edge = object.__new__(Schema__MGraph__Json__Edge)
base_edge = self.schema_factory.create__Schema__MGraph__Edge()
edge_dict = dict(edge_config = base_edge.edge_config,
edge_data = base_edge.edge_data,
edge_type = Schema__MGraph__Json__Edge,
from_node_id = base_edge.from_node_id,
to_node_id = base_edge.to_node_id)
object.__setattr__(edge, '__dict__', edge_dict)
return edge

def create__Schema__MGraph__Json__Graph__Data(self):
data = object.__new__(Schema__MGraph__Json__Graph__Data)
data_dict = dict(root_id = None)
object.__setattr__(data, '__dict__', data_dict)
return data

def create__Schema__MGraph__Json__Types(self):
types = object.__new__(Schema__MGraph__Json__Types)
types_dict = dict(edge_type = Schema__MGraph__Json__Edge,
edge_config_type = self.schema_factory.create__Schema__MGraph__Edge__Config().__class__,
graph_data_type = Schema__MGraph__Json__Graph__Data,
node_type = Schema__MGraph__Json__Node,
node_data_type = Schema__MGraph__Json__Node__Value__Data)
object.__setattr__(types, '__dict__', types_dict)
return types

def create__Schema__MGraph__Json__Graph(self):
graph = object.__new__(Schema__MGraph__Json__Graph)
base_graph = self.schema_factory.create__Schema__MGraph__Graph()
graph_dict = dict(edges = {},
graph_data = self.create__Schema__MGraph__Json__Graph__Data(),
graph_id = base_graph.graph_id,
graph_type = Schema__MGraph__Json__Graph,
nodes = {},
schema_types = self.create__Schema__MGraph__Json__Types())
object.__setattr__(graph, '__dict__', graph_dict)
return graph
2 changes: 1 addition & 1 deletion modules/OSBot-Utils
Loading

0 comments on commit 1c28eca

Please sign in to comment.