-
Notifications
You must be signed in to change notification settings - Fork 868
chore(imports): reduce startup time #3257
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: feature/geti-inspect
Are you sure you want to change the base?
chore(imports): reduce startup time #3257
Conversation
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
This PR reduces application startup time from ~13s to ~7s by optimizing imports and dependency management. The main approach is to move heavy imports (torch, lightning.pytorch, numpy, anomalib) into TYPE_CHECKING blocks to defer their loading until runtime when needed, and switching from anomalib[full] to anomalib[openvino] with tensorboard to reduce unnecessary dependencies.
Changes:
- Moved heavy imports into TYPE_CHECKING blocks across multiple files
- Switched from anomalib[full] to anomalib[openvino] + tensorboard in pyproject.toml
- Fixed max_epochs handling to properly handle None values from UI
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| application/backend/pyproject.toml | Changed dependency from anomalib[full] to anomalib[openvino] + tensorboard to reduce startup overhead |
| application/backend/src/services/training_service.py | Fixed max_epochs to handle None values from UI using walrus operator |
| application/backend/src/services/dispatchers/*.py | Moved numpy and anomalib imports to TYPE_CHECKING blocks, updated copyright years |
| src/anomalib/deploy/inferencers/*.py | Moved imports to TYPE_CHECKING blocks and removed string quotes from type hints |
| src/anomalib/data/datamodules/base/image.py | Moved imports to TYPE_CHECKING and changed to more specific lightning import path |
| src/anomalib/data/dataclasses/generic.py | Moved Iterator and Callable imports to TYPE_CHECKING block |
| application/backend/src/entities/stream_data.py | Moved numpy and anomalib imports to TYPE_CHECKING block, updated copyright |
| application/backend/src/pydantic_models/model.py | Added blank line after copyright header |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Ashwin Vaidya <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from anomalib.data import NumpyImageBatch as PredictionResult | ||
|
|
||
|
|
||
| def numpy_to_base64(image: np.ndarray, fmt: str = ".jpg") -> str: |
Copilot
AI
Jan 13, 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.
The function uses np.ndarray as a type annotation but numpy is now only imported in the TYPE_CHECKING block. This will cause a NameError at runtime. Either import numpy unconditionally or use a string literal for the type annotation: image: 'np.ndarray'.
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/geti-inspect.yaml:1
- The copyright year includes 2026, which is in the future. The current date is January 13, 2026, so the copyright should only include years up to 2026 if work was actually done in 2026. If this work was completed in 2025, the copyright should remain as 2025 only.
name: Geti Inspect UI checks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Ashwin Vaidya <[email protected]>
Signed-off-by: Ashwin Vaidya <[email protected]>
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.
Pull request overview
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| snapshot_id = UUID(snapshot_id_) if snapshot_id_ else None | ||
| max_epochs = job.payload.get("max_epochs", 200) | ||
|
|
||
| snapshot_id = UUID(snapshot_id_str) if (snapshot_id_str := job.payload.get("dataset_snapshot_id")) else None |
Copilot
AI
Jan 13, 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.
The variable name 'snapshot_id_str' is ambiguous. Consider renaming it to 'dataset_snapshot_id_str' to better reflect that it comes from the dataset_snapshot_id payload field.
| snapshot_id = UUID(snapshot_id_str) if (snapshot_id_str := job.payload.get("dataset_snapshot_id")) else None | |
| snapshot_id = UUID(dataset_snapshot_id_str) if (dataset_snapshot_id_str := job.payload.get("dataset_snapshot_id")) else None |
📝 Description
13s to7s.To test
✨ Changes
Select what type of change your PR is:
✅ Checklist
Before you submit your pull request, please make sure you have completed the following steps:
For more information about code review checklists, see the Code Review Checklist.