Skip to content

Undefined error when trying to write to a non-writeable zgroup #199

@bwalker1

Description

@bwalker1

The functions zgroup and zcreate to create a subgroup and subarray in a group attempt to throw an IOError if the group is not writeable, but IOError is not defined. (c.f. Base.IOError in the function consolidate_metadata which is defined).

Zarr.jl/src/ZGroup.jl

Lines 149 to 169 in 0a6cf35

"Create a subgroup of the group g"
function zgroup(g::ZGroup, name; attrs=Dict())
g.writeable || throw(IOError("Zarr group is not writeable. Please re-open in write mode to create an array"))
g.groups[name] = zgroup(g.storage,_concatpath(g.path,name),attrs=attrs)
end
"Create a new subarray of the group g"
function zcreate(::Type{T},g::ZGroup, name::AbstractString, addargs...; kwargs...) where T
g.writeable || throw(IOError("Zarr group is not writeable. Please re-open in write mode to create an array"))
name = string(name)
z = zcreate(T, g.storage, addargs...; path = _concatpath(g.path,name), kwargs...)
g.arrays[name] = z
return z
end
HTTP.serve(s::Union{ZArray,ZGroup}, args...; kwargs...) = HTTP.serve(s.storage, s.path, args...; kwargs...)
writezip(io::IO, s::Union{ZArray,ZGroup}; kwargs...) = writezip(io, s.storage, s.path; kwargs...)
function consolidate_metadata(z::Union{ZArray,ZGroup})
z.writeable || throw(Base.IOError("Zarr group is not writeable. Please re-open in write mode to create an array",0))
consolidate_metadata(z.storage,z.path)
end

Example:

using Zarr
g = zgroup("test.zarr")
g = zopen("test.zarr")
zcreate(Float32, g, "foo", 5)

produces

ERROR: UndefVarError: `IOError` not defined in `Zarr`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] zcreate(::Type{Float32}, g::ZGroup{DirectoryStore}, name::String, addargs::Int64; kwargs::@Kwargs{})
   @ Zarr ~/.julia/packages/Zarr/3QSdj/src/ZGroup.jl:151
 [2] zcreate(::Type{Float32}, g::ZGroup{DirectoryStore}, name::String, addargs::Int64)
   @ Zarr ~/.julia/packages/Zarr/3QSdj/src/ZGroup.jl:150
 [3] top-level scope
   @ REPL[13]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions