Skip to content

Removing .arrow files without closing Julia seems impossible in Windows #492

@Tortar

Description

@Tortar

Hi,

I'm a bit in a desperate situation since I'd like to resolve an issue in Agents.jl involving the Arrow.jl package on Windows but even if I tried hard I couldn't: it seems to me that in reality it could be a problem with Arrow.jl since all my (maybe poor) attempts to solve the problem failed. This is the PR trying to solve it: JuliaDynamics/Agents.jl#909.

In practice we have currently in Agents.jl here a test which performs:

            # Arrow, fails on Windows (see issue #826 (https://github.com/JuliaDynamics/Agents.jl/issues/826))
            if !(Sys.iswindows())
                offline_run!(model, 365 * 5;
                    when_model = each_year,
                    when = six_months,
                    backend = :arrow,
                    mdata = [:flag, :year],
                    adata = [(:weight, mean)],
                    writing_interval = 3
                )

                adata_saved = DataFrame(Arrow.Table("adata.arrow"))
                @test size(adata_saved) == (11, 2)
                @test propertynames(adata_saved) == [:step, :mean_weight]

                mdata_saved = DataFrame(Arrow.Table("mdata.arrow"))
                @test size(mdata_saved) == (6, 3)
                @test propertynames(mdata_saved) == [:step, :flag, :year]

                @test size(vcat(DataFrame.(Arrow.Stream("adata.arrow"))...)) == (11, 2)
                @test size(vcat(DataFrame.(Arrow.Stream("mdata.arrow"))...)) == (6, 3)

                rm("adata.arrow")
                rm("mdata.arrow")
                @test !isfile("adata.arrow")
                @test !isfile("mdata.arrow")
            end

On Linux and MacOS it works fine, but on Windows the operating system refuses to remove the .arrow files giving:

ERROR: IOError: unlink("adata.arrow"): permission denied (EACCES)
Stacktrace:
 [1] uv_error
   @ .\libuv.jl:100 [inlined]
 [2] unlink(p::String)
   @ Base.Filesystem .\file.jl:972
 [3] rm(path::String; force::Bool, recursive::Bool)
   @ Base.Filesystem .\file.jl:283
 [4] rm(path::String)
   @ Base.Filesystem .\file.jl:273
 [5] top-level scope
   @ REPL[17]:1

As you can see for Windows it is disables since we didn't manage to make it work.

It's probably necessary to describe what is the relationship between the Agents.jl function offline_run! and Arrow.jl, it is rather simple, offline_run! calls multiple times this other function:

function Agents.writer_arrow(filename, data, append)
    if append
        Arrow.append(filename, data)
    else
        Arrow.write(filename, data; file = false)
    end
end

I'm trying multiple ways to solve the issue, but none worked. I will try to provide an MWE if necessary.

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