Skip to content

Commit

Permalink
fix tutorial installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Ortner committed Sep 16, 2024
1 parent 19158e8 commit a937f62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
10 changes: 6 additions & 4 deletions examples/Tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ This tutorial was originall developed by W Chuck Witt for the 2023 GAP/(M)ACE Us
To install the tutorial
- install Julia 1.10
- create a new folder
- active a new Julia project in this folder
- add the `ACEpotentials` package to the folder
- From the Julia repl run `using ACEpotentials; ACEpotentials.install_tutorial(@__DIR__())`; this will install `Literate` and `IJulia`, copy the notebook to the current folder in Literate format, then convert it to Jupyter format.
- Exit Julia, open Jupyter, open the `ACEpotentials-Tutorial.ipynb` notebook
- active a new Julia project in this folder, add `ACEpotentials` and run `using ACEpotentials; ACEpotentials.copy_tutorial()`. Or copy-paste the following into a terminal
```
j110 --project=. -e 'using Pkg; Pkg.add("ACEpotentials"); using ACEpotentials; ACEpotentials.copy_tutorial(@__DIR__())'
```
this will install `Literate` and `IJulia`, copy the notebook to the current folder in Literate format, then convert it to Jupyter format.
- Exit Julia, open Jupyter (e.g. `jupyter notebook`), open the `ACEpotentials-Tutorial.ipynb` notebook, start reading...

23 changes: 15 additions & 8 deletions src/json_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ end


"""
copy_runfit(dest)
copy_runfit(dest = pwd())
Copies the `runfit.jl` script and an example model parameter file to `dest`.
If called from the destination directory, use
```julia
ACEpotentials.copy_runfit(@__DIR__())
ACEpotentials.copy_runfit()
```
This is intended to setup a local project directory with the necessary
scripts to run a fitting job.
"""
function copy_runfit(dest)
function copy_runfit(dest = pwc())
script_path = joinpath(@__DIR__(), "..", "scripts")
runfit_orig = joinpath(script_path, "runfit.jl")
exjson_orig = joinpath(script_path, "example_params.json")
Expand Down Expand Up @@ -184,12 +184,19 @@ end
"""
copy_tutorial(dest)
Copies the `ACEpotential-Tutorial.ipynb` notebook file to `dest`.
Converts the `ACEpotential-Tutorial.jl` literate notebook to a jupyter notebook
and copies it to the folder `dest`.
"""
function copy_tutorial(dest)
function copy_tutorial(dest = pwd())
path = joinpath(@__DIR__(), "..", "examples", "Tutorial")
orig = joinpath(path, "ACEpotentials-Tutorial.ipynb")
dest = joinpath(dest, "ACEpotentials-Tutorial.ipynb")
run(`cp $orig $dest`)
orig = joinpath(path, "ACEpotentials-Tutorial.jl")
dest_jl = joinpath(dest, "ACEpotentials-Tutorial.jl")
cp(orig, dest_jl)
julia_cmd = Base.julia_cmd()
run(`$julia_cmd --project=. -e 'using Pkg; Pkg.add(["IJulia", "Literate"])'`)
jl_script = "using Literate; Literate.notebook(\"$dest_jl\", \"$dest\"; config = Dict(\"execute\" => false))"
run(`$julia_cmd --project=. -e $jl_script`)
rm(dest_jl)
return nothing
end

0 comments on commit a937f62

Please sign in to comment.