Add submodule for tools#226
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a small utility API in zospy.functions to manage OpticStudio “Tools” via a Python context manager, ensuring that tools are closed after use and optionally closing any already-open tool beforehand.
Changes:
- Added
zospy.functions.tools.open_tool()context manager for opening/closing OpticStudio tools safely. - Exposed the new
toolssubmodule viazospy.functions.__init__. - Added a dedicated test suite for
open_toolbehavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
zospy/functions/tools.py |
Adds the open_tool context manager for safe tool lifecycle management. |
zospy/functions/__init__.py |
Exposes the new tools functions submodule in the public zospy.functions API. |
tests/functions/test_tools.py |
Adds tests covering tool opening, closing, and exception-handling behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crnh
marked this pull request as draft
June 5, 2026 11:53
Member
Author
|
@jwmbeenakker @andibarg following the discussion in #225, I extended this PR with a wrapper class for tools. @andibarg you can check the |
crnh
marked this pull request as ready for review
June 15, 2026 19:03
jwmbeenakker
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Adds
zospy.toolswith base functionality and wrappers for tools.1. Context manager for opening tools:
This context manager does 2 things:
close_currentis true) or otherwise raises an exception.withblock.2. New tool wrapper class
BaseToolWrapperclass with functionality similar toBaseAnalysisWrapper, but for tools.Example for the Quick Focus tool:
For now, I chose to reuse the
analysis_settingsdecorator because settings for tools and analyses behave the same.Type of change
Additional information
Related issues
Checklist
hatch test -a).If you updated an example:
hatch run all-examples).If you contributed an example: