-
Notifications
You must be signed in to change notification settings - Fork 2
Explicitly specify an empty HF cache during testing of offline load #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a380ee8
Explicitly specify an empty HF cache during testing of offline load
mart-r de7d8fb
Delay the exiting from context managers to allow for async network ca…
mart-r 677cfd4
[DEBUG] Add debug output to check stuff happening in workflow
mart-r 00c289d
Add explicit assertion for BertModel.from_pretrained call
mart-r c8f36d1
[DEBUG] Add mode debug output to check stuff happening in workflow
mart-r 99b88b1
[DEBUG] Add mode debug output to check stuff happening in workflow (a…
mart-r 15011ff
[DEBUG] Add usage of MetaCAT object after load to make sure it works
mart-r 529cc10
Add assertion for Meta Annotation data
mart-r 387a735
[DEBUG] Add more debug output regarding from_pretrained and network c…
mart-r 1f06a62
Update model variant before saving so as to force network call
mart-r cebd9b2
Revert "[DEBUG] Add more debug output regarding from_pretrained and n…
mart-r 6f0c306
Revert "[DEBUG] Add mode debug output to check stuff happening in wor…
mart-r 54fd41b
Revert "[DEBUG] Add mode debug output to check stuff happening in wor…
mart-r 3b5f0ea
Revert "[DEBUG] Add debug output to check stuff happening in workflow"
mart-r 246698e
Revert "Delay the exiting from context managers to allow for async ne…
mart-r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ok I'm officially out of my depth here it feels like
Forces the from_pretrained method to use force_download=True during the test
Yep I get this one
Asserts that a network call is attempted (but refused)
Yep I see the assert for sure
But when do you actually expect it to call "transformers.BertModel.from_pretrained " inside the code next?
I just see serialize to dill then deserialize, but the deserialize doesnt call
from_pretrained
, at least not in itself...My gut is feeling like it should do something like "mc = deserialize(...); now do something with mc which calls from_pretrained", if this is anything like java/c# serialization anyway - like the saved file is just the object state, loading it back wont trigger a constructor or anything
But anyway - I'm sure there's a magic line that's likely to be found by people that know what they're doing :D
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.
Forgot to press send on the above...
Looking at the new lines around the wait for async - I'd hope there's some function like "do something on mc, that waits until its ready internally". Feels like there should be some way to use the deserialise funciton and rely on the asyc calls having finished, else anyone using this (not in a test) would be equally stuck.
Would always want to avoid the waits as it implies an underlying design issue, esp if we can fix it inside the library itself.
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.
Within deserialisation it'll get to
MetaCATAddon.load_existing
. Which in turn callsMetaCATAddon.load
method. And that deserialises the underlying object. Which then should call theMetaCAT.__init__
. And that callsMetaCAT.get_model
, which (in case of Bert-based MetaCAT like here) initsBertForMetaAnnotation
. And that finally callsBertModel.from_pretrained
.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.
The thing is, this is built on a custom serialisation that is designed to tirgger the init. The trivial implementation of
pickle
'ing stuff would indeed avoid the calls to__init__
. But we don't really want that since:pickle
ing would preserve the state of the class as well - not just its attributes)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.
I'm pretty sure this is an async issue because (when testing locally) the network call is done from the same process, but on a different thread.
Now, this isn't anything we've designed, it's something on
transformers
side. I don't know this for certain, but my best guess is that they will wait for completion if/when the bit that's being downloaded is needed. Because - like you said - otherwise people would fail to use a model they've initialised / loaded.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.
Can we then call something on mc? Basically assert it works, not just that is the right class
Feels like:
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.
That's certainly a good idea!
I can have it run through a document and that should work if my assumption about the lazy loading from above is correct.
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.
Added something to workflow that runs through a document and an entity.
But it still fails.
So clearly it's actually getting the model from somewhere. And it does so without doing a network call (at least not in the way I'm guarding against).