-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add a mapping function in transforms.io #7769
Conversation
cedd53e
to
93ccbdb
Compare
Add a function to create a JSON file that maps input and output paths. Signed-off-by: staydelight <[email protected]>
Remove changes unrelated to this issue. Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Remove changes unrelated to this issue. Signed-off-by: staydelight <[email protected]>
Remove changes unrelated to this issue. Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
Add code for generating a mapping json file. Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Change mapping_json_path init way. Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Fixing unsuccessful checks. Signed-off-by: staydelight <[email protected]>
Fixes unseccessful ckecks. (if mapping_json_path is not None) Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
f4520d1
to
37d19ed
Compare
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
Adding a dictionary version would be better since dictionary version pipeline may be more commonly used. |
The dictionary version can be something very simple I think, like this: class WriteFileMappingd(MapTransform):
def __init__(self, keys: KeysCollection, mapping_file_path: Path | str = "mapping.json", allow_missing_keys: bool = False) -> None:
super().__init__(keys, allow_missing_keys)
self.mapping = WriteFileMapping(mapping_file_path)
def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor]:
d = dict(data)
for key in self.key_iterator(d):
d[key] = self.mapping(d[key])
return d This would needed added tests as well. |
Hi @staydelight, just a quick note—if you want this new feature included in version 1.4, we only have one or two weeks left to add new features. |
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
Signed-off-by: staydelight <[email protected]>
I would like to ask if data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor] must include Ndarray. Since both the input and output paths require metadata, the input parameter for WriteFileMapping is MetaTensor. In this case, is it possible to use data: Mapping[Hashable, torch.Tensor]) -> dict[Hashable, torch.Tensor] or data: Mapping[Hashable, MetaTensor]) -> dict[Hashable, MetaTensor]? Also, I've added the test for the dictionary. Please let me know if it's okay. Thank you! |
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.
Thanks for the quick update, overall looks good to me.
@ericspod @binliunls, do you have any further comments on this one?
Signed-off-by: staydelight <[email protected]>
/build |
Add a function to create a JSON file that maps input and output paths.
Fixes #7557 .
Description
A few sentences describing the changes proposed in this pull request.
Types of changes
./runtests.sh -f -u --net --coverage
../runtests.sh --quick --unittests --disttests
.make html
command in thedocs/
folder.