Skip to content

Commit 8a28026

Browse files
committed
temp allow mithril fork
1 parent 6b0cf8b commit 8a28026

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

utilities/earthly-cache-watcher/helper.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ def get_subdirectory_name(working_dir_path: str, path: str):
2727
working_dir_path = os.path.abspath(working_dir_path)
2828
path = os.path.abspath(path)
2929

30-
if (
31-
os.path.commonpath([working_dir_path])
32-
!= os.path.commonpath([working_dir_path, path])
30+
if os.path.commonpath([working_dir_path]) != os.path.commonpath(
31+
[working_dir_path, path]
3332
):
3433
return None
35-
34+
3635
relative_path = os.path.relpath(path, working_dir_path)
3736
parts = relative_path.split(os.sep)
38-
37+
3938
if parts:
4039
return parts[0]
4140
return None
4241

42+
4343
def add_or_init(obj: dict[str, int], key: str, value: int):
4444
obj.setdefault(key, 0)
45-
obj[key] += value
45+
obj[key] += value

utilities/earthly-cache-watcher/main.py

+22-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def list_initial_sizes(self):
9393
self.file_index[file_path] = size
9494
helper.add_or_init(self.layer_index, layer_name, size)
9595

96-
logger.debug(f"initial file: {file_path} (size: {size:,} bytes)")
96+
logger.debug(
97+
f"initial file: {file_path} (size: {size:,} bytes)"
98+
)
9799
except OSError as e:
98100
if log_file_accessing_err:
99101
logger.error(f"{e}: {file_path}")
@@ -225,11 +227,15 @@ def check_sizes(self, layer_name: str, skip_sum_check=False):
225227

226228
if (
227229
not skip_sum_check
228-
and sum(self.layer_growth_index.values()) >= max_time_window_growth_size
230+
and sum(self.layer_growth_index.values())
231+
>= max_time_window_growth_size
229232
):
230233
self.trigger_interval_growth_exceeded()
231234

232-
if not skip_sum_check and sum(self.layer_index.values()) >= max_cache_size:
235+
if (
236+
not skip_sum_check
237+
and sum(self.layer_index.values()) >= max_cache_size
238+
):
233239
self.trigger_max_cache_size()
234240

235241
def trigger_layer_size_exceeded(self, layer_name: str):
@@ -323,7 +329,13 @@ def drop(self):
323329

324330

325331
def main():
326-
global watch_dir, large_layer_size, max_cache_size, time_window, max_time_window_growth_size, log_file_accessing_err
332+
global \
333+
watch_dir, \
334+
large_layer_size, \
335+
max_cache_size, \
336+
time_window, \
337+
max_time_window_growth_size, \
338+
log_file_accessing_err
327339

328340
default_config_path = sys.argv[1] if len(sys.argv) > 1 else "default.conf"
329341

@@ -336,7 +348,9 @@ def main():
336348
log_file_accessing_err = True
337349

338350
if os.path.isfile(default_config_path):
339-
logger.info(f"read config from {os.path.abspath(default_config_path)!r}")
351+
logger.info(
352+
f"read config from {os.path.abspath(default_config_path)!r}"
353+
)
340354

341355
cfg = dotenv_values(default_config_path)
342356

@@ -362,7 +376,9 @@ def main():
362376
)
363377
)
364378
logger.info(
365-
" ".join(["with `log_file_accessing_err` set to", log_file_accessing_err])
379+
" ".join(
380+
["with `log_file_accessing_err` set to", log_file_accessing_err]
381+
)
366382
)
367383

368384
# init watcher

0 commit comments

Comments
 (0)