Skip to content
Snippets Groups Projects
Commit b472ec21 authored by Pat Alt's avatar Pat Alt
Browse files

artifacts

parent a1aff096
No related branches found
No related tags found
1 merge request!7669 initial run including fmnist lenet and new method
......@@ -19,12 +19,9 @@ MLJFlux = "094fc8d1-fd35-5302-93ea-dabda2abf845"
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SliceMap = "82cb661a-3f19-5665-9e27-df437c7e54c8"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
Term = "22787eb5-b846-44ae-b979-8e399b8463ab"
[compat]
......@@ -42,10 +39,7 @@ MLJFlux = "0.2.10"
MLJModelInterface = "1.8.0"
MLUtils = "0.4.3"
Parameters = "0.12.3"
Plots = "1.38.17"
SliceMap = "0.2.7"
StatsBase = "0.33.0 - 0.34.0"
StatsPlots = "0.15.6"
Term = "2.0.5"
julia = "1.8, 1.9"
......
This diff is collapsed.
......@@ -10,6 +10,7 @@ ECCCo = "0232c203-4013-4b0d-ad96-43e3e11ac3bf"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
JointEnergyModels = "48c56d24-211d-4463-bbc0-7a701b291131"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
MLJEnsembles = "50ed68f4-41fd-4504-931a-ed422449fee0"
......
......@@ -49,7 +49,7 @@ end
include("data/data.jl")
include("models/models.jl")
include("benchmarking/benchmarking.jl")
include("post_processing.jl")
include("post_processing/post_processing.jl")
"""
train_models!(outcome::ExperimentOutcome, exp::Experiment)
......
using ghr_jll
using LazyArtifacts
using LibGit2
using Pkg.Artifacts
using Serialization
"""
generate_artifacts(
datafiles=DEFAULT_OUTPUT_PATH;
artifact_name=nothing,
root=".",
artifact_toml=LazyArtifacts.find_artifacts_toml("."),
deploy=true,
tag=nothing
)
Uploads results to github releases. If `deploy=true`, then the results will be uploaded to a github release. If `deploy=false`, then the results will be saved locally.
"""
function generate_artifacts(
datafiles=DEFAULT_OUTPUT_PATH;
artifact_name=nothing,
root=".",
artifact_toml=LazyArtifacts.find_artifacts_toml("."),
deploy=true,
tag=nothing
)
# Artifact name:
if isnothing(artifact_name)
suffix = TIME_STAMPED ? "" : "_$(Dates.format(now(), "yyyy-mm-dd@HH:MM"))"
artifact_name = "artifacts_$(split(datafiles, "/")[end])$(suffix)"
end
# Artifact tag:
if isnothing(tag)
tag = replace(lowercase(artifact_name), " " => "-")
end
if deploy && !haskey(ENV, "GITHUB_TOKEN")
@warn "For automatic github deployment, need GITHUB_TOKEN. Not found in ENV, attemptimg global git config."
end
if deploy
# Where we will put our tarballs
tempdir = mktempdir()
# Try to detect where we should upload these weights to (or just override
# as shown in the commented-out line)
origin_url = get_git_remote_url(root)
deploy_repo = "$(basename(dirname(origin_url)))/$(basename(origin_url))"
end
# create_artifact() returns the content-hash of the artifact directory once we're finished creating it
hash = create_artifact() do artifact_dir
cp(datafiles, joinpath(artifact_dir, artifact_name))
end
# Spit tarballs to be hosted out to local temporary directory:
if deploy
tarball_hash = archive_artifact(hash, joinpath(tempdir, "$(artifact_name).tar.gz"))
# Calculate tarball url
tarball_url = "https://github.com/$(deploy_repo)/releases/download/$(tag)/$(artifact_name).tar.gz"
# Bind this to an Artifacts.toml file
@info("Binding $(artifact_name) in Artifacts.toml...")
bind_artifact!(
artifact_toml,
artifact_name,
hash;
download_info=[(tarball_url, tarball_hash)],
lazy=true,
force=true
)
end
if deploy
# Upload tarballs to a special github release
@info("Uploading tarballs to $(deploy_repo) tag `$(tag)`")
ghr() do ghr_exe
println(
readchomp(
`$ghr_exe -replace -u $(dirname(deploy_repo)) -r $(basename(deploy_repo)) $(tag) $(tempdir)`,
),
)
end
@info("Artifacts.toml file now contains all bound artifact names")
end
end
function get_git_remote_url(repo_path::String=".")
repo = LibGit2.GitRepo(repo_path)
origin = LibGit2.get(LibGit2.GitRemote, repo, "origin")
return LibGit2.url(origin)
end
......@@ -10,7 +10,7 @@ function meta(outcome::ExperimentOutcome; save_output::Bool=false)
generator_params = meta_generators(outcome; save_output=save_output)
return model_params, model_performance, generator_params
end
"""
......@@ -40,7 +40,7 @@ function meta_model(outcome::ExperimentOutcome; save_output::Bool=false)
:jem_sampling_steps => exp.sampling_steps,
)
)
if save_output
save_path = joinpath(exp.params_path, "$(exp.save_name)_model_params.csv")
@info "Saving model parameters to $(save_path)."
......@@ -107,7 +107,7 @@ function meta_model_performance(outcome::ExperimentOutcome; measures::Union{Noth
_perf.dataname .= exp.dataname
model_performance = vcat(model_performance, _perf)
end
@info "Model performance:"
println(model_performance)
......@@ -121,4 +121,5 @@ function meta_model_performance(outcome::ExperimentOutcome; measures::Union{Noth
end
return model_performance
end
\ No newline at end of file
end
include("meta_data.jl")
include("artifacts.jl")
\ No newline at end of file
......@@ -42,3 +42,8 @@ end
if USE_MPI
MPI.Finalize()
end
if UPLOAD
@info "Uploading results."
generate_artifacts()
end
......@@ -61,16 +61,19 @@ artifact_toml = LazyArtifacts.find_artifacts_toml(".")
_hash = artifact_hash(ARTIFACT_NAME, artifact_toml)
const LATEST_ARTIFACT_PATH = joinpath(artifact_path(_hash), ARTIFACT_NAME)
time_stamped = false
if any(contains.(ARGS, "output_path"))
@assert sum(contains.(ARGS, "output_path")) == 1 "Only one output path can be specified."
_path = ARGS[findall(contains.(ARGS, "output_path"))][1] |> x -> replace(x, "output_path=" => "")
else
timestamp = Dates.format(now(), "yyyy-mm-dd@HH:MM")
time_stamped = true
_path = "$(pwd())/results_$(timestamp)"
end
"Default output path."
const DEFAULT_OUTPUT_PATH = _path
const TIME_STAMPED = time_stamped
ispath(DEFAULT_OUTPUT_PATH) || mkpath(DEFAULT_OUTPUT_PATH)
......@@ -101,4 +104,8 @@ const CE_MEASURES = [
]
"Test set proportion."
const TEST_SIZE = 0.2
\ No newline at end of file
const TEST_SIZE = 0.2
if "upload" ARGS
const UPLOAD = true
end
\ No newline at end of file
include("setup_env.jl");
generate_artifacts()
\ No newline at end of file
......@@ -6,7 +6,6 @@ using MLJBase
using MLJEnsembles
using MLJFlux
using MLUtils
using SliceMap
using Statistics
const CompatibleAtomicModel = Union{<:MLJFlux.MLJFluxProbabilistic,MLJEnsembles.ProbabilisticEnsembleModel{<:MLJFlux.MLJFluxProbabilistic}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment