From e4d784b8b82e8007f966798ebf0d21171d879e41 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 16 Oct 2024 23:00:43 -0700 Subject: [PATCH 01/15] initial loading of sphinx api documentation --- .github/workflows/sphinx.yml | 24 +++++++++++++++++++++ .gitignore | 1 + docs/Makefile | 20 +++++++++++++++++ docs/make.bat | 35 ++++++++++++++++++++++++++++++ docs/source/conf.py | 42 ++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 19 ++++++++++++++++ src/lasdi/inputs.py | 2 +- 7 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/sphinx.yml create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml new file mode 100644 index 0000000..674ff26 --- /dev/null +++ b/.github/workflows/sphinx.yml @@ -0,0 +1,24 @@ +name: "Sphinx: Render docs" + +on: push + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Build HTML + uses: ammaraskar/sphinx-action@master + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: html-docs + path: docs/build/html/ + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + # if: github.ref == 'refs/heads/main' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: docs/build/html \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5d540ee..793942b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ examples/results examples/checkpoint *.npy build +docs/build \ No newline at end of file diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..747ffb7 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..7b0c61a --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,42 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information + +import os, sys +sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath('../../src')) + +project = 'LaSDI' +copyright = '2024, Kevin Chung' +author = 'Kevin Chung' +release = '2.0' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'autoapi.extension', + 'sphinx.ext.napoleon', +] + +autoapi_dirs = ['../../src'] + +napoleon_google_docstring = False +napoleon_use_param = False +napoleon_use_ivar = True + +templates_path = ['_templates'] +exclude_patterns = [] + + + +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output + +html_theme = 'sphinx_rtd_theme' +html_static_path = ['_static'] diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..3ebe8d0 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,19 @@ +.. LaSDI documentation master file, created by + sphinx-quickstart on Wed Oct 16 22:11:53 2024. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +LaSDI documentation +=================== + +Add your content using ``reStructuredText`` syntax. See the +`reStructuredText `_ +documentation for details. + + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + lasdi + diff --git a/src/lasdi/inputs.py b/src/lasdi/inputs.py index 656102f..0a654b6 100644 --- a/src/lasdi/inputs.py +++ b/src/lasdi/inputs.py @@ -47,7 +47,7 @@ def getDictFromList(list_, inputDict): ''' get a dict with {key: val} from a list of dicts NOTE: it returns only the first item in the list, - even if the list has more than one dict with {key: val}. + even if the list has more than one dict with {key: val}. ''' dict_ = None for item in list_: From 48be0cf208b240c9b4631bfb71c7b02da6ec9bbe Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 16 Oct 2024 23:10:50 -0700 Subject: [PATCH 02/15] docker container and ci workflow --- .github/workflows/ci.yml | 17 +++++++++ .github/workflows/docker.yml | 69 ++++++++++++++++++++++++++++++++++++ .github/workflows/sphinx.yml | 13 ++++++- docker/Dockerfile | 36 +++++++++++++++++++ 4 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/docker.yml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f4cfc78 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,17 @@ +name: CI +on: + push: + branches: + - main + workflow_dispatch: {} + pull_request: + types: [opened, synchronize] + branches: + - main + +jobs: + docker-image: + uses: ./.github/workflows/docker.yml + api-doc: + needs: [docker-image] + uses: ./.github/workflows/sphinx.yml \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..3001815 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,69 @@ +name: docker-image +on: + workflow_call: + +env: + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: LLNL/GPLaSDI/lasdi_env + DOCKERPATH: docker + +jobs: + docker-ci: + runs-on: ubuntu-latest + name: "docker env" + env: + DOCKERPATH: docker + steps: + - name: test command + run: echo "docker-ci command" + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - uses: Ana06/get-changed-files@v2.2.0 + id: files + - name: DockerPATH configuration + run: echo "DOCKERPATH=$DOCKERPATH" + - name: DockerPATH - check if files in docker path changed + if: contains(steps.files.outputs.all,env.DOCKERPATH) || contains(steps.files.outputs.all,'docker.yml') + run: | + echo "CI container needs rebuilding..." + echo "CI_NEEDS_REBUILD=true" >> $GITHUB_ENV + - name: Log into registry ${{ env.REGISTRY }} + if: env.CI_NEEDS_REBUILD + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + if: env.CI_NEEDS_REBUILD + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: type=sha + flavor: latest=true + - name: Build Container motd + if: env.CI_NEEDS_REBUILD + run: | + echo "#!/bin/bash" > ${{env.DOCKERPATH}}/motd.sh + echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh + echo "echo lasdi_env/CI Development Container" >> ${{env.DOCKERPATH}}/motd.sh + echo "echo \"Revision: `echo ${GITHUB_SHA} | cut -c1-8`\"" >> ${{env.DOCKERPATH}}/motd.sh + echo "echo --------------------------" >> ${{env.DOCKERPATH}}/motd.sh + chmod 755 ${{env.DOCKERPATH}}/motd.sh + cat ${{env.DOCKERPATH}}/motd.sh + - name: Docker Image - Build and push + if: env.CI_NEEDS_REBUILD + uses: docker/build-push-action@v5 + with: + push: true + context: ${{ env.DOCKERPATH }} + tags: ${{ steps.meta.outputs.tags }} + # platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 674ff26..4549f5d 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,13 +1,24 @@ name: "Sphinx: Render docs" -on: push +# on: push +on: + workflow_call: jobs: build: runs-on: ubuntu-latest + container: + image: ghcr.io/llnl/gplasdi/lasdi_env:latest + options: --user 1001 --privileged + volumes: + - /mnt:/mnt permissions: contents: write steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.11.0 + with: + access_token: ${{ github.token }} - uses: actions/checkout@v4 - name: Build HTML uses: ammaraskar/sphinx-action@master diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..aff014a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,36 @@ +FROM ubuntu:22.04 + +ENV ENVDIR=env + +# install sudo +RUN apt-get -yq update && apt-get -yq install sudo + +WORKDIR /$ENVDIR + +# install packages +RUN sudo apt-get install -yq git +RUN sudo apt-get install --no-install-recommends -yq make gcc gfortran libssl-dev cmake +RUN sudo apt-get install -yq libopenblas-dev libmpich-dev libblas-dev liblapack-dev libscalapack-mpi-dev libhdf5-mpi-dev hdf5-tools +RUN sudo apt-get install -yq vim +RUN sudo apt-get install -yq git-lfs +RUN sudo apt-get install -yq valgrind +RUN sudo apt-get install -yq wget +RUN sudo apt-get install -yq astyle + +# install python +RUN sudo apt-get install -yq python3 +RUN sudo apt-get install -yq python3-dev +RUN sudo apt-get install -yq python3-pip +RUN sudo pip3 install --upgrade pip +RUN sudo pip3 install sphinx-autoapi sphinx_rtd_theme +#RUN sudo pip3 install numpy scipy argparse tables PyYAML h5py pybind11 pytest mpi4py merlin +# +RUN sudo apt-get clean -q + +# create and switch to a user +ENV USERNAME=test +RUN echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers +RUN useradd --no-log-init -u 1001 --create-home --shell /bin/bash $USERNAME +RUN adduser $USERNAME sudo +USER $USERNAME +WORKDIR /home/$USERNAME From 8751e11af3ec07682dfd850f4800e2e591e529e2 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 16 Oct 2024 23:22:20 -0700 Subject: [PATCH 03/15] pip install fix --- .github/workflows/sphinx.yml | 3 +++ docker/Dockerfile | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 4549f5d..27726e4 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -20,6 +20,9 @@ jobs: with: access_token: ${{ github.token }} - uses: actions/checkout@v4 + - name: check autoapi.extension + run: | + python -m autoapi.extension - name: Build HTML uses: ammaraskar/sphinx-action@master - name: Upload artifacts diff --git a/docker/Dockerfile b/docker/Dockerfile index aff014a..7463bbc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,18 +11,19 @@ WORKDIR /$ENVDIR RUN sudo apt-get install -yq git RUN sudo apt-get install --no-install-recommends -yq make gcc gfortran libssl-dev cmake RUN sudo apt-get install -yq libopenblas-dev libmpich-dev libblas-dev liblapack-dev libscalapack-mpi-dev libhdf5-mpi-dev hdf5-tools -RUN sudo apt-get install -yq vim +# RUN sudo apt-get install -yq vim RUN sudo apt-get install -yq git-lfs -RUN sudo apt-get install -yq valgrind +# RUN sudo apt-get install -yq valgrind RUN sudo apt-get install -yq wget -RUN sudo apt-get install -yq astyle +# RUN sudo apt-get install -yq astyle # install python RUN sudo apt-get install -yq python3 RUN sudo apt-get install -yq python3-dev RUN sudo apt-get install -yq python3-pip -RUN sudo pip3 install --upgrade pip -RUN sudo pip3 install sphinx-autoapi sphinx_rtd_theme +RUN sudo apt-get install python-is-python3 +RUN sudo python -m pip install --upgrade pip +RUN sudo python -m pip install sphinx-autoapi sphinx_rtd_theme #RUN sudo pip3 install numpy scipy argparse tables PyYAML h5py pybind11 pytest mpi4py merlin # RUN sudo apt-get clean -q From c300014fd40b4684b4478f453f1c56f90a45a258 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 09:18:46 -0700 Subject: [PATCH 04/15] custom build command instead of github action --- .github/workflows/sphinx.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 27726e4..3ebef27 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -24,7 +24,10 @@ jobs: run: | python -m autoapi.extension - name: Build HTML - uses: ammaraskar/sphinx-action@master + # uses: ammaraskar/sphinx-action@master + run: | + sphinx-build --version + sphinx-build -b html source/ build/ - name: Upload artifacts uses: actions/upload-artifact@v4 with: From 1784ba577e1e8587da7d686c9d6bf53e829f8714 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 09:33:09 -0700 Subject: [PATCH 05/15] another try.. --- .github/workflows/sphinx.yml | 14 ++++++++++---- docker/Dockerfile | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 3ebef27..a89bda6 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -24,10 +24,16 @@ jobs: run: | python -m autoapi.extension - name: Build HTML - # uses: ammaraskar/sphinx-action@master - run: | - sphinx-build --version - sphinx-build -b html source/ build/ + uses: ammaraskar/sphinx-action@master + with: + docs-folder: "docs/" + build-command: "sphinx-build -b html . build" + pre-build-command: "pip install sphinx-autoapi sphinx_rtd_theme" + # run: | + # sphinx-build --version + # cd ${GITHUB_WORKSPACE}/docs + # mkdir build + # sphinx-build -b html source/ build/ - name: Upload artifacts uses: actions/upload-artifact@v4 with: diff --git a/docker/Dockerfile b/docker/Dockerfile index 7463bbc..bb49ef6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -23,7 +23,7 @@ RUN sudo apt-get install -yq python3-dev RUN sudo apt-get install -yq python3-pip RUN sudo apt-get install python-is-python3 RUN sudo python -m pip install --upgrade pip -RUN sudo python -m pip install sphinx-autoapi sphinx_rtd_theme +RUN sudo python -m pip install sphinx sphinx-autoapi sphinx_rtd_theme #RUN sudo pip3 install numpy scipy argparse tables PyYAML h5py pybind11 pytest mpi4py merlin # RUN sudo apt-get clean -q From abdb9c89752cfd3a6e68bb8bce862931022b6c72 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 09:38:45 -0700 Subject: [PATCH 06/15] without docker --- .github/workflows/ci.yml | 6 +++--- .github/workflows/sphinx.yml | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4cfc78..71f5e16 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,8 +10,8 @@ on: - main jobs: - docker-image: - uses: ./.github/workflows/docker.yml + # docker-image: + # uses: ./.github/workflows/docker.yml api-doc: - needs: [docker-image] + # needs: [docker-image] uses: ./.github/workflows/sphinx.yml \ No newline at end of file diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index a89bda6..8c38e95 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -7,11 +7,11 @@ on: jobs: build: runs-on: ubuntu-latest - container: - image: ghcr.io/llnl/gplasdi/lasdi_env:latest - options: --user 1001 --privileged - volumes: - - /mnt:/mnt + # container: + # image: ghcr.io/llnl/gplasdi/lasdi_env:latest + # options: --user 1001 --privileged + # volumes: + # - /mnt:/mnt permissions: contents: write steps: @@ -20,15 +20,15 @@ jobs: with: access_token: ${{ github.token }} - uses: actions/checkout@v4 - - name: check autoapi.extension - run: | - python -m autoapi.extension + # - name: check autoapi.extension + # run: | + # python -m autoapi.extension - name: Build HTML uses: ammaraskar/sphinx-action@master with: docs-folder: "docs/" - build-command: "sphinx-build -b html . build" - pre-build-command: "pip install sphinx-autoapi sphinx_rtd_theme" + build-command: "sphinx-build -b html source build" + pre-build-command: "pip install --upgrade pip && pip install sphinx-autoapi sphinx_rtd_theme" # run: | # sphinx-build --version # cd ${GITHUB_WORKSPACE}/docs From 369a7aec1fc478400431902bed86b6d1d707f366 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 10:07:18 -0700 Subject: [PATCH 07/15] check resulting file --- .github/workflows/sphinx.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 8c38e95..f8bb125 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -34,6 +34,11 @@ jobs: # cd ${GITHUB_WORKSPACE}/docs # mkdir build # sphinx-build -b html source/ build/ + - name: check resulting files + run: | + ls ${GITHUB_WORKSPACE}/docs/ + ls ${GITHUB_WORKSPACE}/docs/build + ls ${GITHUB_WORKSPACE}/docs/build/html - name: Upload artifacts uses: actions/upload-artifact@v4 with: From 0e5b083337124c3855e5cb5521e9d9fab592a59b Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 10:12:49 -0700 Subject: [PATCH 08/15] fix artifact path --- .github/workflows/sphinx.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index f8bb125..60548e4 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -36,17 +36,15 @@ jobs: # sphinx-build -b html source/ build/ - name: check resulting files run: | - ls ${GITHUB_WORKSPACE}/docs/ ls ${GITHUB_WORKSPACE}/docs/build - ls ${GITHUB_WORKSPACE}/docs/build/html - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: html-docs - path: docs/build/html/ + path: docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 # if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: docs/build/html \ No newline at end of file + publish_dir: docs/build \ No newline at end of file From 3142819e0477c46d96c2a59a299bcd2b654cf323 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 10:26:11 -0700 Subject: [PATCH 09/15] deploy only when pushed to main --- .github/workflows/sphinx.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 60548e4..557608b 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -20,9 +20,6 @@ jobs: with: access_token: ${{ github.token }} - uses: actions/checkout@v4 - # - name: check autoapi.extension - # run: | - # python -m autoapi.extension - name: Build HTML uses: ammaraskar/sphinx-action@master with: @@ -44,7 +41,7 @@ jobs: path: docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/build \ No newline at end of file From 1f2201e4ac737cf7416d61185252dc583890eabb Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 11:11:30 -0700 Subject: [PATCH 10/15] updating front page --- .github/workflows/sphinx.yml | 2 +- docs/source/conf.py | 4 ++-- docs/source/index.rst | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 557608b..c3074a8 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -41,7 +41,7 @@ jobs: path: docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/build \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 7b0c61a..29afdaa 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,8 +12,8 @@ sys.path.insert(0, os.path.abspath('../../src')) project = 'LaSDI' -copyright = '2024, Kevin Chung' -author = 'Kevin Chung' +copyright = '2023-2024, Lawrence Livermore National Security, LLC and other LaSDI project developers.' +author = 'Christophe Bonneville, Kevin Chung, Youngsoo Choi' release = '2.0' # -- General configuration --------------------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 3ebe8d0..bb10aef 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,10 +6,10 @@ LaSDI documentation =================== -Add your content using ``reStructuredText`` syntax. See the -`reStructuredText `_ -documentation for details. - +LaSDI is a light-weight python package for Latent Space Dynamics Identification. +LaSDI maps full-order PDE solutions to a latent space using autoencoders and learns the system of ODEs governing the latent space dynamics. +By interpolating and solving the ODE system in the reduced latent space, fast and accurate ROM predictions can be made by feeding the predicted latent space dynamics into the decoder. +It also supports parametric interpolation of latent dynamics according to uncertainties evaluated via Gaussian process. .. toctree:: :maxdepth: 2 From e1c3548e7c2bcb29a24104cd906b004b2b738f24 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 11:13:51 -0700 Subject: [PATCH 11/15] deploy only when pushed to main --- .github/workflows/sphinx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index c3074a8..557608b 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -41,7 +41,7 @@ jobs: path: docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 - # if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/build \ No newline at end of file From c43bdededf54037258726fd60afeda0072528442 Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Thu, 17 Oct 2024 12:02:27 -0700 Subject: [PATCH 12/15] added references --- .github/workflows/sphinx.yml | 2 +- docs/source/index.rst | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 557608b..c3074a8 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -41,7 +41,7 @@ jobs: path: docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 - if: github.ref == 'refs/heads/main' + # if: github.ref == 'refs/heads/main' with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: docs/build \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index bb10aef..12f389c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -15,5 +15,12 @@ It also supports parametric interpolation of latent dynamics according to uncert :maxdepth: 2 :caption: Contents: - lasdi +References +=================== +* Fries, William D., Xiaolong He, and Youngsoo Choi. "LaSDI: Parametric latent space dynamics identification." Computer Methods in Applied Mechanics and Engineering 399 (2022): 115436. +* He, Xiaolong, Youngsoo Choi, William D. Fries, Jonathan L. Belof, and Jiun-Shyan Chen. "gLaSDI: Parametric physics-informed greedy latent space dynamics identification." Journal of Computational Physics 489 (2023): 112267. +* Tran, April, Xiaolong He, Daniel A. Messenger, Youngsoo Choi, and David M. Bortz. "Weak-form latent space dynamics identification." Computer Methods in Applied Mechanics and Engineering 427 (2024): 116998. +* Park, Jun Sur Richard, Siu Wun Cheung, Youngsoo Choi, and Yeonjong Shin. "tLaSDI: Thermodynamics-informed latent space dynamics identification." arXiv preprint arXiv:2403.05848 (2024). +* Bonneville, Christophe, Youngsoo Choi, Debojyoti Ghosh, and Jonathan L. Belof. "Gplasdi: Gaussian process-based interpretable latent space dynamics identification through deep autoencoder." Computer Methods in Applied Mechanics and Engineering 418 (2024): 116535. +* He, Xiaolong, April Tran, David M. Bortz, and Youngsoo Choi. "Physics-informed active learning with simultaneous weak-form latent space dynamics identification." arXiv preprint arXiv:2407.00337 (2024). From 3747cb6868e7b8dc231b8300f01d976abdb96deb Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Wed, 23 Oct 2024 13:21:15 -0700 Subject: [PATCH 13/15] added a reference --- docs/source/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/index.rst b/docs/source/index.rst index 12f389c..69cf38c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,6 +18,7 @@ It also supports parametric interpolation of latent dynamics according to uncert References =================== +* Bonneville, Christophe, Xiaolong He, April Tran, Jun Sur Park, William Fries, Daniel A. Messenger, Siu Wun Cheung et al. "A Comprehensive Review of Latent Space Dynamics Identification Algorithms for Intrusive and Non-Intrusive Reduced-Order-Modeling." arXiv preprint arXiv:2403.10748 (2024). * Fries, William D., Xiaolong He, and Youngsoo Choi. "LaSDI: Parametric latent space dynamics identification." Computer Methods in Applied Mechanics and Engineering 399 (2022): 115436. * He, Xiaolong, Youngsoo Choi, William D. Fries, Jonathan L. Belof, and Jiun-Shyan Chen. "gLaSDI: Parametric physics-informed greedy latent space dynamics identification." Journal of Computational Physics 489 (2023): 112267. * Tran, April, Xiaolong He, Daniel A. Messenger, Youngsoo Choi, and David M. Bortz. "Weak-form latent space dynamics identification." Computer Methods in Applied Mechanics and Engineering 427 (2024): 116998. From f0ace0c2452be0432236081bd496a2a2987f681f Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Sat, 26 Oct 2024 20:20:07 -0700 Subject: [PATCH 14/15] example comments on timing.py --- src/lasdi/timing.py | 81 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/src/lasdi/timing.py b/src/lasdi/timing.py index da7d7c3..978045a 100644 --- a/src/lasdi/timing.py +++ b/src/lasdi/timing.py @@ -1,14 +1,49 @@ +""" + +.. _NumPy docstring standard: + https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard + +""" + from time import perf_counter class Timer: - def __init__(self): + """A light-weight timer class. + """ + + def __init__(self): + self.names = {} + """:obj:`dict(str:int)`: Dictionary that maps job names to job indices.""" + self.calls = [] + """:obj:`list(int)`: List that stores the number of calls for each job.""" + self.times = [] + """:obj:`list(float)`: List that stores the total time for each job.""" + self.starts = [] + """ + :obj:`list(float)`: List that stores the start time for each job. + If the job is not running, :obj:`None` is stored instead. + """ return def start(self, name): + """Start a job named :obj:`name`. + If the job is not listed, register the job in the job list. + + Args: + name (:obj:`str`): Name of the job to be started. + + Note: + The job must not have started before calling this method. + + Returns: + Does not return a value. + + """ + if name not in self.names: self.names[name] = len(self.names) self.calls += [0] @@ -16,15 +51,30 @@ def start(self, name): self.starts += [None] idx = self.names[name] + # check if the job is already being measured if (self.starts[idx] is not None): raise RuntimeError("Timer.start: %s timer is already ticking!" % name) self.starts[idx] = perf_counter() return def end(self, name): + """End a job named :obj:`name`. + Increase the number of calls and the runtime for the job. + + Args: + name (:obj:`str`): Name of the job to be ended. + + Note: + The job must have started before calling this method. + + Returns: + Does not return a value. + + """ assert(name in self.names) idx = self.names[name] + # check if the job has started. if (self.starts[idx] is None): raise RuntimeError("Timer.end: %s start time is not measured yet!" % name) @@ -34,12 +84,28 @@ def end(self, name): return def print(self): + """Print the list of jobs and their number of calls, total time and time per each call. + + Returns: + Does not return a value. + """ + print("Function name\tCalls\tTotal time\tTime/call\n") for name, idx in self.names.items(): print("%s\t%d\t%.3e\t%.3e\n" % (name, self.calls[idx], self.times[idx], self.times[idx] / self.calls[idx])) return def export(self): + """Export the list of jobs and their number of calls and total time + into a dictionary. + + Note: + All jobs must be ended before calling this method. + + Returns: + :obj:`dict` that contains "names", "calls", and "times" as keys + """ + for start in self.starts: if (start is not None): raise RuntimeError('Timer.export: cannot export while Timer is still ticking!') @@ -51,6 +117,19 @@ def export(self): return param_dict def load(self, dict_): + """Load the list of jobs and their number of calls and total time + from a dictionary. + + Args: + `dict_` (:obj:`dict`): Dictionary that contains the list of jobs and their calls and times. + + Note: + :obj:`dict_['names']`, :obj:`dict_['calls']` and :obj:`dict_['times']` must have the same size. + + Returns: + Does not return a value + """ + self.names = dict_['names'] self.calls = dict_['calls'] self.times = dict_['times'] From abeb1c25486f05a65aca468547bcc10192a228ed Mon Sep 17 00:00:00 2001 From: Kevin Chung Date: Mon, 28 Oct 2024 09:03:17 -0700 Subject: [PATCH 15/15] v2.0.0 tag --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f134c31..bf18591 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lasdi" -version = "2.0.0-dev" +version = "2.0.0" authors = [ { name="Christophe Bonneville", email="cpb97@cornell.edu" }, { name="Kevin (Seung Whan) Chung", email="chung28@llnl.gov" },