From 6d4e627458ffe56306362c97c43b4278fc4d0588 Mon Sep 17 00:00:00 2001 From: Emmanuel Lujan Date: Sat, 13 Jul 2024 15:50:28 -0400 Subject: [PATCH 1/3] test: fix paths using ENV --- docs/make.jl | 24 +++++++++---------- examples/ACE-aHfO2/fit-ace-ahfo2.jl | 3 ++- examples/DPP-ACE-Na/fit-dpp-ace-na.jl | 2 +- examples/DPP-ACE-Si/fit-dpp-ace-si.jl | 2 +- examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl | 2 +- examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl | 2 +- examples/LJ-Ar/lennard-jones-ar.jl | 2 +- examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl | 2 +- examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 46d3ced..77eb6ea 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -12,20 +12,20 @@ DocMeta.setdocmeta!( # Citations #################################################################### -bib = CitationBibliography(joinpath(@__DIR__, "citation.bib")) +bib = CitationBibliography("citation.bib") # Generate examples ############################################################ +ENV["BASE_PATH"] = joinpath(@__DIR__, "../") +const examples_path = joinpath(@__DIR__, "..", "examples") +const output_path = joinpath(@__DIR__, "src/generated") -const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples") -const OUTPUT_DIR = joinpath(@__DIR__, "src/generated") - -function create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +function create_examples(examples, examples_path, output_path) for (_, example_path) in examples s = split(example_path, "/") sub_path, file_name = string(s[1:end-1]...), s[end] - example_filepath = joinpath(EXAMPLES_DIR, example_path) + example_filepath = joinpath(examples_path, example_path) Literate.markdown(example_filepath, - joinpath(OUTPUT_DIR, sub_path), + joinpath(output_path, sub_path), documenter = true) end examples = [title => joinpath("generated", replace(example_path, ".jl" => ".md")) @@ -37,7 +37,7 @@ end examples = [ "Fit a-HfO2 dataset with ACE" => "ACE-aHfO2/fit-ace-ahfo2.jl", ] -basic_examples = create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +basic_examples = create_examples(examples, examples_path, output_path) # Subsampling examples examples = [ @@ -45,24 +45,24 @@ examples = [ "Subsample Na dataset with DPP and fit with ACE" => "DPP-ACE-Na/fit-dpp-ace-na.jl", "Subsample Si dataset with DPP, fit with ACE, and cross validate" => "DPP-ACE-Si/fit-dpp-ace-si.jl", ] -ss_examples = create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +ss_examples = create_examples(examples, examples_path, output_path) # Optimization examples examples = [ "Optimize ACE hyper-parameters: minimize force time and fitting error" => "Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl", ] -opt_examples = create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +opt_examples = create_examples(examples, examples_path, output_path) # Dimension reduction examples examples = [ "Reduce ACE descriptors with PCA and fit a-HfO2 dataset" => "PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl", ] -dr_examples = create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +dr_examples = create_examples(examples, examples_path, output_path) examples = [ "Load Ar+Lennard-Jones dataset and postprocess" => "LJ-Ar/lennard-jones-ar.jl" ] -misc_examples = create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR) +misc_examples = create_examples(examples, examples_path, output_path) # Make and deploy docs ######################################################### diff --git a/examples/ACE-aHfO2/fit-ace-ahfo2.jl b/examples/ACE-aHfO2/fit-ace-ahfo2.jl index 429ffd2..d49fb08 100644 --- a/examples/ACE-aHfO2/fit-ace-ahfo2.jl +++ b/examples/ACE-aHfO2/fit-ace-ahfo2.jl @@ -8,11 +8,12 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/ACE-aHfO2/results/"; # Load utility functions. + include("$base_path/examples/utils/utils.jl") # Create experiment folder. diff --git a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl index 0e1c9db..e0d04cb 100644 --- a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl +++ b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl @@ -8,7 +8,7 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/Na/liquify_sodium.yaml" # ## b. Load atomistic dataset and split it into training and test. diff --git a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl index 2d2e83e..2bd7342 100644 --- a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl +++ b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl @@ -13,7 +13,7 @@ using CSV, JLD, DataFrames elname, elspec = "Si", [:Si] # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." inpath = "$base_path/examples/data/Si-3Body-LAMMPS/" outpath = "$base_path/examples/DPP-ACE-Si/output/$elname/"; diff --git a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl index 214633b..bad3d27 100644 --- a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl @@ -8,7 +8,7 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/DPP-ACE-aHfO2-1/results/"; diff --git a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl index ad87cb1..3e2763d 100644 --- a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl @@ -6,7 +6,7 @@ using JLD, CairoMakie #################### Importing Data ################### -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/a-HfO2/aHfO2_diverse_descriptors_3600.jld" res_path = "$base_path/examples/DPP-ACE-aHfO2-2/results/"; diff --git a/examples/LJ-Ar/lennard-jones-ar.jl b/examples/LJ-Ar/lennard-jones-ar.jl index edcc2e8..944fe1c 100644 --- a/examples/LJ-Ar/lennard-jones-ar.jl +++ b/examples/LJ-Ar/lennard-jones-ar.jl @@ -8,7 +8,7 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots, DisplayAs # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/LJ-AR/lj-ar.yaml" # ## b. Load atomistic dataset. diff --git a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl index c49bcab..01ce81d 100644 --- a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl +++ b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl @@ -9,7 +9,7 @@ using LinearAlgebra, Random, DisplayAs using DataFrames, Hyperopt # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/Opt-ACE-aHfO2/results/"; diff --git a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl index a7f7373..cdf9564 100644 --- a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl +++ b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl @@ -8,7 +8,7 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = match(r"^(.*/PotentialLearning/)", @__DIR__).match +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/PCA-ACE-aHfO2/results/"; From 2dc9cbb42b45227f5c0766bab4f0ca3e707863ea Mon Sep 17 00:00:00 2001 From: Emmanuel Lujan Date: Sat, 13 Jul 2024 15:57:59 -0400 Subject: [PATCH 2/3] Fix paths --- examples/ACE-aHfO2/fit-ace-ahfo2.jl | 2 +- examples/DPP-ACE-Na/fit-dpp-ace-na.jl | 2 +- examples/DPP-ACE-Si/fit-dpp-ace-si.jl | 2 +- examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl | 2 +- examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl | 2 +- examples/LJ-Ar/lennard-jones-ar.jl | 2 +- examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl | 2 +- examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/ACE-aHfO2/fit-ace-ahfo2.jl b/examples/ACE-aHfO2/fit-ace-ahfo2.jl index d49fb08..caf9053 100644 --- a/examples/ACE-aHfO2/fit-ace-ahfo2.jl +++ b/examples/ACE-aHfO2/fit-ace-ahfo2.jl @@ -8,7 +8,7 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/ACE-aHfO2/results/"; diff --git a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl index e0d04cb..7b86601 100644 --- a/examples/DPP-ACE-Na/fit-dpp-ace-na.jl +++ b/examples/DPP-ACE-Na/fit-dpp-ace-na.jl @@ -8,7 +8,7 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/Na/liquify_sodium.yaml" # ## b. Load atomistic dataset and split it into training and test. diff --git a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl index 2bd7342..6acd335 100644 --- a/examples/DPP-ACE-Si/fit-dpp-ace-si.jl +++ b/examples/DPP-ACE-Si/fit-dpp-ace-si.jl @@ -13,7 +13,7 @@ using CSV, JLD, DataFrames elname, elspec = "Si", [:Si] # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" inpath = "$base_path/examples/data/Si-3Body-LAMMPS/" outpath = "$base_path/examples/DPP-ACE-Si/output/$elname/"; diff --git a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl index bad3d27..5c12ac4 100644 --- a/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl @@ -8,7 +8,7 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/DPP-ACE-aHfO2-1/results/"; diff --git a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl index 3e2763d..a04d49d 100644 --- a/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl +++ b/examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl @@ -6,7 +6,7 @@ using JLD, CairoMakie #################### Importing Data ################### -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/a-HfO2/aHfO2_diverse_descriptors_3600.jld" res_path = "$base_path/examples/DPP-ACE-aHfO2-2/results/"; diff --git a/examples/LJ-Ar/lennard-jones-ar.jl b/examples/LJ-Ar/lennard-jones-ar.jl index 944fe1c..580615d 100644 --- a/examples/LJ-Ar/lennard-jones-ar.jl +++ b/examples/LJ-Ar/lennard-jones-ar.jl @@ -8,7 +8,7 @@ using AtomsBase, InteratomicPotentials, PotentialLearning using LinearAlgebra, Plots, DisplayAs # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/LJ-AR/lj-ar.yaml" # ## b. Load atomistic dataset. diff --git a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl index 01ce81d..6f00e41 100644 --- a/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl +++ b/examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl @@ -9,7 +9,7 @@ using LinearAlgebra, Random, DisplayAs using DataFrames, Hyperopt # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/Opt-ACE-aHfO2/results/"; diff --git a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl index cdf9564..f53f1a9 100644 --- a/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl +++ b/examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl @@ -8,7 +8,7 @@ using Unitful, UnitfulAtomic using LinearAlgebra, Random, DisplayAs # Define paths. -base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "." +base_path = haskey(ENV, "BASE_PATH") ? ENV["BASE_PATH"] : "../../" ds_path = "$base_path/examples/data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz" res_path = "$base_path/examples/PCA-ACE-aHfO2/results/"; From cc4f9c0a22bf705194b336edf0980de33eaa9c98 Mon Sep 17 00:00:00 2001 From: Emmanuel Lujan Date: Sat, 13 Jul 2024 16:08:47 -0400 Subject: [PATCH 3/3] Fix paths --- docs/make.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 77eb6ea..e780f9b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -10,15 +10,15 @@ DocMeta.setdocmeta!( recursive = true, ) +ENV["BASE_PATH"] = joinpath(@__DIR__, "../") + # Citations #################################################################### +bib = CitationBibliography(joinpath(@__DIR__, "citation.bib")) -bib = CitationBibliography("citation.bib") # Generate examples ############################################################ -ENV["BASE_PATH"] = joinpath(@__DIR__, "../") const examples_path = joinpath(@__DIR__, "..", "examples") const output_path = joinpath(@__DIR__, "src/generated") - function create_examples(examples, examples_path, output_path) for (_, example_path) in examples s = split(example_path, "/")