-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift 6 Complete Concurrency Checking #85
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #85 +/- ##
=======================================
Coverage 38.57% 38.57%
=======================================
Files 64 64
Lines 2331 2331
=======================================
Hits 899 899
Misses 1432 1432
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jdisho for the PR, great work! 🚀
As you mentioned, it makes sense to wait for the SpeziLLM OpenAI layer to be rewamped, but you can already start tackling the local layer in the meantime.
Also, as mentioned, SpeziSpeech
and SpeziChat
need to be lifted to Swift 6 language mode as well at some point, let me know if you're interested in that!
Edit: Tackled in StanfordSpezi/SpeziSpeech#10 and StanfordSpezi/SpeziChat#20
Package.swift
Outdated
#if swift(<6) | ||
let swiftConcurrency: SwiftSetting = .enableExperimentalFeature("StrictConcurrency") | ||
#else | ||
let swiftConcurrency: SwiftSetting = .enableUpcomingFeature("StrictConcurrency") | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to do that if you just specify // swift-tools-version:6.0
at the top of the file.
See https://github.com/StanfordSpezi/Spezi/blob/main/Package.swift
@philippzagar - Thanks for the input! This is great 🚀 |
Ah, I just saw that you opened the PRs already. |
} | ||
|
||
@MainActor | ||
|
||
private func downloadWithHub() async throws { | ||
let repo = Hub.Repo(id: model.hubID) | ||
let modelFiles = ["*.safetensors", "config.json"] | ||
|
||
try await HubApi.shared.snapshot(from: repo, matching: modelFiles) { progress in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is forcing me to make the whole class @unchecked Sendable
, because we can't pass progress
safely without potentially causing data races. Do you have another idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we don't want to mark the manager Sendable
cause it isn't.
The issue is the double capture of self, once within the snapshot()
callback and once within the Task
.
Did you try something like (rough sketch)
try await HubApi.shared.snapshot(from: repo, matching: modelFiles) { progress in
Task { @MainActor [mutate = self.mutate] in
mutate(progress)
}
}
}
@MainActor private func mutate(progress: Progress) {
self.state = .downloading(progress: progress)
}
Addressing: #54
Swift6 - Complete Concurrency Checking
♻️ Current situation & Problem
Xcode is throwing concurrency warnings for the
SpeziLLM
,SpeziLLMFog
,SpeziLLMLocal
,SpeziLLMLocalDownload
, andSpeziLLMLocalOpenAI
targets because they currently have concurrency concerns.⚙️ Release Notes
SpeziLLM
,SpeziLLMFog
,SpeziLLMLocal
andSpeziLLMLocalDownload
are resolved. For the remaining targets, it would be best to wait until SpeziLLMOpenAI: Replace MacPaw/OpenAI With Generated API Calls #64 is merged.📚 Documentation
No additional changes.
✅ Testing
Warnings will be resolved after #64 is merged.
📝 Code of Conduct & Contributing Guidelines
By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: