DiamondLightSource / DiamondLightSource/httomo
Use `click.IntRange` type to catch integer values < 1 instead of manually checking `max_cpu_slices`
- Dominant language
- Python
- Stars
- 10
- Forks
- 5
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
The `--max-cpu-slices` flag has type `click.INT` which allows for integers < 1: https://github.com/DiamondLightSource/httomo/blob/6af2e2eef2c432f68d474c55de282168af8878b1/httomo/cli.py#L86-L91
However, for the maximum number of CPU slices, a value < 1 doesn't make sense, and thus there is a bit of code manually checking if the given value is < 1: https://github.com/DiamondLightSource/httomo/blob/6af2e2eef2c432f68d474c55de282168af8878b1/httomo/cli.py#L200-L201
Click provides the type [`click.IntRange`](https://click.palletsprojects.com/en/8.1.x/options/#range-options) which allows for specifying a certain range. In particular, it can be used to provide a boundary on one side of the range, and have the other side of the range be unbounded. This would allow clipping the range of the max CPU slices to not be below 1, but still be anything above 1.
A similar case this has been used for already is in the `--frames-per-chunk` flag value, which can't be less than 0, but can be any integer from 0 and above: https://github.com/DiamondLightSource/httomo/blob/6af2e2eef2c432f68d474c55de282168af8878b1/httomo/cli.py#L137-L142
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.