- Notifications
You must be signed in to change notification settings - Fork130
Replace usage of Bundle.module to build outside SPM context#125
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
Very cool, thanks for showing how to do it! 🔥
Apologies for the delay in reviewing, it was a 🦙 week.
I'll check what's happening with the CI.
@@ -202,7 +202,8 @@ public class LanguageModelConfigurationFromHub { | |||
} | |||
static func fallbackTokenizerConfig(for modelType: String) -> Config? { | |||
guard let url = Bundle.module.url(forResource: "\(modelType)_tokenizer_config", withExtension: "json") else { return nil } | |||
let bundle = Bundle(for: self) |
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.
We could fix the tests doing something like:
letbundle=Bundle(for:self) | |
letbundle=NSClassFromString("XCTest")!=nil?Bundle.module:Bundle(for:self) |
But upon additional testing I found that building a CLI that usesTokenizers
would not find the fallback configuration either.
Do you have any thoughts on that? Some additional ideas:
- Iterate through the bundles and select the right one.
- Create a bundle (or framework?) solely dedicated to hosting the resources.
- Download the fallback configs from a well-known location in the Hub.
Replacing
Bundle.module
withBundle(for: self)
to accommodate building transformers outside SPM context.