-
Notifications
You must be signed in to change notification settings - Fork 5
Stop using Memento #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using Memento #116
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -38,7 +38,6 @@ module JLSO | |||
| using BSON | ||||
| using CodecZlib | ||||
| using FilePathsBase: AbstractPath | ||||
| using Memento | ||||
| using Pkg: Pkg | ||||
| using Pkg.Types: semver_spec | ||||
| using Serialization | ||||
|
|
@@ -59,8 +58,6 @@ export JLSOFile | |||
| const READABLE_VERSIONS = semver_spec("1, 2, 3, 4") | ||||
| const WRITEABLE_VERSIONS = semver_spec("3, 4") | ||||
|
|
||||
| const LOGGER = getlogger(@__MODULE__) | ||||
| __init__() = Memento.register(LOGGER) | ||||
|
|
||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||
| include("JLSOFile.jl") | ||||
| include("upgrade.jl") | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,7 @@ function Base.read(io::IO, ::Type{JLSOFile}) | |||||
| ) | ||||||
| ) | ||||||
| catch e | ||||||
| warn(LOGGER, e) | ||||||
| @warn exception=e | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| Dict("raw" => d["metadata"]["manifest"]) | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,7 @@ | ||||||||||||||||||
| function _versioncheck(version::VersionNumber, valid_versions) | ||||||||||||||||||
| supported = version ∈ valid_versions | ||||||||||||||||||
| supported || error(LOGGER, ArgumentError( | ||||||||||||||||||
| string( | ||||||||||||||||||
| "Unsupported version ($version). ", | ||||||||||||||||||
| "Expected a value between ($valid_versions)." | ||||||||||||||||||
| ) | ||||||||||||||||||
| supported || throw(ArgumentError( | ||||||||||||||||||
| "Unsupported version ($version). Expected a value between ($valid_versions)." | ||||||||||||||||||
| )) | ||||||||||||||||||
|
Comment on lines
+3
to
5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| end | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,7 @@ function getindex(jlso::JLSOFile, name::Symbol) | |||||
| decompressing_buffer = decompress(jlso.compression, buffer) | ||||||
| return deserialize(jlso.format, decompressing_buffer) | ||||||
| catch e | ||||||
| warn(LOGGER, e) | ||||||
| @warn exception=e | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| return jlso.objects[name] | ||||||
| end | ||||||
| end | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,13 +16,13 @@ upgrade step. Won't be needed once the v2 file format is dropped. | |||||
| The project generated is accurate, except for duplicated names (no UUID) and custom branchs. | ||||||
| """ | ||||||
| function upgrade(src, dest) | ||||||
| info(LOGGER, "Upgrading $src -> $dest") | ||||||
| @info "Upgrading" src dest | ||||||
| jlso = open(io -> read(io, JLSOFile), src) | ||||||
| write(dest, jlso) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| end | ||||||
|
|
||||||
| function upgrade(src, dest, project, manifest) | ||||||
| info(LOGGER, "Upgrading $src -> $dest") | ||||||
| @info "Upgrading" src dest | ||||||
| parsed = BSON.load(string(src)) | ||||||
| haskey(parsed["metadata"], "pkgs") && empty!(parsed["metadata"]["pkgs"]) | ||||||
| d = upgrade_jlso(parsed) | ||||||
|
|
@@ -81,7 +81,7 @@ version_number(x::String) = VersionNumber(x) | |||||
|
|
||||||
| # Metadata changes to upgrade file from v1 to v2 | ||||||
| function upgrade_jlso(raw_dict::AbstractDict, ::Val{1}) | ||||||
| info(LOGGER, "Upgrading JLSO format from v1 to v2") | ||||||
| @info "Upgrading JLSO format from v1 to v2" | ||||||
| metadata = copy(raw_dict["metadata"]) | ||||||
| version = version_number(metadata["version"]) | ||||||
| @assert version ∈ semver_spec("1") | ||||||
|
|
@@ -98,7 +98,7 @@ end | |||||
|
|
||||||
| # Metadata changes to upgrade from v2 to v3 | ||||||
| function upgrade_jlso(raw_dict::AbstractDict, ::Val{2}) | ||||||
| info(LOGGER, "Upgrading JLSO format from v2 to v3") | ||||||
| @info "Upgrading JLSO format from v2 to v3" | ||||||
| metadata = copy(raw_dict["metadata"]) | ||||||
| version = version_number(metadata["version"]) | ||||||
| @assert version ∈ semver_spec("2") | ||||||
|
|
@@ -154,10 +154,12 @@ function _upgrade_env(pkgs::Dict{String, VersionNumber}) | |||||
| catch e | ||||||
| # Warn about failure and fallback to simply trying to install the pacakges | ||||||
| # without version constraints. | ||||||
| warn(LOGGER) do | ||||||
| @warn( | ||||||
| "Failed to construct an environment with the provide package version " * | ||||||
| "($pkgs): $e.\n Falling back to simply adding the packages." | ||||||
| end | ||||||
| "\nFalling back to simply adding the packages.", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| pkgs, | ||||||
| exception=e | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [JuliaFormatter] reported by reviewdog 🐶
Suggested change
|
||||||
| ) | ||||||
| Pkg.add([Pkg.PackageSpec(; name=key) for (key, value) in pkgs]) | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated to this PR.
CI has actually been broken for ages.
https://github.com/invenia/JLSO.jl/actions/runs/1428133005
This is because we have specimen files that were saved with TimeZones prior to v1.5.