From 73a1ea336068f03d84f502f063437f885e1e56e2 Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Wed, 10 Apr 2024 22:26:30 +0530 Subject: [PATCH 1/8] reduced the image to one --- scripts/Dockerfile | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/scripts/Dockerfile b/scripts/Dockerfile index 152c8f01d9..4f83b20ba1 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -26,35 +26,12 @@ RUN conda init --all SHELL ["conda", "run", "-n", "pybamm", "/bin/bash", "-c"] RUN conda install -y pip -ARG IDAKLU -ARG JAX -ARG ALL - RUN pip install --upgrade --user pip setuptools wheel wget RUN pip install cmake -RUN if [ "$IDAKLU" = "true" ]; then \ - python scripts/install_KLU_Sundials.py && \ - rm -rf pybind11 && \ - git clone https://github.com/pybind/pybind11.git && \ - pip install --user -e ".[all,dev,docs]"; \ - fi - -RUN if [ "$JAX" = "true" ]; then \ - pip install --user -e ".[all,dev,docs,jax]"; \ - fi - -RUN if [ "$ALL" = "true" ]; then \ - python scripts/install_KLU_Sundials.py && \ +RUN python scripts/install_KLU_Sundials.py && \ rm -rf pybind11 && \ git clone https://github.com/pybind/pybind11.git && \ - pip install --user -e ".[all,dev,docs,jax]"; \ - fi - -RUN if [ -z "$IDAKLU" ] \ - && [ -z "$JAX" ] \ - && [ -z "$ALL" ]; then \ - pip install --user -e ".[all,dev,docs]"; \ - fi + pip install --user -e ".[all,dev,docs,jax]"; ENTRYPOINT ["/bin/bash"] From 2b81a92c45eb6d3022e84f1f429aacfe22bc3eef Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Thu, 11 Apr 2024 13:20:29 +0530 Subject: [PATCH 2/8] removed build time args and multiple image builds --- .github/workflows/docker.yml | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d51231d972..04bca1f4dd 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,12 +10,8 @@ jobs: build_docker_images: # This workflow is only of value to PyBaMM and would always be skipped in forks if: github.repository_owner == 'pybamm-team' - name: Image (${{ matrix.build-args }}) + name: Image runs-on: ubuntu-latest - strategy: - matrix: - build-args: ["No solvers", "JAX", "IDAKLU", "ALL"] - fail-fast: true steps: - name: Checkout @@ -33,22 +29,11 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create tags for Docker images based on build-time arguments + - name: Create latest tag for Docker image id: tags - run: | - if [ "${{ matrix.build-args }}" = "No solvers" ]; then - echo "tag=latest" >> "$GITHUB_OUTPUT" - elif [ "${{ matrix.build-args }}" = "JAX" ]; then - echo "tag=jax" >> "$GITHUB_OUTPUT" - elif [ "${{ matrix.build-args }}" = "ODES" ]; then - echo "tag=odes" >> "$GITHUB_OUTPUT" - elif [ "${{ matrix.build-args }}" = "IDAKLU" ]; then - echo "tag=idaklu" >> "$GITHUB_OUTPUT" - elif [ "${{ matrix.build-args }}" = "ALL" ]; then - echo "tag=all" >> "$GITHUB_OUTPUT" - fi - - - name: Build and push Docker image to Docker Hub (${{ matrix.build-args }}) + run: echo "tag=latest" >> "$GITHUB_OUTPUT" + + - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 with: context: . From 942c4c7c2a5e8c9bb42c1d353fc4d75aa5832cdc Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Thu, 11 Apr 2024 13:33:03 +0530 Subject: [PATCH 3/8] removed optional solvers from docker docs --- .../installation/install-from-docker.rst | 97 ++----------------- 1 file changed, 6 insertions(+), 91 deletions(-) diff --git a/docs/source/user_guide/installation/install-from-docker.rst b/docs/source/user_guide/installation/install-from-docker.rst index 1d49ae8f54..aa707a8eff 100644 --- a/docs/source/user_guide/installation/install-from-docker.rst +++ b/docs/source/user_guide/installation/install-from-docker.rst @@ -20,29 +20,11 @@ Pulling the Docker image Use the following command to pull the PyBaMM Docker image from Docker Hub: -.. tab:: No optional solver - .. code:: bash - - docker pull pybamm/pybamm:latest - -.. tab:: JAX solver - - .. code:: bash - - docker pull pybamm/pybamm:jax - -.. tab:: IDAKLU solver - - .. code:: bash - - docker pull pybamm/pybamm:idaklu - -.. tab:: All solvers +.. code:: bash - .. code:: bash + docker pull pybamm/pybamm:latest - docker pull pybamm/pybamm:all Running the Docker container ---------------------------- @@ -51,35 +33,11 @@ Once you have pulled the Docker image, you can run a Docker container with the P 1. In your terminal, use the following command to start a Docker container from the pulled image: -.. tab:: Basic - - .. code:: bash - - docker run -it pybamm/pybamm:latest - -.. tab:: ODES Solver - .. code:: bash - - docker run -it pybamm/pybamm:odes - -.. tab:: JAX Solver - - .. code:: bash - - docker run -it pybamm/pybamm:jax - -.. tab:: IDAKLU Solver - - .. code:: bash - - docker run -it pybamm/pybamm:idaklu - -.. tab:: All Solver +.. code:: bash - .. code:: bash + docker run -it pybamm/pybamm:latest - docker run -it pybamm/pybamm:all 2. You will now be inside the Docker container's shell. You can use PyBaMM and its dependencies as if you were in a virtual environment. @@ -138,52 +96,9 @@ If you want to build the PyBaMM Docker image locally from the PyBaMM source code conda activate pybamm -Building Docker images with optional arguments ----------------------------------------------- - -When building the PyBaMM Docker images locally, you have the option to include specific solvers by using optional arguments. These solvers include: - -- ``IDAKLU``: For IDA solver provided by the SUNDIALS plus KLU. -- ``JAX``: For Jax solver. -- ``ALL``: For all the above solvers. - -To build the Docker images with optional arguments, you can follow these steps for each solver: - -.. tab:: JAX solver - - .. code-block:: bash - - docker build -t pybamm:jax -f scripts/Dockerfile --build-arg JAX=true . - -.. tab:: IDAKLU solver - - .. code-block:: bash - - docker build -t pybamm:idaklu -f scripts/Dockerfile --build-arg IDAKLU=true . - -.. tab:: All solvers - - .. code-block:: bash - - docker build -t pybamm:all -f scripts/Dockerfile --build-arg ALL=true . - -After building the Docker images with the desired solvers, use the ``docker run`` command followed by the desired image name. For example, to run a container from the image built with all optional solvers: - -.. code-block:: bash - - docker run -it pybamm:all - -Activate PyBaMM development environment inside docker container using: - -.. code-block:: bash - - conda activate pybamm - -If you want to exit the Docker container's shell, you can simply type: - -.. code-block:: bash +.. note:: - exit + PyBaMM Docker image comes with all the solvers by default. These solvers include ``IDAKLU`` IDA solver provided by the SUNDIALS plus KLU and ``JAX`` solver. Using Git inside a running Docker container From 5074b8cf3d534869ed89b67fcbc26fe416c0c5cd Mon Sep 17 00:00:00 2001 From: Santhosh <52504160+santacodes@users.noreply.github.com> Date: Fri, 12 Apr 2024 07:32:14 +0530 Subject: [PATCH 4/8] Apply suggestions from code review Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- .github/workflows/docker.yml | 4 ++-- docs/source/user_guide/installation/install-from-docker.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 04bca1f4dd..ad1b1ffa73 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,10 +7,10 @@ on: - develop jobs: - build_docker_images: + build_docker_image: # This workflow is only of value to PyBaMM and would always be skipped in forks if: github.repository_owner == 'pybamm-team' - name: Image + name: Build image runs-on: ubuntu-latest steps: diff --git a/docs/source/user_guide/installation/install-from-docker.rst b/docs/source/user_guide/installation/install-from-docker.rst index aa707a8eff..654e2afce9 100644 --- a/docs/source/user_guide/installation/install-from-docker.rst +++ b/docs/source/user_guide/installation/install-from-docker.rst @@ -98,7 +98,7 @@ If you want to build the PyBaMM Docker image locally from the PyBaMM source code .. note:: - PyBaMM Docker image comes with all the solvers by default. These solvers include ``IDAKLU`` IDA solver provided by the SUNDIALS plus KLU and ``JAX`` solver. + PyBaMM's Docker image comes with all available solvers by default. These solvers include ``IDAKLU`` IDAS solver provided by the SUNDIALS linked with SuiteSparse's KLU and the ``JAX`` solver. Using Git inside a running Docker container From 95844a1c335c7248f552f812520fd5f96eb5671c Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Fri, 12 Apr 2024 07:37:40 +0530 Subject: [PATCH 5/8] code review suggestions --- .github/workflows/docker.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ad1b1ffa73..6e60454586 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -29,16 +29,12 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create latest tag for Docker image - id: tags - run: echo "tag=latest" >> "$GITHUB_OUTPUT" - - name: Build and push Docker image to Docker Hub uses: docker/build-push-action@v5 with: context: . file: scripts/Dockerfile - tags: pybamm/pybamm:${{ steps.tags.outputs.tag }} + tags: pybamm/pybamm:latest push: true platforms: linux/amd64, linux/arm64 From ae642b68e414e6489c6656ac18aaa812351af5d7 Mon Sep 17 00:00:00 2001 From: Santhosh Sundaram Date: Fri, 12 Apr 2024 07:58:51 +0530 Subject: [PATCH 6/8] added breaking change to changelog.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b474549bc2..99b10ab6f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ ## Breaking changes +- Removed multiple docker images and reduced it to a single docker image tagged `pybamm/pybamm:latest` with all the solvers (`IDAKLU` and `JAX`) contained in it by default ([#3992](https://github.com/pybamm-team/PyBaMM/pull/3961)) - Removed support for Python 3.8 ([#3961](https://github.com/pybamm-team/PyBaMM/pull/3961)) - Renamed "ocp_soc_0_dimensional" to "ocp_soc_0" and "ocp_soc_100_dimensional" to "ocp_soc_100" ([#3942](https://github.com/pybamm-team/PyBaMM/pull/3942)) - The ODES solver was removed due to compatibility issues. Users should use IDAKLU, Casadi, or JAX instead. ([#3932](https://github.com/pybamm-team/PyBaMM/pull/3932)) From 8a9d72801336c73e111b1eaa262d8c48ead705df Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Fri, 12 Apr 2024 08:17:26 +0530 Subject: [PATCH 7/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99b10ab6f5..59d99eba5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,7 +30,7 @@ ## Breaking changes -- Removed multiple docker images and reduced it to a single docker image tagged `pybamm/pybamm:latest` with all the solvers (`IDAKLU` and `JAX`) contained in it by default ([#3992](https://github.com/pybamm-team/PyBaMM/pull/3961)) +- Removed multiple Docker images. Here on, a single Docker image tagged `pybamm/pybamm:latest` will be provided with both solvers (`IDAKLU` and `JAX`) pre-installed. ([#3992](https://github.com/pybamm-team/PyBaMM/pull/3992)) - Removed support for Python 3.8 ([#3961](https://github.com/pybamm-team/PyBaMM/pull/3961)) - Renamed "ocp_soc_0_dimensional" to "ocp_soc_0" and "ocp_soc_100_dimensional" to "ocp_soc_100" ([#3942](https://github.com/pybamm-team/PyBaMM/pull/3942)) - The ODES solver was removed due to compatibility issues. Users should use IDAKLU, Casadi, or JAX instead. ([#3932](https://github.com/pybamm-team/PyBaMM/pull/3932)) From facda8fde6bcb30221d4d994ff7df40971dd7538 Mon Sep 17 00:00:00 2001 From: Arjun Verma Date: Sun, 14 Apr 2024 12:04:16 +0530 Subject: [PATCH 8/8] Apply suggestions from code review --- docs/source/user_guide/installation/install-from-docker.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/user_guide/installation/install-from-docker.rst b/docs/source/user_guide/installation/install-from-docker.rst index 654e2afce9..f8fe733098 100644 --- a/docs/source/user_guide/installation/install-from-docker.rst +++ b/docs/source/user_guide/installation/install-from-docker.rst @@ -23,7 +23,7 @@ Use the following command to pull the PyBaMM Docker image from Docker Hub: .. code:: bash - docker pull pybamm/pybamm:latest + docker pull pybamm/pybamm Running the Docker container @@ -36,7 +36,7 @@ Once you have pulled the Docker image, you can run a Docker container with the P .. code:: bash - docker run -it pybamm/pybamm:latest + docker run -it pybamm/pybamm 2. You will now be inside the Docker container's shell. You can use PyBaMM and its dependencies as if you were in a virtual environment.