coreml: disable auto restart to work around coreml caching bug filling macos disk until reboot

This commit is contained in:
Koushik Dutta
2025-12-09 12:25:31 -08:00
parent aa85e7ec19
commit 2c267f6b26
4 changed files with 15 additions and 4 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@scrypted/coreml",
"version": "0.1.83",
"version": "0.1.84",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@scrypted/coreml",
"version": "0.1.83",
"version": "0.1.84",
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
}

View File

@@ -50,5 +50,5 @@
"devDependencies": {
"@scrypted/sdk": "file:../../sdk"
},
"version": "0.1.83"
"version": "0.1.84"
}

View File

@@ -79,6 +79,10 @@ class CoreMLPlugin(
def __init__(self, nativeId: str | None = None, forked: bool = False):
super().__init__(nativeId=nativeId, forked=forked)
# this used to work but a bug in macos is causing recompilation of the coreml models every time it restarts
# and the cache is not reused and also not cleared until the whole system reboots.
self.periodic_restart = False
self.custom_models = {}
model = self.storage.getItem("model") or "Default"

View File

@@ -59,6 +59,8 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.ClusterForkInterface, scrypted_sd
):
super().__init__(nativeId=nativeId)
self.periodic_restart = True
self.systemDevice = {
"deviceCreator": "Model",
}
@@ -119,7 +121,8 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.ClusterForkInterface, scrypted_sd
return ["motion"]
def requestRestart(self):
asyncio.ensure_future(scrypted_sdk.deviceManager.requestRestart())
if self.periodic_restart:
asyncio.ensure_future(scrypted_sdk.deviceManager.requestRestart())
# width, height, channels
def get_input_details(self) -> Tuple[int, int, int]:
@@ -392,6 +395,10 @@ class PredictPlugin(DetectPlugin, scrypted_sdk.ClusterForkInterface, scrypted_sd
self.forks[cwid] = pf
continue
if self.pluginId not in workers[cwid]['labels']:
print(f"not using cluster worker {workers[cwid]['name']} without label {self.pluginId}")
continue
async def startClusterWorker(clusterWorkerId=cwid):
print("starting cluster worker", clusterWorkerId)
try: