Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slider bug fix #1043

Merged
merged 52 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0a3c674
Temporarily remove test_on_push gh-actions workflow
tlestang May 27, 2020
5eaf07c
Add workflow to build manylinux wheels
tlestang May 27, 2020
5cdfd23
Add test workflow to build on manylinux, macos and win
tlestang May 27, 2020
6e70cba
Windows wheel doent need to be built for both python versions
tlestang May 27, 2020
ca198f3
Add upload to PyPI step
tlestang May 27, 2020
7adc558
Bump version number
tlestang May 27, 2020
49129c2
Remove spurious ls wheelhouse/
tlestang May 27, 2020
393e5ef
Add missing repository_url for testPyPI
tlestang May 27, 2020
553aa6f
Upload wheels as artifacts
tlestang May 27, 2020
80c156f
Use entire directory for uploading artifact
tlestang May 27, 2020
c0d35da
publish wheels
tlestang May 27, 2020
eae98fc
Fix indent for publish step
tlestang May 27, 2020
089d925
Publish package if push event on master branch
tlestang May 27, 2020
a98bb27
Revert "Temporarily remove test_on_push gh-actions workflow"
tlestang May 27, 2020
0b9e2b9
Rename build wheels action
tlestang May 28, 2020
d66e380
Move bash script for installing sundials in manylinux
tlestang May 28, 2020
12e4d76
Bump version number
tlestang May 28, 2020
a492f67
Add name for build and deploy workflow
tlestang May 28, 2020
7053b3d
Fix typo in conditional of coverage step
tlestang Jun 1, 2020
b7fe22b
Add step that installs and run coverage
tlestang Jun 4, 2020
fc8e49e
Get sundials from Homebrew
tlestang Jun 4, 2020
0f88786
export LD_LIBRARY_PATH in codecov step
tlestang Jun 4, 2020
a59f64b
Use homemade action to build manylinux wheels
tlestang Jun 4, 2020
b6b613d
Bump post version number
tlestang Jun 4, 2020
e6ff599
Disable CI
tlestang Jun 4, 2020
3887a3b
Enable CD on any branch
tlestang Jun 4, 2020
3e17d6b
fix tab
tlestang Jun 4, 2020
58d0698
Remove spurious COPY cmd in Dockerfile
tlestang Jun 4, 2020
36a12b3
Install wget on image
tlestang Jun 4, 2020
ebc0e31
Generate xml report
tlestang Jun 5, 2020
ee87dfb
Forgot to copy n exec entry point in Dockerfile
tlestang Jun 5, 2020
692ff35
Add pybind11 dir
tlestang Jun 5, 2020
7bd18bb
List wheels before repair step
tlestang Jun 5, 2020
2ea3511
Use https instead of ssh
tlestang Jun 5, 2020
20a4d16
Move git clone to entry point
tlestang Jun 5, 2020
17cae03
Install SuiteSparse and Sundials in common location in docker image
tlestang Jun 5, 2020
ec5d7ce
Get pybind11 on MacOS
tlestang Jun 5, 2020
7c970a2
Bump post release number to 7
tlestang Jun 5, 2020
2c699c8
Update .gitignore
tlestang Jun 5, 2020
122de84
Update docs
tlestang Jun 5, 2020
4ae5e63
Restore expected triggers for workflows
tlestang Jun 5, 2020
2ac166e
Merge pull request #1034 from tlestang/fix_codecov
valentinsulzer Jun 5, 2020
c15fc2d
Add version tag to manylinux image in Dockerfile
tlestang Jun 5, 2020
eb6e8c0
Remove obsolete install shell script
tlestang Jun 5, 2020
93bb50d
Pin version tag for manylinux image
tlestang Jun 5, 2020
814f5d9
Merge pull request #1027 from tlestang/develop
valentinsulzer Jun 5, 2020
01a9e47
#1037 fix timescale
rtimms Jun 8, 2020
94fb9f8
#1037 fix dashed line
rtimms Jun 8, 2020
c693933
#1037 changelog
rtimms Jun 9, 2020
672a512
Merge pull request #1041 from pybamm-team/issue-1037-slider-bug
rtimms Jun 9, 2020
1cf5aac
version number
rtimms Jun 9, 2020
d1a7e88
Merge pull request #1042 from pybamm-team/version-0-2-2-post2
rtimms Jun 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/build_wheels_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and deployment

on:
push:
branches: master

jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
python-version: [3.6, 3.7]
include:
- os: ubuntu-latest
python-version: 3.8
- os: windows-latest
python-version: 3.6
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Build manylinux Python wheels
if: matrix.os == 'ubuntu-latest'
uses: './build_manylinux_wheels'

- name: Install standard python dependencies
if: matrix.os != 'ubuntu-latest'
run: |
python -m pip install --upgrade pip wheel setuptools

- name: Install build-time deps for MacOS
if: matrix.os == 'macos-latest'
run: |
brew update
brew install graphviz
brew install sundials
git clone https://github.com/pybind/pybind11.git

- name: Build wheels for MacOS and Windows
if: matrix.os != 'ubuntu-latest'
run: |
python -m pip wheel . -w dist/ --no-deps

- name: Upload wheels
uses: actions/upload-artifact@v1
with:
name: dist
path: dist


publish-pyi:
name: Upload wheels to PyPI
needs: build-wheels
runs-on: ubuntu-latest
steps:
- name: Download wheels
uses: actions/download-artifact@v1
with:
name: dist

- name: Publish wheels
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
16 changes: 12 additions & 4 deletions .github/workflows/test_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,22 @@ jobs:
export LD_LIBRARY_PATH=$HOME/.local/lib:scikits.odes/sundials5/lib:$LD_LIBRARY_PATH
pip install -e .[docs]
python run-tests.py --doctest

- name: Install dev dependencies and run example tests
if: matrix.os != 'windows-latest'
run: |
export LD_LIBRARY_PATH=$HOME/.local/lib:scikits.odes/sundials5/lib:$LD_LIBRARY_PATH
pip install -e .[dev]
python run-tests.py --examples

- name: Instal and run coverage
if: success() && (matrix.os == 'unbuntu-latest' && matrix.python-version == 3.7)

- name: Install and run coverage
if: success() && (matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7)
run: |
pip install coverage
export LD_LIBRARY_PATH=$HOME/.local/lib:scikits.odes/sundials5/lib:$LD_LIBRARY_PATH
coverage run run-tests.py --nosub
coverage xml

- name: Upload coverage report
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.7
uses: codecov/codecov-action@v1
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ sundials4
sundials-*
SuiteSparse-*
build_sundials
KLU_module_deps

# downloads
*.gz
Expand All @@ -96,6 +97,9 @@ cmake_install.cmake


third-party/pybind11
pybind11/

setup.log



# Build dependencies/
KLU_module_deps
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ New SEI models, simplification of submodel structure, as well as optimisations a

## Bug fixes

- Fix a bug where slider plots do not update properly in notebooks ([#1041](https://github.com/pybamm-team/PyBaMM/pull/1041))
- Fix storing and plotting external variables in the solution ([#1026](https://github.com/pybamm-team/PyBaMM/pull/1026))
- Fix running a simulation with a model that is already discretized ([#1025](https://github.com/pybamm-team/PyBaMM/pull/1025))
- Fix CI not triggering for PR. ([#1013](https://github.com/pybamm-team/PyBaMM/pull/1013))
Expand Down
17 changes: 17 additions & 0 deletions build_manylinux_wheels/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM quay.io/pypa/manylinux2010_x86_64:2020-05-29-c06f15c

ENV PLAT manylinux2010_x86_64

RUN yum -y remove cmake
RUN yum -y install wget openblas-devel
RUN /opt/python/cp37-cp37m/bin/pip install --upgrade pip cmake
RUN ln -s /opt/python/cp37-cp37m/bin/cmake /usr/bin/cmake

COPY install_sundials.sh /install_sundials.sh
RUN chmod +x /install_sundials.sh
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

RUN ./install_sundials.sh

ENTRYPOINT ["/entrypoint.sh"]
17 changes: 17 additions & 0 deletions build_manylinux_wheels/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# action.yml
# Based on RalfG/python-wheels-manylinux-build/action.yml by Ralf Gabriels

name: 'Python wheels manylinux build'
author: 'Thibault Lestang'
description: 'Build manylinux wheels for PyBaMM'
inputs:
python-versions:
description: 'Python versions to target, space-separated'
required: true
default: 'cp36-cp36m cp37-cp37m'

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.python-versions }}
25 changes: 25 additions & 0 deletions build_manylinux_wheels/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
set -e -x

# CLI arguments
PY_VERSIONS=$1

git clone https://github.com/pybind/pybind11.git /github/workspace/pybind11
# Compile wheels
arrPY_VERSIONS=(${PY_VERSIONS// / })
for PY_VER in "${arrPY_VERSIONS[@]}"; do
# Update pip
/opt/python/"${PY_VER}"/bin/pip install --upgrade --no-cache-dir pip

# Build wheels
/opt/python/"${PY_VER}"/bin/pip wheel /github/workspace/ -w /github/workspace/wheelhouse/ --no-deps || { echo "Building wheels failed."; exit 1; }
done
ls -l /github/workspace/wheelhouse/

# Bundle external shared libraries into the wheels
for whl in /github/workspace/wheelhouse/*-linux*.whl; do
auditwheel repair "$whl" --plat "${PLAT}" -w /github/workspace/dist/ || { echo "Repairing wheels failed."; auditwheel show "$whl"; exit 1; }
done

echo "Succesfully built wheels:"
ls -l /github/workspace/dist/
35 changes: 35 additions & 0 deletions build_manylinux_wheels/install_sundials.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

mkdir /deps
wget https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/v5.7.2.tar.gz .
wget https://computing.llnl.gov/projects/sundials/download/sundials-5.3.0.tar.gz .
tar -xf v5.7.2.tar.gz --directory /deps
tar -xf sundials-5.3.0.tar.gz --directory /deps
rm v5.7.2.tar.gz
rm sundials-5.3.0.tar.gz

SUITESPARSE_DIR=/deps/SuiteSparse-5.7.2
SUNDIALS_DIR=/deps/sundials-5.3.0

for dir in SuiteSparse_config AMD COLAMD BTF KLU
do
cd $SUITESPARSE_DIR/$dir;
make library
make install INSTALL=/usr
cd ../
done

KLU_INCLUDE_DIR=/usr/include
KLU_LIBRARY_DIR=/usr/lib
mkdir -p /deps/build_sundials
cd /deps/build_sundials
cmake -DLAPACK_ENABLE=ON\
-DSUNDIALS_INDEX_SIZE=32\
-DEXAMPLES_ENABLE:BOOL=OFF\
-DKLU_ENABLE=ON\
-DKLU_INCLUDE_DIR=$KLU_INCLUDE_DIR\
-DKLU_LIBRARY_DIR=$KLU_LIBRARY_DIR\
-DCMAKE_INSTALL_PREFIX=/usr\
$SUNDIALS_DIR
make install

10 changes: 10 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ PyBaMM is available on GNU/Linux, MacOS and Windows.
Using pip
----------

GNU/Linux and Windows
~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash

pip install pybamm

macOS
~~~~~~~~~~~~~~~~~~~~~~

.. code:: bash

brew install sundials && pip install pybamm

Using conda
-------------
PyBaMM is available as a conda package through the conda-forge channel.
Expand Down
64 changes: 37 additions & 27 deletions docs/install/GNU-linux.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
GNU-Linux & MacOS
======================
===================
GNU-Linux & MacOS
===================

.. contents::

Prerequisites
---------------
=============

To use and/or contribute to PyBaMM, you must have Python 3.6 or 3.7
installed (note that 3.8 is not yet supported).
Expand Down Expand Up @@ -37,10 +38,12 @@ then follow instructions in link on adding brew to path, and run
brew install python3

Install PyBaMM
-----------------
==============

.. _user-install-label:

User install
~~~~~~~~~~~~
------------

We recommend to install PyBaMM within a virtual environment, in order
not to alter any distribution python files. To create a virtual
Expand All @@ -64,10 +67,20 @@ the environment and go back to your original system, just type:

deactivate

PyBaMM can be installed via pip:
PyBaMM can be installed via pip. On macOS, it is necessary to install the `SUNDIALS <https://computing.llnl.gov/projects/sundials/>`__
library beforehand.

GNU/Linux and Windows
~~~~~~~~~~~~~~~~~~~~~
.. code:: bash

pip install pybamm

macOS
~~~~~
.. code:: bash

brew install sundials
pip install pybamm

PyBaMM’s dependencies (such as ``numpy``, ``scipy``, etc) will be
Expand All @@ -79,38 +92,35 @@ For an introduction to virtual environments, see
.. _scikits.odes-label:

Optional - scikits.odes solver
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
------------------------------

Users can install `scikits.odes <https://github.com/bmcage/odes>`__ in
order to use the wrapped SUNDIALS ODE and DAE
`solvers <https://pybamm.readthedocs.io/en/latest/source/solvers/scikits_solvers.html>`__.
Currently, only GNU/Linux and macOS are supported.

**A pre-requisite** is the installation of a BLAS library (such as
`openblas <https://www.openblas.net/>`__). On Ubuntu/debian

::
GNU/Linux
~~~~~~~~~

sudo apt install libopenblas-dev

and on Mac OS
.. code:: bash

::
apt install libopenblas-dev
pybamm_install_odes --install-sundials

brew install openblas
The ``pybamm_install_odes`` command is installed with PyBaMM. It automatically downloads and installs the SUNDIALS library on your
system (under ``~/.local``), before installing ``sckits.odes`` (by running ``pip install scikits.odes``).

After installing PyBaMM, the following command can be used to
automatically install ``scikits.odes`` and its dependencies
macOS
~~~~~

::

$ pybamm_install_odes --install-sundials
.. code:: bash

The ``--install-sundials`` option is used to activate automatic
downloads and installation of the sundials library, which is required by
``scikits.odes``.
pip install scikits.odes
Assuming that the SUNDIALS were installed as described :ref:`above<user-install-label>`.

Developer install
~~~~~~~~~~~~~~~~~~
-----------------

If you wish to contribute to PyBaMM, you should get the latest version
from the GitHub repository. To do so, you must have Git and graphviz
Expand Down Expand Up @@ -159,7 +169,7 @@ Before you start contributing to PyBaMM, please read the `contributing
guidelines <CONTRIBUTING.md>`__.

Uninstall PyBaMM
--------------------
================

PyBaMM can be uninstalled by running

Expand All @@ -170,7 +180,7 @@ PyBaMM can be uninstalled by running
in your virtual environment.

Troubleshooting
-------------------
===============

**Problem:** I’ve made edits to source files in PyBaMM, but these are
not being used when I run my Python script.
Expand Down
8 changes: 4 additions & 4 deletions pybamm/plotting/quick_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ def plot(self, t):
Parameters
----------
t : float
Dimensional time (in hours) at which to plot.
Dimensional time (in 'time_units') at which to plot.
"""

import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from matplotlib import cm, colors

t_in_seconds = t / self.time_scaling_factor
t_in_seconds = t * self.time_scaling_factor
self.fig = plt.figure(figsize=self.figsize)

self.gridspec = gridspec.GridSpec(self.n_rows, self.n_cols)
Expand Down Expand Up @@ -526,8 +526,8 @@ def plot(self, t):
ax.set_ylim(y_min, y_max)
(self.time_lines[key],) = ax.plot(
[
t_in_seconds * self.time_scaling_factor,
t_in_seconds * self.time_scaling_factor,
t_in_seconds / self.time_scaling_factor,
t_in_seconds / self.time_scaling_factor,
],
[y_min, y_max],
"k--",
Expand Down
Loading