Skip to content

Commit

Permalink
WIP: adjustments for bluesky and event_model
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Jan 13, 2025
1 parent 4598584 commit 06ae3fc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .documents.event_descriptor import (
Configuration,
DataKey,
Dtype,
EventDescriptor,
Limits,
LimitsRange,
Expand Down Expand Up @@ -75,6 +76,7 @@
"PartialEvent",
"Configuration",
"DataKey",
"Dtype",
"EventDescriptor",
"Limits",
"LimitsRange",
Expand Down
10 changes: 6 additions & 4 deletions src/event_model/basemodels/event_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from pydantic.config import JsonDict
from typing_extensions import Annotated, Literal

Dtype = Literal["string", "number", "array", "boolean", "integer"]

class Dtype(RootModel):
root: Literal["string", "number", "array", "boolean", "integer"]


NO_DOTS_PATTERN = r"^([^./]+)$"
Expand Down Expand Up @@ -112,7 +114,7 @@ class Limits(BaseModel):
class DataKey(BaseModel):
"""Describes the objects in the data property of Event documents"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="allow")

limits: Annotated[
Limits,
Expand Down Expand Up @@ -199,7 +201,7 @@ class DataKey(BaseModel):
class PerObjectHint(BaseModel):
"""The 'interesting' data keys for this device."""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="allow")

fields: Annotated[
List[str],
Expand All @@ -216,7 +218,7 @@ class PerObjectHint(BaseModel):


class Configuration(BaseModel):
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="allow")
data: Annotated[
Dict[str, Any],
Field(default={}, description="The actual measurement data"),
Expand Down
4 changes: 2 additions & 2 deletions src/event_model/basemodels/run_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def validate_root(cls, value):
class Hints(BaseModel):
"""Start-level hints"""

model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="allow")

dimensions: Annotated[
List[List[Union[List[str], str]]],
Expand All @@ -48,7 +48,7 @@ class Hints(BaseModel):


class Calculation(BaseModel):
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="allow")

args: Annotated[List, Field(default=[])]
callable: Annotated[
Expand Down
5 changes: 4 additions & 1 deletion src/event_model/documents/event_descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
DataType = Any


Dtype = Literal["string", "number", "array", "boolean", "integer"]


class LimitsRange(TypedDict):
high: Optional[float]
low: Optional[float]
Expand Down Expand Up @@ -100,7 +103,7 @@ class DataKey(TypedDict):
"""
The names for dimensions of the data. Null or empty list if scalar data
"""
dtype: Literal["string", "number", "array", "boolean", "integer"]
dtype: Dtype
"""
The type of the data in the event, given as a broad JSON schema type.
"""
Expand Down
27 changes: 15 additions & 12 deletions src/event_model/schemas/event_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"default": {}
}
},
"additionalProperties": false
"additionalProperties": true
},
"DataKey": {
"title": "DataKey",
Expand All @@ -55,16 +55,8 @@
}
},
"dtype": {
"title": "Dtype",
"description": "The type of the data in the event, given as a broad JSON schema type.",
"type": "string",
"enum": [
"string",
"number",
"array",
"boolean",
"integer"
]
"$ref": "#/$defs/Dtype"
},
"dtype_numpy": {
"title": "Dtype Numpy",
Expand Down Expand Up @@ -151,7 +143,7 @@
"shape",
"source"
],
"additionalProperties": false
"additionalProperties": true
},
"DataType": {
"title": "DataType",
Expand All @@ -162,6 +154,17 @@
},
"additionalProperties": false
},
"Dtype": {
"title": "Dtype",
"type": "string",
"enum": [
"string",
"number",
"array",
"boolean",
"integer"
]
},
"Limits": {
"title": "Limits",
"description": "Epics limits:\nsee 3.4.1 https://epics.anl.gov/base/R3-14/12-docs/AppDevGuide/node4.html",
Expand Down Expand Up @@ -298,7 +301,7 @@
}
}
},
"additionalProperties": false
"additionalProperties": true
},
"RdsRange": {
"title": "RdsRange",
Expand Down
4 changes: 2 additions & 2 deletions src/event_model/schemas/run_start.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"required": [
"callable"
],
"additionalProperties": false
"additionalProperties": true
},
"ConfigurationProjection": {
"title": "ConfigurationProjection",
Expand Down Expand Up @@ -148,7 +148,7 @@
}
}
},
"additionalProperties": false
"additionalProperties": true
},
"LinkedEventProjection": {
"title": "LinkedEventProjection",
Expand Down

0 comments on commit 06ae3fc

Please sign in to comment.