Skip to content

Commit 8f86f18

Browse files
authored
Merge pull request #1269 from AllenNeuralDynamics/release-v1.4.0
Release v1.4.0
2 parents 732edac + 1155926 commit 8f86f18

23 files changed

+285
-137
lines changed

examples/bergamo_ophys_session.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/session.py",
3-
"schema_version": "1.1.1",
3+
"schema_version": "1.1.2",
44
"protocol_id": [],
55
"experimenter_full_name": [
66
"John Doe"
@@ -153,6 +153,7 @@
153153
"stimulus_device_names": [],
154154
"speaker_config": null,
155155
"light_source_config": [],
156+
"objects_in_arena": null,
156157
"output_parameters": {},
157158
"reward_consumed_during_epoch": null,
158159
"reward_consumed_unit": "microliter",

examples/ephys_rig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/rig.py",
3-
"schema_version": "1.0.4",
3+
"schema_version": "1.1.1",
44
"rig_id": "323_EPHYS1_20231003",
55
"modification_date": "2023-10-03",
66
"mouse_platform": {

examples/ephys_session.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/session.py",
3-
"schema_version": "1.1.1",
3+
"schema_version": "1.1.2",
44
"protocol_id": [],
55
"experimenter_full_name": [
66
"Max Quibble",
@@ -326,6 +326,7 @@
326326
"stimulus_device_names": [],
327327
"speaker_config": null,
328328
"light_source_config": [],
329+
"objects_in_arena": null,
329330
"output_parameters": {},
330331
"reward_consumed_during_epoch": null,
331332
"reward_consumed_unit": "microliter",
@@ -368,6 +369,7 @@
368369
"stimulus_device_names": [],
369370
"speaker_config": null,
370371
"light_source_config": [],
372+
"objects_in_arena": null,
371373
"output_parameters": {},
372374
"reward_consumed_during_epoch": null,
373375
"reward_consumed_unit": "microliter",

examples/fip_behavior_rig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/rig.py",
3-
"schema_version": "1.0.4",
3+
"schema_version": "1.1.1",
44
"rig_id": "447_FIP-Behavior_20000101",
55
"modification_date": "2000-01-01",
66
"mouse_platform": {

examples/fip_ophys_rig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/rig.py",
3-
"schema_version": "1.0.4",
3+
"schema_version": "1.1.1",
44
"rig_id": "428_FIP1_20231003",
55
"modification_date": "2023-10-03",
66
"mouse_platform": {

examples/mri_session.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/session.py",
3-
"schema_version": "1.1.1",
3+
"schema_version": "1.1.2",
44
"protocol_id": [
55
"dx.doi.org/10.57824/protocols.io.bh7kl4n6"
66
],

examples/multiplane_ophys_session.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/session.py",
3-
"schema_version": "1.1.1",
3+
"schema_version": "1.1.2",
44
"protocol_id": [],
55
"experimenter_full_name": [
66
"John Doe"

examples/ophys_session.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/session.py",
3-
"schema_version": "1.1.1",
3+
"schema_version": "1.1.2",
44
"protocol_id": [],
55
"experimenter_full_name": [
66
"John Doe"

pyproject.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ dynamic = ["version"]
1515

1616
dependencies = [
1717
'aind-data-schema-models>=0.5.4, <1.0.0',
18-
'dictdiffer',
1918
'pydantic>=2.7',
20-
'inflection',
21-
'jsonschema',
2219
'semver'
2320
]
2421

2522
[project.optional-dependencies]
2623
dev = [
2724
'aind_data_schema[linters]',
28-
'pydantic>=2.7, !=2.9.0, !=2.9.1'
25+
'pydantic>=2.7, !=2.9.0, !=2.9.1',
26+
'dictdiffer',
2927
]
3028

3129
linters = [
@@ -35,7 +33,7 @@ linters = [
3533
'flake8',
3634
'interrogate',
3735
'isort',
38-
'aind-flake8-extensions==0.5.2'
36+
'aind-flake8-extensions>=0.6,<0.7'
3937
]
4038

4139
docs = [

schemas/metadata_schema.json

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57247,8 +57247,8 @@
5724757247
"type": "string"
5724857248
},
5724957249
"schema_version": {
57250-
"const": "1.0.4",
57251-
"default": "1.0.4",
57250+
"const": "1.1.1",
57251+
"default": "1.1.1",
5725257252
"title": "Schema Version",
5725357253
"type": "string"
5725457254
},
@@ -62306,8 +62306,8 @@
6230662306
"type": "string"
6230762307
},
6230862308
"schema_version": {
62309-
"const": "1.1.1",
62310-
"default": "1.1.1",
62309+
"const": "1.1.2",
62310+
"default": "1.1.2",
6231162311
"title": "Schema Version",
6231262312
"type": "string"
6231362313
},
@@ -70874,6 +70874,21 @@
7087470874
"description": "Light sources for stimulation",
7087570875
"title": "Light source config"
7087670876
},
70877+
"objects_in_arena": {
70878+
"anyOf": [
70879+
{
70880+
"items": {
70881+
"type": "string"
70882+
},
70883+
"type": "array"
70884+
},
70885+
{
70886+
"type": "null"
70887+
}
70888+
],
70889+
"default": null,
70890+
"title": "Objects in arena"
70891+
},
7087770892
"output_parameters": {
7087870893
"$ref": "#/$defs/AindGeneric",
7087970894
"default": {},
@@ -70961,6 +70976,7 @@
7096170976
"description": "Types of stimulus modalities",
7096270977
"enum": [
7096370978
"Auditory",
70979+
"Free moving",
7096470980
"Olfactory",
7096570981
"Optogenetics",
7096670982
"None",
@@ -72341,6 +72357,30 @@
7234172357
"$ref": "#/$defs/SizeUnit",
7234272358
"default": "centimeter",
7234372359
"title": "Width unit"
72360+
},
72361+
"encoder": {
72362+
"anyOf": [
72363+
{
72364+
"$ref": "#/$defs/Device"
72365+
},
72366+
{
72367+
"type": "null"
72368+
}
72369+
],
72370+
"default": null,
72371+
"title": "Encoder"
72372+
},
72373+
"pulse_per_revolution": {
72374+
"anyOf": [
72375+
{
72376+
"type": "integer"
72377+
},
72378+
{
72379+
"type": "null"
72380+
}
72381+
],
72382+
"default": null,
72383+
"title": "Pulse per revolution"
7234472384
}
7234572385
},
7234672386
"required": [
@@ -107144,8 +107184,8 @@
107144107184
"type": "string"
107145107185
},
107146107186
"schema_version": {
107147-
"const": "1.1.2",
107148-
"default": "1.1.2",
107187+
"const": "1.2.1",
107188+
"default": "1.2.1",
107149107189
"title": "Schema Version",
107150107190
"type": "string"
107151107191
},

schemas/rig_schema.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12505,6 +12505,30 @@
1250512505
"$ref": "#/$defs/SizeUnit",
1250612506
"default": "centimeter",
1250712507
"title": "Width unit"
12508+
},
12509+
"encoder": {
12510+
"anyOf": [
12511+
{
12512+
"$ref": "#/$defs/Device"
12513+
},
12514+
{
12515+
"type": "null"
12516+
}
12517+
],
12518+
"default": null,
12519+
"title": "Encoder"
12520+
},
12521+
"pulse_per_revolution": {
12522+
"anyOf": [
12523+
{
12524+
"type": "integer"
12525+
},
12526+
{
12527+
"type": "null"
12528+
}
12529+
],
12530+
"default": null,
12531+
"title": "Pulse per revolution"
1250812532
}
1250912533
},
1251012534
"required": [
@@ -18777,8 +18801,8 @@
1877718801
"type": "string"
1877818802
},
1877918803
"schema_version": {
18780-
"const": "1.0.4",
18781-
"default": "1.0.4",
18804+
"const": "1.1.1",
18805+
"default": "1.1.1",
1878218806
"title": "Schema Version",
1878318807
"type": "string"
1878418808
},

schemas/session_schema.json

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27601,6 +27601,21 @@
2760127601
"description": "Light sources for stimulation",
2760227602
"title": "Light source config"
2760327603
},
27604+
"objects_in_arena": {
27605+
"anyOf": [
27606+
{
27607+
"items": {
27608+
"type": "string"
27609+
},
27610+
"type": "array"
27611+
},
27612+
{
27613+
"type": "null"
27614+
}
27615+
],
27616+
"default": null,
27617+
"title": "Objects in arena"
27618+
},
2760427619
"output_parameters": {
2760527620
"$ref": "#/$defs/AindGeneric",
2760627621
"default": {},
@@ -27688,6 +27703,7 @@
2768827703
"description": "Types of stimulus modalities",
2768927704
"enum": [
2769027705
"Auditory",
27706+
"Free moving",
2769127707
"Olfactory",
2769227708
"Optogenetics",
2769327709
"None",
@@ -58914,8 +58930,8 @@
5891458930
"type": "string"
5891558931
},
5891658932
"schema_version": {
58917-
"const": "1.1.1",
58918-
"default": "1.1.1",
58933+
"const": "1.1.2",
58934+
"default": "1.1.2",
5891958935
"title": "Schema Version",
5892058936
"type": "string"
5892158937
},

src/aind_data_schema/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
""" imports for AindModel subclasses
22
"""
33

4-
__version__ = "1.3.0"
4+
__version__ = "1.4.0"

src/aind_data_schema/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import re
55
import logging
6+
import warnings
67
from pathlib import Path
78
from typing import Any, Generic, Optional, TypeVar, get_args
89

@@ -85,10 +86,13 @@ class AindGeneric(BaseModel, extra="allow"):
8586

8687
@model_validator(mode="after")
8788
def validate_fieldnames(self):
88-
"""Ensure that field names do not contain forbidden characters"""
89+
"""Warn users when field names contain forbidden characters
90+
91+
These characters will cause issues with MongoDB queries
92+
"""
8993
model_dict = json.loads(self.model_dump_json(by_alias=True))
9094
if is_dict_corrupt(model_dict):
91-
raise ValueError("Field names cannot contain '.' or '$'")
95+
warnings.warn("MongoDB queries may not work as expected for fields that contain '.' or '$'")
9296
return self
9397

9498

src/aind_data_schema/components/devices.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ class Treadmill(MousePlatform):
777777
device_type: Literal["Treadmill"] = "Treadmill"
778778
treadmill_width: Decimal = Field(..., title="Width of treadmill (mm)")
779779
width_unit: SizeUnit = Field(default=SizeUnit.CM, title="Width unit")
780+
encoder: Optional[Device] = Field(default=None, title="Encoder")
781+
pulse_per_revolution: Optional[int] = Field(default=None, title="Pulse per revolution")
780782

781783

782784
class Arena(MousePlatform):

src/aind_data_schema/core/metadata.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
model_validator,
2222
)
2323

24-
from aind_data_schema.base import AindCoreModel, is_dict_corrupt, AwareDatetimeWithDefault
24+
from aind_data_schema.base import AindCoreModel, AwareDatetimeWithDefault
2525
from aind_data_schema.core.acquisition import Acquisition
2626
from aind_data_schema.core.data_description import DataDescription
2727
from aind_data_schema.core.instrument import Instrument
@@ -72,7 +72,7 @@ class Metadata(AindCoreModel):
7272

7373
_DESCRIBED_BY_URL = AindCoreModel._DESCRIBED_BY_BASE_URL.default + "aind_data_schema/core/metadata.py"
7474
describedBy: str = Field(default=_DESCRIBED_BY_URL, json_schema_extra={"const": _DESCRIBED_BY_URL})
75-
schema_version: SkipValidation[Literal["1.1.2"]] = Field(default="1.1.2")
75+
schema_version: SkipValidation[Literal["1.2.1"]] = Field(default="1.2.1")
7676
id: UUID = Field(
7777
default_factory=uuid4,
7878
alias="_id",
@@ -144,13 +144,11 @@ def validate_core_fields(cls, value, info: ValidationInfo):
144144
field_name = info.field_name
145145
field_class = [f for f in get_args(cls.model_fields[field_name].annotation) if inspect.isclass(f)][0]
146146

147-
# If the input is a json object, we will try to create the field
148147
if isinstance(value, dict):
149148
try:
150-
core_model = field_class.model_validate_json(value)
151-
# If a validation error is raised,
152-
# we will construct the field without validation.
153-
except ValidationError:
149+
core_model = field_class.model_validate(value)
150+
except ValidationError as e:
151+
logging.warning(f"Error in validating {field_name}: {e}")
154152
core_model = field_class.model_construct(**value)
155153
else:
156154
core_model = value
@@ -203,7 +201,8 @@ def validate_metadata(self):
203201
model_contents = model.model_dump()
204202
try:
205203
model_class(**model_contents)
206-
except ValidationError:
204+
except ValidationError as e:
205+
logging.warning(f"Error in {field_name}: {e}")
207206
metadata_status = MetadataStatus.INVALID
208207
# For certain required fields, like subject, if they are not present,
209208
# mark the metadata record as missing
@@ -319,10 +318,7 @@ def create_metadata_json(
319318
core_fields = dict()
320319
for key, value in core_jsons.items():
321320
if key in CORE_FILES and value is not None:
322-
if is_dict_corrupt(value):
323-
logging.warning(f"Provided {key} is corrupt! It will be ignored.")
324-
else:
325-
core_fields[key] = value
321+
core_fields[key] = value
326322
# Create Metadata object and convert to JSON
327323
# If there are any validation errors, still create it
328324
# but set MetadataStatus as Invalid

0 commit comments

Comments
 (0)