Example #1
0
def test_tar_gz():
    """test_tar_gz"""
    filename = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        "test_parquet",
        "parquet_cpp_example.parquet.tar.gz",
    )
    filename = "file://" + filename

    (
        format,  # pylint: disable=redefined-builtin
        entries,
    ) = archive_io.list_archive_entries(filename, ["gz", "tar.gz"])
    assert format.numpy().decode() == "tar.gz"
    assert entries.shape == [2]
    assert entries[0].numpy().decode() == "parquet_cpp_example.parquet.1"
    assert entries[1].numpy().decode() == "parquet_cpp_example.parquet.2"

    elements = archive_io.read_archive(filename, format, entries)
    assert elements.shape == [2]

    expected_filename = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        "test_parquet",
        "parquet_cpp_example.parquet",
    )
    expected_filename = "file://" + expected_filename

    assert elements[0].numpy() == tf.io.read_file(expected_filename).numpy()
    assert elements[1].numpy() == tf.io.read_file(expected_filename).numpy()
Example #2
0
def test_none():
    """test_none"""
    filename = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            "test_parquet", "parquet_cpp_example.parquet")
    filename = "file://" + filename

    format, entries = archive_io.list_archive_entries(filename, ["none", "gz"])  # pylint: disable=redefined-builtin
    assert format.numpy().decode() == "none"
    assert entries.shape == [1]

    elements = archive_io.read_archive(filename, format, entries)
    assert elements.shape == [1]

    assert elements[0].numpy() == tf.io.read_file(filename).numpy()