Fix: Store price calculations on small file #706
Merged
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.
For store message we used a
SizedVolumewho havesize_mib: int.for file of example 14 bytes when it will be converted to mib it's will be really small number and it's will be be round at
0Self proofreading checklist
Changes
This pull request focuses on improving the precision of volume size calculations by changing the type of
size_mibfrominttoDecimalacross various functions and classes in thealephcodebase. Additionally, it includes related updates to tests to ensure the new type is handled correctly.Changes to improve precision:
src/aleph/services/cost.py: Updated multiple functions (_get_volumes_costs,_get_execution_volumes_costs,_calculate_storage_costs) to convert volume sizes toDecimalfor more accurate calculations. [1] [2] [3] [4] [5]Type change in class definition:
src/aleph/types/cost.py: Modified theSizedVolumeclass to useDecimalforsize_mibinstead ofint.Updates to tests:
tests/message_processing/test_process_stores.py: AddedDecimalimport and updated tests to check the newDecimaltype for volume sizes. Included a new test to assert the cost calculation using theDecimaltype. [1] [2] [3]