From acecb77b316cce7279eab4193646e6e3c8979321 Mon Sep 17 00:00:00 2001 From: Andrew Giuliani Date: Fri, 19 Apr 2024 11:25:54 -0400 Subject: [PATCH] initial commit --- .github/workflows/conda.yml | 66 -------- .github/workflows/docker.yml | 63 -------- .github/workflows/docs_test.yml | 35 ---- .github/workflows/extensive_test.yml | 9 +- .github/workflows/linting.yml | 24 --- .github/workflows/non_simd_tests.yml | 125 --------------- .github/workflows/singularity.yml | 63 -------- .github/workflows/tests.yml | 232 --------------------------- .github/workflows/wheel.yml | 81 ---------- 9 files changed, 7 insertions(+), 691 deletions(-) delete mode 100644 .github/workflows/conda.yml delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/docs_test.yml delete mode 100644 .github/workflows/linting.yml delete mode 100644 .github/workflows/non_simd_tests.yml delete mode 100644 .github/workflows/singularity.yml delete mode 100644 .github/workflows/tests.yml delete mode 100644 .github/workflows/wheel.yml diff --git a/.github/workflows/conda.yml b/.github/workflows/conda.yml deleted file mode 100644 index 48926a07f..000000000 --- a/.github/workflows/conda.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Conda - -on: - workflow_dispatch: - push: - branches: - - master - - mbk/conda_package - pull_request: - release: - types: [published] - -jobs: - build: - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest, macos-11] - python-version: ["3.9"] - - runs-on: ${{ matrix.platform }} - - # The setup-miniconda action needs this to activate miniconda - defaults: - run: - shell: "bash -l {0}" - - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Fetch all history for setuptools_scm to work - run: git fetch --prune --unshallow - - - name: Get conda - uses: conda-incubator/setup-miniconda@v3 - with: - python-version: ${{ matrix.python-version }} - channels: conda-forge - channel-priority: strict - - - name: Prepare - run: conda install -y conda-build conda-verify setuptools_scm anaconda-client scikit-build-core - - - name: Build and upload - if: github.event_name == 'release' && github.event.action == 'published' - run: | - conda config --set anaconda_upload yes - conda build --token ${{ secrets.ANACONDA_TOKEN }} conda.recipe - - - name: Build and upload to test - if: github.event_name == 'push' && github.ref == 'refs/heads/mbk/conda_package' - run: | - conda config --set anaconda_upload yes - conda build --token ${{ secrets.MBK_ANACONDA_TOKEN }} conda.recipe - - - name: Build - if: github.event_name == 'push' && github.ref == 'refs/heads/master' - run: | - conda build --no-test conda.recipe - - - name: Build on PR - if: github.event_name == 'pull_request' - run: | - conda build --no-test conda.recipe diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 878924726..000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: docker container - -on: - push: - branches: - - '**' - tags: - - v* - pull_request: - branches: - - master - tags: - - v* - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Fetch all history for all tags and branches - run: git fetch --prune --unshallow - - - name: Setup docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: medbha - password: ${{ secrets.DOCKER_TOKEN }} - - - name: Step to get tag name - id: vars - run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT - - - name: Build and push - uses: docker/build-push-action@v3 - if: ${{ startsWith(github.ref, 'refs/heads') && github.ref == 'refs/heads/master' }} - with: - context: ci - file: ci/Dockerfile.ubuntu - push: true - tags: hiddensymmetries/simsopt:latest - - - name: Build for branches - uses: docker/build-push-action@v3 - if: ${{ startsWith(github.ref, 'refs/heads') && github.ref != 'refs/heads/master' }} - with: - context: ci - file: ci/Dockerfile.ubuntu - push: false - tags: hiddensymmetries/simsopt:test - - - name: Build and push for tag - uses: docker/build-push-action@v3 - if: startsWith(github.event.ref, 'refs/tags/v') - with: - context: ci - file: ci/Dockerfile.ubuntu - push: true - tags: "hiddensymmetries/simsopt:${{steps.vars.outputs.tag}}" diff --git a/.github/workflows/docs_test.yml b/.github/workflows/docs_test.yml deleted file mode 100644 index 57b0cfc24..000000000 --- a/.github/workflows/docs_test.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Docs_test - -on: [push, pull_request] - -jobs: - CI: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - python-version: [3.9] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Upgrade pip - run: python -m pip install --upgrade pip - - - name: Install sphinx and its dependencies for building docs - run: | - pip install -r docs/requirements.txt - - - name: Install simsopt package - run: pip install -v . - - - name: Build docs - run: | - cd docs - sphinx-build -b html source build diff --git a/.github/workflows/extensive_test.yml b/.github/workflows/extensive_test.yml index f60d2e15f..ff028aa17 100644 --- a/.github/workflows/extensive_test.yml +++ b/.github/workflows/extensive_test.yml @@ -27,9 +27,9 @@ jobs: strategy: fail-fast: false matrix: - test-type: [unit, integrated] + test-type: [unit] packages: [all, vmec, spec, none] - python-version: [3.8, 3.9, "3.10"] + python-version: [3.9, "3.10"] include: - python-version: 3.9 test-type: unit @@ -220,6 +220,11 @@ jobs: coverage run --source=simsopt -m unittest discover -t tests -v -s tests/field - name: Run remaining tests on 1 MPI process using coverage + + - uses: actions/checkout@v3 + - name: Setup tmate session + uses: mxschmitt/action-tmate@v3 + if: contains(matrix.test-type, 'unit') run: | coverage run --source=simsopt -m unittest discover -t tests -v -s tests/core diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index 5eea66ef0..000000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Linting - -on: [push, pull_request] - -jobs: - CI: - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - python-version: [3.9] - - steps: - - uses: actions/checkout@v4 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: Run ruff - uses: chartboost/ruff-action@v1 - diff --git a/.github/workflows/non_simd_tests.yml b/.github/workflows/non_simd_tests.yml deleted file mode 100644 index f3ae7c6c3..000000000 --- a/.github/workflows/non_simd_tests.yml +++ /dev/null @@ -1,125 +0,0 @@ -# This file is based on examples in -# https://docs.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions - -# Note that all the "sudo" commands here appear to cause a warning message -# "sudo: setrlimit(RLIMIT_CORE): operation not permitted" -# This appears to be a known harmless annoyance: -# https://gitlab.alpinelinux.org/alpine/aports/-/issues/11122 - -name: Tests with no XSIMD - -on: - push: - branches-ignore: [master] - tags-ignore: [v*] - pull_request: - branches-ignore: [master] - -jobs: - test: - runs-on: ubuntu-latest - - env: - OMPI_ALLOW_RUN_AS_ROOT: 1 - OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 - NO_XSIMD: 1 - - strategy: - fail-fast: false - matrix: - python-version: [3.9] - - steps: - # First print out lots of information. We do this in separate - # "name" blocks because otherwise the output gets mixed together - # in the github actions log. - - - name: Print user and group id - run: | - set -ex - id - - - name: PWD - run: | - set -ex - pwd - - - name: ls -l - run: | - set -ex - ls -l - - - name: apt-get stuff needed for libstell and vmec - run: | - sudo apt-get update - sudo apt-get install -y build-essential gfortran openmpi-bin libopenmpi-dev libnetcdf-dev libnetcdff-dev liblapack-dev libscalapack-mpi-dev libhdf5-dev libhdf5-serial-dev git m4 libfftw3-dev libboost-all-dev libopenblas-dev - - - uses: actions/checkout@v4 - - - name: Fetch all history for all tags - run: git fetch --all --tags --prune --unshallow - - - name: ls -l again - run: | - set -ex - ls -l - pwd - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: which python3 after python setup - run: which python3 - - - name: which pip after python setup - run: | - python -m pip install --upgrade pip - pip --version - - - name: env after adding python - run: env - - - name: Install python dependencies - run: | - sudo apt-get install graphviz graphviz-dev - pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz - - - name: Install booz_xform - run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform - - - name: Install virtual_casing - run: pip install -v git+https://github.com/hiddenSymmetries/virtual-casing - - - name: ls in /usr/lib/x86_64-linux-gnu - run: ls -l /usr/lib/x86_64-linux-gnu - - - name: Add to LD_LIBRARY_PATH so scalapack etc can be found - run: echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV - - - name: env after adding to LD_LIBRARY_PATH - run: env - - - name: Install simsopt package - run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI] - - - name: Verify that importing simsopt does not automatically initialize MPI - run: ./tests/verify_MPI_not_initialized.py - - - name: Run examples as part of integrated tests - run: | - cd examples - ./run_serial_examples - ./run_parallel_examples - - - name: Run tests on 1 process - run: | - python -m unittest discover -t tests -v -s tests/field - python -m unittest discover -t tests -v -s tests/geo - python -m unittest discover -t tests -v -s tests/objectives - - - name: Run MPI tests - run: | - mpiexec -n 2 python -m unittest discover -k "mpi" -s tests -v - diff --git a/.github/workflows/singularity.yml b/.github/workflows/singularity.yml deleted file mode 100644 index 55f686e49..000000000 --- a/.github/workflows/singularity.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Singularity Build -on: - push: - - # This recipe shows how to manually define a matrix of singularity recipes (paths) to build - # Edit the branches here if you want to change deploy behavior - branches: - - master - - mbk/singularity - tags: - - v* - - # Do the builds on all pull requests (to test them) - pull_request: [] - -jobs: - build-containers: - runs-on: ubuntu-latest - # container: - # image: quay.io/singularity/singularity:v3.9.3 - # options: --security-opt seccomp=unconfined --security-opt systempaths=unconfined - strategy: - fail-fast: true - - name: Check ${{ matrix.recipe }} - steps: - - - name: Check out code for the container build - uses: actions/checkout@v4 - - uses: eWaterCycle/setup-singularity@v7 - with: - singularity-version: 3.8.3 - - - name: Fetch all history for all tags and branches - run: git fetch --prune --unshallow - - - name: Step to get tag name - if: startsWith(github.event.ref, 'refs/tags/v') - run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - - - name: Step to get tag name - if: ${{ startsWith(github.ref, 'refs/heads') && github.ref == 'refs/heads/master' }} - #id: vars - #run: echo ::set-output name=tag::"latest" - run: echo "tag=latest" >> $GITHUB_ENV - - - name: Step to get tag name - if: ${{ startsWith(github.ref, 'refs/heads') && github.ref != 'refs/heads/master' }} - #id: vars - #run: echo ::set-output name=tag::"test" - run: echo "tag=test" >> $GITHUB_ENV - - - name: Build Container - run: | - ls ${SINGULARITY_ROOT} - sudo -E ${SINGULARITY_ROOT}/bin/singularity build simsopt.sif ci/singularity.def - - - name: Login and Deploy Container - if: (github.event_name != 'pull_request') - run: | - echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ secrets.GHCR_USERNAME }} --password-stdin oras://ghcr.io - singularity push simsopt.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${tag} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 637981a4c..000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,232 +0,0 @@ -# This file is based on examples in -# https://docs.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions - -# Note that all the "sudo" commands here appear to cause a warning message -# "sudo: setrlimit(RLIMIT_CORE): operation not permitted" -# This appears to be a known harmless annoyance: -# https://gitlab.alpinelinux.org/alpine/aports/-/issues/11122 - -name: Tests - -on: - push: - branches-ignore: [master] - tags-ignore: [v*] - pull_request: - branches-ignore: [master] - -jobs: - test: - runs-on: ubuntu-latest - - env: - OMPI_ALLOW_RUN_AS_ROOT: 1 - OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1 - - strategy: - fail-fast: false - matrix: - python-version: [3.9] - test-type: [unit, integrated] - - steps: - # First print out lots of information. We do this in separate - # "name" blocks because otherwise the output gets mixed together - # in the github actions log. - - - name: Print user and group id - run: | - set -ex - id - - - name: PWD - run: | - set -ex - pwd - - - name: ls -l - run: | - set -ex - ls -l - - - name: Print python location - run: | - set -ex - which python - - - name: apt-get stuff needed for libstell and vmec - run: | - sudo apt-get update - sudo apt-get install -y build-essential gfortran openmpi-bin libopenmpi-dev libnetcdf-dev libnetcdff-dev liblapack-dev libscalapack-mpi-dev libhdf5-dev libhdf5-serial-dev git m4 libfftw3-dev libboost-all-dev libopenblas-dev - - - uses: actions/checkout@v4 - - - name: Fetch all history for all tags - run: git fetch --all --tags --prune --unshallow - - # We must run actions/checkout before downloading and building VMEC, since checkout deletes the contents of the directory. - - name: Download the VMEC2000 standalone repository - run: git clone --depth=1 https://github.com/hiddensymmetries/VMEC2000.git - - - name: ls -l again - run: | - set -ex - ls -l - pwd - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - - name: which python3 after python setup - run: which python3 - - - name: which pip after python setup - run: | - python -m pip install --upgrade pip - pip --version - - - name: env after adding python - run: env - - - name: Install python dependencies - run: | - sudo apt-get install graphviz graphviz-dev - pip install numpy cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec pyoculus h5py - - - name: Install booz_xform - run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform - - - name: Install virtual_casing - run: pip install -v git+https://github.com/hiddenSymmetries/virtual-casing - - # See https://github.community/t/best-way-to-clone-a-private-repo-during-script-run-of-private-github-action/16116/7 - # https://stackoverflow.com/questions/57612428/cloning-private-github-repository-within-organisation-in-actions - # https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token - - name: Check out SPEC - uses: actions/checkout@v4 - with: - repository: PrincetonUniversity/SPEC - path: SPEC - - - name: ls -l again - run: | - ls -l - pwd - - - name: ls -l inside SPEC - run: | - cd SPEC - pwd - ls -l - - # For some reason, installing py_spec does not install the dependencies f90nml and h5py. Therefore I installed these manually above. - - name: Install py_spec - run: | - pip install -r SPEC/Utilities/pythontools/requirements.txt - pip install -e SPEC/Utilities/pythontools - python -c "import py_spec; print('success')" - - - name: Install f90wrap - run: pip install -U git+https://github.com/zhucaoxiang/f90wrap - - - name: Build SPEC python wrapper. - run: | - cd SPEC - pip install . - - - name: Try import spec - run: python -c "import spec.spec_f90wrapped as spec; print(spec.constants.version)" - - - name: ls in /usr/lib/x86_64-linux-gnu - run: ls -l /usr/lib/x86_64-linux-gnu - - - name: Add to LD_LIBRARY_PATH so scalapack etc can be found - run: echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV - - - name: env after adding to LD_LIBRARY_PATH - run: env - - - name: ls in VMEC2000/python 1 - run: ls -l VMEC2000/python - - - name: Configure and install VMEC2000 module - run: | - cd VMEC2000 - cp cmake/machines/ubuntu.json cmake_config_file.json - cat cmake_config_file.json - pip install . - - - name: Try importing vmec module - run: python -c "print(dir()); import vmec; print(dir()); print(dir(vmec)); print('package:', vmec.__package__); print('spec:', vmec.__spec__); print('doc:', vmec.__doc__); print('file:', vmec.__file__); print('path:', vmec.__path__)" - - - name: Install simsopt package - # run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC] - run: pip install -v ".[MPI,SPEC,VIS]" - - - name: Verify that importing simsopt does not automatically initialize MPI - run: ./tests/verify_MPI_not_initialized.py - - - name: Run examples as part of integrated tests - if: contains(matrix.test-type, 'integrated') - run: | - cd examples - ./run_serial_examples - ./run_parallel_examples - ./run_vmec_examples - ./run_spec_examples - ./run_spec_vmec_examples - - - name: Install coverage dependencies - if: contains(matrix.test-type, 'unit') - run: pip install coverage - - - name: Run tests on 1 process using coverage - if: contains(matrix.test-type, 'unit') - run: | - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/core - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/field - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/geo - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/mhd - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/objectives - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/solve - coverage run --source=simsopt -m unittest discover -t tests -v -s tests/util - - - name: Run MPI tests using coverage - if: contains(matrix.test-type, 'unit') - run: | - mpiexec -n 1 coverage run -m unittest discover -k "mpi" -s tests -v - mpiexec -n 2 coverage run -m unittest discover -k "mpi" -s tests -v - mpiexec -n 3 --oversubscribe coverage run -m unittest discover -k "mpi" -s tests -v - - - name: Combine coverage reports - if: contains(matrix.test-type, 'unit') - run: | - coverage combine - coverage report - coverage xml - - - name: Upload coverage to github - if: contains(matrix.test-type, 'unit') - uses: actions/upload-artifact@v3 - with: - name: tox-gh-actions-coverage - path: coverage.xml - if-no-files-found: error - - - name: Upload coverage to Codecov - # The last conditional on the next line prevents github from trying to upload to Codecov on forks of the repository, avoiding a permissions error - if: contains(matrix.test-type, 'unit') && github.repository_owner == 'hiddenSymmetries' - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - file: ./coverage.xml - #files: ./coverage1.xml,./coverage2.xml - #directory: ./coverage/reports/ - flags: unittests - env_vars: PYTHON - name: codecov-umbrella - fail_ci_if_error: true - #path_to_write_report: ./coverage/codecov_report.gz - verbose: true diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml deleted file mode 100644 index 8044ebfe4..000000000 --- a/.github/workflows/wheel.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Wheel Builder - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [macos-11, ubuntu-20.04] - - steps: - - uses: actions/checkout@v4 - - - name: Fetch all history for all tags - run: git fetch --prune --unshallow - - - name: Build wheels - uses: pypa/cibuildwheel@v2.11.4 - # To supply options, put them in 'env' - env: - # Only build for python 3.{8,9,10,11} - CIBW_BUILD : cp38-* cp39-* cp310-* cp311-* - # Supports only x86_64 arch for linux - CIBW_ARCHS_LINUX: x86_64 - CIBW_ARCHS_MACOS: "x86_64 arm64" - CIBW_SKIP: cp27-* cp36-* cp37-* - CIBW_DEPENDENCY_VERSIONS: latest - - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Fetch all history for all tags - run: git fetch --prune --unshallow - - - uses: actions/setup-python@v5 - name: Install Python - with: - python-version: '3.9' - - - name: Download all submodules - run: git submodule update --init - - - name: Install setuptools_scm - run: python -m pip install setuptools_scm build - - - name: Build sdist - run: python -m build -s -o dist . - - - uses: actions/upload-artifact@v3 - with: - path: dist/*.tar.gz - - upload_pypi: - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' - steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} - #password: ${{ secrets.TEST_PYPI_TOKEN }} - #repository_url: https://test.pypi.org/legacy/