build: trim default runtime dependencies - #76
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR trims BatDetect2’s default runtime dependency set (notably removing Lightning’s extra bundle and moving TensorBoard to an opt-in group) while also applying small typing-related adjustments in plotting and Parquet output loading.
Changes:
- Switch
lightning[extra]tolightningand remove some default runtime dependencies; add explicit runtime deps liketqdm. - Add a
tensorboarddependency group instead of installing TensorBoard by default. - Adjust plotting and Parquet code paths to resolve typing/tooling issues.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/batdetect2/plotting/heatmaps.py |
Uses plt.get_cmap for colormap resolution and updates imports accordingly. |
src/batdetect2/plotting/detections.py |
Adds inline type ignores for Patch(..., linestyle=...) calls. |
src/batdetect2/outputs/formats/parquet.py |
Adds TypedDict for clip info and annotates predictions_by_clip for improved typing. |
pyproject.toml |
Trims default deps (Lightning extras, netcdf4, tensorboard) and adds dependency group(s) + new runtime deps. |
Suppressed comments (4)
src/batdetect2/outputs/formats/parquet.py:133
predictions_by_clipis annotated asdict[UUID, ClipInfo], butclip_uuidis read from the DataFrame as a string and used as the dict key. This makes the type annotation incorrect and can also break ifrow["clip_uuid"]ever comes through as aUUID(sinceUUID(clip_uuid)would then raise). Convert to aUUIDonce and use it consistently for both the dict key and theClip.uuid.
predictions_by_clip: dict[UUID, ClipInfo] = {}
for _, row in df.iterrows():
clip_uuid = row["clip_uuid"]
if clip_uuid not in predictions_by_clip:
src/batdetect2/plotting/detections.py:194
- Prefer a targeted
# type: ignore[...]code instead of a blanket# type: ignoreto avoid silencing unrelated type errors on this line.
linestyle=missed_gt_linestyle, # type: ignore
src/batdetect2/plotting/detections.py:200
- Prefer a targeted
# type: ignore[...]code instead of a blanket# type: ignoreto avoid silencing unrelated type errors on this line.
linestyle=true_pred_linestyle, # type: ignore
src/batdetect2/plotting/detections.py:206
- Prefer a targeted
# type: ignore[...]code instead of a blanket# type: ignoreto avoid silencing unrelated type errors on this line.
linestyle=false_pred_linestyle, # type: ignore
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| edgecolor=gt_color, | ||
| facecolor="none" if not fill else gt_color, | ||
| linestyle=gt_linestyle, | ||
| linestyle=gt_linestyle, # type: ignore |
Comment on lines
24
to
+29
| "soundevent[audio,geometry,plot]>=2.10.0", | ||
| "soundfile>=0.12.1", | ||
| "tensorboard>=2.16.2", | ||
| "tabulate>=0.10.0", | ||
| "torch>=2.0.0", | ||
| "torchaudio>=2.0.0", | ||
| "tqdm>=4.70.0", |
Comment on lines
89
to
92
| "pytest-xdist[psutil]>=3.8.0", | ||
| ] | ||
| tensorboard = ["tensorboard>=2.16.2"] | ||
| dvclive = ["dvclive>=3.48.2"] |
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.
Summary
lightning[extra]with plainlightningnetcdf4and defaulttensorboardfrom runtime dependencieshydra-core,tabulate, andtqdmuv.lockRationale
The default install was pulling in Lightning's broad
extradependency bundle, including packages that are not required by BatDetect2's default runtime paths. This keeps the base package install leaner while preserving explicit dependencies for packages the code imports directly.Verification
uv lock --check