Dataset Viewer issue

#3
by mickylan2367 - opened
make brain project 2023 org
edited Oct 15, 2023

The dataset viewer Error details:

Error code:   StreamingRowsError
Exception:    ValueError
Message:      I/O operation on closed file.
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/src/worker/utils.py", line 258, in get_rows_or_raise
                  return get_rows(
                File "/src/services/worker/src/worker/utils.py", line 199, in decorator
                  return func(*args, **kwargs)
                File "/src/services/worker/src/worker/utils.py", line 236, in get_rows
                  rows_plus_one = list(itertools.islice(ds, rows_max_number + 1))
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 1379, in __iter__
                  for key, example in ex_iterable:
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/iterable_dataset.py", line 233, in __iter__
                  yield from self.generate_examples_fn(**self.kwargs)
                File "/tmp/modules-cache/datasets_modules/datasets/mb23--GraySpectrogram/2cd67b64a683468a4b0f76e08e6613e6cb0351c19e21a59f40cf0a88a0855386/GraySpectrogram.py", line 183, in _generate_examples
                  "bytes": file_obj.read()
                File "/usr/local/lib/python3.9/zipfile.py", line 910, in read
                  buf += self._read1(self.MAX_N)
                File "/usr/local/lib/python3.9/zipfile.py", line 992, in _read1
                  data += self._read2(n - len(data))
                File "/usr/local/lib/python3.9/zipfile.py", line 1024, in _read2
                  data = self._fileobj.read(n)
                File "/usr/local/lib/python3.9/zipfile.py", line 744, in read
                  data = self._file.read(n)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/download/streaming_download_manager.py", line 333, in read_with_retries
                  out = read(*args, **kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/fsspec/spec.py", line 1743, in read
                  raise ValueError("I/O operation on closed file.")
              ValueError: I/O operation on closed file.

Although the title of this discussion is "Dataset Viewer issue ", I think the reason why this error occured is ascribable to "_split_generators" function in the loading script. The code I mentioned is below.

// in the _split_generators()
for split, files in iter_archive.items():
            '''
            split : "train" or "test" or "val"
            files : zip files
            '''
            metadata_path = dl_manager.download_and_extract(metadata_paths[split])
            gs.append(
                datasets.SplitGenerator(
                    name = split,
                    gen_kwargs = {
                        "images" : iter(iter_archive[split]),
                        "metadata_path": metadata_path 
                    }
                )
            )
        return gs

iter_archive is dict and the constructor is like

{
    "train" : [
            ( file_name,  zipfile.ZipExtFile object)...
      ], 
    "test":[
            (file_name,  zipfile.ZipExtFile object])...
      ]
}

In addition, I got the error below when I used "load_dataset("mb23/GrayScectrogram")".

ValueError: seek of closed file

Would you give me some advise to solve this problem?

cc @albertvillanova @lhoestq @severo .

make brain project 2023 org

For文回している最中にリストにして外に出してしまうと、勝手にファイルはcloseしてしまうのかも?

mickylan2367 changed discussion status to closed

Sign up or log in to comment