Open kescobo opened 4 years ago
That could be a good idea, there's also FormatSpecimens.jl which is versioned like a package and has a few functions for querying and getting lists of the provided specimens.
I wrote this helper to bind downloads of individual files or packed/zipped files. This may assist with setting up Artifacts.toml. It generates both of the required hashes.
using Pkg
using Pkg.Artifacts
using Pkg.PlatformEngines #Note: supplies unpack.
using SHA
function bind_download!(artifacts_toml::String, url::String, artifact_name::String=basename(url); lazy::Bool = true, force::Bool = false, packed::Bool=false, platform::Union{Platform,Nothing} = nothing)
function acquire(path::AbstractString, io::IO)
download(url, path)
tarball_hash = open(path) do f
bytes2hex(sha2_256(f))
end
tree_hash = create_artifact() do path_artifact #Note: this will create an artifact that is ready for use.
if packed === true
unpack(path, path_artifact)
else
cp(path, joinpath(path_artifact, basename(url))) #Note: path is expected for cleanup.
end
end
return tree_hash, tarball_hash
end
# Acquire artifact.
(tree_hash, tarball_hash) = mktemp(acquire)
bind_artifact!(artifacts_toml, artifact_name, tree_hash, download_info=[(url,tarball_hash)], lazy=lazy, force=force, platform=platform)
return tree_hash
end
I've made my artifacts workflow available at ArtifactHelpers.jl.
ArtifactHelpers has changed quite a bit over the past 8 days and is probably worth another look.
Right now, most julia packages making use of these files do so using something like this (taken from here)
I was wondering if we should move instead to using Lazy-loading Artifacts.toml files instead.