Skip to content

Commit

Permalink
Yield found dataset references even when some exception was invoked
Browse files Browse the repository at this point in the history
If any of the paths cannot be read by `register.list_dataset_references`, it yields all the found references and raises an exception at the end. Before this change an empty list of references was returned whenever there was a problem with a path, so you would miss all the references that were found.

PiperOrigin-RevId: 615421306
  • Loading branch information
tomvdw authored and The TensorFlow Datasets Authors committed Mar 13, 2024
1 parent 303814e commit bcfdf26
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tensorflow_datasets/core/community/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,16 @@ def list_dataset_references(
for registers in self.registers_per_namespace.values():
all_registers.extend(registers)

def _get_references(register: register_base.BaseRegister):
def _get_references(
register: register_base.BaseRegister,
) -> Iterable[naming.DatasetReference]:
try:
return list(register.list_dataset_references())
yield from register.list_dataset_references()
except Exception: # pylint: disable=broad-except
logging.exception(
'Exception while getting dataset references from register %s',
register,
)
return []

with concurrent.futures.ThreadPoolExecutor(
max_workers=max_workers
Expand Down

0 comments on commit bcfdf26

Please sign in to comment.