diff --git a/.github/workflows/test_setup.yml b/.github/workflows/test_setup.yml index 9e743a5..0e23693 100644 --- a/.github/workflows/test_setup.yml +++ b/.github/workflows/test_setup.yml @@ -1,13 +1,10 @@ name: Run Tests -on: - push: - branches: - - main - - branch-bug - - update-test-branch - - test-branch7 - - test-branch8 +#on: +# push: +# branches: + #- main + #- test-branch-pyDict jobs: test: @@ -15,15 +12,16 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-14] + matlab-version: ['R2023b','R2024a'] steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set up MATLAB R2024a + - name: Set up MATLAB uses: matlab-actions/setup-matlab@v2 with: - release: R2024a + release: ${{matrix.matlab-version}} - name: Set up Python uses: actions/setup-python@v5 @@ -36,7 +34,7 @@ jobs: pip install numpy==1.26.4 tensorstore==0.1.73 - name: Run tests - uses: matlab-actions/run-tests@v2 + uses: matlab-actions/run-tests@v4 with: select-by-folder: 'test' code-coverage-cobertura: cobertura.xml diff --git a/PythonModule/ZarrPy.py b/PythonModule/ZarrPy.py index 704395d..3e51709 100644 --- a/PythonModule/ZarrPy.py +++ b/PythonModule/ZarrPy.py @@ -7,6 +7,32 @@ import numpy as np import tensorstore as ts +def createKVStore(isRemote, objPath, bucketName="") -> dict: + """ + Creates a KV store (a python dictionary) for reading or writing + a Zarr file + + Parameters: + - isRemote (bool): whether the resource to be accessed with this +KV store is remote (S3) or local + - objPath (str): path to local Zarr file or to S3 object + - bucketName (str): If file is remote, this should be the S3 bucket +name + + Returns: + - KVStore (dict): Key-Value store as required by tensorstore to work +with Zarr + """ + KVStore = dict(path=objPath); + + if isRemote: + KVStore['driver'] = 's3' + KVStore['bucket'] = bucketName + else: + KVStore['driver'] = 'file' + + return KVStore + def createZarr(kvstore_schema, data_shape, chunk_shape, tstoreDataType, zarrDataType, compressor, fillvalue): """ Creates a new Zarr array and writes data to it. @@ -72,4 +98,4 @@ def readZarr (kvstore_schema): # Read a subset of the data data = zarr_file[...].read().result() - return data \ No newline at end of file + return data diff --git a/Zarr.m b/Zarr.m index 3402b35..b16351f 100644 --- a/Zarr.m +++ b/Zarr.m @@ -198,14 +198,12 @@ function makeZarrGroups(existingParentPath, newGroupsPath) % Extract the S3 bucket name and path [bucketName, objectPath] = obj.extractS3BucketNameAndPath(obj.Path); % Create a Python dictionary for the KV store driver - RemoteStoreSchema = dictionary(["driver", "bucket", "path"], ["s3", bucketName, objectPath]); - obj.KVStoreSchema = py.dict(RemoteStoreSchema); + obj.KVStoreSchema = py.ZarrPy.createKVStore(obj.isRemote, objectPath, bucketName); else % Local file % use full path obj.Path = Zarr.getFullPath(path); - FileStoreSchema = dictionary(["driver", "path"], ["file", obj.Path]); - obj.KVStoreSchema = py.dict(FileStoreSchema); + obj.KVStoreSchema = py.ZarrPy.createKVStore(obj.isRemote, obj.Path); end end