Added a Setting to set the Model Download Folder - #1557
Conversation
Signed-off-by: Alexander Ratajczak <a4blue@hotmail.de>
b782a1e to
796d972
Compare
There was a problem hiding this comment.
Pull request overview
Adds a configurable model download location and migrates existing models.
Changes:
- Adds model-path settings and admin UI.
- Updates model downloading and status checks.
- Adds an upgrade repair step for existing models.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
src/components/ViewAdmin.vue |
Adds model-path controls and status. |
package-lock.json |
Updates package version metadata. |
lib/Settings/AdminSettings.php |
Provides model-path status. |
lib/Service/SettingsService.php |
Defines and resolves the path setting. |
lib/Service/DownloadModelsService.php |
Downloads models to the configured location. |
lib/Migration/MoveDefaultModelFolder.php |
Migrates existing model files. |
appinfo/info.xml |
Registers the migration step. |
馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| $targetPath = $this->settingsService->getSetting('models_target_path'); | ||
| $modelPath = $targetPath . '/models'; |
| $archivePath = $targetPath . '/models.tar.gz'; | ||
| $timeout = $this->isCLI ? 0 : 480; | ||
| $this->clientService->newClient()->get($archiveUrl, ['sink' => $archivePath, 'timeout' => $timeout]); |
| $modelsPath = __DIR__ . '/../../models'; | ||
| $modelsDownloaded = file_exists($modelsPath); | ||
| $targetPath = $this->settingsService->getSetting('models_target_path'); | ||
| $modelsDownloaded = file_exists($targetPath .' /models'); |
| foreach ($filesToMove as $file) { | ||
| rename($file, $newModelTargetPath.'/'.basename($file)); |
| <post-migration> | ||
| <step>OCA\Recognize\Migration\InstallDeps</step> | ||
| </post-migration> | ||
| <post-migration> | ||
| <step>OCA\Recognize\Migration\MoveDefaultModelFolder</step> | ||
| </post-migration> |
| } | ||
|
|
||
| const SETTINGS = ['tensorflow.cores', 'tensorflow.gpu', 'tensorflow.purejs', 'imagenet.enabled', 'landmarks.enabled', 'faces.enabled', 'musicnn.enabled', 'movinet.enabled', 'node_binary', 'ffmpeg_binary', 'faces.status', 'imagenet.status', 'landmarks.status', 'movinet.status', 'musicnn.status', 'faces.lastFile', 'imagenet.lastFile', 'landmarks.lastFile', 'movinet.lastFile', 'musicnn.lastFile', 'faces.batchSize', 'imagenet.batchSize', 'landmarks.batchSize', 'movinet.batchSize', 'musicnn.batchSize', 'clusterFaces.status', 'clusterFaces.lastRun', 'nice_binary', 'nice_value', 'concurrency.enabled', 'taskprocessing.enabled'] | ||
| const SETTINGS = ['tensorflow.cores', 'tensorflow.gpu', 'tensorflow.purejs', 'imagenet.enabled', 'landmarks.enabled', 'faces.enabled', 'musicnn.enabled', 'movinet.enabled', 'node_binary', 'ffmpeg_binary', 'faces.status', 'imagenet.status', 'landmarks.status', 'movinet.status', 'musicnn.status', 'faces.lastFile', 'imagenet.lastFile', 'landmarks.lastFile', 'movinet.lastFile', 'musicnn.lastFile', 'faces.batchSize', 'imagenet.batchSize', 'landmarks.batchSize', 'movinet.batchSize', 'musicnn.batchSize', 'clusterFaces.status', 'clusterFaces.lastRun', 'nice_binary', 'nice_value', 'concurrency.enabled', 'taskprocessing.enabled', 'models_target_path', 'models_archive_file'] |
There was a problem hiding this comment.
Removing is probably not what we want though. We should add it to SettingsService
| private function isPathAbsolute(string $path): bool { | ||
| if ($path === '') { | ||
| return false; | ||
| } | ||
| if ($path[0] === '/') { | ||
| return true; | ||
| } | ||
|
|
||
| return false; |
|
|
||
| if (is_dir($oldModelTargetPath)) { | ||
| $filesToMove = scandir($oldModelTargetPath); | ||
| $filesToMove = array_filter($filesToMove, fn ($value) => $value !== '.' && $value === '..'); |
| $filesToMove = scandir($oldModelTargetPath); | ||
| $filesToMove = array_filter($filesToMove, fn ($value) => $value !== '.' && $value === '..'); | ||
| $filesToMove = array_map(fn ($value) => $oldModelTargetPath.'/'.$value, $filesToMove); | ||
| mkdir($newModelTargetPath); |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
This should fix #1160
In order to be compatible with existing users i added a repair step to move the old Files to the new Location
馃 AI (if applicable)