Skip to content
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
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,31 @@ Static outputs in pdf, markdown, and html reside in [SciMLTutorialsOutput](https

## Interactive Notebooks

To run the tutorials interactively via Jupyter notebooks and benchmark on your
own machine
1. Run Weave for the file (or folder) you are interested in
2. Activate the appropriate environment
3. Open and run the notebook.
To generate the interactive notebooks, first install the SciMLTutorials, instantiate the
environment, and then run `SciMLTutorials.open_notebooks()`. This looks as follows:

Note: Since notebooks default to looking for a Project.toml file at the same level or parent folder, you might need to move the notebook to the folder with the appropriate Project.toml.

### Example (starting from the project root folder)
```julia
]activate .
]add SciMLTutorials#master
]activate SciMLTutorials
]instantiate
using SciMLTutorials
SciMLTutorials.weave_file("tutorials/models", "01-classical_physics.jmd", [:notebook])
]activate tutorials/models
SciMLTutorials.open_notebooks()
```

The tutorials will be generated at your `pwd()` in a folder called `generated_notebooks`.

Note that when running the tutorials, the packages are not automatically added. Thus you
will need to add the packages manually or use the internal Project/Manifest tomls to
instantiate the correct packages. This can be done by activating the folder of the tutorials.
For example,

```julia
using Pkg
Pkg.activate(joinpath(pkgdir(SciMLTutorials),"tutorials","models"))
Pkg.instantiate()
```

Then move `01-classical_physics.jmd` to "tutorials/models" and open the notebook.
will add all of the packages required to run any tutorial in the `models` folder.

## Contributing

Expand Down
8 changes: 5 additions & 3 deletions src/SciMLTutorials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function weave_file(folder,file,build_list=default_builds)
target = joinpath(folder, file)
@info("Weaving $(target)")

if isfile(joinpath(folder, "Project.toml"))
if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,)
@info("Instantiating", folder)
Pkg.activate(joinpath(folder))
Pkg.instantiate()
Expand Down Expand Up @@ -61,7 +61,7 @@ end
function weave_all(build_list=default_builds)
for folder in readdir(joinpath(repo_directory,"tutorials"))
folder == "test.jmd" && continue
weave_folder(folder,build_list)
weave_folder(joinpath(repo_directory,"tutorials",folder),build_list)
end
end

Expand Down Expand Up @@ -130,7 +130,9 @@ function open_notebooks()
Base.eval(Main, Meta.parse("import IJulia"))
weave_all((:notebook,))
path = joinpath(repo_directory,"notebook")
IJulia.notebook(;dir=path)
newpath = joinpath(pwd(),"generated_notebooks")
mv(path, newpath)
IJulia.notebook(;dir=newpath)
end

end