-
Notifications
You must be signed in to change notification settings - Fork 2
CU-869ahw0mw: Add argument to control data flow when saving results. #144
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
mart-r
merged 10 commits into
main
from
feat/medcat/CU-869ahw0mw-allow-mp-to-realise-iterator
Sep 24, 2025
Merged
CU-869ahw0mw: Add argument to control data flow when saving results. #144
mart-r
merged 10 commits into
main
from
feat/medcat/CU-869ahw0mw-allow-mp-to-realise-iterator
Sep 24, 2025
Conversation
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
When is provided, the user (probably) expects the data to be saved on disk upon method call. But the current implementation forced the user to iterate over the results to force the annotation to actually happen. So this change allows the method to materialise the list internally to force the annotation to happen and results to be saved on disk. Additionally, it adds 2 other options: 1. The lazy iteration (what happens when no is provided) where the iteration of data is left to the user 2. The combined / saved and return option where the results are materialised, but also yielded. Notably, this will take up a lot of memory if/when used with large data sets
The previous implementation would always consider the method a generator. And as such, the work would never be done at call time, regardless of whether or not the was provided. This commit fixes that by making the wrapper method a regular method that (sometimes) returns the iterator and other times just a (potentially empty) list.
alhendrickson
approved these changes
Sep 23, 2025
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.
lgtm
alhendrickson
approved these changes
Sep 24, 2025
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.
lgtm, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When is provided, the user (probably) expects the data to be saved on disk upon method call. But the current implementation forced the user to iterate over the results to force the annotation to actually happen.
So this change allows the method to materialise the list internally to force the annotation to happen and results to be saved on disk. Additionally, it adds 2 other options:The lazy iteration (what happens when no is provided) where the iteration of data is left to the userThe combined / saved and return option where the results are materialised, but also yielded. Notably, this will take up a lot of memory if/when used with large data setsInstead of the above, the current version of the PR introduces a new method:
CAT.save_entities_multi_texts
that:a) requires a
save_dir_path
b) always saves data on disk
c) never returns anything
The save + return option is still (kind of) available with
get_entities_multi_texts
, but it still requires manual iteration over the result.This appraoch separates this concern into a separate method and makes the
get_entities_multi_texts
method less complex.