Skip to content

Commit 1dd0da5

Browse files
authored
Fix unit tests (#170)
* fix unit tests * Fix s3 example
1 parent 2a2ad03 commit 1dd0da5

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

docs/src/s3examples.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,31 @@ account, you can access the dataset without credentials as follows:
1212

1313
````@example aws
1414
using Zarr, AWS
15-
AWS.global_aws_config(AWSConfig(creds=nothing, region = "eu-west-2"))
15+
Zarr.AWSS3.AWS.global_aws_config(Zarr.AWSS3.AWS.AWSConfig(creds=nothing, region="us-west-2"))
1616
````
1717

1818
Then we can directly open a zarr group stored on s3
1919

2020
````@example aws
21-
z = zopen("s3://zarr-demo/store/foo/bar")
21+
z = zopen("s3://mur-sst/zarr-v1")
2222
````
2323

24-
So we see that the store points to a zarr group with a single variable `baz`.
24+
So we see that the store points to a zarr group with a few arrays
2525

2626
````@example aws
27-
v = z["baz"]
27+
v = z["analysed_sst"]
2828
````
2929

30-
The variable seems to contain an ASCIIString.
30+
And we can read the attributes from the array
3131

3232
````@example aws
33-
String(v[:])
33+
v.attrs
34+
````
35+
36+
Or some data
37+
38+
````@example aws
39+
v[1:1000,1:1000,1]
3440
````
3541

3642
## Accessing CMIP6 data on GCS
@@ -156,7 +162,7 @@ a[:,:,:] = reshape(1.0:24.0, (2,3,4))
156162
Now we test if the data can be accessed
157163

158164
````@example minio
159-
a2 = zopen("s3://zarrdata/group_1/array_1")
165+
a2 = zopen("s3://zarrdata/group_1/bar")
160166
a2[2,2,1:4]
161167
````
162168
`````

src/Storage/consolidated.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ _pdict(d::ConsolidatedStore,p) = filter(((k,v),)->startswith(k,p),d.cons)
4242
function subdirs(d::ConsolidatedStore,p)
4343
p2 = _unconcpath(d,p)
4444
d2 = _pdict(d,p2)
45-
_searchsubdict(d2,p,(sp,lp)->length(sp) > lp+1)
45+
_searchsubdict(d2, p2, (sp, lp) -> length(sp) > lp + 1)
4646
end
4747

4848
function subkeys(d::ConsolidatedStore,p)

test/storage.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,15 @@ end
171171
end
172172

173173
@testset "AWS S3 Storage" begin
174-
Zarr.AWSS3.AWS.global_aws_config(Zarr.AWSS3.AWS.AWSConfig(creds=nothing, region="eu-west-2"))
175-
S3,p = Zarr.storefromstring("s3://zarr-demo/store/foo")
176-
@test storagesize(S3,p) == 0
177-
@test Zarr.is_zgroup(S3,p) == true
174+
Zarr.AWSS3.AWS.global_aws_config(Zarr.AWSS3.AWS.AWSConfig(creds=nothing, region="us-west-2"))
175+
S3, p = Zarr.storefromstring("s3://mur-sst/zarr-v1")
176+
@test Zarr.is_zgroup(S3, p)
177+
@test storagesize(S3, p) == 10551
178178
S3group = zopen(S3,path=p)
179-
S3Array = S3group.groups["bar"].arrays["baz"]
180-
@test eltype(S3Array) == Zarr.ASCIIChar
181-
@test storagesize(S3Array) == 69
182-
@test String(S3Array[:]) == "Hello from the cloud!"
179+
S3Array = S3group["time"]
180+
@test eltype(S3Array) == Int64
181+
@test storagesize(S3Array) == 72184
182+
@test S3Array[1:5] == [0, 1, 2, 3, 4]
183183
end
184184

185185
@testset "GCS Storage" begin

0 commit comments

Comments
 (0)