Confusing error when saving the wrong thing

未关闭
#347 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
julia
领域
tooling

调研方向

复现 issue 中的 tuple 情况,然后检查 src/loadsave.jl 中 FileIO 的 action 路径以及 src/error_handling.jl 中的错误处理。将其与成功保存 figure 的情况进行比较,并确保报告的失败将无效参数与不可用的 image loaders 区分开来,同时不提供误导性的安装指导;重新运行复现以验证产生的错误。

由索引模型根据 Issue 内容生成。

描述

julia> using CairoMakie

julia> fig = lines(rand(10));

julia> save("test.png", fig) # works
CairoScreen{Cairo.CairoSurfaceBase{UInt32}} with surface:
Cairo.CairoSurfaceBase{UInt32}(Ptr{Nothing} @0x00007fef60cecfa0, 800.0, 600.0)

julia> save("test.png", (fig, )) # wrong argument gives confusing errors
Errors encountered while save FileIO.File{FileIO.DataFormat{:PNG}, String}("test.png").
All errors:
===========================================
ImageIO writer error: neither save nor fileio_save is defined
  due to MethodError(ImageIO.save, (FileIO.File{FileIO.DataFormat{:PNG}, String}("test.png"), (Scene (800px, 600px):
  18 Plots:
    ├ Combined{Makie.poly, Tuple{Vector{Vector{Point{2, Float32}}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{String}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{String}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    └ MakieCore.Text{Tuple{String}}
  1 Child Scene:
    └ Scene (724px, 541px),)), 0x0000000000007aad)
  Will try next loader.

===========================================
ArgumentError: Package QuartzImageIO [dca85d43-d64c-5e67-8c65-017450d5d020] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

===========================================
ArgumentError: Package ImageMagick [6218d12a-5da1-5696-b52f-db25d2ecc6d1] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

===========================================
ArgumentError: Argument does not support conversion to png.
===========================================

Fatal error:
ERROR: ImageIO writer error: neither save nor fileio_save is defined
  due to MethodError(ImageIO.save, (FileIO.File{FileIO.DataFormat{:PNG}, String}("test.png"), (Scene (800px, 600px):
  18 Plots:
    ├ Combined{Makie.poly, Tuple{Vector{Vector{Point{2, Float32}}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{String}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ LineSegments{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{String}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ MakieCore.Text{Tuple{Vector{Tuple{AbstractString, Point{2, Float32}}}}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    ├ Lines{Tuple{Vector{Point{2, Float32}}}}
    └ MakieCore.Text{Tuple{String}}
  1 Child Scene:
    └ Scene (724px, 541px),)), 0x0000000000007aad)
  Will try next loader.

Stacktrace:
  [1] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
  [2] invokelatest
    @ ./essentials.jl:714 [inlined]
  [3] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, file::FileIO.Formatted, args::Tuple{Makie.FigureAxisPlot}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:217
  [4] action
    @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:197 [inlined]
  [5] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, sym::Symbol, file::String, args::Tuple{Makie.FigureAxisPlot}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185
  [6] action
    @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185 [inlined]
  [7] #save#20
    @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:129 [inlined]
  [8] save(file::String, args::Tuple{Makie.FigureAxisPlot})
    @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:126
  [9] top-level scope
    @ REPL[23]:1
 [10] eval
    @ ./boot.jl:373 [inlined]
 [11] eval_user_input(ast::Any, backend::REPL.REPLBackend)
    @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:150
 [12] repl_backend_loop(backend::REPL.REPLBackend)
    @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:241
 [13] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
    @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:226
 [14] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
    @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:359
 [15] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/REPL/src/REPL.jl:346
 [16] (::Base.var"#919#921"{Bool, Bool, Bool})(REPL::Module)
    @ Base ./client.jl:394
 [17] #invokelatest#2
    @ ./essentials.jl:716 [inlined]
 [18] invokelatest
    @ ./essentials.jl:714 [inlined]
 [19] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
    @ Base ./client.jl:379
 [20] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:309
 [21] _start()
    @ Base ./client.jl:495
Stacktrace:
 [1] handle_error(e::FileIO.WriterError, q::Base.PkgId, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
   @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/error_handling.jl:61
 [2] handle_exceptions(exceptions::Vector{Tuple{Any, Union{Base.PkgId, Module}, Vector}}, action::String)
   @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/error_handling.jl:56
 [3] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, file::FileIO.Formatted, args::Tuple{Makie.FigureAxisPlot}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:226
 [4] action
   @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:197 [inlined]
 [5] action(call::Symbol, libraries::Vector{Union{Base.PkgId, Module}}, sym::Symbol, file::String, args::Tuple{Makie.FigureAxisPlot}; options::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185
 [6] action
   @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:185 [inlined]
 [7] #save#20
   @ ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:129 [inlined]
 [8] save(file::String, args::Tuple{Makie.FigureAxisPlot})
   @ FileIO ~/.julia/packages/FileIO/JA3Vl/src/loadsave.jl:126
 [9] top-level scope
   @ REPL[23]:1

As you can see, save("test.png", fig) works correctly (so in particular, no additional packages need to be installed to save a PNG). However, if you get the second argument wrong (here I pass a tuple containing the figure instead of the figure), the error seems to suggest installing other packages, etc.

I think the right information is there (there's some MethodErrors and Argument does not support conversion to png) but there's also a bunch of what feels to be misleading information, e.g.

ArgumentError: Package QuartzImageIO [dca85d43-d64c-5e67-8c65-017450d5d020] is required but does not seem to be installed:
 - Run `Pkg.instantiate()` to install all recorded dependencies.

seems to be telling me to run Pkg.instantiate() to try to fix the problem, or maybe add QuartzImageIO.

主要语言
Julia
星标
228
派生
83
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

JuliaIO/FileIO.jl 的其他 Issue

查看 JuliaIO/FileIO.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。