diff --git a/.github/workflows/process.yml b/.github/workflows/process.yml index 9975f7cdcf..13a23f4c34 100644 --- a/.github/workflows/process.yml +++ b/.github/workflows/process.yml @@ -11,45 +11,13 @@ permissions: id-token: write jobs: - docker: + make: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Check for changed files affecting the container - uses: dorny/paths-filter@v2 - id: changes + - uses: actions/setup-python@v4 with: - filters: | - build_container: - - 'docker/ci/Dockerfile' - - 'requirements.txt' - - 'requirements_dev.txt' - - name: Login to GitHub Container Registry - if: steps.changes.outputs.build_container == 'true' && github.ref == 'refs/heads/main' - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: timothy-nunn - password: ${{ secrets.PROCESS_CI_PAT }} - - name: Build the PROCESS Docker image - if: steps.changes.outputs.build_container == 'true' && github.ref == 'refs/heads/main' - run: | - cp requirements.txt docker/ci/ - cp requirements_dev.txt docker/ci/ - cd docker/ci - docker build . -t ghcr.io/ukaea/process-ci:latest - docker push ghcr.io/ukaea/process-ci:latest - - make-py38: - runs-on: ubuntu-latest - needs: docker - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 + python-version: '3.10' - name: Build PROCESS run: | git config --global --add safe.directory '*' @@ -75,16 +43,14 @@ jobs: name: ford-artifact path: build/ford_project.pickle - unit-py38: + unit-test: runs-on: ubuntu-latest - needs: make-py38 - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + needs: make steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' - name: Download build artifacts uses: actions/download-artifact@v3 with: @@ -92,7 +58,9 @@ jobs: path: process/ - name: Install PROCESS # Editable install to match default install - run: pip install -e . + run: | + pip install -e '.[test, examples]' + pip install -r requirements_dev.txt - name: Run unit tests run: pytest --cov=process tests/unit -v - name: Archive unit test coverage data @@ -101,39 +69,39 @@ jobs: name: unit-coverage-artifacts path: .coverage - integration-py38: + integration-test: runs-on: ubuntu-latest - needs: make-py38 - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + needs: make steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' - name: Download build artifacts uses: actions/download-artifact@v3 with: name: process-build-artifacts path: process/ - name: Install PROCESS - run: pip install -e . + # Editable install to match default install + run: | + pip install -e '.[test, examples]' + pip install -r requirements_dev.txt + - name: Install poppler + run: | + sudo apt update + sudo apt install poppler-utils - name: Run integration tests run: pytest tests/integration -n auto -v - regression-py38: + regression-test: runs-on: ubuntu-latest - needs: [make-py38, tracking] + needs: [make, tracking] # depend on make and tracking job, check make job was successful # but dont skip if tracking was skipped - if: always() && needs.make-py38.result == 'success' + if: always() && needs.make.result == 'success' continue-on-error: true - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: tolerance: [0, 5] @@ -141,26 +109,27 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' - name: Download build artifacts uses: actions/download-artifact@v3 with: name: process-build-artifacts path: process/ - name: Install PROCESS - run: pip install -e . + # Editable install to match default install + run: | + pip install -e '.[test, examples]' + pip install -r requirements_dev.txt - name: Allow git commands to be run - run: git config --system --add safe.directory '*' + run: sudo git config --system --add safe.directory '*' - name: Run regression tests run: pytest tests/regression -sv --reg-tolerance=${{ matrix.tolerance }} run-tracking-inputs: runs-on: ubuntu-latest - needs: make-py38 - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + needs: make if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 @@ -187,29 +156,17 @@ jobs: name: tracked-mfiles path: tracking/*_MFILE.DAT - flake8: + pre-commit-quality-check: runs-on: ubuntu-latest - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - - name: Run Flake8 linter - run: python -m flake8 --tee . - - black: - runs-on: ubuntu-latest - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: actions/checkout@v3 - - name: Run Black - run: python -m black --check . + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + - name: Install dev dependencies + run: pip install -r requirements_dev.txt + - name: Run pre-commit + run: pre-commit run --all-files tracking: concurrency: @@ -218,11 +175,6 @@ jobs: runs-on: ubuntu-latest needs: run-tracking-inputs if: github.ref == 'refs/heads/main' - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} env: COMMIT_MESSAGE: ${{ github.event.head_commit.message }} steps: @@ -234,6 +186,8 @@ jobs: path: process/ - name: Install PROCESS run: pip install -e . + - name: Install dev dependencies + run: pip install -r requirements_dev.txt - name: Setup SSH identity uses: webfactory/ssh-agent@v0.7.0 with: @@ -249,7 +203,7 @@ jobs: shell: bash run: | MSG=$(printf "%q" $COMMIT_MESSAGE) - git config --global --add safe.directory '*' + sudo git config --global --add safe.directory '*' python tracking/tracking_data.py track process-tracking-data --mfile tracking/large_tokamak_MFILE.DAT --hash ${{ github.sha }} --commit '${MSG}' cp tracking/large_tokamak_MFILE.DAT process-tracking-data/large_tokamak_MFILE_$(git rev-parse HEAD).DAT python tracking/tracking_data.py track process-tracking-data --mfile tracking/st_regression_MFILE.DAT --hash ${{ github.sha }} --commit '${MSG}' @@ -267,8 +221,8 @@ jobs: path: tracking.html - name: Setup Git identity run: | - git config --global user.email "${{ github.triggering_actor }}@github.runner" - git config --global user.name "${{ github.job }}" + sudo git config --global user.email "${{ github.triggering_actor }}@github.runner" + sudo git config --global user.name "${{ github.job }}" - name: Commit and push tracking data run: | cd process-tracking-data @@ -283,11 +237,6 @@ jobs: runs-on: ubuntu-latest needs: tracking if: github.ref == 'refs/heads/main' - container: - image: ghcr.io/ukaea/process-ci:latest - credentials: - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 with: @@ -299,6 +248,10 @@ jobs: path: process/ - name: Install PROCESS run: pip install -e . + - name: Install dev dependencies + run: pip install -r requirements_dev.txt + - name: Install ford + run: pip install git+https://github.com/jonmaddock/ford - run: ford documentation/ford/index.md - name: Download ford project uses: actions/download-artifact@v3 @@ -307,7 +260,7 @@ jobs: path: build/ - run: python scripts/document_fortran_interface.py - run: python scripts/vardes.py - - run: git config --global --add safe.directory '*' + - run: sudo git config --global --add safe.directory '*' - run: mkdocs build - run: mv ford_site site - name: Download tracking html diff --git a/CMakeLists.txt b/CMakeLists.txt index db15c7829e..908764827a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # CMake file for Pythonic PROCESS # Author : PROCESS Team (UKAEA) -# Date : last modified 2023-07-24 +# Date : last modified 2024-04-24 # Specify the minimum version for CMake # 3.12 is required due to use of list TRANSFORM commands @@ -18,8 +18,8 @@ if(CMAKE_HOST_APPLE) set(CMAKE_MACOSX_RPATH ON) endif() -# Python 3.8 or greater -find_package(Python3 3.8 COMPONENTS Interpreter Development) +# Python 3.10 or greater +find_package(Python3 3.10 COMPONENTS Interpreter Development) # Read in external CMake scripts for preprocessing, f2py, ford, etc. INCLUDE(${CMAKE_SOURCE_DIR}/cmake/pip.cmake) @@ -176,9 +176,15 @@ ADD_CUSTOM_TARGET(coverage_cleanup ) # Run the Pip Install -ADD_CUSTOM_TARGET(install_process ALL - COMMAND ${Python3_EXECUTABLE} -m pip install --no-cache-dir -e ${CMAKE_SOURCE_DIR} -) +if(${RELEASE}) + ADD_CUSTOM_TARGET(install_process ALL + COMMAND ${Python3_EXECUTABLE} -m pip install --no-cache-dir -e ${CMAKE_SOURCE_DIR} + ) +else() + ADD_CUSTOM_TARGET(install_process ALL + COMMAND ${Python3_EXECUTABLE} -m pip install --no-cache-dir -e '${CMAKE_SOURCE_DIR}[test,examples]' + ) +endif() ADD_DEPENDENCIES(install_process ${PIP_NAME} f2py ${FORD_NAME} ${GFORTLIB_NAME} ${DICTS_NAME} coverage_cleanup) diff --git a/cmake/ford.cmake b/cmake/ford.cmake index 9ecb36574f..349e158a40 100644 --- a/cmake/ford.cmake +++ b/cmake/ford.cmake @@ -34,6 +34,9 @@ MACRO(DICTS) ADD_CUSTOM_COMMAND(OUTPUT ${DICTS_OUTPUT_FILE} ${DICTS_PYTHON_OUT} + # The dicts import process, install it (it will be installed again later) + COMMAND ${Python3_EXECUTABLE} -m pip install ${CMAKE_SOURCE_DIR} + # The create_dicts script needs to know the Fortran source dir, the pickled # Ford project object and the dicts.json file to output to COMMAND ${Python3_EXECUTABLE} ${CREATE_DICTS_SCRIPT} ${PROCESS_SRC_DIR} ${FORD_OUTPUT} diff --git a/cmake/pip.cmake b/cmake/pip.cmake index 4ee35aa1cc..bde19e84c3 100644 --- a/cmake/pip.cmake +++ b/cmake/pip.cmake @@ -7,12 +7,13 @@ MACRO(PIP_INSTALL) SET(PIP_NAME "pip_installs") - if ( RELEASE ) + + if(RELEASE) SET(RELEASE TRUE) else() SET(RELEASE FALSE) endif() - + EXECUTE_PROCESS( COMMAND bash -c "${Python3_EXECUTABLE} -c \"import ford\"" OUTPUT_VARIABLE FORD_CHECK @@ -48,24 +49,11 @@ MACRO(PIP_INSTALL) DEPENDS ${PIP_COMPLETE_FILE} ) - # Manually install numpy as including it in requirements doesnt install it - # It is a pre-requisite to f90wrap install - if (${RELEASE}) - ADD_CUSTOM_COMMAND( - OUTPUT ${PIP_COMPLETE_FILE} - COMMAND ${Python3_EXECUTABLE} -m pip install numpy - COMMAND ${Python3_EXECUTABLE} -m pip install -r ${MODULE_REQUIREMENTS_FILE} - COMMAND touch ${PIP_COMPLETE_FILE} - ) - else() - ADD_CUSTOM_COMMAND( - OUTPUT ${PIP_COMPLETE_FILE} - COMMAND ${Python3_EXECUTABLE} -m pip install numpy - COMMAND ${Python3_EXECUTABLE} -m pip install -r ${MODULE_REQUIREMENTS_FILE} - COMMAND ${Python3_EXECUTABLE} -m pip install -r ${DEVELOP_REQUIREMENTS_FILE} - COMMAND touch ${PIP_COMPLETE_FILE} - ) - endif() + ADD_CUSTOM_COMMAND( + OUTPUT ${PIP_COMPLETE_FILE} + COMMAND ${Python3_EXECUTABLE} -m pip install -r ${MODULE_REQUIREMENTS_FILE} + COMMAND touch ${PIP_COMPLETE_FILE} + ) ADD_DEPENDENCIES(${PIP_NAME} ford_git) ENDMACRO() diff --git a/docker/ci/Dockerfile b/docker/ci/Dockerfile deleted file mode 100644 index f0a845b8be..0000000000 --- a/docker/ci/Dockerfile +++ /dev/null @@ -1,74 +0,0 @@ -# Docker image for CI system -FROM ubuntu:20.04 -LABEL description="Process Ubuntu 20.04 image for running CI jobs" - - -# Required to get around interactive timezone prompt -ENV DEBIAN_FRONTEND=noninteractive - - -COPY requirements.txt /tmp/requirements.txt -COPY requirements_dev.txt /tmp/requirements_dev.txt - - -# Install apt packages -# gfortran, debugging tools, git, maths and Latex libraries -# poppler-utils is required by pdf2image -# This syntax is recommended by Docker to bust caching -RUN apt-get update && apt-get install -y \ - gdb \ - gfortran \ - git \ - graphviz \ - libblas-dev \ - liblapack-dev \ - liblapack3 \ - pandoc \ - poppler-utils \ - python3-pip \ - python-is-python3 \ - texlive-base \ - texlive-font-utils \ - texlive-latex-extra \ - lcov \ - cmake \ - bc - - -# Install apt packages for pyenv. -RUN apt-get install -y \ - build-essential \ - curl \ - libbz2-dev \ - libffi-dev \ - liblzma-dev \ - libncurses5-dev \ - libncursesw5-dev \ - libreadline-dev \ - libsqlite3-dev \ - libssl-dev \ - llvm \ - python-openssl \ - tk-dev \ - wget \ - xz-utils \ - zlib1g-dev - - -# Install pyenv. -RUN curl https://pyenv.run | bash -ENV PYENV_ROOT /root/.pyenv -ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/versions/3.8.12/bin:$PATH - - -# Install python version 3.8.12 and set as global. -RUN pyenv install 3.8.12 && \ - pyenv global 3.8.12 - - -RUN python -m pip install --upgrade pip && \ - python -m pip install -r /tmp/requirements.txt && \ - python -m pip install -r /tmp/requirements_dev.txt && \ - python -m pip install git+https://github.com/jonmaddock/ford - -RUN git clone https://github.com/jmorris-uk/anybadge.git /root/anybadge/ && pip install anybadge diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile deleted file mode 100644 index 717647330c..0000000000 --- a/docker/dev/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# Development image for Process, used in challenging environments to give -# identical results to CI or to quickly provide a working environment to a -# casual user. Differs from CI image by not using virtual environments for -# differt Python versions and doesn't require the CI script to perform extra -# installations -FROM ubuntu:20.04 -LABEL description="Process development image" - -# Required to get around interactive timezone prompt -ENV DEBIAN_FRONTEND=noninteractive -ENV FC=gfortran - -# Install apt packages -# poppler-utils is required by pdf2image -RUN apt-get update && apt-get install -y \ - gdb \ - gfortran \ - git \ - graphviz \ - libblas-dev \ - liblapack-dev \ - liblapack3 \ - poppler-utils \ - python3-pip \ - python-is-python3 \ - libhdf5-serial-dev \ - netcdf-bin \ - libnetcdf-dev - -# Install Python packages into a virtual environment -# Use virtualenv to prevent "running pip as root" warnings -RUN python -m pip install --upgrade pip && \ - python -m pip install \ - cmake \ - Markdown \ - matplotlib \ - mkdocs \ - mkdocs-material \ - netCDF4 \ - numpy \ - pathlib \ - pillow \ - pymdown-extensions \ - pytest \ - scipy \ - toposort \ - wheel diff --git a/documentation/proc-pages/development/numba.md b/documentation/proc-pages/development/numba.md index 0a309123ca..89c1b40636 100644 --- a/documentation/proc-pages/development/numba.md +++ b/documentation/proc-pages/development/numba.md @@ -90,7 +90,7 @@ First ensure that `gprof2dot` is installed by issuing the command `pip install g Execute the following commands from the PROCESS root directory: ```bash -> python3.8 -m cProfile -o large-tok.pstats process/main.py -i tests/regression/scenarios/large-tokamak/IN.DAT +> python3 -m cProfile -o large-tok.pstats process/main.py -i tests/regression/scenarios/large-tokamak/IN.DAT > gprof2dot -f pstats large-tok.pstats | dot -Tpng -o large_tokamak_profile.png ``` diff --git a/documentation/proc-pages/development/pre-commit.md b/documentation/proc-pages/development/pre-commit.md index 3fda3667b6..83aac78c64 100755 --- a/documentation/proc-pages/development/pre-commit.md +++ b/documentation/proc-pages/development/pre-commit.md @@ -39,7 +39,7 @@ pre-commit -h If pre-commit is not installed, then it can be installed by: ```bash -python3.8 -m pip install pre-commit +python3 -m pip install pre-commit ``` For developers of PROCESS diff --git a/documentation/proc-pages/installation/csd3-for-process.md b/documentation/proc-pages/installation/csd3-for-process.md index 52d2f8161d..d0114783af 100644 --- a/documentation/proc-pages/installation/csd3-for-process.md +++ b/documentation/proc-pages/installation/csd3-for-process.md @@ -43,7 +43,7 @@ conda create --name my_process conda activate my_process ``` -It is worth checking that a compatible version of python has been installed (Python3.8 or 3.10). You can check this by entering `which python` into the terminal. You can install a compatible version of python with the command `conda install python=3.10`. +It is worth checking that a compatible version of python has been installed (Python3.10 or 3.11). You can check this by entering `which python` into the terminal. You can install a compatible version of python with the command `conda install python=3.10`. Next, install gfortran. diff --git a/documentation/proc-pages/installation/installation-docker.md b/documentation/proc-pages/installation/installation-docker.md deleted file mode 100644 index 3a9e966107..0000000000 --- a/documentation/proc-pages/installation/installation-docker.md +++ /dev/null @@ -1,70 +0,0 @@ -# Installation using Docker - -!!! Note "Note" - This section is for users of a privileged machine of the wrong OS e.g MacOS. If you are a using a shared resource e.g. computing cluster, please go [here](https://ukaea.github.io/PROCESS/installation/installation-singularity/).* - -PROCESS can be run on Mac or in other environments inside a Docker container. The PROCESS -repository, including source and build directories, remain in the host filesystem, but the -building and running of PROCESS is performed inside the container. This ensures that PROCESS -produces the same results as in other fully-supported environments, such as the CI system. The -Ubuntu-based development image used is similar to the one used on the CI system, but it is -designed to work immediately with no further installations. - -!!! Note "Docker licence" - Please note due to recent changes in the Docker Desktop ToS, you will require either a Docker - Desktop license to run on Mac, or you will require a Linux environment by other means, such - as a virtual machine. - -Firstly, [install Docker](https://docs.docker.com/get-docker/). On Mac, this can be accomplished -using `homebrew`: - -``` -brew --cask install docker -``` - -Then download the Docker image from the Process Gitlab container registry: - -``` -docker pull ghcr.io/ukaea/process-ci:latest -``` - -Running `docker image ls` should show the image in your local Docker image repository. Optionally, -you can change the image name to something more manageable: - -``` -docker tag ghcr.io/ukaea/process-ci:latest process-dev -``` - -to rename the image to "process-dev" with the "latest" tag: "process:latest". - -Now run the container: - -``` -docker run -it -v ~/process:/root/process process-dev -``` - -This runs a container which is an instance of the process-dev image. `-it` runs the container in -interactive mode (`-i`, allows `stdin`) with a terminal (`-t`, allows bash-like interaction). `-v` -specifies the bind mount to use; mount the host `~/process` directory to the `/root/process` -directory in the container. This means that the container has read and write access to the `process` -project directory on the host filesystem and will stay in sync with it. Please be aware that -changes made in a Docker container outside of mounted folders will not be saved on exiting the container. - -Now the container is running, configure, clean and build from the project root directory inside the container: - -``` -cd ~/process -cmake -S . -B build -cmake --build build --clean-first -``` - -The clean step is required to remove any build targets or caches from previous host builds to ensure -a completely fresh build from inside the container. This is only required when using the container -for the first time. - -Once PROCESS has built inside the container, it can be tested (as in the following section) by -running `pytest`. Once the test suite passes, this confirms that your Docker container runs PROCESS -with the same results as the CI system. PROCESS can now be developed and run as before, with the -build and running taking place inside the container. - -There is also a VS Code extension for Docker containers that may be helpful. diff --git a/documentation/proc-pages/installation/installation-singularity.md b/documentation/proc-pages/installation/installation-singularity.md deleted file mode 100644 index b90b4b2c34..0000000000 --- a/documentation/proc-pages/installation/installation-singularity.md +++ /dev/null @@ -1,71 +0,0 @@ - - -# Installation using Singularity/Apptainer container - -Singularity is a container environment similar to Docker. This means a user can run PROCESS with -all required dependencies installed. Singularity, however, is designed to work with user-level -permissions and, as such, is supported by many shared resource administrators (unlike Docker, -which poses a security risk). - -Singularity can convert OCI compliant containers into the Singularity Image Format (SIF) to run -the Docker container above. Download, and convert the Docker container by running: - -```bash -apptainer pull process.sif docker://ghcr.io/ukaea/process-ci:latest -``` - -Singularity will then ask for a username and password, your CCFE GitLab short username and -password. Singularity will write the container into your current directory, it can then be moved or -copied like any file. Running the following command will load a Singularity shell with the -dependencies for PROCESS installed: - -```bash -apptainer shell process.sif -``` - -Singularity will automatically mount your home (`$HOME`) directory into the container. Therefore, -if PROCESS lives in `~/process` on your system, it will also live inside of `~/process` in the -shell environment. - -It should also be noted that while the Singularity container has a Python 3.8 by default, it will -be impossible to pip install any packages without getting a `Read-only file system` error. This is -because you are treated as a non-admin user within the container, and, as such, you cannot update -the system Python. For this reason, it is recommended that you still use a virtual environment -within the Singularity container (as described above). `pip install --user` will work; -however, it will cause conflicts with existing Python packages you have installed outside of your container. - -

Steps to use Singularity to install PROCESS on Freia

- -Log onto Freia and make sure the Singularity module is loaded - -```bash -module load singularity/3.7.1 -``` - -Pull the Singularity image and enter your git username and password when prompted: - -```bash -apptainer pull process.sif docker://ghcr.io/ukaea/process-ci:latest -``` - -Make sure you have created [ssh keys](https://docs.gitlab.com/ee/ssh/) and open the Singularity shell: - -```bash -apptainer shell process.sif -``` - -Singularity is an environment which allows you to use dependencies not available on Freia, like -the correct versions of Python and cmake. With the shell open, the installation of PROCESS can proceed as usual: - -```bash -git clone git@git.ccfe.ac.uk:process/process.git -cd process -python3 -m venv env --without-pip --system-site-packages -source env/bin/activate -export PATH=$PATH:~USERNAME/.local/bin/ -cmake -S . -B build -cmake --build build -``` - -Now you can run commands within the shell like `process -i tests/regression/scenarios/large-tokamak/IN.DAT` -to verify installation and create [batch jobs](https://ukaea.github.io/PROCESS/io/utilities/). diff --git a/documentation/proc-pages/installation/installation-ubuntu.md b/documentation/proc-pages/installation/installation-ubuntu.md index 73248a39e0..661f30c010 100644 --- a/documentation/proc-pages/installation/installation-ubuntu.md +++ b/documentation/proc-pages/installation/installation-ubuntu.md @@ -1,5 +1,5 @@ # Installation on Ubuntu/Windows -PROCESS is developed using Ubuntu 22 and tested using Ubuntu 20. We cannot guarantee any other operating system will be able to compile PROCESS or reproduce results. We do unofficially support MacOS however PROCESS is **not** currently tested on this OS by the CI system. +PROCESS is developed using Ubuntu 22 and tested using Ubuntu 20. We cannot guarantee any other operating system will be able to compile PROCESS or reproduce results. PROCESS is known to build on some versions of MacOS, however, PROCESS is **not** supported or tested on MacOS. !!! Info "Windows User" Windows users should run PROCESS using WSL. @@ -16,11 +16,7 @@ PROCESS is developed using Ubuntu 22 and tested using Ubuntu 20. We cannot guara If the above procedure fails to work, there is a [Microsoft help page](https://learn.microsoft.com/en-us/windows/wsl/install). -!!! Info "Users on unsupported OS'" - Other users may find benefit in our [Docker installation guide](https://ukaea.github.io/PROCESS/installation/installation-docker/) if they are on a machine which they have admin privledges. - - Users of shared resources should see our [Singularity/Apptainer installation guide](https://ukaea.github.io/PROCESS/installation/installation-singularity/). - +## Installing PROCESS GFortran version 9 or above is needed for successful installation and execution of PROCESS. Versions below GFortran-9 will be rejected by CMake by default since, while PROCESS might compile @@ -33,6 +29,10 @@ sudo apt update sudo apt install -y cmake gfortran python3-pip lcov poppler-utils python3-venv ``` +!!! Note "CMake" + CMake can also be installed into your (virtual) Python environment by running `pip install cmake`. + + Next, the code will need to be downloaded so you can work with it. The PROCESS code is stored in a GitHub repository and as such needs to be 'cloned' - i.e bought to your VSCode window from GitHub. @@ -74,17 +74,27 @@ cmake -S . -B build cmake --build build ``` -If you plan on developing code for PROCESS, please see the `pre-commit` documentation for -installing this tool required by developers: [development/pre-commit](http://process.gitpages.ccfe.ac.uk/process/development/pre-commit/) - The build step may take some time when run for the first time (~3 mins) as the Fortran code is compiled and then wrapped using `f2py` to create the Python libraries. Once this is completed the PROCESS Python package is then automatically installed using `pip` and should be ready to use -on Linux. If the installation was successful the command `process` should be available on the command line. +on Linux. If the installation was successful the `process` command should be available on the command line. To rebuild, for example after making a change to the Fortran source, run `cmake --build build` again. Python-only changes are reflected immediately, as the `cmake` build script performs a development (editable) installation by default. +## Examples + +If you are new to PROCESS, you may want to run some of the examples in the `examples/` directory. These will introduce you to the basic functionality of reactor design with PROCESS. The examples require additional dependencies that can be installed using: +``` +pip install '.[examples]' +``` + +## PROCESS Development + +If you plan on developing code for PROCESS, please see the `pre-commit` documentation for +installing this tool required by developers: [development/pre-commit](http://process.gitpages.ccfe.ac.uk/process/development/pre-commit/). + + !!! warning "Users of multiple branches" For users of PROCESS that run on multiple branches, it is recommended that each time you switch branches you **fully rebuild** PROCESS: ```bash @@ -94,12 +104,9 @@ Python-only changes are reflected immediately, as the `cmake` build script perfo ``` The PROCESS test suite provides through tests that can be used to confirm a successful installation; -the tests can then be used to verify changes you make have not affected the wider codebase. - -Firstly, ensure you are in the PROCESS root directory. - -```BASH -cd PROCESS +the tests can then be used to verify changes you make have not affected the wider codebase. The tests should be run from the PROCESS root directory. The tests require additional requirements installed by running: +``` +pip install '.[examples, test]' ``` The test suite uses PyTest and can be fully run using: @@ -113,9 +120,7 @@ which runs unit, integration, and regression tests. A more in-depth discussion of testing can be found [here](https://ukaea.github.io/PROCESS/development/testing/). If everything passes, this indicates a successful installation. If anything fails, this indicates -that your environment produces different results to what is expected. You might consider -creating an issue in GitHub, or trying out the -[Docker container](https://ukaea.github.io/PROCESS/installation/installation-docker/) instead. +that your environment produces different results to what is expected. !!! Question "Installation troubleshooting" @@ -198,5 +203,5 @@ creating an issue in GitHub, or trying out the E.g. ```bash - sudo apt install libpython3.8-dev + sudo apt install libpython3.10-dev ``` diff --git a/documentation/proc-pages/installation/introduction.md b/documentation/proc-pages/installation/introduction.md index 2627f39fdb..3cbdca3e6c 100644 --- a/documentation/proc-pages/installation/introduction.md +++ b/documentation/proc-pages/installation/introduction.md @@ -6,10 +6,4 @@ different operating systems. PROCESS is natively supported on Ubuntu 20 and 22, and requires Python 3.8 or greater. Other Linux distributions will be able to successfully build and execute PROCESS however may give inconsistent results due to version disparities of -dynamically linked libraries; therefore these can't be guaranteed. To install on Ubuntu, please follow the [installation guide](installation-ubuntu.md). - -Additionally, there are three supported ways to run PROCESS on a non-native Ubuntu 22.04 machine: - -1. WSL (Windows Subsystem for Linux- if you are a Windows user) --> [guide](installation-ubuntu.md) -2. Docker (for users on privileged machines that are of the wrong OS) --> [guide](installation-docker.md) -3. Singularity (mainly for use on shared resources e.g. Freia) --> [guide](installation-singularity.md) +dynamically linked libraries; therefore these can't be guaranteed. To install on Ubuntu, Mac, or Windows, please follow the [installation guide](installation-ubuntu.md). diff --git a/mkdocs.yml b/mkdocs.yml index f45c394889..9a9290374e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,8 +7,6 @@ nav: - Installation: - Introduction: installation/introduction.md - Installation on Ubuntu/Windows: installation/installation-ubuntu.md - - Installation using Docker: installation/installation-docker.md - - Installation using Singularity: installation/installation-singularity.md - Installation on CSD3: installation/csd3-for-process.md - Visual Studio Code: installation/vs-code.md - Usage: @@ -42,23 +40,23 @@ nav: # - Versioning: development/versioning.md - Reference: - Physics Models: - - Plasma: - - Overview: physics-models/plasma_overview.md - - Geometry: physics-models/plasma_geometry.md - - Profiles: - - Overview: physics-models/profiles/plasma_profiles.md - - Density Profile: physics-models/profiles/plasma_density_profile.md - - Temperature Profile: physics-models/profiles/plasma_temperature_profile.md - - Profile Base Class: physics-models/profiles/plasma_profiles_abstract_class.md - - Fusion Reactions: physics-models/plasma_reactions.md - - Beta Limit: physics-models/plasma_beta.md - - Fast Alpha: physics-models/plasma_alpha.md - - Density Limit: physics-models/plasma_density.md - - Composition & Impurities: physics-models/plasma_radiation_impurities.md - - Radiation: physics-models/plasma_radiation_impurities.md - - Plasma Current: physics-models/plasma_current.md - - Confinement time: physics-models/plasma_confinement.md - - Plasma Core Power Balance: physics-models/plasma_power_balance.md + - Plasma: + - Overview: physics-models/plasma_overview.md + - Geometry: physics-models/plasma_geometry.md + - Profiles: + - Overview: physics-models/profiles/plasma_profiles.md + - Density Profile: physics-models/profiles/plasma_density_profile.md + - Temperature Profile: physics-models/profiles/plasma_temperature_profile.md + - Profile Base Class: physics-models/profiles/plasma_profiles_abstract_class.md + - Fusion Reactions: physics-models/plasma_reactions.md + - Beta Limit: physics-models/plasma_beta.md + - Fast Alpha: physics-models/plasma_alpha.md + - Density Limit: physics-models/plasma_density.md + - Composition & Impurities: physics-models/plasma_radiation_impurities.md + - Radiation: physics-models/plasma_radiation_impurities.md + - Plasma Current: physics-models/plasma_current.md + - Confinement time: physics-models/plasma_confinement.md + - Plasma Core Power Balance: physics-models/plasma_power_balance.md - Pulsed Plant Operation: physics-models/pulsed-plant.md - Engineering Models: - Machine Build: eng-models/machine-build.md @@ -71,31 +69,31 @@ nav: - Shield: eng-models/shield.md - Divertor: eng-models/divertor.md - Heat transport: eng-models/power-conversion-and-heat-dissipation-systems.md - - Auxiliary Heating & Current Drive Systems: - - Overview: eng-models/heating_and_current_drive/heating-and-current-drive.md - - Radio Frequency: - - Overview: eng-models/heating_and_current_drive/RF/rf_overview.md - - Lower Hybrid: - - Overview: eng-models/heating_and_current_drive/RF/lhcd_overview.md - - Fenstermacher Model: eng-models/heating_and_current_drive/RF/fenstermacher_lower_hybrid.md - - Ehst Model: eng-models/heating_and_current_drive/RF/ehst_lower_hybrid.md - - Culham Model: eng-models/heating_and_current_drive/RF/culham_lower_hybrid.md - - Electron Cyclotron: - - Overview: eng-models/heating_and_current_drive/RF/ec_overview.md - - Fenstermacher Resonnance Model: eng-models/heating_and_current_drive/RF/fenstermacher_electron_cyclotron_resonance.md - - Culham Model: eng-models/heating_and_current_drive/RF/culham_electron_cyclotron.md - - User Input Gamma Model: eng-models/heating_and_current_drive/RF/ecrh_gamma.md - - Cutoff mode: eng-models/heating_and_current_drive/RF/cutoff_ecrh.md - - Ion Cyclotron: - - Overview: eng-models/heating_and_current_drive/RF/ic_overview.md - - Ion cyclotron model: eng-models/heating_and_current_drive/RF/ic_model.md - - Electron Bernstein Wave: - - Overview: eng-models/heating_and_current_drive/RF/ebw_overview.md - - EBW Model: eng-models/heating_and_current_drive/RF/ebw_freethy.md - - Neutral Beam Injection: - - Overview: eng-models/heating_and_current_drive/NBI/nbi_overview.md - - ITER Model: eng-models/heating_and_current_drive/NBI/iter_nb.md - - Culham Model: eng-models/heating_and_current_drive/NBI/culham_nb.md + - Auxiliary Heating & Current Drive Systems: + - Overview: eng-models/heating_and_current_drive/heating-and-current-drive.md + - Radio Frequency: + - Overview: eng-models/heating_and_current_drive/RF/rf_overview.md + - Lower Hybrid: + - Overview: eng-models/heating_and_current_drive/RF/lhcd_overview.md + - Fenstermacher Model: eng-models/heating_and_current_drive/RF/fenstermacher_lower_hybrid.md + - Ehst Model: eng-models/heating_and_current_drive/RF/ehst_lower_hybrid.md + - Culham Model: eng-models/heating_and_current_drive/RF/culham_lower_hybrid.md + - Electron Cyclotron: + - Overview: eng-models/heating_and_current_drive/RF/ec_overview.md + - Fenstermacher Resonnance Model: eng-models/heating_and_current_drive/RF/fenstermacher_electron_cyclotron_resonance.md + - Culham Model: eng-models/heating_and_current_drive/RF/culham_electron_cyclotron.md + - User Input Gamma Model: eng-models/heating_and_current_drive/RF/ecrh_gamma.md + - Cutoff mode: eng-models/heating_and_current_drive/RF/cutoff_ecrh.md + - Ion Cyclotron: + - Overview: eng-models/heating_and_current_drive/RF/ic_overview.md + - Ion cyclotron model: eng-models/heating_and_current_drive/RF/ic_model.md + - Electron Bernstein Wave: + - Overview: eng-models/heating_and_current_drive/RF/ebw_overview.md + - EBW Model: eng-models/heating_and_current_drive/RF/ebw_freethy.md + - Neutral Beam Injection: + - Overview: eng-models/heating_and_current_drive/NBI/nbi_overview.md + - ITER Model: eng-models/heating_and_current_drive/NBI/iter_nb.md + - Culham Model: eng-models/heating_and_current_drive/NBI/culham_nb.md - Cryostat and vacuum system: eng-models/cryostat-and-vacuum-system.md - Plant Availability: eng-models/plant-availability.md - Power Requirements: eng-models/power-requirements.md diff --git a/process/impurity_radiation.py b/process/impurity_radiation.py index 0c513a1e04..a0997370e4 100644 --- a/process/impurity_radiation.py +++ b/process/impurity_radiation.py @@ -1,18 +1,13 @@ import numpy import dataclasses import re -import sys +from importlib import resources from typing import Optional, List from pathlib import Path from scipy import integrate from process.fortran import impurity_radiation_module from process.fortran import error_handling -if sys.version_info >= (3, 9): - from importlib import resources -else: - import importlib_resources as resources - import logging diff --git a/process/io/plot_proc.py b/process/io/plot_proc.py index 2a154b89ea..c3394b2868 100755 --- a/process/io/plot_proc.py +++ b/process/io/plot_proc.py @@ -15,11 +15,11 @@ """ import os -import sys import argparse from argparse import RawTextHelpFormatter import matplotlib import matplotlib.pyplot as plt +from importlib import resources from matplotlib.patches import Rectangle from matplotlib.patches import Circle import matplotlib.backends.backend_pdf as bpdf @@ -59,11 +59,6 @@ matplotlib.use("Agg") matplotlib.rcParams["figure.max_open_warning"] = 40 -if sys.version_info >= (3, 7): - from importlib import resources -else: - import importlib_resources as resources - def parse_args(args): """Parse supplied arguments. diff --git a/process/io/run_process.conf b/process/io/run_process.conf index 390f619edb..4c2eb6cbcd 100644 --- a/process/io/run_process.conf +++ b/process/io/run_process.conf @@ -16,7 +16,7 @@ ORIGINAL_IN_DAT = PROCESS_DIR/RUN_DIR/STEP_IN.DAT * PROCESS= PROCESS_DIR/bin/process.exe * ONE line comment to be put into README.txt -COMMENT = +COMMENT = * Max no. iterations NITER = 50 diff --git a/requirements.txt b/requirements.txt index 76aa750397..4a0ac4d6bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,25 +1,11 @@ -importlib-resources==5.0.0 ; python_version < '3.9' -mkdocs>=1.1 -mkdocs-material>=4.6.3 -mkdocs-git-revision-date-localized-plugin >= 1.2 -mkdocs-glightbox >= 0.3.4 -pymdown-extensions>=6.3 +# requirements.txt includes the dependencies necessary for running the PROCESS build system +# (cmake --build build). + +# numpy is required for some of the install scripts numpy>=1.23 -scipy>=1.10 -matplotlib>=2.1.1 -pillow>=5.1.0 + +# Markdown versions for ford compatibility Markdown>=3.2.2,<3.4 -toposort>=1.5 -netCDF4>=1.5.4 -wheel>=0.36.2 -jupyter==1.0.0 -pdf2image==1.16.0 -numba>=0.57 -pandas>=1.1.5 -bokeh==2.4.0 -mkdocstrings==0.18.0 -PyVMCON>=2.2.2,<3.0.0 -CoolProp>=6.4 -Jinja2>=3.0 -cvxpy!=1.3.0,!=1.3.1 -seaborn>=0.12.2 + +# f2py requires to read some Fortran code +charset-normalizer>=3.3 diff --git a/requirements_dev.txt b/requirements_dev.txt index ad5a4ac09d..221cc3a397 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,8 +1,14 @@ -black>=22.3.0,<=23.0.0 -flake8>=5.0.4 -flinter==0.3.0 +# requirements_dev.txt includes the dependencies for running scripts on the CI +# e.g. documentation building and quality assurance (pre-commit). + pre-commit>=2.16.0 -pytest>=5.4.1 pytest-cov>=3.0.0 pytest-xdist>=2.5.0 -testbook>=0.4 +mkdocs>=1.1 +mkdocs-material>=4.6.3 +mkdocs-git-revision-date-localized-plugin >= 1.2 +mkdocs-glightbox >= 0.3.4 +pymdown-extensions>=6.3 +bokeh==2.4.0 +mkdocstrings==0.18.0 +Jinja2>=3.0 diff --git a/setup.py b/setup.py index 875a443a9f..ca700977da 100644 --- a/setup.py +++ b/setup.py @@ -23,9 +23,6 @@ "process": [ "lib/lib*", "fortran*.so", - "data/fluids/*", - "data/h_data/*", - "data/lz_non_corona/*", "data/lz_non_corona_14_elements/*", "utilities/*", ], @@ -34,26 +31,25 @@ "process.uncertainties": ["*.json"], }, "test_suite": "pytest", + "python_requires": ">=3.10", "install_requires": [ "numpy>=1.23", "scipy>=1.10", "cvxpy!=1.3.0,!=1.3.1", - "importlib-resources ; python_version<'3.9'", - "pandas", + "pandas>=2.0", "tables", "SALib", "numba>=0.57", "PyVMCON>=2.2.2,<3.0.0", "CoolProp>=6.4", + "matplotlib>=2.1.1", "seaborn>=0.12.2", ], - "extras_require": {"test": ["pytest"]}, - "entry_points": { - "console_scripts": [ - "process_script=process.process_script_advanced:main", - "process=process.main:main", - ] + "extras_require": { + "test": ["pytest>=5.4.1", "requests>=2.30", "testbook>=0.4"], + "examples": ["pillow>=5.1.0", "jupyter==1.0.0", "pdf2image==1.16.0"], }, + "entry_points": {"console_scripts": ["process=process.main:main"]}, "extra_link_args": EXTRA_ARGS, } diff --git a/source/fortran/impurity_radiation.f90 b/source/fortran/impurity_radiation.f90 index 09815f8467..e282c65eca 100644 --- a/source/fortran/impurity_radiation.f90 +++ b/source/fortran/impurity_radiation.f90 @@ -42,7 +42,7 @@ module impurity_radiation_module !! fimp(nimp) /1.0,0.1,0.02,0.0,0.0,0.0,0.0,0.0,0.0016,0.0,0.0,0.0,0.0,0.0/ : !! impurity number density fractions relative to electron density - !! + !! real(dp), public, dimension(nimp) :: fimp character*2, public, dimension(nimp) :: imp_label diff --git a/source/fortran/iteration_variables.f90 b/source/fortran/iteration_variables.f90 index 1371cd56da..99257e4b04 100755 --- a/source/fortran/iteration_variables.f90 +++ b/source/fortran/iteration_variables.f90 @@ -3849,7 +3849,7 @@ subroutine set_itv_172(ratio) real(kind(1.d0)) :: ratio casths = ratio end subroutine set_itv_172 - + !--------------------------------- ! DUMMY variables below here !--------------------------------- @@ -4116,8 +4116,8 @@ subroutine loadxc case (168); xcm(i) = itv_168() case (169); xcm(i) = itv_169() case (170); xcm(i) = itv_170() - case (171); xcm(i) = itv_171() - case (172); xcm(i) = itv_172() + case (171); xcm(i) = itv_171() + case (172); xcm(i) = itv_172() ! DUMMY Cases case (173); xcm(i) = itv_173() case (174); xcm(i) = itv_174() @@ -4384,7 +4384,7 @@ subroutine convxc(xc,nn) case (169); call set_itv_169(ratio) case (170); call set_itv_170(ratio) case (171); call set_itv_171(ratio) - case (172); call set_itv_172(ratio) + case (172); call set_itv_172(ratio) ! DUMMY Cases case (173); call set_itv_173(ratio) case (174); call set_itv_174(ratio)