feat: implement timeline#985
Conversation
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #985 +/- ##
==========================================
- Coverage 89.98% 88.50% -1.49%
==========================================
Files 45 47 +2
Lines 10685 10957 +272
==========================================
+ Hits 9615 9697 +82
- Misses 1070 1260 +190 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds timeline support to the inverse simulation API, exposing a toggle and a start time that map to the underlying inverse_mc_simulation_properties.timeline protobuf field.
Changes:
- Added
timelineandstart_timeproperties toSimulationInverse, including enabling/disabling behavior via protobufHasField/ClearField. - Extended inverse simulation tests to cover default behavior, enable/disable, and start-time-driven re-enabling.
- Added a changelog fragment documenting the new capability.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
tests/core/test_simulation.py |
Adds assertions covering timeline defaults and transitions for inverse simulations. |
src/ansys/speos/core/simulation.py |
Implements timeline and start_time properties and wires defaults during inverse simulation initialization. |
src/ansys/speos/core/generic/parameters.py |
Introduces timeline-related parameters for inverse simulations. |
doc/changelog.d/985.added.md |
Documents the new timeline feature. |
| timeline: bool = False | ||
| """whether timeline is enabled""" | ||
| start_time: float = 0.00 | ||
| """timeline start time (s)""" |
There was a problem hiding this comment.
updated to make start_time optional, but retained the boolean field timeline.
|
@ZachDerocher Hi after review we found out that both lightbox timeline and source timeline functionality is not implemented you can find the related properties in the scene instance and source template lightbox is now implemented in main |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
As discussed, I will implement timeline for LB in this feature branch. Timeline support for source will be implemented as a separate feature. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Pengyuan LU <89462462+pluAtAnsys@users.noreply.github.com>
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…speos into feat/implement-timeline
for more information, see https://pre-commit.ci
…speos into feat/implement-timeline
| def timeline(self) -> bool: | ||
| """Switch to enable/disable the simulation timeline. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| State of timeline activation. | ||
| """ | ||
| return self._job.inverse_mc_simulation_properties.HasField("timeline") | ||
|
|
||
| @timeline.setter | ||
| def timeline(self, value: bool) -> None: | ||
| props = self._job.inverse_mc_simulation_properties | ||
|
|
||
| if value: | ||
| if not props.HasField("timeline"): | ||
| timeline = props.timeline | ||
| timeline.start_time = 0.0 | ||
| else: | ||
| props.ClearField("timeline") |
There was a problem hiding this comment.
you are not using the boolean
why can a user set a timeline when the boolean is false -> either use the boolean or not have it
There was a problem hiding this comment.
you could make it read only
There was a problem hiding this comment.
SpeosRPC doesn't have a "timeline" boolean, but the Speos UI does have it. My aim was to mimic the UI functionality, for consistency.
I expect a user to set timeline=True, and then set start_time. For disabling, they can set timeline=False. This behavior mimics the Speos UI.
Alternatively, since the timeline property I created here is just an intermediary, the user can optionally work solely with the start_time property. Setting start_time to any value enables timeline; setting start_time to None disables timeline.
There was a problem hiding this comment.
In SpeosRPC, the "timeline" boolean is the presence or not of the field timeline in the job.
Exactly what you checked for the timeline property getter few lines above.
I think also that the timeline property can be useful for the client to understand that he is activating/deactivating the timeline.
But then, it is important that you check this property when setting the start_time one.
-> Error if the user tries to set start_time and that he didn't previously activated timeline.
| start_time: Optional[float] = None | ||
| """Timeline start time in seconds. Set to ``None`` to disable the simulation timeline.""" |
There was a problem hiding this comment.
| start_time: Optional[float] = None | |
| """Timeline start time in seconds. Set to ``None`` to disable the simulation timeline.""" | |
| start_time: Optional[float] = 0.0 | |
| """Timeline start time in seconds.""" |
I would rather separate notion of start_time, of the one of timeline (de)activation.
It can be weird for the user to set start_time to 0.0 in order to activate the timeline.
Instead, setting the default value to 0.0, will mimic SpaceClaim behavior.
| timeline = props.timeline | ||
| timeline.start_time = 0.0 |
There was a problem hiding this comment.
This is equivalent to:
| timeline = props.timeline | |
| timeline.start_time = 0.0 | |
| props.timeline.start_time = 0.0 |
| def timeline(self) -> bool: | ||
| """Switch to enable/disable the simulation timeline. | ||
|
|
||
| Returns | ||
| ------- | ||
| bool | ||
| State of timeline activation. | ||
| """ | ||
| return self._job.inverse_mc_simulation_properties.HasField("timeline") | ||
|
|
||
| @timeline.setter | ||
| def timeline(self, value: bool) -> None: | ||
| props = self._job.inverse_mc_simulation_properties | ||
|
|
||
| if value: | ||
| if not props.HasField("timeline"): | ||
| timeline = props.timeline | ||
| timeline.start_time = 0.0 | ||
| else: | ||
| props.ClearField("timeline") |
There was a problem hiding this comment.
In SpeosRPC, the "timeline" boolean is the presence or not of the field timeline in the job.
Exactly what you checked for the timeline property getter few lines above.
I think also that the timeline property can be useful for the client to understand that he is activating/deactivating the timeline.
But then, it is important that you check this property when setting the start_time one.
-> Error if the user tries to set start_time and that he didn't previously activated timeline.
|
Would it be interesting to build a specific example notebook for timeline? |
…speos into feat/implement-timeline
for more information, see https://pre-commit.ci
Signed-off-by: pluAtAnsys <pengyuan.lu@ansys.com>
Signed-off-by: pluAtAnsys <pengyuan.lu@ansys.com>
Description
Please provide a brief description of the changes made in this pull request.
Issue linked
Please mention the issue number or describe the problem this pull request addresses.
Checklist
feat: add optical property)