Skip to content

Commit a937f62

Browse files
author
Christoph Ortner
committed
fix tutorial installation
1 parent 19158e8 commit a937f62

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

examples/Tutorial/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ This tutorial was originall developed by W Chuck Witt for the 2023 GAP/(M)ACE Us
33
To install the tutorial
44
- install Julia 1.10
55
- create a new folder
6-
- active a new Julia project in this folder
7-
- add the `ACEpotentials` package to the folder
8-
- 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.
9-
- Exit Julia, open Jupyter, open the `ACEpotentials-Tutorial.ipynb` notebook
6+
- 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
7+
```
8+
j110 --project=. -e 'using Pkg; Pkg.add("ACEpotentials"); using ACEpotentials; ACEpotentials.copy_tutorial(@__DIR__())'
9+
```
10+
this will install `Literate` and `IJulia`, copy the notebook to the current folder in Literate format, then convert it to Jupyter format.
11+
- Exit Julia, open Jupyter (e.g. `jupyter notebook`), open the `ACEpotentials-Tutorial.ipynb` notebook, start reading...
1012

src/json_interface.jl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,17 @@ end
7979

8080

8181
"""
82-
copy_runfit(dest)
82+
copy_runfit(dest = pwd())
8383
8484
Copies the `runfit.jl` script and an example model parameter file to `dest`.
8585
If called from the destination directory, use
8686
```julia
87-
ACEpotentials.copy_runfit(@__DIR__())
87+
ACEpotentials.copy_runfit()
8888
```
8989
This is intended to setup a local project directory with the necessary
9090
scripts to run a fitting job.
9191
"""
92-
function copy_runfit(dest)
92+
function copy_runfit(dest = pwc())
9393
script_path = joinpath(@__DIR__(), "..", "scripts")
9494
runfit_orig = joinpath(script_path, "runfit.jl")
9595
exjson_orig = joinpath(script_path, "example_params.json")
@@ -184,12 +184,19 @@ end
184184
"""
185185
copy_tutorial(dest)
186186
187-
Copies the `ACEpotential-Tutorial.ipynb` notebook file to `dest`.
187+
Converts the `ACEpotential-Tutorial.jl` literate notebook to a jupyter notebook
188+
and copies it to the folder `dest`.
188189
"""
189-
function copy_tutorial(dest)
190+
function copy_tutorial(dest = pwd())
190191
path = joinpath(@__DIR__(), "..", "examples", "Tutorial")
191-
orig = joinpath(path, "ACEpotentials-Tutorial.ipynb")
192-
dest = joinpath(dest, "ACEpotentials-Tutorial.ipynb")
193-
run(`cp $orig $dest`)
192+
orig = joinpath(path, "ACEpotentials-Tutorial.jl")
193+
dest_jl = joinpath(dest, "ACEpotentials-Tutorial.jl")
194+
cp(orig, dest_jl)
195+
julia_cmd = Base.julia_cmd()
196+
run(`$julia_cmd --project=. -e 'using Pkg; Pkg.add(["IJulia", "Literate"])'`)
197+
jl_script = "using Literate; Literate.notebook(\"$dest_jl\", \"$dest\"; config = Dict(\"execute\" => false))"
198+
run(`$julia_cmd --project=. -e $jl_script`)
199+
rm(dest_jl)
194200
return nothing
195201
end
202+

0 commit comments

Comments
 (0)