Implement "replace" transformation in Field operation module#879
Open
sebschu wants to merge 9 commits intomlcommons:mainfrom
Open
Implement "replace" transformation in Field operation module#879sebschu wants to merge 9 commits intomlcommons:mainfrom
sebschu wants to merge 9 commits intomlcommons:mainfrom
Conversation
Implements correct functionality for "replace" attirbute in mlc.Transform. It takes a string of the form "pattern/replacement" and peforms re.sub with `pattern` and `replacement`. Slashes can be escaped using a backslash, e.g, "my\/path/your\/path".
Implements correct functionality for "replace" attirbute in mlc.Transform. It takes a string of the form "pattern/replacement" and peforms re.sub with `pattern` and `replacement`. Slashes can be escaped using a backslash, e.g, "my\/path/your\/path".
|
MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅ |
Author
|
I added my GitHub ID when signing up for the newsletter. Please let me know if there is anything else I have to do to sign the CLA. |
Contributor
|
Hi @sebschu , thank you for your contribution! |
Author
|
recheck |
Contributor
|
Could you please also add details on this transformation to the new 1.1 specs? Thank you! |
ccl-core
reviewed
May 27, 2025
python/mlcroissant/mlcroissant/_src/operation_graph/operations/field.py
Outdated
Show resolved
Hide resolved
ccl-core
reviewed
May 27, 2025
Contributor
|
Thank you! Looks great, and it seems that the CLA check passes now :) |
Author
|
I fixed the two issues and added a brief description to the 1.1 specs draft. |
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.
The "replace" transformation is currently not implemented. This is an implementation that allows users to specify a string of the form
pattern/replacementto replace substitutereplacementforpattern. In the background it runsre.sub, so match groups can be included in the replacement string.Slashes can be escaped using a backslash, e.g,
my\/path/your\/pathto replacemy/pathwithyour/path.Functional tests are implemented in
python/mlcroissant/mlcroissant/_src/operation_graph/operations/field_test.py.I followed the syntax of
python/mlcroissant/mlcroissant/_src/structure_graph/nodes/source_test.py#L19for the replacement string.