Skip to content

Commit

Permalink
Make the modeling metadata optional
Browse files Browse the repository at this point in the history
  • Loading branch information
WardLT committed May 8, 2024
1 parent 81e5596 commit 4bd93a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions batdata/schemas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from datetime import date
from typing import List, Tuple, Optional, Dict

from pydantic import BaseModel, Field, AnyUrl, Extra
from pydantic import BaseModel, Field, AnyUrl

from batdata.schemas.modeling import ModelMetadata
from batdata.schemas.battery import BatteryDescription
from batdata.version import __version__


class BatteryMetadata(BaseModel, extra=Extra.allow):
class BatteryMetadata(BaseModel, extra='allow'):
"""Representation for the metadata about a battery
The metadata captures the information about what experiment was run
Expand All @@ -35,7 +35,7 @@ class BatteryMetadata(BaseModel, extra=Extra.allow):
battery: Optional[BatteryDescription] = Field(None, description="Description of the battery being tested")

# Fields that describe source of synthetic data
modeling: ModelMetadata = Field(None, description="Description of simulation approach")
modeling: Optional[ModelMetadata] = Field(None, description="Description of simulation approach")

# Fields that describe the source of data
source: Optional[str] = Field(None, description="Organization who created this data")
Expand Down
10 changes: 5 additions & 5 deletions batdata/schemas/battery.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Schemas associated with the components of a battery"""
from typing import Optional, List

from pydantic import BaseModel, Field, Extra
from pydantic import BaseModel, Field


class ElectrodeDescription(BaseModel, extra=Extra.allow):
class ElectrodeDescription(BaseModel, extra='allow'):
"""Description of an electrode"""

name: str = Field(..., description='Short description of the electrolyte type')
Expand All @@ -20,22 +20,22 @@ class ElectrodeDescription(BaseModel, extra=Extra.allow):
porosity: Optional[float] = Field(None, description='Relative volume of the electrode occupied by gas (units: %)', ge=0, le=100)


class ElectrolyteAdditive(BaseModel, extra=Extra.allow):
class ElectrolyteAdditive(BaseModel, extra='allow'):
"""Additive to the electrolyte"""

name: str = Field(..., description='Name of the additive')
amount: Optional[float] = Field(None, description='Amount added to the solution')
units: Optional[float] = Field(None, description='Units of the amount')


class ElectrolyteDescription(BaseModel, extra=Extra.allow):
class ElectrolyteDescription(BaseModel, extra='allow'):
"""Description of the electrolyte"""

name: str = Field(..., description='Short description of the electrolyte types')
additives: List[ElectrolyteAdditive] = Field(default_factory=list, help='Any additives present in the electrolyte')


class BatteryDescription(BaseModel, extra=Extra.allow):
class BatteryDescription(BaseModel, extra='allow'):
"""Description of the entire battery"""

# Overall design information
Expand Down
2 changes: 1 addition & 1 deletion batdata/schemas/modeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ModelTypes(str, Enum):
IRI: https://w3id.org/emmo#EMMO_67c70dcd_2adf_4e6c_b3f8_f33dd1512487"""


class ModelMetadata(BaseModel):
class ModelMetadata(BaseModel, extra='allow'):
"""Describe the type and version of a computational tool used to generate battery data"""

# High-level information about the code
Expand Down

0 comments on commit 4bd93a3

Please sign in to comment.