Skip to content

Commit

Permalink
When a BuilderConfig is given, then use the version from there
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 696400814
  • Loading branch information
tomvdw authored and The TensorFlow Datasets Authors committed Nov 14, 2024
1 parent 4aef4ae commit c3c62b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tensorflow_datasets/core/dataset_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,21 +1361,26 @@ def _create_builder_config(
if isinstance(builder_config, str):
if version is None and ":" in builder_config:
builder_config, version = builder_config.split(":")
elif version is None:
version = self.VERSION
config = self.get_builder_config(name=builder_config, version=version)
if config is not None:
return config
else:
close_matches = difflib.get_close_matches(
builder_config, self.builder_configs.keys(), n=10
f"{builder_config}:{version}",
[f"{bc.name}:{bc.version}" for bc in self.builder_configs.values()],
n=100,
)
close_matches = "\n".join(sorted(close_matches))
raise ValueError(
f"BuilderConfig {builder_config} not found with version {version}."
" Here are 10 BuilderConfigs whose name closely match:"
f" {close_matches}"
)

cls_builder_config = self.get_builder_config(
name=builder_config.name, version=version
name=builder_config.name, version=builder_config.version
)
if cls_builder_config is None:
logging.warning("Using custom data configuration: %s", builder_config)
Expand All @@ -1384,7 +1389,7 @@ def _create_builder_config(
raise ValueError(
"Cannot name a custom BuilderConfig the same as an available"
" BuilderConfig. Change the name.\n"
f"Requested: {builder_config}\n"
f"Requested: {builder_config}\n\n"
f"BuilderConfig in class: {cls_builder_config}"
)
else:
Expand Down

0 comments on commit c3c62b8

Please sign in to comment.