abderrahim commented on code in PR #1950:
URL: https://github.com/apache/buildstream/pull/1950#discussion_r1738345904


##########
src/buildstream/_context.py:
##########
@@ -185,6 +185,12 @@ def __init__(self, *, use_casd: bool = True) -> None:
         # User specified cache quota, used for display messages
         self.config_cache_quota_string: Optional[str] = None
 
+        # Reserved disk space for local cache in bytes
+        self.config_cache_reserved: Optional[int] = None
+
+        # Low watermark for local cache in bytes

Review Comment:
   this is not "in bytes"



##########
src/buildstream/utils.py:
##########
@@ -832,6 +832,35 @@ def _parse_size(size, volume):
     return int(num) * 1024 ** units.index(unit)
 
 
+# _parse_percentage():
+#
+# Convert a string representing a percentage between 0% and 100% to a float.
+# E.g. "80%" -> 0.8.
+#
+# Arguments:
+#     percentage (str) The string to parse
+#
+# Returns:
+#     (float) The percentage as a float
+#
+# Raises:
+#     UtilError if the string is not a valid percentage.
+#
+def _parse_percentage(percentage):
+    if not percentage.endswith("%"):
+        raise UtilError("{} is not a valid percentage.".format(percentage))
+
+    try:
+        num = int(percentage[:-1])

Review Comment:
   It seems `_parse_size()` accepts a float as a percentage value. Maybe we 
should here too for consistency.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to