Skip to content

Commit

Permalink
change "entity_type" back to "type"
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Jun 1, 2024
1 parent 4dbb738 commit f89354d
Show file tree
Hide file tree
Showing 29 changed files with 234 additions and 253 deletions.
4 changes: 2 additions & 2 deletions src/ibek/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def lookup_instance(cls, id):

# add the type literal which discriminates between the different Entity classes
typ = Literal[full_name] # type: ignore
args["entity_type"] = (typ, Field(description=definition.description))
args["type"] = (typ, Field(description=definition.description))

class_name = full_name.replace(".", "_")
entity_cls = create_model(
Expand Down Expand Up @@ -187,7 +187,7 @@ def resolve_sub_entities(self, entities: List[Entity]) -> List[Entity]:
# add in SubEntities if any
for sub_entity in definition.sub_entities:
# find the Entity Class that the SubEntity represents
entity_cls = self._entity_models[sub_entity.entity_type]
entity_cls = self._entity_models[sub_entity.type]
# get the SubEntity arguments
sub_args_dict = sub_entity.model_dump()
# jinja render any references to parent Args in the SubEntity Args
Expand Down
2 changes: 1 addition & 1 deletion src/ibek/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Entity(BaseSettings):
A baseclass for all generated Entity classes.
"""

entity_type: str = Field(description="The type of this entity")
type: str = Field(description="The type of this entity")
entity_enabled: bool = Field(
description="enable or disable this entity instance", default=True
)
Expand Down
2 changes: 1 addition & 1 deletion src/ibek/ioc_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def make_ioc_model(self, entity_models: List[Type[Entity]]) -> Type[IOC]:
"""

entity_union = Union[tuple(entity_models)] # type: ignore
discriminated = Annotated[entity_union, Field(discriminator="entity_type")] # type: ignore
discriminated = Annotated[entity_union, Field(discriminator="type")] # type: ignore

class NewIOC(IOC):
entities: Sequence[discriminated] = Field( # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion src/ibek/sub_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SubEntity(BaseModel, extra="allow"):
section
"""

entity_type: str = Field(description="The type of this entity")
type: str = Field(description="The type of this entity")

entity_enabled: bool = Field(
description="enable or disable this entity instance", default=True
Expand Down
4 changes: 2 additions & 2 deletions tests/samples/iocs/bad_counter.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ioc_name: counter
description: an example motion ioc for ibek testing

entities:
- entity_type: epics.InterruptVectorVME
- type: epics.InterruptVectorVME
name: Vec0
- entity_type: epics.InterruptVectorVME2
- type: epics.InterruptVectorVME2
name: Vec1
8 changes: 4 additions & 4 deletions tests/samples/iocs/bad_counter2.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ ioc_name: counter
description: an example motion ioc for ibek testing

entities:
- entity_type: epics.InterruptVectorVME2
- type: epics.InterruptVectorVME2
name: Vec1
- entity_type: epics.InterruptVectorVME2
- type: epics.InterruptVectorVME2
name: Vec2
- entity_type: epics.InterruptVectorVME2
- type: epics.InterruptVectorVME2
name: Vec3
- entity_type: epics.InterruptVectorVME2
- type: epics.InterruptVectorVME2
name: Vec4
2 changes: 1 addition & 1 deletion tests/samples/iocs/bad_db.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ ioc_name: test-bad-db-ioc
description: demo bad database definition

entities:
- entity_type: object_module.RefObject
- type: object_module.RefObject
name: Ref1
2 changes: 1 addition & 1 deletion tests/samples/iocs/bad_default.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ description: an example for testing missing non-default values

entities:
# deliberately do not specify port to test failure case
- entity_type: asyn.AsynIP
- type: asyn.AsynIP
name: controllerOnePort
4 changes: 2 additions & 2 deletions tests/samples/iocs/bad_ref.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ ioc_name: test-multiple-ioc
description: demo bad object reference

entities:
- entity_type: asyn.AsynIP
- type: asyn.AsynIP
name: controllerOnePort
port: 192.168.0.55:2002

- entity_type: motorSim.simMotorController
- type: motorSim.simMotorController
port: controllerOnePort_BAD_REF
controllerName: controllerOne
numAxes: 4
Expand Down
12 changes: 6 additions & 6 deletions tests/samples/iocs/gauges.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ ioc_name: "{{ ioc_yaml_file_name }}"
description: Example of initialising a gauge group with defaults to gauge1

entities:
- entity_type: asyn.AsynIP
- type: asyn.AsynIP
name: controllerOnePort
port: 192.168.0.55:2002

- entity_type: asyn.AsynIP
- type: asyn.AsynIP
name: controllerTwoPort
port: 192.168.0.55:2002

- entity_type: gauges.Mks937bGauge
- type: gauges.Mks937bGauge
port: controllerOnePort
name: MyGauge1
P: "IBEK-VA-GAUGE-01:"

- entity_type: gauges.Mks937bGauge
- type: gauges.Mks937bGauge
port: controllerTwoPort
name: MyGauge2
P: "IBEK-VA-GAUGE-02:"

# an un-referenced Gauge
- entity_type: gauges.Mks937bGauge
- type: gauges.Mks937bGauge
port: controllerTwoPort
name: MyGauge3
P: "IBEK-VA-GAUGE-03:"

- entity_type: gauges.GaugeGroup
- type: gauges.GaugeGroup
name: MyGaugeGroup
gauge1: MyGauge1
gauge2: MyGauge2
8 changes: 4 additions & 4 deletions tests/samples/iocs/ipac-test.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ ioc_name: ipac-test
description: example IOC with IPAC modules

entities:
- entity_type: epics.InterruptVectorVME
- type: epics.InterruptVectorVME
name: Vec1
- entity_type: epics.InterruptVectorVME
- type: epics.InterruptVectorVME
name: Vec2

- entity_type: ipac.Hy8002
- type: ipac.Hy8002
slot: 4
interrupt_vector: Vec1

- entity_type: ipac.Hy8002
- type: ipac.Hy8002
slot: 5
interrupt_vector: Vec2
4 changes: 2 additions & 2 deletions tests/samples/iocs/listarg.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ioc_name: counter
description: an example motion ioc for ibek testing

entities:
- entity_type: listtest.lister
- type: listtest.lister
friends: ["Rimmer", "Holly", "Cat", "Kryten"]

- entity_type: listtest.lister
- type: listtest.lister
friends: |-
{{ ["Rimmer"] + ["tt"] | list }}
16 changes: 8 additions & 8 deletions tests/samples/iocs/motorSim.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ ioc_name: "{{ ioc_yaml_file_name }}"
description: Example simulated motion IOC for Testing ibek

entities:
- entity_type: asyn.AsynIP
- type: asyn.AsynIP
name: controllerOnePort
port: 192.168.0.55:2002

- entity_type: motorSim.simMotorController
- type: motorSim.simMotorController
port: controllerOnePort
controllerName: controllerOne
numAxes: 4
P: "IBEK-MO-TST-01:"

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
# Use ADDR in other fields to verify jinja templating between Args
M: M{{ADDR}}
Expand All @@ -23,29 +23,29 @@ entities:
DESC: "Motor {{ADDR}} for ioc {{ioc_name}}"
home: 500

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 1
# verify escaping for jinja templating
DESC: "Motor {{ADDR}} {% raw %} {{enclosed in escaped curly braces}} {% endraw %}"
home: 500

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 2
# testing default DESC
home: 1500

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
M: M{{ADDR}}
ADDR: 3
DESC: "Motor {{ADDR}}"
home: 2500

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
M: CS_M{{ADDR}}
ADDR: 1
Expand All @@ -54,7 +54,7 @@ entities:
CS_NUM: 3
is_cs: true

- entity_type: motorSim.simMotorAxis
- type: motorSim.simMotorAxis
controller: controllerOne
M: CS_M{{ADDR}}
ADDR: 2
Expand Down
4 changes: 2 additions & 2 deletions tests/samples/iocs/quadem.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ ioc_name: "{{ __utils__.get_env('IOC_NAME') }}"
description: Example TetrAMM for BL03I

entities:
- entity_type: quadEM.TetrAMM
- type: quadEM.TetrAMM
PORT: XBPM1.DRV
P: BL03I-EA-XBPM-01
R: ":DRV:"
QSIZE: 20
IP: "172.23.103.85:10001"

- entity_type: quadEM.Plugins
- type: quadEM.Plugins
DEVICE: XBPM1.DRV
PORTPREFIX: XBPM1
STAT_NCHAN: 1000
Expand Down
4 changes: 2 additions & 2 deletions tests/samples/iocs/technosoft.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: YAG motors

shared:
- &motor
entity_type: motorTML.motorAxis
type: motorTML.motorAxis
controller: TML
NSTEPS: 200
NMICROSTEPS: 256
Expand All @@ -25,7 +25,7 @@ shared:
TIMEOUT: 0

entities:
- entity_type: motorTML.CreateController
- type: motorTML.CreateController
controllerName: TML
P: "SPARC:TML"
TTY: /tmp # /var/tmp/ttyV0
Expand Down
2 changes: 1 addition & 1 deletion tests/samples/iocs/utils.ibek.ioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ ioc_name: counter
description: an example motion ioc for ibek testing

entities:
- entity_type: epics.InterruptVectorVME
- type: epics.InterruptVectorVME
name: Vec0
20 changes: 10 additions & 10 deletions tests/samples/schemas/gauges.ibek.ioc.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"asyn_AsynIP": {
"additionalProperties": false,
"properties": {
"entity_type": {
"type": {
"const": "asyn.AsynIP",
"description": "Asyn IP Port",
"title": "Entity Type"
"title": "Type"
},
"entity_enabled": {
"default": true,
Expand Down Expand Up @@ -147,7 +147,7 @@
}
},
"required": [
"entity_type",
"type",
"port",
"name"
],
Expand Down Expand Up @@ -183,10 +183,10 @@
"gauges_GaugeGroup": {
"additionalProperties": false,
"properties": {
"entity_type": {
"type": {
"const": "gauges.GaugeGroup",
"description": "Group of gauges",
"title": "Entity Type"
"title": "Type"
},
"entity_enabled": {
"default": true,
Expand Down Expand Up @@ -220,7 +220,7 @@
}
},
"required": [
"entity_type",
"type",
"name",
"gauge1"
],
Expand All @@ -230,10 +230,10 @@
"gauges_Mks937bGauge": {
"additionalProperties": false,
"properties": {
"entity_type": {
"type": {
"const": "gauges.Mks937bGauge",
"description": "MKS 937b Gauge controller",
"title": "Entity Type"
"title": "Type"
},
"entity_enabled": {
"default": true,
Expand All @@ -257,7 +257,7 @@
}
},
"required": [
"entity_type",
"type",
"port",
"name",
"P"
Expand Down Expand Up @@ -304,7 +304,7 @@
"gauges.GaugeGroup": "#/$defs/gauges_GaugeGroup",
"gauges.Mks937bGauge": "#/$defs/gauges_Mks937bGauge"
},
"propertyName": "entity_type"
"propertyName": "type"
},
"oneOf": [
{
Expand Down
6 changes: 3 additions & 3 deletions tests/samples/schemas/ibek.support.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@
"additionalProperties": true,
"description": "A loosely defined class to declare the Entities\nin an ibek.support.yaml file in the 'sub_entities' property of an Entity\nsection",
"properties": {
"entity_type": {
"type": {
"description": "The type of this entity",
"title": "Entity Type",
"title": "Type",
"type": "string"
},
"entity_enabled": {
Expand All @@ -638,7 +638,7 @@
}
},
"required": [
"entity_type"
"type"
],
"title": "SubEntity",
"type": "object"
Expand Down
Loading

0 comments on commit f89354d

Please sign in to comment.