-
-
Notifications
You must be signed in to change notification settings - Fork 276
WIP: Implement new manifest format with top-level metadata #2557
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
Conversation
@@ -1024,8 +1024,8 @@ function precompile(ctx::Context; internal_call::Bool=false, strict::Bool=false, | |||
for (name, uuid) in ctx.env.project.deps if !Base.in_sysimage(Base.PkgId(uuid, name)) | |||
] | |||
|
|||
man = Pkg.Types.read_manifest(ctx.env.manifest_file) | |||
deps_pair_or_nothing = Iterators.map(man) do dep | |||
man = ctx.env.manifest |
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.
I don't see why the manifest needed re-reading here. I may have just been unaware of the manifest cache when writing it. This change should just speed things up
It looks like the structure in this PR is this:
How about doing this instead?
That way, if we add more metadata in the future, we don't need to add them as top-level keys. |
c589dfd
to
29908fd
Compare
Why not have a toplevel key that can never be a name of a Julia package? For example |
This would still be breaking. For example, this manifest instantiates just fine on Julia master: [[Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
uuid = "7876af07-990d-54b4-ab0e-23690620f79a"
version = "0.5.3" However, if I take this manifest... [manifest-metadata]
julia_version = "123"
[[Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
uuid = "7876af07-990d-54b4-ab0e-23690620f79a"
version = "0.5.3" ... and I try to instantiate it, I get this error: julia> Pkg.instantiate()
┌ Error: Could not parse entry for `manifest-metadata`
└ @ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:153
ERROR: MethodError: no method matching get(::Pair{String, Any}, ::String, ::Nothing)
Closest candidates are:
get(::IdDict{K, V}, ::Any, ::Any) where {K, V} at iddict.jl:101
get(::IOContext, ::Any, ::Any) at show.jl:343
get(::Dict{K, V}, ::Any, ::Any) where {K, V} at dict.jl:504
...
Stacktrace:
[1] Dict{Base.UUID, Pkg.Types.PackageEntry}(raw::Dict{String, Any})
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:141
[2] read_manifest(f_or_io::String)
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:177
[3] Pkg.Types.EnvCache(env::Nothing)
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/Types.jl:306
[4] EnvCache
@ ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/Types.jl:285 [inlined]
[5] Pkg.Types.Context()
@ Pkg.Types ./util.jl:471
[6] #instantiate#278
@ ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/API.jl:1399 [inlined]
[7] instantiate()
@ Pkg.API ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/API.jl:1399
[8] top-level scope
@ REPL[2]:1 Similarly, if I take this manifest... [".metadata"]
julia_version = "123"
[[Example]]
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc"
uuid = "7876af07-990d-54b4-ab0e-23690620f79a"
version = "0.5.3" ... and I try to instantiate it, I get the same error: julia> Pkg.instantiate()
┌ Error: Could not parse entry for `.metadata`
└ @ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:153
ERROR: MethodError: no method matching get(::Pair{String, Any}, ::String, ::Nothing)
Closest candidates are:
get(::IdDict{K, V}, ::Any, ::Any) where {K, V} at iddict.jl:101
get(::IOContext, ::Any, ::Any) at show.jl:343
get(::Dict{K, V}, ::Any, ::Any) where {K, V} at dict.jl:504
...
Stacktrace:
[1] Dict{Base.UUID, Pkg.Types.PackageEntry}(raw::Dict{String, Any})
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:141
[2] read_manifest(f_or_io::String)
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/manifest.jl:177
[3] Pkg.Types.EnvCache(env::Nothing)
@ Pkg.Types ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/Types.jl:306
[4] EnvCache
@ ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/Types.jl:285 [inlined]
[5] Pkg.Types.Context()
@ Pkg.Types ./util.jl:471
[6] #instantiate#278
@ ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/API.jl:1399 [inlined]
[7] instantiate()
@ Pkg.API ~/dev/repos/JuliaLang/julia/usr/share/julia/stdlib/v1.7/Pkg/src/API.jl:1399
[8] top-level scope
@ REPL[2]:1 I am pretty sure that all three of those manifests are valid TOML. All three parse just fine using the But the second and third manifests throw errors when you try to |
0f7f779
to
975af0d
Compare
975af0d
to
bddd72c
Compare
Tests are passing now (ignore appveyor, only github actions are set to use JuliaLang/julia#40765) On the format, I think this format makes most sense to me of the things brought up. There was some discussion on slack and I think it's fair to say that the conclusion was that there's no decent way to add the julia version and retain backwards compatibility, so the format might as well be redone to make it more expandable. |
I agree that we should redo the format in a breaking way. I.e. I don't think that there is any way to keep backwards-compatibility. But I'm still having trouble understanding why Is there a specific reason why |
E.g. this is what I'm suggesting: # This file is machine-generated - editing it directly is not advised
[metadata]
julia_version = "1.7.0-DEV.1077"
project_hash = "nothing"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[deps.Distributed]]
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" To me personally, it looks a lot cleaner to just have two top-level keys ( |
If we really want to be concise, we can make the top-level keys # This file is machine-generated - editing it directly is not advised
[meta]
julia_version = "1.7.0-DEV.1077"
project_hash = "nothing"
[[deps.Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[deps.Distributed]]
deps = ["LinearAlgebra", "Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" |
But it wouldn't require changes to code loading |
I personally don't like metadata that is "non-structural", for example by some naming convention. It makes writing code for it very awkward. |
I don't see a reason to add an extra "metadata" key. I think the first PR should only change things to have If this is the format we go with, we should probably backport the support for reading it to 1.6 (which is another reason for trying to keep it as minimal as possible). |
Presumably, in the future, we want to be able to add more metadata, right? Won't it get messy if each new piece of metadata is a top-level key? |
Wouldn't having a top-level But in contrast, if we have each piece of metadata as a top-level key, then when we backport support to 1.6, we need to teach 1.6 about each individual top-level key and how to handle it. Whereas if all metadata is under |
Also, what if in the future we want to add information to the manifest that is neither dependencies nor metadata? E.g. maybe (just for example, I'm not saying we should actually do this) we start putting information in the manifest about the specific versions of artifacts that were downloaded. That information would not go into the If we have separate But if we don't have a top-level |
I tried to keep it minimal in #2561 |
This is great! Has there been some discussion about the behavior if one tries to load a project with a non-matching Julia version? I'm curios because the stuff I've been doing over at https://github.com/JuliaLang/juliaup would make it relatively trivial to have a situation where the launcher from I think that discussion is potentially orthogonal to the more narrow design of this PR, but at the same time clearly related. If you feel this would derail this PR, we could also discuss my question over at JuliaLang/juliaup#10. |
Another thought: might it make sense to add another field |
A WIP go at implementing a new manifest format that:
julia_version
andproject_hash
metadata fieldsdeps
fieldDependent on:
Base.hash
methods and add tests #2556Example manifest:
Notes:
julia_version
is set tonothing