Praveen Kulkarni commited on
Commit ·
53eadfe
1
Parent(s): 9766e96
utf8 encoding
Browse files
test.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import zarr
|
| 2 |
import numpy as np
|
| 3 |
import datasets
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
|
|
@@ -31,13 +32,24 @@ class ZarrTest:
|
|
| 31 |
|
| 32 |
@staticmethod
|
| 33 |
def create():
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
z1[:] = 42
|
| 37 |
z1[0, :] = np.arange(100)
|
| 38 |
z1[:, 0] = np.arange(100)
|
| 39 |
-
z2 =
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
print(test)
|
| 42 |
|
| 43 |
@staticmethod
|
|
@@ -77,10 +89,11 @@ class ZarrTest:
|
|
| 77 |
"""
|
| 78 |
from datasets import load_dataset
|
| 79 |
import datasets
|
| 80 |
-
|
| 81 |
-
ds = load_dataset("spikingneurons/test", streaming=True)
|
| 82 |
print(ds)
|
| 83 |
|
|
|
|
|
|
|
| 84 |
class Test(datasets.GeneratorBasedBuilder):
|
| 85 |
VERSION = datasets.Version("1.0.0")
|
| 86 |
BUILDER_CONFIGS = []
|
|
@@ -106,11 +119,21 @@ class Test(datasets.GeneratorBasedBuilder):
|
|
| 106 |
)
|
| 107 |
|
| 108 |
def _split_generators(self, dl_manager):
|
|
|
|
| 109 |
print(dl_manager)
|
| 110 |
print(self.config.name)
|
| 111 |
urls = ["example.zip"]
|
| 112 |
-
data_dir = dl_manager.
|
| 113 |
print(data_dir)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
streaming = dl_manager.is_streaming
|
| 115 |
return [
|
| 116 |
datasets.SplitGenerator(
|
|
|
|
| 1 |
import zarr
|
| 2 |
import numpy as np
|
| 3 |
import datasets
|
| 4 |
+
import fsspec
|
| 5 |
|
| 6 |
|
| 7 |
|
|
|
|
| 32 |
|
| 33 |
@staticmethod
|
| 34 |
def create():
|
| 35 |
+
store = zarr.DirectoryStore('data.zarr')
|
| 36 |
+
root = zarr.group(store=store)
|
| 37 |
+
z1 = root.zeros('trace', shape=(100, 100), chunks=(10, 10), dtype='i1', overwrite=True)
|
| 38 |
z1[:] = 42
|
| 39 |
z1[0, :] = np.arange(100)
|
| 40 |
z1[:, 0] = np.arange(100)
|
| 41 |
+
z2 = root.zeros('plaintext', shape=100, dtype='u1', overwrite=True)
|
| 42 |
+
z3 = root.zeros('ciphertext', shape=100, dtype='u1', overwrite=True)
|
| 43 |
+
z4 = root.zeros('key', shape=100, dtype='u1', overwrite=True)
|
| 44 |
+
z2[:] = 22
|
| 45 |
+
z3[:] = 33
|
| 46 |
+
z4[:] = 44
|
| 47 |
+
zarr.consolidate_metadata(store)
|
| 48 |
+
store.close()
|
| 49 |
+
|
| 50 |
+
store = zarr.DirectoryStore('data.zarr')
|
| 51 |
+
root = zarr.group(store=store)
|
| 52 |
+
test = np.all(z1[:] == root['trace'][:])
|
| 53 |
print(test)
|
| 54 |
|
| 55 |
@staticmethod
|
|
|
|
| 89 |
"""
|
| 90 |
from datasets import load_dataset
|
| 91 |
import datasets
|
| 92 |
+
ds = load_dataset("spikingneurons/test", streaming=True, trust_remote_code=True)
|
|
|
|
| 93 |
print(ds)
|
| 94 |
|
| 95 |
+
# ZarrTest.load_zip_partially_from_hf()
|
| 96 |
+
|
| 97 |
class Test(datasets.GeneratorBasedBuilder):
|
| 98 |
VERSION = datasets.Version("1.0.0")
|
| 99 |
BUILDER_CONFIGS = []
|
|
|
|
| 119 |
)
|
| 120 |
|
| 121 |
def _split_generators(self, dl_manager):
|
| 122 |
+
from fsspec.implementations.zip import ZipFileSystem
|
| 123 |
print(dl_manager)
|
| 124 |
print(self.config.name)
|
| 125 |
urls = ["example.zip"]
|
| 126 |
+
data_dir = dl_manager.download_and_extract(urls)
|
| 127 |
print(data_dir)
|
| 128 |
+
|
| 129 |
+
# Open the zip file using fsspec
|
| 130 |
+
with fsspec.open(data_dir[0]) as f:
|
| 131 |
+
with fsspec.filesystem("zip", fo=f) as fs:
|
| 132 |
+
# List all files in the zip
|
| 133 |
+
all_files = fs.glob("*")
|
| 134 |
+
print("All files in the zip:", all_files)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
streaming = dl_manager.is_streaming
|
| 138 |
return [
|
| 139 |
datasets.SplitGenerator(
|