Skip to content

Commit

Permalink
fix utf-8 yaml dump
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoestq committed Sep 23, 2022
1 parent da414e6 commit a1df085
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/datasets/utils/metadata.py
Expand Up @@ -87,13 +87,15 @@ def from_yaml_string(cls, string: str) -> "DatasetMetadata":
return cls(**metadata_dict)

def to_yaml_string(self) -> str:
return yaml.dump(
return yaml.safe_dump(
{
(key.replace("_", "-") if key in self._FIELDS_WITH_DASHES else key): value
for key, value in self.items()
},
sort_keys=False,
)
allow_unicode=True,
encoding="utf-8",
).decode("utf-8")


if __name__ == "__main__":
Expand Down

1 comment on commit a1df085

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.009537 / 0.011353 (-0.001816) 0.004643 / 0.011008 (-0.006365) 0.034744 / 0.038508 (-0.003764) 0.040880 / 0.023109 (0.017771) 0.348944 / 0.275898 (0.073046) 0.419291 / 0.323480 (0.095812) 0.006642 / 0.007986 (-0.001344) 0.005340 / 0.004328 (0.001011) 0.008045 / 0.004250 (0.003795) 0.055639 / 0.037052 (0.018587) 0.362025 / 0.258489 (0.103536) 0.401826 / 0.293841 (0.107986) 0.036421 / 0.128546 (-0.092125) 0.010751 / 0.075646 (-0.064895) 0.307589 / 0.419271 (-0.111682) 0.061494 / 0.043533 (0.017961) 0.351756 / 0.255139 (0.096617) 0.377616 / 0.283200 (0.094416) 0.120550 / 0.141683 (-0.021133) 1.718634 / 1.452155 (0.266480) 1.765017 / 1.492716 (0.272301)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.238606 / 0.018006 (0.220600) 0.520880 / 0.000490 (0.520391) 0.005832 / 0.000200 (0.005632) 0.000170 / 0.000054 (0.000115)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.026639 / 0.037411 (-0.010772) 0.115324 / 0.014526 (0.100798) 0.125948 / 0.176557 (-0.050608) 0.181691 / 0.737135 (-0.555445) 0.129251 / 0.296338 (-0.167087)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.456009 / 0.215209 (0.240800) 4.461121 / 2.077655 (2.383466) 2.033990 / 1.504120 (0.529870) 1.820336 / 1.541195 (0.279141) 1.852290 / 1.468490 (0.383800) 0.467280 / 4.584777 (-4.117497) 4.481000 / 3.745712 (0.735288) 2.245855 / 5.269862 (-3.024006) 1.363274 / 4.565676 (-3.202403) 0.060187 / 0.424275 (-0.364088) 0.013275 / 0.007607 (0.005668) 0.573740 / 0.226044 (0.347695) 5.739523 / 2.268929 (3.470594) 2.612191 / 55.444624 (-52.832434) 2.226230 / 6.876477 (-4.650247) 2.420277 / 2.142072 (0.278204) 0.627501 / 4.805227 (-4.177727) 0.137738 / 6.500664 (-6.362926) 0.071195 / 0.075469 (-0.004274)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.735849 / 1.841788 (-0.105939) 16.071828 / 8.074308 (7.997520) 28.028989 / 10.191392 (17.837597) 1.024598 / 0.680424 (0.344174) 0.654321 / 0.534201 (0.120120) 0.447317 / 0.579283 (-0.131966) 0.524570 / 0.434364 (0.090206) 0.316736 / 0.540337 (-0.223601) 0.324626 / 1.386936 (-1.062310)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.006619 / 0.011353 (-0.004734) 0.004608 / 0.011008 (-0.006400) 0.032082 / 0.038508 (-0.006427) 0.037854 / 0.023109 (0.014744) 0.403432 / 0.275898 (0.127534) 0.469001 / 0.323480 (0.145522) 0.004894 / 0.007986 (-0.003092) 0.005597 / 0.004328 (0.001269) 0.005531 / 0.004250 (0.001281) 0.048263 / 0.037052 (0.011211) 0.395226 / 0.258489 (0.136737) 0.451612 / 0.293841 (0.157771) 0.033910 / 0.128546 (-0.094636) 0.011515 / 0.075646 (-0.064132) 0.281502 / 0.419271 (-0.137770) 0.065105 / 0.043533 (0.021572) 0.401045 / 0.255139 (0.145906) 0.399552 / 0.283200 (0.116353) 0.122995 / 0.141683 (-0.018688) 1.608097 / 1.452155 (0.155943) 1.690601 / 1.492716 (0.197885)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.295130 / 0.018006 (0.277124) 0.493906 / 0.000490 (0.493417) 0.021154 / 0.000200 (0.020954) 0.000163 / 0.000054 (0.000108)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.026505 / 0.037411 (-0.010907) 0.119786 / 0.014526 (0.105260) 0.135648 / 0.176557 (-0.040909) 0.176721 / 0.737135 (-0.560414) 0.138107 / 0.296338 (-0.158232)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.492433 / 0.215209 (0.277224) 4.759386 / 2.077655 (2.681731) 2.326954 / 1.504120 (0.822834) 2.099965 / 1.541195 (0.558770) 2.194932 / 1.468490 (0.726442) 0.485357 / 4.584777 (-4.099420) 4.527258 / 3.745712 (0.781546) 2.253934 / 5.269862 (-3.015927) 1.403055 / 4.565676 (-3.162622) 0.060942 / 0.424275 (-0.363333) 0.012535 / 0.007607 (0.004928) 0.605740 / 0.226044 (0.379696) 6.099849 / 2.268929 (3.830920) 2.888622 / 55.444624 (-52.556003) 2.519563 / 6.876477 (-4.356914) 2.618701 / 2.142072 (0.476628) 0.630999 / 4.805227 (-4.174228) 0.142892 / 6.500664 (-6.357772) 0.074575 / 0.075469 (-0.000894)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.739364 / 1.841788 (-0.102423) 15.750895 / 8.074308 (7.676587) 28.815638 / 10.191392 (18.624246) 1.099180 / 0.680424 (0.418756) 0.744971 / 0.534201 (0.210770) 0.455153 / 0.579283 (-0.124130) 0.497745 / 0.434364 (0.063381) 0.305890 / 0.540337 (-0.234448) 0.314825 / 1.386936 (-1.072111)

CML watermark

Please sign in to comment.