JuliaTime / TimeZones.jl

IANA time zone database access for the Julia programming language
Other
86 stars 52 forks source link

Fix deprecations for julia 1.6 #339

Closed morris25 closed 3 years ago

morris25 commented 3 years ago

When running jobs to find deprecations on our CI on julia 1.6, our jobs are failing with errors like:

ERROR: LoadError: LoadError: LoadError: ArgumentError: Unable to find time zone "America/New_York". Try running `TimeZones.build()`.
Stacktrace:
  [1] (::TimeZones.var"#3#4"{String})()
    @ TimeZones ~/.julia/packages/TimeZones/ACKYR/src/types/timezone.jl:56
  [2] get!(default::TimeZones.var"#3#4"{String}, h::Dict{String, Tuple{Dates.TimeZone, TimeZones.Class}}, key::String)
    @ Base ./dict.jl:465
  [3] Dates.TimeZone(str::String, mask::TimeZones.Class) (repeats 2 times)
    @ TimeZones ~/.julia/packages/TimeZones/ACKYR/src/types/timezone.jl:46
  [4] var"@tz_str"(__source__::LineNumberNode, __module__::Module, str::Any)
    @ TimeZones ~/.julia/packages/TimeZones/ACKYR/src/types/timezone.jl:86
  [5] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
  [6] include(x::String)
    @ ElectricityMarkets ~/.julia/packages/ElectricityMarkets/gDt52/src/ElectricityMarkets.jl:1
  [7] top-level scope
    @ ~/.julia/packages/ElectricityMarkets/gDt52/src/ElectricityMarkets.jl:28
  [8] include
    @ ./Base.jl:386 [inlined]
  [9] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base ./loading.jl:1213
 [10] top-level scope
    @ none:1
 [11] eval
    @ ./boot.jl:360 [inlined]
 [12] eval(x::Expr)
    @ Base.MainInclude ./client.jl:446
 [13] top-level scope
    @ none:1

This error shows up only in our deprecations jobs and started happening directly after we switched the jobs to julia 1.6. When packages are built, TimeZones claims to have built successfully but then fails when used.

This seems to be due to a couple of version dependent deprecations to the locations of @artifact_str and download causing failures when trying to build TimeZones with depwarn set to error.

Deprecation failures when run directly:

     Testing Running tests...
ERROR: LoadError: using Pkg instead of using LazyArtifacts is deprecated
Stacktrace:
  [1] depwarn(msg::String, funcsym::Symbol; force::Bool)
    @ Base ./deprecated.jl:82
  [2] _artifact_str(__module__::Module, artifacts_toml::String, name::SubString{String}, path_tail::String, artifact_dict::Dict{String, Any}, hash::Base.SHA1, platform::Base.BinaryPlatforms.Platform, lazyartifacts::Any)
    @ Artifacts /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Artifacts/src/Artifacts.jl:545
  [3] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [4] invokelatest
    @ ./essentials.jl:706 [inlined]
  [5] macro expansion
    @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Artifacts/src/Artifacts.jl:689 [inlined]
  [6] build(version::String, regions::Vector{String}, archive_dir::String, tz_source_dir::String, compiled_dir::String; verbose::Bool)
    @ TimeZones.TZData ~/.julia/dev/TimeZones/src/tzdata/build.jl:52
  [7] build (repeats 2 times)
    @ ~/.julia/dev/TimeZones/src/tzdata/build.jl:31 [inlined]
  [8] top-level scope
    @ ~/.julia/dev/TimeZones/test/runtests.jl:28
  [9] include(fname::String)
    @ Base.MainInclude ./client.jl:444
 [10] top-level scope
    @ none:6
in expression starting at /Users/sam/.julia/dev/TimeZones/test/runtests.jl:28
ERROR: Package TimeZones errored during testing
     Testing Running tests...
  Downloaded artifact: tzdata2016j
[ Info: Installing 2016j tzdata region data
TimeZones: Error During Test at /Users/sam/.julia/dev/TimeZones/test/runtests.jl:43
  Got exception outside of a @test
  LoadError: Base.download is deprecated; use Downloads.download instead
  Stacktrace:
    [1] depwarn(msg::String, funcsym::Symbol; force::Bool)
      @ Base ./deprecated.jl:82
    [2] depwarn
      @ ./deprecated.jl:80 [inlined]
    [3] do_download
      @ ./download.jl:32 [inlined]
    [4] download
      @ ./download.jl:28 [inlined]
    [5] tzdata_download(version::String, dir::String)
      @ TimeZones.TZData ~/.julia/dev/TimeZones/src/tzdata/download.jl:122
    [6] top-level scope
      @ ~/.julia/dev/TimeZones/test/tzdata/archive.jl:11
    [7] include(fname::String)
      @ Base.MainInclude ./client.jl:444
    [8] macro expansion
      @ ~/.julia/dev/TimeZones/test/runtests.jl:49 [inlined]
    [9] macro expansion
      @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/Test/src/Test.jl:1151 [inlined]
   [10] top-level scope
      @ ~/.julia/dev/TimeZones/test/runtests.jl:44
   [11] include(fname::String)
      @ Base.MainInclude ./client.jl:444
   [12] top-level scope
      @ none:6
   [13] eval
      @ ./boot.jl:360 [inlined]
   [14] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:261
   [15] _start()
      @ Base ./client.jl:485
  in expression starting at /Users/sam/.julia/dev/TimeZones/test/tzdata/archive.jl:3

Unfortunately Downloads.jl only works on julia v1.3 or greater. I'm not sure how to get packages to resolve on 1.0.

omus commented 3 years ago

Can you post the full deprecation messages for the record?

omus commented 3 years ago

Unfortunately Downloads.jl only works on julia v1.3 or greater. I'm not sure how to get packages to resolve on 1.0.

We should be able to get this working by doing:

if VERSION >= v"1.3"
    using Downloads: download
else
    using Base: download
end
omus commented 3 years ago

This seems to be due to a couple of version dependent deprecations to the locations of @artifact_str and download causing failures when trying to build TimeZones with depwarn set to error.

You may also need to change this line: https://github.com/JuliaTime/TimeZones.jl/blob/781e59a2075a24651d6ae70491c4b87392640e51/src/compat.jl#L48

morris25 commented 3 years ago

Unfortunately Downloads.jl only works on julia v1.3 or greater. I'm not sure how to get packages to resolve on 1.0.

We should be able to get this working by doing:

if VERSION >= v"1.3"
    using Downloads: download
else
    using Base: download
end

The problem is that including Downloads in the Project.toml results in resolution failures in julia 1.0

(TimeZones) pkg> build
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating registry at `~/.julia/registries/Invenia`
  Updating git-repo `git@gitlab.invenia.ca:invenia/PackageRegistry.git`
 Resolving package versions...
ERROR: Unsatisfiable requirements detected for package LibCURL [b27032c2]:
 LibCURL [b27032c2] log:
 ├─possible versions are: [0.3.0-0.3.2, 0.4.0-0.4.1, 0.5.0-0.5.2, 0.6.0-0.6.3] or uninstalled
 ├─restricted by compatibility requirements with Downloads [f43a241f] to versions: 0.6.0-0.6.3
 │ └─Downloads [f43a241f] log:
 │   ├─possible versions are: [0.1.0, 0.2.0, 1.0.0, 1.1.0-1.1.1, 1.2.0, 1.3.0, 1.4.0-1.4.1, 1.5.0] or uninstalled
 │   └─restricted to versions * by an explicit requirement, leaving only versions [0.1.0, 0.2.0, 1.0.0, 1.1.0-1.1.1, 1.2.0, 1.3.0, 1.4.0-1.4.1, 1.5.0]
 └─restricted by julia compatibility requirements to versions: [0.3.0-0.3.2, 0.4.0-0.4.1, 0.5.0-0.5.2] or uninstalled — no versions left

I'm not sure if there is a way to resolve the dependencies without updating a bunch of other packages.

omus commented 3 years ago

I'm not sure if there is a way to resolve the dependencies without updating a bunch of other packages.

Posted solution ideas here: https://github.com/JuliaTime/TimeZones.jl/pull/339#discussion_r629505488

codecov-commenter commented 3 years ago

Codecov Report

Merging #339 (c34367b) into master (781e59a) will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #339   +/-   ##
=======================================
  Coverage   93.59%   93.60%           
=======================================
  Files          32       32           
  Lines        1531     1532    +1     
=======================================
+ Hits         1433     1434    +1     
  Misses         98       98           
Impacted Files Coverage Δ
src/compat.jl 0.00% <ø> (ø)
src/tzdata/build.jl 63.63% <ø> (ø)
src/tzdata/download.jl 96.00% <100.00%> (+0.08%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 781e59a...c34367b. Read the comment docs.