Interface to fetch entries in primitive types from DataPack#900
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## master #900 +/- ##
==========================================
+ Coverage 80.87% 80.93% +0.05%
==========================================
Files 253 253
Lines 19619 19677 +58
==========================================
+ Hits 15867 15925 +58
Misses 3752 3752
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
mylibrar
reviewed
Aug 24, 2022
Collaborator
mylibrar
left a comment
There was a problem hiding this comment.
There might be a few more places to refactor in the current get method:
entry_typecan just be a string. This will save the cost ofget_full_module_namerange_annotationcould be atidinstead of an entry object.
To maintain backward compatibility, there is a potential workaround:
- We may add a new
get_rawmethod with the following signaturedef get_raw( # type: ignore self, entry_type: str, range_annotation_tid: Optional[int] = None, components: Optional[Union[str, Iterable[str]]] = None, include_sub_type: bool = True, ) -> Iterator[List]
- And then in the
getmethod, we can do:def get( # type: ignore self, entry_type: Union[str, Type[EntryType]], range_annotation: Optional[Union[Annotation, AudioAnnotation]] = None, components: Optional[Union[str, Iterable[str]]] = None, include_sub_type: bool = True ): # Convert entry_type to string if it's Type[EntryType] ... # Convert range_annotation to tid ... # Convert result from get_raw to entry objects for entry_data in get_raw(...): yield self.get_entry(tid=entry_data[TID])
You can try out other solutions as well.
mylibrar
reviewed
Aug 25, 2022
Member
|
quick comment on the title, not "fetch entries directly from Data Store", but fetch primitive types from data pack. Data store is still invisible to users. |
DataPack
This was referenced Jan 3, 2023
Open
mylibrar
approved these changes
Jan 3, 2023
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
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.
This PR is the first step towards fixing #881
Description of changes
Current, when fetching entries from a
DataPackorMultiPackusing thegetmethod, Forte converts data store entries into object form. We wanted a way for users to directly interact withDataStoreentries. In this PR, we provide a modification to thegetmethod ofDataPackto be able to return an entry in its primitive form directly fromDataStorewithout needing to be converted to an object.Additionally, since
DataStoreentries are not very interpretable (since they are in alistformat), this PR introduces a way to retain data store entries in their primitive form and also represent them in a more interpretable way by converting it to adictionary. This happens by thetransform_data_store_entrymethod indata_store.py. An example of this is as follows:Possible influences of this PR.
By allowing
DataPackorMultiRackto fetch entries in their primitive form, users can interact withDataStoremore easily.Test Conducted
The working of the
getmethod with theget_rawattribute set toTruewas tested indata_pack_test.pyandmulti_pack_test.py