Repository: activeloopai/Hub
File: deeplake/util/transform.py (Python)

Code before:

                write_sample_to_transform_dataset(out, transform_dataset)

            except SampleAppendError as e:
                if ignore_errors:
                    skipped_samples += 1
                    skipped_samples_in_current_batch += 1
                else:
                    raise TransformError(offset + i, sample) from e

            finally:
                if i == n - 1:
                    transform_dataset.flush()
                else:
                    transform_dataset.check_flush()

                # dataset flushed, reset skipped sample count
                if transform_dataset.start_input_idx is None:
                    skipped_samples_in_current_batch = 0

                if pg_callback is not None:
                    pg_callback(1)

        # failure at chunk_engine
        # retry one sample at a time
        except SampleAppendError:
            # reset skipped sample count to avoid double counting
            skipped_samples -= skipped_samples_in_current_batch
            skipped_samples_in_current_batch = 0

            skipped_samples += _handle_transform_error(
                data_slice,
                offset,
                transform_dataset,
                pipeline,
                tensors,
                i,
                ignore_errors,
            )
            continue

    if skipped_samples == n:
        return False
    return True


def _retrieve_memory_objects(all_chunk_engines):
    all_tensor_metas = {}
    all_chunk_id_encoders = {}
    all_tile_encoders = {}
    all_sequence_encoders = {}

Review comment (suggestion):
If we wanted to catch Transform error, isn't it better to do like this?

```
except (TransformError, SampleAppendError):
    # TransformError pass through
    raise e
```

Code after:
                write_sample_to_transform_dataset(out, transform_dataset)

            except Exception as e:
                if ignore_errors:
                    skipped_samples += 1
                    skipped_samples_in_current_batch += 1
                else:
                    raise TransformError(offset + i, sample) from e

            finally:
                if i == n - 1:
                    transform_dataset.flush()
                else:
                    transform_dataset.check_flush()

                # dataset flushed, reset skipped sample count
                if transform_dataset.start_input_idx is None:
                    skipped_samples_in_current_batch = 0

                if pg_callback is not None:
                    pg_callback(1)

        # failure at chunk_engine
        # retry one sample at a time
        except Exception as e:
            # TransformError pass through
            if isinstance(e, TransformError):
                raise e

            # reset skipped sample count to avoid double counting
            skipped_samples -= skipped_samples_in_current_batch
            skipped_samples_in_current_batch = 0

            skipped_samples += _handle_transform_error(
                data_slice,
                offset,
                transform_dataset,
                pipeline,
                tensors,
                i,
                ignore_errors,
            )
            continue

    if skipped_samples == n:
        return False
    return True


def _retrieve_memory_objects(all_chunk_engines):
    all_tensor_metas = {}