async def get_fs_usage(self) -> FSUsage: loop = asyncio.get_running_loop() stat = await loop.run_in_executor(None, os.statvfs, self.mount_path) return FSUsage( capacity_bytes=BinarySize(stat.f_frsize * stat.f_blocks), used_bytes=BinarySize(stat.f_frsize * (stat.f_blocks - stat.f_bavail)), )
async def delete_vfolder(self, vfid: UUID) -> None: async with FileLock(LOCK_FILE): await self.registry.read_project_info() if vfid in self.registry.name_id_map.keys(): try: log.info("removing project quota (f:{})", vfid) await self.set_quota(vfid, BinarySize(0)) except (asyncio.CancelledError, asyncio.TimeoutError) as e: log.exception("vfolder deletion timeout", exc_info=e) pass # Pass to delete the physical directlry anyway. except Exception as e: log.exception("vfolder deletion error", exc_info=e) pass # Pass to delete the physical directlry anyway. finally: await self.registry.remove_project_entry(vfid) await super().delete_vfolder(vfid) await self.registry.read_project_info()
async def get_attached_devices( self, device_alloc: Mapping[SlotName, Mapping[DeviceId, Decimal]], ) -> Sequence[DeviceModelInfo]: device_ids: List[DeviceId] = [] if SlotName('cuda.devices') in device_alloc: device_ids.extend(device_alloc[SlotName('cuda.devices')].keys()) available_devices = await self.list_devices() attached_devices: List[DeviceModelInfo] = [] for device in available_devices: if device.device_id in device_ids: proc = device.processing_units mem = BinarySize(device.memory_size) attached_devices.append({ # TODO: update common.types.DeviceModelInfo 'device_id': device.device_id, 'model_name': device.model_name, 'smp': proc, 'mem': mem, }) return attached_devices