@@ -52,10 +52,6 @@ def _get_normalized_folder_name(path: Path) -> str:
5252 return f"{ path } " .replace ("/" , "_" )
5353
5454
55- def _have_common_entries (a : set [str ], b : set [str ]) -> bool :
56- return bool (len (a & b ) > 0 )
57-
58-
5955@dataclass
6056class DiskUsageMonitor :
6157 app : FastAPI
@@ -124,11 +120,11 @@ def _replace_incoming_usage(
124120
125121 @staticmethod
126122 def _get_grouped_usage_to_folder_names (
127- normalized_disk_usage : dict [str , DiskUsage ]
123+ local_disk_usage : dict [str , DiskUsage ]
128124 ) -> dict [DiskUsage , set [str ]]:
129125 """Groups all paths that have the same metrics together"""
130126 usage_to_folder_names : dict [DiskUsage , set [str ]] = {}
131- for folder_name , disk_usage in normalized_disk_usage .items ():
127+ for folder_name , disk_usage in local_disk_usage .items ():
132128 if disk_usage not in usage_to_folder_names :
133129 usage_to_folder_names [disk_usage ] = set ()
134130
@@ -170,18 +166,12 @@ async def _monitor(self) -> None:
170166 msg = f"Could not assign { disk_usage = } for { folder_names = } "
171167 raise RuntimeError (msg )
172168
173- detected_items = set (usage .keys ())
174- if not detected_items .issubset (_SUPPORTED_ITEMS ):
175- msg = (
176- f"Computed { usage = } , has unsupported items { detected_items = } . "
177- f"Currently only the following are supported: { _SUPPORTED_ITEMS } "
178- )
179- raise RuntimeError (msg )
169+ supported_usage = {k : v for k , v in usage .items () if k in _SUPPORTED_ITEMS }
180170
181171 # notify only when usage changes
182- if self ._last_usage != usage :
183- await self ._publish_disk_usage (usage )
184- self ._last_usage = usage
172+ if self ._last_usage != supported_usage :
173+ await self ._publish_disk_usage (supported_usage )
174+ self ._last_usage = supported_usage
185175
186176 async def setup (self ) -> None :
187177 self ._monitor_task = start_periodic_task (
0 commit comments