-
Notifications
You must be signed in to change notification settings - Fork 137
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
Setting for number format in archive tab #1719
Conversation
I added the |
Thank you. I changed the typo in setting tooltip, and have begun work writing tests. |
Hey, I'm the one who made the single unit pr in the first place, sorry for replying so late. I'm glad you jumped in and made the setting yourself, it's a good idea. I also propose to improve my algorithm so if someone want to have a single size unit, and there are big differences like in your case, the smallest sizes could be rounded to zero, maybe with a symbol that indicates It's probably difficult to come up with a configuration that satisfy everybody, so let's talk about it and if we find a good fit i can do the change myself. |
I really like your idea here. The question that comes to my mind is what the threshold would be for something to be considered 'near 0' and what approach to take to implement this? |
I added the tests for the archive units setting, pretty_bytes_dynamic_units, and the pyqt signal that connects the setting to a refresh of the archive tab. Additionally, I renamed @real-yfprojects @m3nu I am eager to hear your thoughts, and what I can do to get this ready to review for merge. |
Looks good when quickly looking over it. I do think the challenge here is more human than technical. So let's also ping @hariseldon78 who first added the feature in Feb. |
He is already part of the discussion: #1719 (comment) |
@hariseldon78 FWIW I left your code largely unchanged, with only a rename of the pretty_bytes method. My aim with this PR was narrow - add back the old pretty_bytes method from v8.10 and offer users a setting to decided which format is best for them. I am eager to hear your thoughts! |
FWIW I approve completely adding a setting, I always appreciate configurability in a software. I'm not sure which methods should be set as default at installation, I leave that to your sensibility. As for the improvement of my algorithm at the moment I don't have the possibility of putting much time in it, but if anybody have ideas on the matter I'm happy to discuss it here or on another issue, just ping me! Looking at my archive list at the moment it is shown in MB, just because 2 on 20 archives are smaller than 100 MB... All the others are at least near a GB or in one case (the first backup) as big as 150 GB, making it hard, at a glance, to see if we are talking 1.5 TB or 150 GB. So it's definitely not perfect, maybe adding the thousands separation could help, but then you need to deal with localization formats because everyone have different ideas about how big numbers should be written... |
Qt might provide methods for that. However I would prefer discussing this in a separate issue. |
@real-yfprojects Thank you for the feedback on this setting. I have addressed each of your concerns with the most recent commits, tested the setting locally, and everything appears to work as intended. |
src/vorta/utils.py
Outdated
def pretty_bytes_dynamic_units(size, metric=True, sign=False, precision=1): | ||
if not isinstance(size, int): | ||
return '' | ||
prefix = '+' if sign and size > 0 else '' | ||
power, units = (10**3, METRIC_UNITS) if metric else (2**10, NONMETRIC_UNITS) | ||
n = find_best_unit_for_size(size, metric=metric, precision=precision) | ||
size /= power**n | ||
try: | ||
unit = units[n] | ||
return f'{prefix}{round(size, precision)} {unit}B' | ||
except KeyError as e: | ||
logger.error(e) | ||
return "NaN" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you changed this method to use find_best_unit_for_size
it does exactly the same as pretty_bytest_fixed_units
when passing fixed_unit=None
. Consequently we only need the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just combined these two into one pretty_bytes()
function, and rewrote the tests to ensure functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, went through the files affected by previous (and now reverted) pretty_bytes
name change and set them back to their original state.
@real-yfprojects Please let me know if anything else is stopping this from being merged 👍 |
Some merge conflicts. |
Fixed merge conflicts, reduced superfluous code in |
Works well and solves the problem we had after adding this feature. 👏 I do think we can do better on the tooltip and label. Here my suggestion: Label: "Use the same unit of measurement for archive sizes" Also pinging @hariseldon78 for his 5 cents. |
'tooltip': trans_late( | ||
'settings', | ||
'When enabled, all archive sizes will use the same unit of measurement, ' | ||
'such as KB or MB. This can make archive sizes easier to compare.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the word "compare" instead of "read", since that might to be closer to the original intention of the setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that!
Thanks for the work, @bigtedde ! Very nice addition. |
I think the text is good and i'm sorry i had to abandon this feature to its destiny, work is increasing costantly and filling all the spare time... Thanks for taking care of improving it! |
Description
Fixes #1713
I am introducing a setting in the Misc tab that allows the user to decide if they want archive sizes in the archive tab to be displayed in a fixed or dynamic number format.
Right now this change adds a setting in the Misc tab, and when the setting is changed it emits a pyqt signal to call
populate_from_profile
in theArchiveTab
, which checks the setting and displays the archive size in a fixed or dynamic number format accordingly. Here is a short demo:Related Issue
#1595
#1598
#1692
Motivation and Context
#1713
How Has This Been Tested?
Added unit test to ensure the setting updates the archive table units as expected. Test locally, and passes all GitHub CI checks.
Types of changes
Checklist:
I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.