datalake:minio:zarrv2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

datalake:minio:zarrv2 [2025/10/15 15:44] – created fabriciodatalake:minio:zarrv2 [2025/10/15 16:37] (current) fabricio
Line 200: Line 200:
  
 Both ''FSStore'' and ''FSMap'' provide the same ''MutableMapping'' interface. ''FSMap'' is more lightweight and part of core ''fsspec''. Both ''FSStore'' and ''FSMap'' provide the same ''MutableMapping'' interface. ''FSMap'' is more lightweight and part of core ''fsspec''.
 +
 +
 +====== RKNS (Zarr V2) from Minio ZIP ======
 +Execute the following with 'uv run', the dependencies are automatically resolved.
 +This assumes you have our internal pypi registry set up with uv.
 +
 +<code python>
 +# /// script
 +# requires-python = ">=3.8"
 +# dependencies = [
 +#     "boto3>=1.40.49",
 +#     "python-dotenv>=0.9.9",
 +#     "packaging>=25.0",
 +#     "rkns==0.6.2",
 +#     "s3fs[boto3]>=2023.12.0",
 +#     "typing-extensions>=4.15.0",
 +# ]
 +# ///
 +import os
 +from pathlib import Path
 +from dotenv import load_dotenv
 +from fsspec.implementations.zip import ZipFileSystem
 +from fsspec.mapping import FSMap
 +import s3fs
 +import zarr
 +import rkns
 +
 +# load credentials from .env file
 +load_dotenv()
 +access_key_id = os.getenv("STORAGE_ACCESS_KEY")
 +secret_access_key = os.getenv("STORAGE_SECRET_KEY")
 +endpoint_url = os.getenv("ENDPOINT")
 +endpoint_url_full = os.getenv("ENDPOINT_FULL")
 +
 +
 +# Specify the path to your custom CA certificate
 +ca_cert_path = "ca.crt.cer"
 +assert Path(ca_cert_path).is_file()
 +
 +
 +# Create s3fs filesystem with custom cert
 +fs = s3fs.S3FileSystem(
 +    client_kwargs={"endpoint_url": endpoint_url_full, "verify": str(ca_cert_path)},
 +    key=access_key_id,
 +    secret=secret_access_key,
 +    use_ssl=True,
 +)
 +
 +s3_path = "rekonas-dataset-shhs-rkns/sub-shhs200001_ses-01_task-sleep_eeg.rkns"
 +
 +zip_fs = ZipFileSystem(fo=fs.open(s3_path, "rb"))
 +store = zarr.storage.FSStore(url='', fs=zip_fs)
 +rkns_obj = rkns.from_RKNS(store)
 +print(rkns_obj.tree)
 +</code>
 +
  • datalake/minio/zarrv2.1760543071.txt.gz
  • Last modified: 2025/10/15 15:44
  • by fabricio