-
Notifications
You must be signed in to change notification settings - Fork 103
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
Cu 1yn0v9e duplicate multiprocessing methods #364
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1327,6 +1327,7 @@ def _save_docs_to_file(self, docs: Iterable, annotated_ids: List[str], save_dir_ | |
pickle.dump((annotated_ids, part_counter), open(annotated_ids_path, 'wb')) | ||
return part_counter | ||
|
||
@deprecated(message="Use `multiprocessing_batch_char_size` instead") | ||
def multiprocessing(self, | ||
data: Union[List[Tuple], Iterable[Tuple]], | ||
nproc: int = 2, | ||
|
@@ -1337,9 +1338,31 @@ def multiprocessing(self, | |
out_split_size_chars: Optional[int] = None, | ||
save_dir_path: str = os.path.abspath(os.getcwd()), | ||
min_free_memory=0.1) -> Dict: | ||
return self.multiprocessing_batch_char_size(data=data, nproc=nproc, | ||
batch_size_chars=batch_size_chars, | ||
only_cui=only_cui, addl_info=addl_info, | ||
separate_nn_components=separate_nn_components, | ||
out_split_size_chars=out_split_size_chars, | ||
save_dir_path=save_dir_path, | ||
min_free_memory=min_free_memory) | ||
|
||
def multiprocessing_batch_char_size(self, | ||
data: Union[List[Tuple], Iterable[Tuple]], | ||
nproc: int = 2, | ||
batch_size_chars: int = 5000 * 1000, | ||
only_cui: bool = False, | ||
addl_info: List[str] = [], | ||
separate_nn_components: bool = True, | ||
out_split_size_chars: Optional[int] = None, | ||
save_dir_path: str = os.path.abspath(os.getcwd()), | ||
min_free_memory=0.1) -> Dict: | ||
r"""Run multiprocessing for inference, if out_save_path and out_split_size_chars is used this will also continue annotating | ||
documents if something is saved in that directory. | ||
|
||
This method batches the data based on the number of characters as specified by user. | ||
|
||
PS: This method is unlikely to work on a Windows machine. | ||
|
||
Args: | ||
data: | ||
Iterator or array with format: [(id, text), (id, text), ...] | ||
|
@@ -1523,15 +1546,35 @@ def _multiprocessing_batch(self, | |
|
||
return docs | ||
|
||
def multiprocessing_pipe(self, | ||
@deprecated(message="Use `multiprocessing_batch_nr_of_docs` instead") | ||
def multiprocessing_pipe(self, in_data: Union[List[Tuple], Iterable[Tuple]], | ||
nproc: Optional[int] = None, | ||
batch_size: Optional[int] = None, | ||
only_cui: bool = False, | ||
addl_info: List[str] = [], | ||
return_dict: bool = True, | ||
batch_factor: int = 2) -> Union[List[Tuple], Dict]: | ||
return self.multiprocessing_batch_nr_of_docs(in_data=in_data, nproc=nproc, | ||
batch_size=batch_size, | ||
only_cui=only_cui, | ||
addl_info=addl_info, | ||
return_dict=return_dict, | ||
batch_factor=batch_factor) | ||
|
||
def multiprocessing_batch_nr_of_docs(self, | ||
in_data: Union[List[Tuple], Iterable[Tuple]], | ||
nproc: Optional[int] = None, | ||
batch_size: Optional[int] = None, | ||
only_cui: bool = False, | ||
addl_info: List[str] = [], | ||
return_dict: bool = True, | ||
batch_factor: int = 2) -> Union[List[Tuple], Dict]: | ||
"""Run multiprocessing NOT FOR TRAINING | ||
"""Run multiprocessing NOT FOR TRAINING. | ||
|
||
Thios method batches the data based on the number of documents as specified by the user. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo |
||
|
||
PS: | ||
This method supports Windows. | ||
|
||
Args: | ||
in_data (Union[List[Tuple], Iterable[Tuple]]): List with format: [(id, text), (id, text), ...] | ||
|
This file contains 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.
maybe rename to
multiprocessing_batch_docs_size
for consistency with above?