Skip to content

✨ Everything as a second level import #173

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

Merged
merged 4 commits into from
May 15, 2025
Merged

✨ Everything as a second level import #173

merged 4 commits into from
May 15, 2025

Conversation

o-laurent
Copy link
Contributor

@o-laurent o-laurent commented May 14, 2025

To make imports shorter...

I didn't include the baselines since they are bound to be deleted in the short/medium term, if I remember correctly.

@o-laurent o-laurent changed the base branch from main to dev May 14, 2025 15:33
@o-laurent o-laurent requested review from Copilot and alafage and removed request for Copilot May 14, 2025 15:33
@o-laurent o-laurent self-assigned this May 14, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 refactors the package to expose utilities, models, layers, datasets, and datamodules at a second-level import, and consolidates duplicate factory functions into single, parameterized versions.

  • Moved plotting logic out of misc.py into a dedicated plotting module and updated exports.
  • Unified deep_lab_v3_resnet50/101 and bts_resnet50/101 into deep_lab_v3_resnet and bts_resnet with an arch parameter.
  • Replaced wildcard imports across __init__.py files with explicit second-level exports for shorter import paths.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
torch_uncertainty/utils/misc.py Removed plotting imports and plot_hist (moved to plotting.py).
torch_uncertainty/utils/init.py Added plot_hist and show from new plotting module.
torch_uncertainty/transforms/init.py Re-exported corruption transforms for direct imports.
torch_uncertainty/models/segmentation/deeplab.py Merged two deep_lab_v3_resnet* functions into one with arch.
torch_uncertainty/models/segmentation/init.py Exposed deep_lab_v3_resnet at package level.
torch_uncertainty/models/depth/bts.py Merged bts_resnet50/101 into bts_resnet with arch.
torch_uncertainty/models/depth/init.py Exposed bts_resnet at package level.
torch_uncertainty/models/classification/wideresnet/init.py Replaced wildcards with explicit exports.
torch_uncertainty/models/classification/vgg/init.py Replaced wildcards with explicit exports.
torch_uncertainty/models/classification/resnet/init.py Replaced wildcards with explicit exports.
torch_uncertainty/models/classification/init.py Consolidated all model exports explicitly.
torch_uncertainty/models/init.py Added unified model factories to top-level exports.
torch_uncertainty/layers/init.py Re-exported new distribution layers for second-level import.
torch_uncertainty/datasets/init.py Re-exported classification, regression, segmentation datasets.
torch_uncertainty/datamodules/classification/init.py Added UCIClassificationDataModule.
torch_uncertainty/datamodules/init.py Added MUADDataModule alongside existing modules.
torch_uncertainty/baselines/segmentation/deeplab.py Updated DeepLabBaseline to call the new factory.
tests/models/test_deeplab.py Updated tests to exercise deep_lab_v3_resnet.
tests/baselines/test_standard.py Removed obsolete error test for legacy version handling.
Comments suppressed due to low confidence (3)

torch_uncertainty/models/classification/resnet/init.py:2

  • Missing re-exports for mimo_resnet, packed_resnet, and resnet, which are referenced by the top-level classification package. Consider adding:
from .mimo import mimo_resnet
from .packed import packed_resnet
from .std import resnet
from .batched import batched_resnet

torch_uncertainty/baselines/segmentation/deeplab.py:18

  • The version parameter is no longer used after consolidating to a single factory call. Consider removing this argument to simplify the constructor signature.
version: Literal["std"],

torch_uncertainty/models/depth/bts.py:579

  • The new bts_resnet function is not covered by existing tests. Add unit tests to verify correct behavior for supported arch values (50, 101) and expected errors for unsupported inputs.
def bts_resnet(

@o-laurent o-laurent linked an issue May 14, 2025 that may be closed by this pull request
Copy link

codecov bot commented May 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.09%. Comparing base (eff9313) to head (99574e1).
Report is 3 commits behind head on dev.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #173      +/-   ##
==========================================
- Coverage   98.13%   96.09%   -2.04%     
==========================================
  Files         153      156       +3     
  Lines        7863     8073     +210     
  Branches     1034     1049      +15     
==========================================
+ Hits         7716     7758      +42     
- Misses         91      259     +168     
  Partials       56       56              
Flag Coverage Δ
pytest 96.09% <100.00%> (-2.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alafage
Copy link
Contributor

alafage commented May 15, 2025

Thanks @o-laurent! Indeed, the baselines will be removed for better clarity and to simplify things.

@o-laurent o-laurent merged commit 14bcbba into dev May 15, 2025
3 checks passed
@o-laurent o-laurent deleted the inits branch May 15, 2025 23:18
@o-laurent o-laurent mentioned this pull request May 15, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🔧 Enable direct imports
2 participants