diff --git a/src/cript/nodes/primary_nodes/collection.py b/src/cript/nodes/primary_nodes/collection.py index 035775e4..6ae9f743 100644 --- a/src/cript/nodes/primary_nodes/collection.py +++ b/src/cript/nodes/primary_nodes/collection.py @@ -1,11 +1,11 @@ from dataclasses import dataclass, field, replace -from typing import Any, List, Optional +from typing import Any, List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode from cript.nodes.supporting_nodes import User -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Collection(PrimaryBaseNode): @@ -57,17 +57,19 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): """ # TODO add proper typing in future, using Any for now to avoid circular import error - member: List[NodeUID[User]] = field(default_factory=list) - admin: List[NodeUID[User]] = field(default_factory=list) - experiment: List[NodeUID[Any]] = field(default_factory=list) - inventory: List[NodeUID[Any]] = field(default_factory=list) + member: List[Union[User, UIDProxy]] = field(default_factory=list) + admin: List[Union[User, UIDProxy]] = field(default_factory=list) + experiment: List[Union[Any, UIDProxy]] = field(default_factory=list) + inventory: List[Union[Any, UIDProxy]] = field(default_factory=list) doi: str = "" - citation: List[NodeUID[Any]] = field(default_factory=list) + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, name: str, experiment: Optional[List[NodeUID[Any]]] = None, inventory: Optional[List[NodeUID[Any]]] = None, doi: str = "", citation: Optional[List[NodeUID[Any]]] = None, notes: str = "", **kwargs) -> None: + def __init__( + self, name: str, experiment: Optional[List[Union[Any, UIDProxy]]] = None, inventory: Optional[List[Union[Any, UIDProxy]]] = None, doi: str = "", citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs + ) -> None: """ create a Collection with a name add list of experiment, inventory, citation, doi, and notes if available. @@ -118,12 +120,12 @@ def __init__(self, name: str, experiment: Optional[List[NodeUID[Any]]] = None, i @property @beartype - def member(self) -> List[User]: + def member(self) -> List[Union[User, UIDProxy]]: return self._json_attrs.member.copy() @property @beartype - def admin(self) -> List[User]: + def admin(self) -> List[Union[User, UIDProxy]]: return self._json_attrs.admin @property diff --git a/src/cript/nodes/primary_nodes/computation.py b/src/cript/nodes/primary_nodes/computation.py index 05e1f1b2..89b0ac43 100644 --- a/src/cript/nodes/primary_nodes/computation.py +++ b/src/cript/nodes/primary_nodes/computation.py @@ -1,10 +1,10 @@ from dataclasses import dataclass, field, replace -from typing import Any, List, Optional +from typing import Any, List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Computation(PrimaryBaseNode): @@ -65,12 +65,12 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): type: str = "" # TODO add proper typing in future, using Any for now to avoid circular import error - input_data: List[NodeUID[Any]] = field(default_factory=list) - output_data: List[NodeUID[Any]] = field(default_factory=list) - software_configuration: List[NodeUID[Any]] = field(default_factory=list) - condition: List[NodeUID[Any]] = field(default_factory=list) - prerequisite_computation: Optional[NodeUID["Computation"]] = None - citation: List[NodeUID[Any]] = field(default_factory=list) + input_data: List[Union[Any, UIDProxy]] = field(default_factory=list) + output_data: List[Union[Any, UIDProxy]] = field(default_factory=list) + software_configuration: List[Union[Any, UIDProxy]] = field(default_factory=list) + condition: List[Union[Any, UIDProxy]] = field(default_factory=list) + prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -79,12 +79,12 @@ def __init__( self, name: str, type: str, - input_data: Optional[List[NodeUID[Any]]] = None, - output_data: Optional[List[NodeUID[Any]]] = None, - software_configuration: Optional[List[NodeUID[Any]]] = None, - condition: Optional[List[NodeUID[Any]]] = None, - prerequisite_computation: Optional[NodeUID["Computation"]] = None, - citation: Optional[List[NodeUID[Any]]] = None, + input_data: Optional[List[Union[Any, UIDProxy]]] = None, + output_data: Optional[List[Union[Any, UIDProxy]]] = None, + software_configuration: Optional[List[Union[Any, UIDProxy]]] = None, + condition: Optional[List[Union[Any, UIDProxy]]] = None, + prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None, + citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs ) -> None: @@ -365,7 +365,7 @@ def condition(self, new_condition_list: List[Any]) -> None: @property @beartype - def prerequisite_computation(self) -> Optional["Computation"]: + def prerequisite_computation(self) -> Optional[Union["Computation", UIDProxy]]: """ prerequisite computation @@ -387,7 +387,7 @@ def prerequisite_computation(self) -> Optional["Computation"]: @prerequisite_computation.setter @beartype - def prerequisite_computation(self, new_prerequisite_computation: Optional["Computation"]) -> None: + def prerequisite_computation(self, new_prerequisite_computation: Optional[Union["Computation", UIDProxy]]) -> None: """ set new prerequisite_computation diff --git a/src/cript/nodes/primary_nodes/computation_process.py b/src/cript/nodes/primary_nodes/computation_process.py index 64da545b..a514e898 100644 --- a/src/cript/nodes/primary_nodes/computation_process.py +++ b/src/cript/nodes/primary_nodes/computation_process.py @@ -1,10 +1,10 @@ from dataclasses import dataclass, field, replace -from typing import Any, List, Optional +from typing import Any, List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class ComputationProcess(PrimaryBaseNode): @@ -114,13 +114,13 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): type: str = "" # TODO add proper typing in future, using Any for now to avoid circular import error - input_data: List[NodeUID[Any]] = field(default_factory=list) - output_data: List[NodeUID[Any]] = field(default_factory=list) - ingredient: List[NodeUID[Any]] = field(default_factory=list) - software_configuration: List[NodeUID[Any]] = field(default_factory=list) - condition: List[NodeUID[Any]] = field(default_factory=list) - property: List[NodeUID[Any]] = field(default_factory=list) - citation: List[NodeUID[Any]] = field(default_factory=list) + input_data: List[Union[Any, UIDProxy]] = field(default_factory=list) + output_data: List[Union[Any, UIDProxy]] = field(default_factory=list) + ingredient: List[Union[Any, UIDProxy]] = field(default_factory=list) + software_configuration: List[Union[Any, UIDProxy]] = field(default_factory=list) + condition: List[Union[Any, UIDProxy]] = field(default_factory=list) + property: List[Union[Any, UIDProxy]] = field(default_factory=list) + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -129,13 +129,13 @@ def __init__( self, name: str, type: str, - input_data: List[NodeUID[Any]], - ingredient: List[NodeUID[Any]], - output_data: Optional[List[NodeUID[Any]]] = None, - software_configuration: Optional[List[NodeUID[Any]]] = None, - condition: Optional[List[NodeUID[Any]]] = None, - property: Optional[List[NodeUID[Any]]] = None, - citation: Optional[List[NodeUID[Any]]] = None, + input_data: List[Union[Any, UIDProxy]], + ingredient: List[Union[Any, UIDProxy]], + output_data: Optional[List[Union[Any, UIDProxy]]] = None, + software_configuration: Optional[List[Union[Any, UIDProxy]]] = None, + condition: Optional[List[Union[Any, UIDProxy]]] = None, + property: Optional[List[Union[Any, UIDProxy]]] = None, + citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs ): diff --git a/src/cript/nodes/primary_nodes/data.py b/src/cript/nodes/primary_nodes/data.py index 52ab261a..ac59dc87 100644 --- a/src/cript/nodes/primary_nodes/data.py +++ b/src/cript/nodes/primary_nodes/data.py @@ -4,7 +4,7 @@ from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Data(PrimaryBaseNode): @@ -75,13 +75,13 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): type: str = "" # TODO add proper typing in future, using Any for now to avoid circular import error - file: List[NodeUID[Any]] = field(default_factory=list) - sample_preparation: NodeUID[Any] = field(default_factory=list) - computation: List[NodeUID[Any]] = field(default_factory=list) - computation_process: NodeUID[Any] = field(default_factory=list) - material: List[NodeUID[Any]] = field(default_factory=list) - process: List[NodeUID[Any]] = field(default_factory=list) - citation: List[NodeUID[Any]] = field(default_factory=list) + file: List[Union[Any, UIDProxy]] = field(default_factory=list) + sample_preparation: Union[Any, UIDProxy] = field(default_factory=list) + computation: List[Union[Any, UIDProxy]] = field(default_factory=list) + computation_process: Union[Any, UIDProxy] = field(default_factory=list) + material: List[Union[Any, UIDProxy]] = field(default_factory=list) + process: List[Union[Any, UIDProxy]] = field(default_factory=list) + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -90,13 +90,13 @@ def __init__( self, name: str, type: str, - file: List[NodeUID[Any]], - sample_preparation: NodeUID[Any] = None, - computation: Optional[List[NodeUID[Any]]] = None, - computation_process: Optional[NodeUID[Any]] = None, - material: Optional[List[NodeUID[Any]]] = None, - process: Optional[List[NodeUID[Any]]] = None, - citation: Optional[List[NodeUID[Any]]] = None, + file: List[Union[Any, UIDProxy]], + sample_preparation: Union[Any, UIDProxy] = None, + computation: Optional[List[Union[Any, UIDProxy]]] = None, + computation_process: Optional[Union[Any, UIDProxy]] = None, + material: Optional[List[Union[Any, UIDProxy]]] = None, + process: Optional[List[Union[Any, UIDProxy]]] = None, + citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs ) -> None: diff --git a/src/cript/nodes/primary_nodes/experiment.py b/src/cript/nodes/primary_nodes/experiment.py index 7968cb23..f75ea04f 100644 --- a/src/cript/nodes/primary_nodes/experiment.py +++ b/src/cript/nodes/primary_nodes/experiment.py @@ -1,10 +1,10 @@ from dataclasses import dataclass, field, replace -from typing import Any, List, Optional +from typing import Any, List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Experiment(PrimaryBaseNode): @@ -66,12 +66,12 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): all Collection attributes """ - process: List[NodeUID[Any]] = field(default_factory=list) - computation: List[NodeUID[Any]] = field(default_factory=list) - computation_process: List[NodeUID[Any]] = field(default_factory=list) - data: List[NodeUID[Any]] = field(default_factory=list) + process: List[Union[Any, UIDProxy]] = field(default_factory=list) + computation: List[Union[Any, UIDProxy]] = field(default_factory=list) + computation_process: List[Union[Any, UIDProxy]] = field(default_factory=list) + data: List[Union[Any, UIDProxy]] = field(default_factory=list) funding: List[str] = field(default_factory=list) - citation: List[NodeUID[Any]] = field(default_factory=list) + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -79,12 +79,12 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): def __init__( self, name: str, - process: Optional[List[NodeUID[Any]]] = None, - computation: Optional[List[NodeUID[Any]]] = None, - computation_process: Optional[List[NodeUID[Any]]] = None, - data: Optional[List[NodeUID[Any]]] = None, + process: Optional[List[Union[Any, UIDProxy]]] = None, + computation: Optional[List[Union[Any, UIDProxy]]] = None, + computation_process: Optional[List[Union[Any, UIDProxy]]] = None, + data: Optional[List[Union[Any, UIDProxy]]] = None, funding: Optional[List[str]] = None, - citation: Optional[List[NodeUID[Any]]] = None, + citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs ): diff --git a/src/cript/nodes/primary_nodes/inventory.py b/src/cript/nodes/primary_nodes/inventory.py index d391608d..16994427 100644 --- a/src/cript/nodes/primary_nodes/inventory.py +++ b/src/cript/nodes/primary_nodes/inventory.py @@ -1,11 +1,11 @@ from dataclasses import dataclass, field, replace -from typing import List +from typing import List, Union from beartype import beartype from cript.nodes.primary_nodes.material import Material from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Inventory(PrimaryBaseNode): @@ -60,12 +60,12 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): all Inventory attributes """ - material: List[NodeUID[Material]] = field(default_factory=list) + material: List[Union[Material, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, name: str, material: List[NodeUID[Material]], notes: str = "", **kwargs) -> None: + def __init__(self, name: str, material: List[Union[Material, UIDProxy]], notes: str = "", **kwargs) -> None: """ Instantiate an inventory node @@ -105,7 +105,7 @@ def __init__(self, name: str, material: List[NodeUID[Material]], notes: str = "" @property @beartype - def material(self) -> List[Material]: + def material(self) -> List[Union[Material, UIDProxy]]: """ List of [material](../material) in this inventory @@ -132,7 +132,7 @@ def material(self) -> List[Material]: @material.setter @beartype - def material(self, new_material_list: List[Material]): + def material(self, new_material_list: List[Union[Material, UIDProxy]]): """ set the list of material for this inventory node diff --git a/src/cript/nodes/primary_nodes/material.py b/src/cript/nodes/primary_nodes/material.py index eb8a17b1..e0ae0968 100644 --- a/src/cript/nodes/primary_nodes/material.py +++ b/src/cript/nodes/primary_nodes/material.py @@ -6,7 +6,7 @@ from cript.nodes.exceptions import CRIPTMaterialIdentifierError from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode from cript.nodes.primary_nodes.process import Process -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Material(PrimaryBaseNode): @@ -75,11 +75,11 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): """ # TODO add proper typing in future, using Any for now to avoid circular import error - component: List[NodeUID["Material"]] = field(default_factory=list) - process: Optional[NodeUID[Process]] = None - property: List[NodeUID[Any]] = field(default_factory=list) - parent_material: Optional[NodeUID["Material"]] = None - computational_forcefield: Optional[NodeUID[Any]] = None + component: List[Union["Material", UIDProxy]] = field(default_factory=list) + process: Optional[Union[Process, UIDProxy]] = None + property: List[Union[Any, UIDProxy]] = field(default_factory=list) + parent_material: Optional[Union["Material", UIDProxy]] = None + computational_forcefield: Optional[Union[Any, UIDProxy]] = None keyword: List[str] = field(default_factory=list) amino_acid: Optional[str] = None bigsmiles: Optional[str] = None @@ -100,11 +100,11 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): def __init__( self, name: str, - component: Optional[List[NodeUID["Material"]]] = None, - process: Optional[NodeUID[Process]] = None, - property: Optional[List[NodeUID[Any]]] = None, - parent_material: Optional[NodeUID["Material"]] = None, - computational_forcefield: Optional[NodeUID[Any]] = None, + component: Optional[List[Union["Material", UIDProxy]]] = None, + process: Optional[Union[Process, UIDProxy]] = None, + property: Optional[List[Union[Any, UIDProxy]]] = None, + parent_material: Optional[Union["Material", UIDProxy]] = None, + computational_forcefield: Optional[Union[Any, UIDProxy]] = None, keyword: Optional[List[str]] = None, amino_acid: Optional[str] = None, bigsmiles: Optional[str] = None, @@ -354,7 +354,7 @@ def pubchem_cid(self, new_pubchem_cid: int) -> None: @property @beartype - def component(self) -> List["Material"]: + def component(self) -> List[Union["Material", UIDProxy]]: """ list of components ([material nodes](./)) that make up this material @@ -386,7 +386,7 @@ def component(self) -> List["Material"]: @component.setter @beartype - def component(self, new_component_list: List["Material"]) -> None: + def component(self, new_component_list: List[Union["Material", UIDProxy]]) -> None: """ set the list of component (material nodes) that make up this material @@ -403,7 +403,7 @@ def component(self, new_component_list: List["Material"]) -> None: @property @beartype - def parent_material(self) -> Optional["Material"]: + def parent_material(self) -> Optional[Union["Material", UIDProxy]]: """ List of parent materials @@ -416,7 +416,7 @@ def parent_material(self) -> Optional["Material"]: @parent_material.setter @beartype - def parent_material(self, new_parent_material: Optional["Material"]) -> None: + def parent_material(self, new_parent_material: Optional[Union["Material", UIDProxy]]) -> None: """ set the [parent materials](./) for this material @@ -459,19 +459,19 @@ def computational_forcefield(self) -> Any: @computational_forcefield.setter @beartype - def computational_forcefield(self, new_computational_forcefield_list: Any) -> None: + def computational_forcefield(self, new_computational_forcefield: Any) -> None: """ sets the list of computational forcefields for this material Parameters ---------- - new_computation_forcefield_list: List[ComputationalForcefield] + new_computation_forcefield: ComputationalForcefield Returns ------- None """ - new_attrs = replace(self._json_attrs, computational_forcefield=new_computational_forcefield_list) + new_attrs = replace(self._json_attrs, computational_forcefield=new_computational_forcefield) self._update_json_attrs_if_valid(new_attrs) @property @@ -519,11 +519,11 @@ def keyword(self, new_keyword_list: List[str]) -> None: @property @beartype - def process(self) -> Optional[Process]: + def process(self) -> Optional[Union[Process, UIDProxy]]: return self._json_attrs.process # type: ignore @process.setter - def process(self, new_process: Process) -> None: + def process(self, new_process: Union[Process, UIDProxy]) -> None: new_attrs = replace(self._json_attrs, process=new_process) self._update_json_attrs_if_valid(new_attrs) diff --git a/src/cript/nodes/primary_nodes/process.py b/src/cript/nodes/primary_nodes/process.py index 84149fdf..56c45115 100644 --- a/src/cript/nodes/primary_nodes/process.py +++ b/src/cript/nodes/primary_nodes/process.py @@ -1,10 +1,10 @@ from dataclasses import dataclass, field, replace -from typing import Any, List, Optional +from typing import Any, List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Process(PrimaryBaseNode): @@ -62,16 +62,16 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): type: str = "" # TODO add proper typing in future, using Any for now to avoid circular import error - ingredient: List[NodeUID[Any]] = field(default_factory=list) + ingredient: List[Union[Any, UIDProxy]] = field(default_factory=list) description: str = "" - equipment: List[NodeUID[Any]] = field(default_factory=list) - product: List[NodeUID[Any]] = field(default_factory=list) - waste: List[NodeUID[Any]] = field(default_factory=list) - prerequisite_process: List[NodeUID["Process"]] = field(default_factory=list) - condition: List[NodeUID[Any]] = field(default_factory=list) - property: List[NodeUID[Any]] = field(default_factory=list) + equipment: List[Union[Any, UIDProxy]] = field(default_factory=list) + product: List[Union[Any, UIDProxy]] = field(default_factory=list) + waste: List[Union[Any, UIDProxy]] = field(default_factory=list) + prerequisite_process: List[Union["Process", UIDProxy]] = field(default_factory=list) + condition: List[Union[Any, UIDProxy]] = field(default_factory=list) + property: List[Union[Any, UIDProxy]] = field(default_factory=list) keyword: List[str] = field(default_factory=list) - citation: List[NodeUID[Any]] = field(default_factory=list) + citation: List[Union[Any, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -80,16 +80,16 @@ def __init__( self, name: str, type: str, - ingredient: Optional[List[NodeUID[Any]]] = None, + ingredient: Optional[List[Union[Any, UIDProxy]]] = None, description: str = "", - equipment: Optional[List[NodeUID[Any]]] = None, - product: Optional[List[NodeUID[Any]]] = None, - waste: Optional[List[NodeUID[Any]]] = None, - prerequisite_process: Optional[List[NodeUID["Process"]]] = None, - condition: Optional[List[NodeUID[Any]]] = None, - property: Optional[List[NodeUID[Any]]] = None, + equipment: Optional[List[Union[Any, UIDProxy]]] = None, + product: Optional[List[Union[Any, UIDProxy]]] = None, + waste: Optional[List[Union[Any, UIDProxy]]] = None, + prerequisite_process: Optional[List[Union["Process", UIDProxy]]] = None, + condition: Optional[List[Union[Any, UIDProxy]]] = None, + property: Optional[List[Union[Any, UIDProxy]]] = None, keyword: Optional[List[str]] = None, - citation: Optional[List[NodeUID[Any]]] = None, + citation: Optional[List[Union[Any, UIDProxy]]] = None, notes: str = "", **kwargs ) -> None: @@ -417,7 +417,7 @@ def waste(self, new_waste_list: List[Any]) -> None: @property @beartype - def prerequisite_process(self) -> List["Process"]: + def prerequisite_process(self) -> List[Union["Process", UIDProxy]]: """ list of prerequisite process nodes @@ -440,7 +440,7 @@ def prerequisite_process(self) -> List["Process"]: @prerequisite_process.setter @beartype - def prerequisite_process(self, new_prerequisite_process_list: List["Process"]) -> None: + def prerequisite_process(self, new_prerequisite_process_list: List[Union["Process", UIDProxy]]) -> None: """ set the prerequisite_process for the process node diff --git a/src/cript/nodes/primary_nodes/project.py b/src/cript/nodes/primary_nodes/project.py index 9706f588..2be3056b 100644 --- a/src/cript/nodes/primary_nodes/project.py +++ b/src/cript/nodes/primary_nodes/project.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field, replace -from typing import List, Optional +from typing import List, Optional, Union from beartype import beartype @@ -7,7 +7,7 @@ from cript.nodes.primary_nodes.material import Material from cript.nodes.primary_nodes.primary_base_node import PrimaryBaseNode from cript.nodes.supporting_nodes import User -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy class Project(PrimaryBaseNode): @@ -60,15 +60,15 @@ class JsonAttributes(PrimaryBaseNode.JsonAttributes): all Project attributes """ - member: List[NodeUID[User]] = field(default_factory=list) - admin: List[NodeUID[User]] = field(default_factory=list) - collection: List[NodeUID[Collection]] = field(default_factory=list) - material: List[NodeUID[Material]] = field(default_factory=list) + member: List[Union[User, UIDProxy]] = field(default_factory=list) + admin: List[Union[User, UIDProxy]] = field(default_factory=list) + collection: List[Union[Collection, UIDProxy]] = field(default_factory=list) + material: List[Union[Material, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, name: str, collection: Optional[List[NodeUID[Collection]]] = None, material: Optional[List[NodeUID[Material]]] = None, notes: str = "", **kwargs): + def __init__(self, name: str, collection: Optional[List[Union[Collection, UIDProxy]]] = None, material: Optional[List[Union[Material, UIDProxy]]] = None, notes: str = "", **kwargs): """ Create a Project node with Project name @@ -149,17 +149,17 @@ def validate(self, api=None, is_patch=False, force_validation: bool = False): @property @beartype - def member(self) -> List[User]: + def member(self) -> List[Union[User, UIDProxy]]: return self._json_attrs.member.copy() @property @beartype - def admin(self) -> List[User]: + def admin(self) -> List[Union[User, UIDProxy]]: return self._json_attrs.admin @property @beartype - def collection(self) -> List[Collection]: + def collection(self) -> List[Union[Collection, UIDProxy]]: """ Collection is a Project node's property that can be set during creation in the constructor or later by setting the project's property @@ -180,7 +180,7 @@ def collection(self) -> List[Collection]: @collection.setter @beartype - def collection(self, new_collection: List[Collection]) -> None: + def collection(self, new_collection: List[Union[Collection, UIDProxy]]) -> None: """ set list of collections for the project node @@ -197,7 +197,7 @@ def collection(self, new_collection: List[Collection]) -> None: @property @beartype - def material(self) -> List[Material]: + def material(self) -> List[Union[Material, UIDProxy]]: """ List of Materials that belong to this Project. @@ -217,7 +217,7 @@ def material(self) -> List[Material]: @material.setter @beartype - def material(self, new_materials: List[Material]) -> None: + def material(self, new_materials: List[Union[Material, UIDProxy]]) -> None: """ set the list of materials for this project diff --git a/src/cript/nodes/subobjects/algorithm.py b/src/cript/nodes/subobjects/algorithm.py index 1bca050b..a643d9b7 100644 --- a/src/cript/nodes/subobjects/algorithm.py +++ b/src/cript/nodes/subobjects/algorithm.py @@ -1,9 +1,9 @@ from dataclasses import dataclass, field, replace -from typing import List, Optional +from typing import List, Optional, Union from cript.nodes.subobjects.citation import Citation from cript.nodes.subobjects.parameter import Parameter -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -70,12 +70,12 @@ class JsonAttributes(UUIDBaseNode.JsonAttributes): key: str = "" type: str = "" - parameter: List[NodeUID[Parameter]] = field(default_factory=list) - citation: List[NodeUID[Citation]] = field(default_factory=list) + parameter: List[Union[Parameter, UIDProxy]] = field(default_factory=list) + citation: List[Union[Citation, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() - def __init__(self, key: str, type: str, parameter: Optional[List[NodeUID[Parameter]]] = None, citation: Optional[List[NodeUID[Citation]]] = None, **kwargs): # ignored + def __init__(self, key: str, type: str, parameter: Optional[List[Union[Parameter, UIDProxy]]] = None, citation: Optional[List[Union[Citation, UIDProxy]]] = None, **kwargs): # ignored """ Create algorithm sub-object @@ -173,7 +173,7 @@ def type(self, new_type: str) -> None: self._update_json_attrs_if_valid(new_attrs) @property - def parameter(self) -> List[Parameter]: + def parameter(self) -> List[Union[Parameter, UIDProxy]]: """ list of [Parameter](../parameter) sub-objects for the algorithm sub-object @@ -195,7 +195,7 @@ def parameter(self) -> List[Parameter]: return self._json_attrs.parameter.copy() @parameter.setter - def parameter(self, new_parameter: List[Parameter]) -> None: + def parameter(self, new_parameter: List[Union[Parameter, UIDProxy]]) -> None: """ set a list of cript.Parameter sub-objects @@ -212,7 +212,7 @@ def parameter(self, new_parameter: List[Parameter]) -> None: self._update_json_attrs_if_valid(new_attrs) @property - def citation(self) -> Citation: + def citation(self) -> List[Union[Citation, UIDProxy]]: """ [citation](../citation) subobject for algorithm subobject @@ -248,7 +248,7 @@ def citation(self) -> Citation: return self._json_attrs.citation.copy() # type: ignore @citation.setter - def citation(self, new_citation: List[Citation]) -> None: + def citation(self, new_citation: List[Union[Citation, UIDProxy]]) -> None: """ set the algorithm citation subobject diff --git a/src/cript/nodes/subobjects/citation.py b/src/cript/nodes/subobjects/citation.py index 5016ba72..c22a33a1 100644 --- a/src/cript/nodes/subobjects/citation.py +++ b/src/cript/nodes/subobjects/citation.py @@ -4,7 +4,7 @@ from beartype import beartype from cript.nodes.primary_nodes.reference import Reference -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -61,12 +61,12 @@ class Citation(UUIDBaseNode): @dataclass(frozen=True) class JsonAttributes(UUIDBaseNode.JsonAttributes): type: str = "" - reference: Optional[NodeUID[Reference]] = None + reference: Optional[Union[Reference, UIDProxy]] = None _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, type: str, reference: NodeUID[Reference], **kwargs): + def __init__(self, type: str, reference: Union[Reference, UIDProxy], **kwargs): """ create a Citation subobject @@ -165,7 +165,7 @@ def type(self, new_type: str) -> None: @property @beartype - def reference(self) -> Union[Reference, None]: + def reference(self) -> Union[Reference, None, UIDProxy]: """ citation reference node diff --git a/src/cript/nodes/subobjects/computational_forcefield.py b/src/cript/nodes/subobjects/computational_forcefield.py index fc346d4e..39c2b0e5 100644 --- a/src/cript/nodes/subobjects/computational_forcefield.py +++ b/src/cript/nodes/subobjects/computational_forcefield.py @@ -1,11 +1,11 @@ from dataclasses import dataclass, field, replace -from typing import List, Optional +from typing import List, Optional, Union from beartype import beartype from cript.nodes.primary_nodes.data import Data from cript.nodes.subobjects.citation import Citation -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -89,8 +89,8 @@ class JsonAttributes(UUIDBaseNode.JsonAttributes): implicit_solvent: str = "" source: str = "" description: str = "" - data: List[NodeUID[Data]] = field(default_factory=list) - citation: List[NodeUID[Citation]] = field(default_factory=list) + data: List[Union[Data, UIDProxy]] = field(default_factory=list) + citation: List[Union[Citation, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -103,8 +103,8 @@ def __init__( implicit_solvent: str = "", source: str = "", description: str = "", - data: Optional[List[NodeUID[Data]]] = None, - citation: Optional[List[NodeUID[Citation]]] = None, + data: Optional[List[Union[Data, UIDProxy]]] = None, + citation: Optional[List[Union[Citation, UIDProxy]]] = None, **kwargs ): """ @@ -405,7 +405,7 @@ def description(self, new_description: str) -> None: @property @beartype - def data(self) -> List[Data]: + def data(self) -> List[Union[Data, UIDProxy]]: """ details of mapping schema and forcefield parameters @@ -438,7 +438,7 @@ def data(self) -> List[Data]: @data.setter @beartype - def data(self, new_data: List[Data]) -> None: + def data(self, new_data: List[Union[Data, UIDProxy]]) -> None: """ set the data attribute of this computational_forcefield node @@ -456,7 +456,7 @@ def data(self, new_data: List[Data]) -> None: @property @beartype - def citation(self) -> List[Citation]: + def citation(self) -> List[Union[Citation, UIDProxy]]: """ reference to a book, paper, or scholarly work @@ -495,7 +495,7 @@ def citation(self) -> List[Citation]: @citation.setter @beartype - def citation(self, new_citation: List[Citation]) -> None: + def citation(self, new_citation: List[Union[Citation, UIDProxy]]) -> None: """ set the citation subobject of the computational_forcefield subobject diff --git a/src/cript/nodes/subobjects/condition.py b/src/cript/nodes/subobjects/condition.py index 993480c9..461952f9 100644 --- a/src/cript/nodes/subobjects/condition.py +++ b/src/cript/nodes/subobjects/condition.py @@ -5,7 +5,7 @@ from beartype import beartype from cript.nodes.primary_nodes.data import Data -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -87,7 +87,7 @@ class JsonAttributes(UUIDBaseNode.JsonAttributes): uncertainty_type: str = "" set_id: Optional[int] = None measurement_id: Optional[int] = None - data: List[NodeUID[Data]] = field(default_factory=list) + data: List[Union[Data, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @@ -103,7 +103,7 @@ def __init__( uncertainty_type: str = "", set_id: Optional[int] = None, measurement_id: Optional[int] = None, - data: Optional[List[NodeUID[Data]]] = None, + data: Optional[List[Union[Data, UIDProxy]]] = None, **kwargs ): """ @@ -505,7 +505,7 @@ def measurement_id(self, new_measurement_id: Union[int, None]) -> None: @property @beartype - def data(self) -> List[Data]: + def data(self) -> List[Union[Data, UIDProxy]]: """ detailed data associated with the condition @@ -540,7 +540,7 @@ def data(self) -> List[Data]: @data.setter @beartype - def data(self, new_data: List[Data]) -> None: + def data(self, new_data: List[Union[Data, UIDProxy]]) -> None: """ set the data node for this Condition Subobject diff --git a/src/cript/nodes/subobjects/equipment.py b/src/cript/nodes/subobjects/equipment.py index 0c31c845..ecac0af2 100644 --- a/src/cript/nodes/subobjects/equipment.py +++ b/src/cript/nodes/subobjects/equipment.py @@ -1,12 +1,12 @@ from dataclasses import dataclass, field, replace -from typing import List, Optional +from typing import List, Optional, Union from beartype import beartype from cript.nodes.subobjects.citation import Citation from cript.nodes.subobjects.condition import Condition from cript.nodes.supporting_nodes.file import File -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -54,14 +54,14 @@ class Equipment(UUIDBaseNode): class JsonAttributes(UUIDBaseNode.JsonAttributes): key: str = "" description: str = "" - condition: List[NodeUID[Condition]] = field(default_factory=list) - file: List[NodeUID[File]] = field(default_factory=list) - citation: List[NodeUID[Citation]] = field(default_factory=list) + condition: List[Union[Condition, UIDProxy]] = field(default_factory=list) + file: List[Union[File, UIDProxy]] = field(default_factory=list) + citation: List[Union[Citation, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, key: str, description: str = "", condition: Optional[List[NodeUID[Condition]]] = None, file: Optional[List[NodeUID[File]]] = None, citation: Optional[List[NodeUID[Citation]]] = None, **kwargs) -> None: + def __init__(self, key: str, description: str = "", condition: Optional[List[Union[Condition, UIDProxy]]] = None, file: Optional[List[Union[File, UIDProxy]]] = None, citation: Optional[List[Union[Citation, UIDProxy]]] = None, **kwargs) -> None: """ create equipment sub-object @@ -175,7 +175,7 @@ def description(self, new_description: str) -> None: @property @beartype - def condition(self) -> List[Condition]: + def condition(self) -> List[Union[Condition, UIDProxy]]: """ conditions under which the property was measured @@ -200,7 +200,7 @@ def condition(self) -> List[Condition]: @condition.setter @beartype - def condition(self, new_condition: List[Condition]) -> None: + def condition(self, new_condition: List[Union[Condition, UIDProxy]]) -> None: """ set a list of Conditions for the equipment sub-object @@ -218,7 +218,7 @@ def condition(self, new_condition: List[Condition]) -> None: @property @beartype - def file(self) -> List[File]: + def file(self) -> List[Union[File, UIDProxy]]: """ list of file nodes to link to calibration or equipment specification documents @@ -243,7 +243,7 @@ def file(self) -> List[File]: @file.setter @beartype - def file(self, new_file: List[File]) -> None: + def file(self, new_file: List[Union[File, UIDProxy]]) -> None: """ set the file node for the equipment subobject @@ -261,7 +261,7 @@ def file(self, new_file: List[File]) -> None: @property @beartype - def citation(self) -> List[Citation]: + def citation(self) -> List[Union[Citation, UIDProxy]]: """ reference to a book, paper, or scholarly work @@ -297,7 +297,7 @@ def citation(self) -> List[Citation]: @citation.setter @beartype - def citation(self, new_citation: List[Citation]) -> None: + def citation(self, new_citation: List[Union[Citation, UIDProxy]]) -> None: """ set the citation subobject for this equipment subobject diff --git a/src/cript/nodes/subobjects/ingredient.py b/src/cript/nodes/subobjects/ingredient.py index 19c04162..7b58b67c 100644 --- a/src/cript/nodes/subobjects/ingredient.py +++ b/src/cript/nodes/subobjects/ingredient.py @@ -5,7 +5,7 @@ from cript.nodes.primary_nodes.material import Material from cript.nodes.subobjects.quantity import Quantity -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -66,14 +66,14 @@ class Ingredient(UUIDBaseNode): @dataclass(frozen=True) class JsonAttributes(UUIDBaseNode.JsonAttributes): - material: Optional[NodeUID[Material]] = None - quantity: List[NodeUID[Quantity]] = field(default_factory=list) + material: Optional[Union[Material, UIDProxy]] = None + quantity: List[Union[Quantity, UIDProxy]] = field(default_factory=list) keyword: List[str] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, material: NodeUID[Material], quantity: List[NodeUID[Quantity]], keyword: Optional[List[str]] = None, **kwargs): + def __init__(self, material: Union[Material, UIDProxy], quantity: List[Union[Quantity, UIDProxy]], keyword: Optional[List[str]] = None, **kwargs): """ create an ingredient sub-object @@ -118,7 +118,7 @@ def _from_json(cls, json_dict: dict): @property @beartype - def material(self) -> Union[Material, None]: + def material(self) -> Union[Material, None, UIDProxy]: """ current material in this ingredient sub-object @@ -131,7 +131,7 @@ def material(self) -> Union[Material, None]: @property @beartype - def quantity(self) -> List[Quantity]: + def quantity(self) -> List[Union[Quantity, UIDProxy]]: """ quantity for the ingredient sub-object @@ -143,7 +143,7 @@ def quantity(self) -> List[Quantity]: return self._json_attrs.quantity.copy() @beartype - def set_material(self, new_material: Material, new_quantity: List[Quantity]) -> None: + def set_material(self, new_material: Union[Material, UIDProxy], new_quantity: List[Union[Quantity, UIDProxy]]) -> None: """ update ingredient sub-object with new material and new list of quantities diff --git a/src/cript/nodes/subobjects/property.py b/src/cript/nodes/subobjects/property.py index 01342ae4..d6af1a7d 100644 --- a/src/cript/nodes/subobjects/property.py +++ b/src/cript/nodes/subobjects/property.py @@ -10,7 +10,7 @@ from cript.nodes.primary_nodes.process import Process from cript.nodes.subobjects.citation import Citation from cript.nodes.subobjects.condition import Condition -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -77,14 +77,14 @@ class JsonAttributes(UUIDBaseNode.JsonAttributes): unit: Optional[str] = "" uncertainty: Optional[Number] = None uncertainty_type: str = "" - component: List[NodeUID[Material]] = field(default_factory=list) + component: List[Union[Material, UIDProxy]] = field(default_factory=list) structure: str = "" method: str = "" - sample_preparation: Optional[NodeUID[Process]] = None - condition: List[NodeUID[Condition]] = field(default_factory=list) - data: List[Data] = field(default_factory=list) - computation: List[NodeUID[Computation]] = field(default_factory=list) - citation: List[NodeUID[Citation]] = field(default_factory=list) + sample_preparation: Optional[Union[Process, UIDProxy]] = None + condition: List[Union[Condition, UIDProxy]] = field(default_factory=list) + data: List[Union[Data, UIDProxy]] = field(default_factory=list) + computation: List[Union[Computation, UIDProxy]] = field(default_factory=list) + citation: List[Union[Citation, UIDProxy]] = field(default_factory=list) notes: str = "" _json_attrs: JsonAttributes = JsonAttributes() @@ -98,14 +98,14 @@ def __init__( unit: Union[str, None], uncertainty: Optional[Number] = None, uncertainty_type: str = "", - component: Optional[List[NodeUID[Material]]] = None, + component: Optional[List[Union[Material, UIDProxy]]] = None, structure: str = "", method: str = "", - sample_preparation: Optional[NodeUID[Process]] = None, - condition: Optional[List[NodeUID[Condition]]] = None, - data: Optional[List[NodeUID[Data]]] = None, - computation: Optional[List[NodeUID[Computation]]] = None, - citation: Optional[List[NodeUID[Citation]]] = None, + sample_preparation: Optional[Union[Process, UIDProxy]] = None, + condition: Optional[List[Union[Condition, UIDProxy]]] = None, + data: Optional[List[Union[Data, UIDProxy]]] = None, + computation: Optional[List[Union[Computation, UIDProxy]]] = None, + citation: Optional[List[Union[Citation, UIDProxy]]] = None, notes: str = "", **kwargs ): @@ -373,7 +373,7 @@ def uncertainty_type(self) -> str: @property @beartype - def component(self) -> List[Material]: + def component(self) -> List[Union[Material, UIDProxy]]: """ list of Materials that the Property relates to @@ -393,7 +393,7 @@ def component(self) -> List[Material]: @component.setter @beartype - def component(self, new_component: List[Material]) -> None: + def component(self, new_component: List[Union[Material, UIDProxy]]) -> None: """ set the list of Materials as components for the Property subobject @@ -487,7 +487,7 @@ def method(self, new_method: str) -> None: @property @beartype - def sample_preparation(self) -> Union[Process, None]: + def sample_preparation(self) -> Union[Process, None, UIDProxy]: """ sample_preparation @@ -507,7 +507,7 @@ def sample_preparation(self) -> Union[Process, None]: @sample_preparation.setter @beartype - def sample_preparation(self, new_sample_preparation: Union[Process, None]) -> None: + def sample_preparation(self, new_sample_preparation: Union[Process, None, UIDProxy]) -> None: """ set the sample_preparation for the Property subobject @@ -525,7 +525,7 @@ def sample_preparation(self, new_sample_preparation: Union[Process, None]) -> No @property @beartype - def condition(self) -> List[Condition]: + def condition(self) -> List[Union[Condition, UIDProxy]]: """ list of Conditions under which the property was measured @@ -545,7 +545,7 @@ def condition(self) -> List[Condition]: @condition.setter @beartype - def condition(self, new_condition: List[Condition]) -> None: + def condition(self, new_condition: List[Union[Condition, UIDProxy]]) -> None: """ set the list of Conditions for this property subobject @@ -563,7 +563,7 @@ def condition(self, new_condition: List[Condition]) -> None: @property @beartype - def data(self) -> List[Data]: + def data(self) -> List[Union[Data, UIDProxy]]: """ List of Data nodes for this Property subobjects @@ -590,7 +590,7 @@ def data(self) -> List[Data]: @data.setter @beartype - def data(self, new_data: List[Data]) -> None: + def data(self, new_data: List[Union[Data, UIDProxy]]) -> None: """ set the Data node for the Property subobject @@ -608,7 +608,7 @@ def data(self, new_data: List[Data]) -> None: @property @beartype - def computation(self) -> List[Computation]: + def computation(self) -> List[Union[Computation, UIDProxy]]: """ list of Computation nodes that produced this property @@ -628,7 +628,7 @@ def computation(self) -> List[Computation]: @computation.setter @beartype - def computation(self, new_computation: List[Computation]) -> None: + def computation(self, new_computation: List[Union[Computation, UIDProxy]]) -> None: """ set the list of Computation nodes that produced this property @@ -646,7 +646,7 @@ def computation(self, new_computation: List[Computation]) -> None: @property @beartype - def citation(self) -> List[Citation]: + def citation(self) -> List[Union[Citation, UIDProxy]]: """ list of Citation subobjects for this Property subobject @@ -682,7 +682,7 @@ def citation(self) -> List[Citation]: @citation.setter @beartype - def citation(self, new_citation: List[Citation]) -> None: + def citation(self, new_citation: List[Union[Citation, UIDProxy]]) -> None: """ set the list of Citation subobjects for the Property subobject diff --git a/src/cript/nodes/subobjects/software_configuration.py b/src/cript/nodes/subobjects/software_configuration.py index 95332648..a7fc4f26 100644 --- a/src/cript/nodes/subobjects/software_configuration.py +++ b/src/cript/nodes/subobjects/software_configuration.py @@ -6,7 +6,7 @@ from cript.nodes.subobjects.algorithm import Algorithm from cript.nodes.subobjects.citation import Citation from cript.nodes.subobjects.software import Software -from cript.nodes.util.json import NodeUID +from cript.nodes.util.json import UIDProxy from cript.nodes.uuid_base import UUIDBaseNode @@ -58,15 +58,15 @@ class SoftwareConfiguration(UUIDBaseNode): @dataclass(frozen=True) class JsonAttributes(UUIDBaseNode.JsonAttributes): - software: Optional[NodeUID[Software]] = None - algorithm: List[NodeUID[Algorithm]] = field(default_factory=list) + software: Optional[Union[Software, UIDProxy]] = None + algorithm: List[Union[Algorithm, UIDProxy]] = field(default_factory=list) notes: str = "" - citation: List[NodeUID[Citation]] = field(default_factory=list) + citation: List[Union[Citation, UIDProxy]] = field(default_factory=list) _json_attrs: JsonAttributes = JsonAttributes() @beartype - def __init__(self, software: NodeUID[Software], algorithm: Optional[List[NodeUID[Algorithm]]] = None, notes: str = "", citation: Union[List[NodeUID[Citation]], None] = None, **kwargs): + def __init__(self, software: Union[Software, UIDProxy], algorithm: Optional[List[Union[Algorithm, UIDProxy]]] = None, notes: str = "", citation: Union[List[Union[Citation, UIDProxy]], None] = None, **kwargs): """ Create Software_Configuration sub-object @@ -103,7 +103,7 @@ def __init__(self, software: NodeUID[Software], algorithm: Optional[List[NodeUID @property @beartype - def software(self) -> Union[Software, None]: + def software(self) -> Union[Software, None, UIDProxy]: """ Software used @@ -123,7 +123,7 @@ def software(self) -> Union[Software, None]: @software.setter @beartype - def software(self, new_software: Union[Software, None]) -> None: + def software(self, new_software: Union[Software, None, UIDProxy]) -> None: """ set the Software used @@ -141,7 +141,7 @@ def software(self, new_software: Union[Software, None]) -> None: @property @beartype - def algorithm(self) -> List[Algorithm]: + def algorithm(self) -> List[Union[Algorithm, UIDProxy]]: """ list of Algorithms used @@ -162,7 +162,7 @@ def algorithm(self) -> List[Algorithm]: @algorithm.setter @beartype - def algorithm(self, new_algorithm: List[Algorithm]) -> None: + def algorithm(self, new_algorithm: List[Union[Algorithm, UIDProxy]]) -> None: """ set the list of Algorithms @@ -225,7 +225,7 @@ def notes(self, new_notes: str) -> None: @property @beartype - def citation(self) -> List[Citation]: + def citation(self) -> List[Union[Citation, UIDProxy]]: """ list of Citation sub-objects for the Software_Configuration @@ -262,7 +262,7 @@ def citation(self) -> List[Citation]: @citation.setter @beartype - def citation(self, new_citation: List[Citation]) -> None: + def citation(self, new_citation: List[Union[Citation, UIDProxy]]) -> None: """ set the Citation sub-object diff --git a/src/cript/nodes/util/json.py b/src/cript/nodes/util/json.py index 351fd642..2b923bab 100644 --- a/src/cript/nodes/util/json.py +++ b/src/cript/nodes/util/json.py @@ -5,7 +5,7 @@ import inspect import json import uuid -from typing import Dict, List, Optional, Set, Union, _SpecialForm, _type_check +from typing import Dict, List, Optional, Set, Union import cript.nodes from cript.nodes.core import BaseNode @@ -215,13 +215,6 @@ def strip_to_edge_uuid(element): return serialize_dict, uid_of_condensed -@_SpecialForm -def NodeUID(self, parameters): - """Node[X] is equivalent to Union[X, UIDProxy]. (Implementation from CPython.typing.Optional)""" - arg = _type_check(parameters, f"{self} requires a single type.") - return Union[arg, UIDProxy] - - class _NodeDecoderHook: def __init__(self, uid_cache: Optional[Dict] = None): """ @@ -247,7 +240,7 @@ def __init__(self, uid_cache: Optional[Dict] = None): def uid_cache(self): return self._uid_cache - def __call__(self, node_str: Union[Dict, str]) -> Dict: + def __call__(self, node_str: Union[Dict, str]) -> Union[Dict, UIDProxy]: """ Internal function, used as a hook for json deserialization.