-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate
Source
to the new dataclass_transform paradigm. (#590)
- Loading branch information
Showing
37 changed files
with
678 additions
and
428 deletions.
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Tests for state.""" | ||
|
||
from etils import epath | ||
|
||
import mlcroissant as mlc | ||
|
||
from .state import Metadata | ||
|
||
|
||
def test_rename_record_set(): | ||
ctx = mlc.Context() | ||
path = epath.Path(__file__).parent.parent / "cypress/fixtures/1.0/titanic.json" | ||
canonical_metadata = mlc.Metadata.from_file(ctx, path) | ||
metadata = Metadata.from_canonical(canonical_metadata) | ||
|
||
# Rename RecordSet: | ||
assert metadata.record_sets[0].id == "genders" | ||
assert metadata.record_sets[2].fields[1].id == "passengers/gender" | ||
assert metadata.record_sets[2].fields[1].references.field == "genders/label" | ||
metadata.rename_record_set("genders", "NEW_GENDERS") | ||
assert metadata.record_sets[0].id == "NEW_GENDERS" | ||
assert metadata.record_sets[2].fields[1].references.field == "NEW_GENDERS/label" | ||
|
||
# Rename Field: | ||
metadata.rename_field("label", "NEW_LABEL") | ||
assert metadata.record_sets[2].fields[1].references.field == "NEW_GENDERS/NEW_LABEL" | ||
|
||
# Rename Distribution: | ||
assert metadata.record_sets[2].fields[0].id == "passengers/name" | ||
assert metadata.record_sets[2].fields[0].source.file_object == "passengers.csv" | ||
metadata.rename_distribution("passengers.csv", "NEW_PASSENGERS.CSV") | ||
assert metadata.record_sets[2].fields[0].source.file_object == "NEW_PASSENGERS.CSV" |
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
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
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
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
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
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
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
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.