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

removed docs, changed Examples to match FMI.jl #54

Merged
merged 5 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
71 changes: 0 additions & 71 deletions .github/workflows/Documentation.yml

This file was deleted.

129 changes: 78 additions & 51 deletions .github/workflows/Example.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,103 @@
name: Examples v1 (latest)
name: Examples

on:
workflow_run:
workflows: ["Test v1 (latest)"]
types:
- completed
workflow_dispatch:
pull_request:
push:
branches:
- examples

branches:
- main
paths:
- 'src/**'
- 'examples/**'
- '.github/workflows/Example.yml'
- 'Project.toml'

jobs:
sync-files:
if: |
${{ (github.event.workflow_run.conclusion == 'success' && github.sha == github.event.workflow_run.head_sha) ||
(github.event_name == 'push' && github.event.head_commit.committer.name != 'github-actions[bot]') }}
jupyter:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
julia-version: ['1.9']
os: [windows-latest] # ubuntu-latest
file-name: []
julia-version: ['1.10'] # 1.9
julia-arch: [x64]
0815Creeper marked this conversation as resolved.
Show resolved Hide resolved
os: [windows-latest]
experimental: [false]
experimental: [false] # true

steps:
- name: "Check out repository"
uses: actions/checkout@v4
with:
ref: examples

- name: "Set up Julia"
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}

- name: "Build package"
uses: julia-actions/julia-buildpkg@v1
- name: "Install dependencies"
run: julia --project=examples/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'

- name: "Install packages"
run: pip install jupyter nbconvert

- name: "Execute notebook"
env:
FILE: examples/jupyter-src/${{ matrix.file-name }}.ipynb
run: jupyter nbconvert --ExecutePreprocessor.kernel_name="julia-${{ matrix.julia-version }}" --to notebook --inplace --execute ${{ env.FILE }}

- name: "Set path filter"
uses: dorny/paths-filter@v3
id: filter
with:
list-files: shell
filters: |
all:
- 'examples/**.ipynb'
changed:
- added|modified: 'examples/**.ipynb'
base: 'examples'
ref: 'examples'

- name: "Execute and synchronize changed files"
if: ${{ github.event_name == 'push' && steps.filter.outputs.changed == 'true' }}
- name: "Export notebook to jl and md"
env:
FILE: examples/jupyter-src/${{ matrix.file-name }}.ipynb
run: |
jupyter nbconvert --ExecutePreprocessor.kernel_name="julia-1.9" --to notebook --inplace --execute ${{ steps.filter.outputs.changed_files }}
jupyter nbconvert --to script ${{ steps.filter.outputs.changed_files }}
jupyter nbconvert --to markdown ${{ steps.filter.outputs.changed_files }}

- name: "Execute and synchronize all files"
if: ${{ github.event_name == 'workflow_run' && steps.filter.outputs.all == 'true'}}
run: |
jupyter nbconvert --ExecutePreprocessor.kernel_name="julia-1.9" --to notebook --inplace --execute ${{ steps.filter.outputs.all_files }}
jupyter nbconvert --to script ${{ steps.filter.outputs.all_files }}
jupyter nbconvert --to markdown ${{ steps.filter.outputs.all_files }}

- name: "Auto commit"
if: ${{ matrix.os == 'ubuntu-latest'}}
uses: stefanzweifel/git-auto-commit-action@v5
jupyter nbconvert --to script ${{ env.FILE }}
jupyter nbconvert --to markdown ${{ env.FILE }}

- name: "run generated jl script to determine success of example building"
run: julia --project=examples/ examples/jupyter-src/${{ matrix.file-name }}.jl

- name: "auto-commit (retry on merge)"
if: success() && github.event_name != 'pull_request' && github.ref_name == 'main'
uses: nick-fields/retry@v3
env:
CI_COMMIT_MESSAGE: jupyter-example-${{ matrix.file-name }}-${{ matrix.os }}-${{ matrix.julia-version }}-${{ matrix.julia-arch }}-${{ matrix.experimental }}[${{ github.ref_name }}]
CI_COMMIT_AUTHOR: github-actions[bot]
EXAMPLES_PATH: examples/jupyter-src
# Fetch all and clear the stash list. Include all files from the examples folder to the stash and switch the branch.
# Reset the branch and remove all current files in the examples folder.
# Checkout the last stash to restore the new notebooks and apply the stash index to restore all other new files in the folder.
with:
timeout_minutes: 999
max_attempts: 10
warning_on_retry: false
shell: bash
command: |
git fetch --all
git stash clear
git stash --include-untracked -- ${{ env.EXAMPLES_PATH }}/${{ matrix.file-name }}*
git switch examples
git reset --hard origin/examples
rm -r ${{ env.EXAMPLES_PATH }}/${{ matrix.file-name }}*
git checkout stash -f -- ${{ env.EXAMPLES_PATH }}
git stash apply --index
git stash drop
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.CI_COMMIT_AUTHOR }}@users.noreply.github.com"
git config --global core.autocrlf false
git pull
git reset
git add ${{ env.EXAMPLES_PATH }}/${{ matrix.file-name }}*
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
git push origin examples || (git reset --soft HEAD~1 && (exit 1))

call-docu:
needs: [jupyter]
if: github.event_name != 'pull_request' && github.ref_name == 'main'
runs-on: ubuntu-latest
steps:
# Trigger an repoisitory dispath event
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
commit_message: Jupyter nbconvert synch - modified, paired .ipynb files
push_options: '--force-with-lease'
token: ${{ secrets.FMI_DOC_TRIGGER_PAT }}
repository: 'ThummeTo/FMIExport.jl'
event-type: trigger-docu
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ docs/site/
# committed for packages, but should be committed for applications that require a static
# environment.
Manifest.toml
LocalPreferences.toml

# Custom
tmp/
.vscode/settings.json
examples/jupyter-src/.ipynb_checkpoints/
1 change: 0 additions & 1 deletion docs/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions docs/Project.toml

This file was deleted.

40 changes: 0 additions & 40 deletions docs/make.jl

This file was deleted.

3 changes: 0 additions & 3 deletions docs/src/contents.md

This file was deleted.

8 changes: 0 additions & 8 deletions docs/src/examples/overview.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/src/faq.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/src/features.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/src/library.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/src/related.md

This file was deleted.

10 changes: 10 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name = "Examples"

[deps]
FMIBuild = "226f0e26-6dd6-4589-ada7-1d32f6e1d800"
FMIExport = "31b88311-cab6-44ed-ba9c-fe5a9abbd67a"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"

[compat]
FMIBuild = "0.3.2"
julia = "1.6"
39 changes: 39 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
![FMI.jl Logo](https://github.com/ThummeTo/FMI.jl/blob/main/logo/dark/fmijl_logo_640_320.png?raw=true "FMI.jl Logo")

# Structure

Examples can be found in the [examples folder in the examples branch](https://github.com/ThummeTo/FMIExport.jl/tree/examples/examples) or the [examples section of the documentation](https://thummeto.github.io/FMI.jl/dev/examples/overview/). All examples are available as Julia-Script (*.jl*), Jupyter-Notebook (*.ipynb*) and Markdown (*.md*).


# Getting Started

## Install Jupyter in Visual Studio Code
The Jupyter Notebooks extension for Visual Studio Code can be [here](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter).

## Add Julia Kernel to Jupyter
To run Julia as kernel in a jupyter notebook it is necessary to add the **IJulia** package.

1. Start the Julia REPL.

```
julia
```

2. Select your environment.
```julia
using Pkg
Pkg.activate("Your Env")
```

3. Add and build the IJulia package by typing inside the Julia REPL.

```julia
using Pkg
Pkg.add("IJulia")
Pkg.build("IJulia")
```

4. Now you should be able to choose a Julia kernel in a Jupyter notebook.


More information can be found [here](https://towardsdatascience.com/how-to-best-use-julia-with-jupyter-82678a482677).
3 changes: 3 additions & 0 deletions examples/jupyter-src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp/
.ipynb_checkpoints/
*.png
Loading