-
Notifications
You must be signed in to change notification settings - Fork 0
feat: expose neuroglancer python exports via __all__ for public API #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,109 +14,63 @@ | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| from . import ( # noqa: I001 | ||||||||||||||||||||||||||||||||||||||||||
| segment_colors, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| server, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| skeleton, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| segment_colors, | ||||||||||||||||||||||||||||||||||||||||||
| server, | ||||||||||||||||||||||||||||||||||||||||||
| skeleton, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| from .default_credentials_manager import set_boss_token # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .equivalence_map import EquivalenceMap # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .local_volume import LocalVolume # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .screenshot import ScreenshotSaver # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .default_credentials_manager import set_boss_token | ||||||||||||||||||||||||||||||||||||||||||
| from .equivalence_map import EquivalenceMap | ||||||||||||||||||||||||||||||||||||||||||
| from .local_volume import LocalVolume | ||||||||||||||||||||||||||||||||||||||||||
| from .screenshot import ScreenshotSaver | ||||||||||||||||||||||||||||||||||||||||||
| from .server import ( | ||||||||||||||||||||||||||||||||||||||||||
| is_server_running, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| set_server_bind_address, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| set_static_content_source, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| set_dev_server_content_source, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| stop, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| from .url_state import parse_url, to_json_dump, to_url # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .viewer import UnsynchronizedViewer, Viewer # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| from .viewer_config_state import ( | ||||||||||||||||||||||||||||||||||||||||||
| PrefetchState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ScaleBarOptions, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| from .viewer_state import ( | ||||||||||||||||||||||||||||||||||||||||||
| SegmentIdMapEntry, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerSelectedValues, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerSelectionState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CoordinateSpace, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| DimensionScale, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CoordinateArray, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| Tool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PlacePointTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PlaceLineTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PlaceBoundingBoxTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PlaceEllipsoidTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PlacePolylineTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| BlendTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| OpacityTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| VolumeRenderingTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| VolumeRenderingGainTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| VolumeRenderingDepthSamplesTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CrossSectionRenderScaleTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SelectedAlphaTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| NotSelectedAlphaTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ObjectAlphaTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| HideSegmentZeroTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| HoverHighlightTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| BaseSegmentColoringTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| IgnoreNullVisibleSetTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ColorSeedTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SegmentDefaultColorTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| MeshRenderScaleTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| MeshSilhouetteRenderingTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SaturationTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SkeletonRenderingMode2dTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SkeletonRenderingMode3dTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SkeletonRenderingLineWidth2dTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SkeletonRenderingLineWidth3dTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ShaderControlTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| MergeSegmentsTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SplitSegmentsTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SelectSegmentsTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| DimensionTool, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SidePanelLocation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SelectedLayerState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| StatisticsDisplayState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerSidePanelState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerListPanelState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| HelpPanelState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| DimensionPlaybackVelocity, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| Layer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PointAnnotationLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CoordinateSpaceTransform, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerDataSubsource, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerDataSource, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerDataSources, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| InvlerpParameters, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| TransferFunctionParameters, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ImageLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SkeletonRenderingOptions, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| StarredSegments, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| VisibleSegments, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SegmentationLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| SingleMeshLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| Annotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PointAnnotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LineAnnotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| PolyLineAnnotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| AxisAlignedBoundingBoxAnnotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| EllipsoidAnnotation, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| AnnotationPropertySpec, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| AnnotationLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LocalAnnotationLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ManagedLayer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| Layers, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LinkedPosition, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LinkedZoomFactor, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LinkedDepthRange, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LinkedOrientationState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CrossSection, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| CrossSectionMap, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| DataPanelLayout, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| StackLayout, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| row_layout, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| column_layout, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| LayerGroupViewer, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| ViewerState, # noqa: F401 | ||||||||||||||||||||||||||||||||||||||||||
| is_server_running, | ||||||||||||||||||||||||||||||||||||||||||
| set_server_bind_address, | ||||||||||||||||||||||||||||||||||||||||||
| set_static_content_source, | ||||||||||||||||||||||||||||||||||||||||||
| set_dev_server_content_source, | ||||||||||||||||||||||||||||||||||||||||||
| stop, | ||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||
| from .url_state import parse_url, to_json_dump, to_url | ||||||||||||||||||||||||||||||||||||||||||
| from .viewer import UnsynchronizedViewer, Viewer | ||||||||||||||||||||||||||||||||||||||||||
| from . import viewer_config_state | ||||||||||||||||||||||||||||||||||||||||||
| from . import viewer_state | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| __all__ = [ | ||||||||||||||||||||||||||||||||||||||||||
| # Submodules | ||||||||||||||||||||||||||||||||||||||||||
| "segment_colors", | ||||||||||||||||||||||||||||||||||||||||||
| "server", | ||||||||||||||||||||||||||||||||||||||||||
| "skeleton", | ||||||||||||||||||||||||||||||||||||||||||
| # From default_credentials_manager | ||||||||||||||||||||||||||||||||||||||||||
| "set_boss_token", | ||||||||||||||||||||||||||||||||||||||||||
| # From equivalence_map | ||||||||||||||||||||||||||||||||||||||||||
| "EquivalenceMap", | ||||||||||||||||||||||||||||||||||||||||||
| # From local_volume | ||||||||||||||||||||||||||||||||||||||||||
| "LocalVolume", | ||||||||||||||||||||||||||||||||||||||||||
| # From screenshot | ||||||||||||||||||||||||||||||||||||||||||
| "ScreenshotSaver", | ||||||||||||||||||||||||||||||||||||||||||
| # From server | ||||||||||||||||||||||||||||||||||||||||||
| "is_server_running", | ||||||||||||||||||||||||||||||||||||||||||
| "set_server_bind_address", | ||||||||||||||||||||||||||||||||||||||||||
| "set_static_content_source", | ||||||||||||||||||||||||||||||||||||||||||
| "set_dev_server_content_source", | ||||||||||||||||||||||||||||||||||||||||||
| "stop", | ||||||||||||||||||||||||||||||||||||||||||
| # From url_state | ||||||||||||||||||||||||||||||||||||||||||
| "parse_url", | ||||||||||||||||||||||||||||||||||||||||||
| "to_json_dump", | ||||||||||||||||||||||||||||||||||||||||||
| "to_url", | ||||||||||||||||||||||||||||||||||||||||||
| # From viewer | ||||||||||||||||||||||||||||||||||||||||||
| "UnsynchronizedViewer", | ||||||||||||||||||||||||||||||||||||||||||
| "Viewer", | ||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Add exports from viewer_config_state and viewer_state | ||||||||||||||||||||||||||||||||||||||||||
| __all__ += viewer_config_state.__all__ | ||||||||||||||||||||||||||||||||||||||||||
| __all__ += viewer_state.__all__ | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+67
|
||||||||||||||||||||||||||||||||||||||||||
| __all__ += viewer_config_state.__all__ | |
| __all__ += viewer_state.__all__ | |
| for _name in viewer_config_state.__all__: | |
| if _name not in __all__: | |
| __all__.append(_name) | |
| for _name in viewer_state.__all__: | |
| if _name not in __all__: | |
| __all__.append(_name) |
Copilot
AI
Mar 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__getattr__ will re-resolve the same symbols on every access and those names won’t appear in dir(neuroglancer). Consider caching the resolved attribute into globals() before returning, and adding a __dir__ that includes the forwarded exports, to improve performance and introspection behavior.
| return getattr(viewer_config_state, name) | |
| if name in viewer_state.__all__: | |
| return getattr(viewer_state, name) | |
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | |
| value = getattr(viewer_config_state, name) | |
| globals()[name] = value | |
| return value | |
| if name in viewer_state.__all__: | |
| value = getattr(viewer_state, name) | |
| globals()[name] = value | |
| return value | |
| raise AttributeError(f"module {__name__!r} has no attribute {name!r}") | |
| def __dir__(): | |
| """ | |
| Return the list of attributes available on the neuroglancer module, | |
| including forwarded exports from viewer_config_state and viewer_state. | |
| """ | |
| return sorted(set(globals().keys()) | set(__all__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports are now only used for re-exporting, but Ruff has
F(pyflakes) enabled and will flag them as unused (F401) because they aren’t referenced in this module. Add# noqa: F401for the intended re-exports (or a file-level# ruff: noqa: F401) so linting doesn’t fail.