Skip to content
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

test: fix paths using ENV #83

Merged
merged 3 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ DocMeta.setdocmeta!(
recursive = true,
)

# Citations ####################################################################
ENV["BASE_PATH"] = joinpath(@__DIR__, "../")

# Citations ####################################################################
bib = CitationBibliography(joinpath(@__DIR__, "citation.bib"))

# Generate examples ############################################################

const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
const OUTPUT_DIR = joinpath(@__DIR__, "src/generated")

function create_examples(examples, EXAMPLES_DIR, OUTPUT_DIR)
# Generate examples ############################################################
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, "/")
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"))
Expand All @@ -37,32 +37,32 @@ 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 = [
"Subsample a-HfO2 dataset with DPP and fit with ACE" => "DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl",
"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 #########################################################
Expand Down
3 changes: 2 additions & 1 deletion examples/ACE-aHfO2/fit-ace-ahfo2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/DPP-ACE-Na/fit-dpp-ace-na.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/DPP-ACE-Si/fit-dpp-ace-si.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
2 changes: 1 addition & 1 deletion examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
2 changes: 1 addition & 1 deletion examples/DPP-ACE-aHfO2-2/fit-dpp-ace-ahfo2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
2 changes: 1 addition & 1 deletion examples/LJ-Ar/lennard-jones-ar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
2 changes: 1 addition & 1 deletion examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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/";

Expand Down
Loading