Commit Graph
10 Commits
Author SHA1 Message Date
Sheikh Bayazid e8a12e04c2 Improve/use shorthand syntax for unwrapping optionals and fix typos (#12369) 2024-05-03 08:50:20 -07:00
Maksym Malyhin 0341e9ccfd ML model downloader fixes (#7515)
* listDownloadedModels: don't cross-check URLs

* Store models in a subfolder.

* Test completion and progress handlers being called on the main thread.

* More tests for callbacks on the main queue.

* Fix public API handlers to be called on the main queue.

* .gitignore ML GoogleService-Info.plist files

* style

* getModel: fail fast when modelName is empty string
2021-02-11 19:42:11 -05:00
manjanac 9597ffe51b Removes saved path on device (#7439)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Add tests for list models.

* Failable emptying of model directory in tests.

* Remove path from local model info and user defaults.

* Clean up user defaults on delete + add interpreter to test app.

* Replace .absoluteString with .path. This makes model.path work directly with TFLite interpreter.

* Fix paths in tests.

* Unit test for successful get model.

* Rename modelPath to modelURL.

* Use defaults.integer instead of casting to Int.

* Remove force casting.

* Mostly minor fixes that came out of the bugbash (#7462)

* Use appropriate errors for network offline and api disabled.

* Error + test for resourceExhausted.

* Surface backend error message in logs whenever available.

* Add disclaimer to empty directories for testing only.

* Add Firelog events for model info retrieval.

* Add documentation + other minor fixes. (#7465)

* Add docs + clean up ModelDownloader.swift.

* Add docs + clean up ModelDownloadTask.swift.

* Add docs + clean up FileDownloader.swift.

* Add docs + clean up LocalModelInfo.swift. Handle TODO for userdefaults init failure.

* Add docs + clean up RemoteModelInfo.swift, DownloaderUserDefaults.swift.

* Add docs + clean up ModelInfoRetriever.swift.

* Add docs + clean up ModelDownloadConditions.swift.

* Add docs + clean up DeviceLogger.swift.

* Add docs + clean up TelemetryLogger.swift.

* Add docs + clean up ModelFileManager.swift.

* Remove resolved TODOs + other minor fixes.

* Update model download conditions init.

* Fix comment formatting.

* Minor newline formatting.

* Minor comment formatting.

* Add docs for ModelDownloadConditions.

* Basic fix for user defaults race condition.

* Minor updates to tests.

* Minor updates to tests.

* Final fixes (#7471)

* Refactor error parsing in model info response.

* Add Firelog for delete event + minor fixes.

* Temporary - test to check telemetry for delete event.

* Disable backup of model files; handle inability to locate model storage dir.

* Minor fixes.

* Add tflite path extension to model file.
2021-02-10 09:47:07 -08:00
manjanac c64ca06431 More on-device logging and better error handling. (#7397)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Add new error type for expired url + fix tests.

* On-device logging + updates to tests.

* Add new error type for expired url + fix tests.

* On-device logging + updates to tests.

* Revert to enum for ModelFileManager.swift

* Remove GoogleService-Info.plist

* Remove GoogleService-Info.plist

* Improve errors, tests, on-device logging.

* Add device compatibility to check for available space.

* Use CocoaError to check for space constraints.
2021-01-28 13:11:31 -08:00
manjanac 2c4c19be42 Logging on-device + Firelog (#7386)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Add new error type for expired url + fix tests.

* On-device logging + updates to tests.

* Add new error type for expired url + fix tests.

* On-device logging + updates to tests.

* Revert to enum for ModelFileManager.swift

* Remove GoogleService-Info.plist

* Remove GoogleService-Info.plist
2021-01-27 13:22:05 -08:00
manjanac e6fa9d42c1 Downloader protocol + tests (#7352)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Add mocks for better unit tests - WIP.

* Remove duplicate proto files.

* Download task protocol + tests.

* Rename protocol file.

* Import foundation.

* Rename to authTokenProvider.

* Rename to authTokenProvider.

* Consolidate handlers for download task.

* Merge #7355.

* Clean up unit tests + add test for successful download retry.

* Add TODO to refactor retry download + add test.

* TODO to handle failed precondition.
2021-01-22 18:28:17 -08:00
manjanac d7950ddbe4 Separate error messages into extensions (#7322)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Update error handling.

* Add logging for background download failure.

* Remove empty file.

* Slight refactor of error descriptions + using ISO8601DateFormatter where available.

* Slight refactor error descriptions + adding availability for ISO8601DateFormatter.
2021-01-19 14:28:20 -08:00
manjanac f6e61e36c1 Logical checkpoint of ModelDownloader implementation (#7259)
* Restores ML Pods after M77.

* Fix Package.swift

* Re-add catalyst to GHA workflow.

* Includes the implementation of: 1) download types, 2) list models, 3) delete model.

* Add protocol to handle writing to user defaults.

* Add protocol to handle writing to user defaults.

* Add empty init to ModelDownloadConditions.

* Copyright year + other minor fixes.

* TODO to use FirebaseApp internal init for test app.

* Test if download progress is in range.

* Remove not nil test for progress.

* Remove not nil test for progress.
2021-01-07 14:54:12 -08:00
manjanac 1a1a91a225 Refactor modelInfo into localModelInfo and remoteModelInfo (#7163)
* Restores ML Pods after M77.

* Fix Package.swift

* Refactor model info to be in-memory.

* Add improved model download functionality w/ single set of download handlers per task.

* Rename model download to better match URLSessionTask.

* Rename model download to better match URLSessionTask.

* Update unit test to read/write to user defaults.

* Configure downloader with Firebase app.

* Minor updates to model downloader and tests.

* Singleton for model downloader instance, for default and custom app.

* Download types WIP - local model.

* Download types WIP.

* Manually add app lifecycle handling + TODOs for Firebase Components.

* Replace options with app name as a property in ModelDownloader.

* Download types WIP.

* Refactor model info.

* Add convenience inits + other minor fixes.

* Explicit enum for model info result.
2021-01-06 12:04:47 -08:00
manjanac dbdefc5163 Refactoring model download functionality. (#7068)
* Restores ML Pods after M77.

* Fix Package.swift

* Refactor model info to be in-memory.

* Add improved model download functionality w/ single set of download handlers per task.

* Rename model download to better match URLSessionTask.

* Rename model download to better match URLSessionTask.

* Update unit test to read/write to user defaults.

* Minor updates to model downloader and tests.

* Use caches directory for model storage on tvOS.

* Change modelInfo to be privately settable.
2020-12-04 15:57:16 -08:00