|
1 | 1 | # PyTensorStore |
2 | 2 |
|
3 | 3 | [](https://github.com/mkitti/PyTensorStore.jl/actions/workflows/CI.yml?query=branch%3Amain) |
| 4 | + |
| 5 | +PyTensorStore.jl provides a wrapper around the Python package `tensorstore`. A future TensorStore.jl may wrap the C++ API directly. |
| 6 | + |
| 7 | +This package is being primarily developed to test Zarr.jl. |
| 8 | + |
| 9 | +## Usage |
| 10 | + |
| 11 | +```julia-repl |
| 12 | +julia> using PyTensorStore |
| 13 | +Precompiling PyTensorStore... |
| 14 | + 1 dependency successfully precompiled in 2 seconds. 50 already precompiled. |
| 15 | +
|
| 16 | +julia> d = Dict( |
| 17 | + "driver" => "n5", |
| 18 | + "kvstore" => Dict( |
| 19 | + "driver" => "file", |
| 20 | + "path" => "tmp/dataset/", |
| 21 | + ), |
| 22 | + "metadata" => Dict( |
| 23 | + "compression" => Dict( |
| 24 | + "type" => "gzip" |
| 25 | + ), |
| 26 | + "dataType" => "uint32", |
| 27 | + "dimensions" => [1000, 20000], |
| 28 | + "blockSize" => [100, 100], |
| 29 | + ), |
| 30 | + "create" => true, |
| 31 | + "delete_existing" => true |
| 32 | + ) |
| 33 | +Dict{String, Any} with 5 entries: |
| 34 | + "driver" => "n5" |
| 35 | + "create" => true |
| 36 | + "kvstore" => Dict("driver"=>"file", "path"=>"tmp/dataset/") |
| 37 | + "metadata" => Dict{String, Any}("blockSize"=>[100, 100], "dataType"=>"… |
| 38 | + "delete_existing" => true |
| 39 | +
|
| 40 | +julia> A = PyTensorStore.open(d).result() |
| 41 | +PyTensorStore.TensorStoreWrapper(<py TensorStore({ |
| 42 | + 'context': { |
| 43 | + 'cache_pool': {}, |
| 44 | + 'data_copy_concurrency': {}, |
| 45 | + 'file_io_concurrency': {}, |
| 46 | + 'file_io_sync': True, |
| 47 | + }, |
| 48 | + 'driver': 'n5', |
| 49 | + 'dtype': 'uint32', |
| 50 | + 'kvstore': {'driver': 'file', 'path': 'tmp/dataset/'}, |
| 51 | + 'metadata': { |
| 52 | + 'blockSize': [100, 100], |
| 53 | + 'compression': {'level': -1, 'type': 'gzip', 'useZlib': False}, |
| 54 | + 'dataType': 'uint32', |
| 55 | + 'dimensions': [1000, 20000], |
| 56 | + }, |
| 57 | + 'transform': { |
| 58 | + 'input_exclusive_max': [[1000], [20000]], |
| 59 | + 'input_inclusive_min': [0, 0], |
| 60 | + }, |
| 61 | +})>) |
| 62 | +
|
| 63 | +julia> A[1:100, 1:100] |
| 64 | +PyTensorStore.TensorStoreWrapper(<py TensorStore({ |
| 65 | + 'context': { |
| 66 | + 'cache_pool': {}, |
| 67 | + 'data_copy_concurrency': {}, |
| 68 | + 'file_io_concurrency': {}, |
| 69 | + 'file_io_sync': True, |
| 70 | + }, |
| 71 | + 'driver': 'n5', |
| 72 | + 'dtype': 'uint32', |
| 73 | + 'kvstore': {'driver': 'file', 'path': 'tmp/dataset/'}, |
| 74 | + 'metadata': { |
| 75 | + 'blockSize': [100, 100], |
| 76 | + 'compression': {'level': -1, 'type': 'gzip', 'useZlib': False}, |
| 77 | + 'dataType': 'uint32', |
| 78 | + 'dimensions': [1000, 20000], |
| 79 | + }, |
| 80 | + 'transform': { |
| 81 | + 'input_exclusive_max': [100, 100], |
| 82 | + 'input_inclusive_min': [0, 0], |
| 83 | + }, |
| 84 | +})>) |
| 85 | +
|
| 86 | +julia> A[1:100, 1:100].write(ones(UInt32, 100, 100)*UInt32(5)).result() |
| 87 | +Python: None |
| 88 | +
|
| 89 | +julia> A[1:100, 1:100].read().result() |
| 90 | +100×100 PyArray{UInt32, 2}: |
| 91 | + 0x00000005 0x00000005 0x00000005 … 0x00000005 0x00000005 0x00000005 |
| 92 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 93 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 94 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 95 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 96 | + 0x00000005 0x00000005 0x00000005 … 0x00000005 0x00000005 0x00000005 |
| 97 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 98 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 99 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 100 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 101 | + 0x00000005 0x00000005 0x00000005 … 0x00000005 0x00000005 0x00000005 |
| 102 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 103 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 104 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 105 | + ⋮ ⋱ |
| 106 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 107 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 108 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 109 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 110 | + 0x00000005 0x00000005 0x00000005 … 0x00000005 0x00000005 0x00000005 |
| 111 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 112 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 113 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 114 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 115 | + 0x00000005 0x00000005 0x00000005 … 0x00000005 0x00000005 0x00000005 |
| 116 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 117 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 118 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 119 | + 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 0x00000005 |
| 120 | +
|
| 121 | +julia> A[1,1].write(9).result() |
| 122 | +Python: None |
| 123 | +
|
| 124 | +julia> A[1,1].read().result() |
| 125 | +0-dimensional PyArray{UInt32, 0}: |
| 126 | +0x00000009 |
| 127 | +``` |
0 commit comments