Skip to content

Info

Overview

A foundational abstract base model used to store immuatable and essential data about a material. It holds primary descriptors such as structure, conpositoin, and material ID, and does not include calculation-specific information. This model acts as a reusable and structured container across multiple workflows.

from DeWorks.schema import Info

Attributes

Field Type Description
id str Unique identifier,used primarily as the _id attribute when stored in mongodb
data dict[str, Any] | BaseModel | MSONable Core payload. Can hold raw dict, Pydantic models, or MSONable objects such as from pymatgen
saved_json str | None Optional file path for storing serialized output

Validator

default_id(cls, value: str | None)

Ensres a UUID is used when no _id is provided. This fixes legacy data without the _id field.

validate_date(cls, value)

Converts any BaseModel or MSONable into a dictionary Removes @class and @modeule from MSONable entries

Dict-Like Methods

getitem(self, key)

Retrieves value from `data

setitem(self, key, value)

Returns number of fields in data

delitem(self, key), del(self), pop(self, s = None), popitem(self, s = None)

Functions to raise RuntimeError to prevent destructive operations

Iteration & Metadata

iter(self)

Enables looping over keys

len(self)

Returns number of fields in data

items(self), keys(self), values(self)

Provide standard dict access

Utility

save(self, path: str | None = None)

Saves the Info object to a JSON file. If path is not provided, saved_json will be used.

info = Info(data={"formula": "Fe2O3"})
info.save("Fe2O3_info.json")

Notes

  • This model is intended to be immutable, meaning it is write-safe and deletion-protected.
  • Helpful for keeping an auditable, validated, and portable form of material descriptors.
  • Accepts both domain-specific types and standard Python types, promoting flexible integration.