Skip to content

Move UNITS registry out of tmt.hardware - #5192

Open
HarshRajSinghania wants to merge 2 commits into
teemtee:mainfrom
HarshRajSinghania:move-units-registry
Open

HarshRajSinghania wants to merge 2 commits into
teemtee:mainfrom
HarshRajSinghania:move-units-registry

Conversation

@HarshRajSinghania

Copy link
Copy Markdown

Summary

Move the shared Pint UnitRegistry (UNITS) from tmt.hardware.constraints to a dedicated tmt.utils.units module so non-hardware code can convert quantities without importing tmt.hardware.

Motivation

Fixes #5171. The registry started in hardware constraints because it was only used for memory/disk sizes. It is now also used for log size limits, directory sizes, and similar values that are not hardware requirements.

Implementation

  • Add tmt/utils/units.py with UNITS (and the Size type alias under TYPE_CHECKING).
  • Import UNITS from there in tmt.hardware.constraints.
  • Keep tmt.hardware.UNITS as a re-export so existing hardware/provision call sites keep working.
  • Point non-hardware call sites at tmt.utils.units:
    • tmt.utils.normalize_data_amount
    • tmt.base.core
    • tmt.steps.report.reportportal
    • tests/unit/test_data_size_validation.py

Provision plugins (testcloud, bootc) still use tmt.hardware.UNITS; that remains valid because they already depend on hardware helpers.

Testing

Could not run the full tmt suite in this environment (project extras such as fmf are not installed here). Changes are import-path only; tmt.hardware.UNITS is the same registry object.

Suggested checks:

pytest tests/unit/test_data_size_validation.py tests/unit/test_hardware.py

Harsh Raj Singhania added 2 commits September 23, 2026 15:07
Relocate the shared Pint UnitRegistry to tmt.utils.units so
non-hardware code does not need to import tmt.hardware. Keep
tmt.hardware.UNITS as a compatibility re-export.

Fixes teemtee#5171

This branch has not been deployed

No deployments
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.

Move UNITS registry out of tmt.hardware

1 participant