feat: core implementation irrad sensor v2 - #1102
Conversation
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Signed-off-by: Stefan Thoene <sthoene@synopsys.com>
Co-authored-by: Elodie Chamblas <100407563+echambla@users.noreply.github.com>
Co-authored-by: Elodie Chamblas <100407563+echambla@users.noreply.github.com>
Signed-off-by: pluAtAnsys <pengyuan@synopsys.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/sensor-template-migration #1102 +/- ##
==================================================================
- Coverage 89.10% 88.83% -0.27%
==================================================================
Files 47 48 +1
Lines 11631 11729 +98
==================================================================
+ Hits 10364 10420 +56
- Misses 1267 1309 +42 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| """ | ||
| if not cls._supports_template_v2: | ||
| return False | ||
| return server_version_checker.is_version_supported(*cls._SENSOR_TEMPLATE_V2_MIN_VERSION) |
There was a problem hiding this comment.
It seems _SENSOR_TEMPLATE_V2_MIN_VERSION is not used somewhere else.
Maybe use here directly (2027, 1, 0)
And remove _SENSOR_TEMPLATE_V2_MIN_VERSION declaration
| self._sensor_template_version = ( | ||
| 2 if isinstance(self.sensor_template_link, SensorTemplateLinkV2) else 1 | ||
| ) | ||
| self._sensor_template = self._new_sensor_template(name, description, metadata) |
There was a problem hiding this comment.
I think this line is useless.
Usually the _sensor_template and _sensor_instance are filled thanks to the reset() call just after
(see comment)
| return ProtoSensorTemplate(name=name, description=description, metadata=metadata) | ||
|
|
||
| @property | ||
| def sensor_template_version(self) -> int: |
There was a problem hiding this comment.
Is a public property useful here?
As the sensor template version is something we want to hide from core user.
There was a problem hiding this comment.
I agree, that can be internal property
| ---------- | ||
| wavelengths_range : ansys.api.speos.sensor.v1.common_pb2.WavelengthsRange | ||
| wavelengths_range : Union[\ | ||
| ansys.api.speos.sensor.v1.common_pb2.WavelengthsRange, \ |
There was a problem hiding this comment.
Missing ansys.api.speos.sensor.v1.sensor_pb2.SensorTemplate.Irradiance3D.TypeColorimetric
There was a problem hiding this comment.
Missing sensor_v2_pb2.SensorTemplate.WavelengthsRange
| self.sensor_template_link = self._project.client.sensor_templates().create( | ||
| message=self._sensor_template | ||
| ) | ||
| if self._sensor_template_version == 2: |
There was a problem hiding this comment.
I am doubting if we really need self._sensor_template_version
Because instead we can just check type of self._sensor_template
Avoiding information redundancy is a way to avoid discrepancies.
| ansys.api.speos.sensor.v2.sensor_pb2.SensorTemplate.Irradiance] | ||
| Protobuf sub-message holding the irradiance sensor template definition. | ||
| """ | ||
| if self._sensor_template_version == 2: |
There was a problem hiding this comment.
instead can check type of self._sensor_template
so that we can get rid of self._sensor_template_version
| str | ||
| Name of the protobuf field for the sensor template version in use. | ||
| """ | ||
| if self._sensor_template_version == 2: |
There was a problem hiding this comment.
instead can check type of self._sensor_template
so that we can get rid of self._sensor_template_version
| One of ``"planar"``, ``"radial"``, ``"hemispherical"``, ``"cylindrical"``, | ||
| ``"semi_cylindrical"``. | ||
| """ | ||
| if self._sensor_template_version == 2: |
There was a problem hiding this comment.
instead can check type of self._sensor_template
so that we can get rid of self._sensor_template_version
| bool | ||
| ``True`` if the integration type is the one currently set. | ||
| """ | ||
| if self._sensor_template_version == 2: |
There was a problem hiding this comment.
instead can check type of self._sensor_template
so that we can get rid of self._sensor_template_version
Description
Update SensorIrradiance in sensor.py to transparently dispatch to sensor template v1 or v2 protobuf fields based on the connected Speos server version, without any change to the user-facing API.
Issue linked
Migrate SensorIrradiance to support sensor template v1 and v2
#1089
Checklist
feat: add optical property)