Skip to content

Commit 9752fc7

Browse files
committed
update props
1 parent 7ce61cc commit 9752fc7

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

atomrdf/datamodels/structure.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ def from_graph(cls, graph, sample):
500500
]
501501

502502
datadict = {
503-
"volume": {"value": volume},
503+
"volume": {"value": volume,},
504504
"number_of_atoms": {"value": int(number_of_atoms)},
505505
"repetitions": {"value": repetitions},
506506
"length": {"value": length},
@@ -600,10 +600,13 @@ def from_graph(cls, graph, sample):
600600
data = json.load(fin)
601601
positions = data[position_identifier]["value"]
602602
species = data[species_identifier]["value"]
603-
603+
604+
position=DataProperty(value=positions)
605+
species=DataProperty(value=species)
606+
604607
return cls(
605-
position=DataProperty(value=positions),
606-
species=DataProperty(value=species),
608+
position=position,
609+
species=species,
607610
)
608611

609612

@@ -690,7 +693,7 @@ def from_graph(cls, graph, sample_id):
690693
if sample_type is None:
691694
raise ValueError(f"Sample {sample_id} not found in graph.")
692695

693-
696+
694697
# material, simulation_cell, atom_attribute handled separately (if needed)
695698
kwargs["material"] = Material.from_graph(graph, sample)
696699
kwargs["simulation_cell"] = SimulationCell.from_graph(graph, sample)

atomrdf/datamodels/workflow/property.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import yaml
55
import uuid
66
import json
7-
from pydantic import Field, field_validator
7+
from pydantic import Field, field_validator, PrivateAttr
8+
89
from atomrdf.datamodels.basemodels import (
910
TemplateMixin,
1011
DataProperty,
@@ -23,9 +24,16 @@
2324
ASMO,
2425
MDO,
2526
)
27+
from atomrdf.graph import KnowledgeGraph
2628

2729

2830
class Property(DataProperty):
31+
graph: Optional[KnowledgeGraph] = Field(default=None) # Private attribute for graph
32+
33+
model_config = {
34+
"arbitrary_types_allowed": True
35+
}
36+
2937
def _add_value(self, graph, property):
3038
if self.value is not None:
3139
graph.add(

atomrdf/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from atomrdf.workflow.workflow import Workflow
4848
from atomrdf.sample import Sample
4949
import atomrdf.mp as amp
50-
from atomrdf.io.write import write
50+
5151

5252
from atomrdf.namespace import (
5353
Namespace,

0 commit comments

Comments
 (0)