Giter VIP home page Giter VIP logo

pychaste's Introduction

PyChaste

PyChaste is a Python wrapper for Chaste, a general purpose simulation package for computational biology.

Currently a limited number of features are supported, mostly related to cell-based Chaste.

Installation

mamba install -c pychaste -c conda-forge chaste

See the website for a detailed guide on installing PyChaste.

Tutorials

See the website for tutorials demonstrating how to use PyChaste.

Extending

See the wiki for guidance on extending PyChaste.

pychaste's People

Contributors

kwabenantim avatar bdevans avatar mileach avatar jmsgrogan avatar

Stargazers

 avatar

Watchers

Gary Mirams avatar Martin Robinson avatar  avatar Alex Fletcher avatar  avatar Chaste Raspberry Pi avatar Joe Pitt-Francis avatar  avatar Jochen Kursawe avatar  avatar

pychaste's Issues

Use New Chaste Mesh Generators

Description
The mesh generators in PyChaste/src/mesh are customised for PyChaste from the originals in Chaste/mesh/src/vertex and Chaste/cell_based/src/mesh:

  • HoneycombMeshGenerator -> SharedHoneycombMeshGenerator
  • CylindricalHoneycombMeshGenerator -> SharedCylindricalHoneycombMeshGenerator
  • ToroidalHoneycombMeshGenerator -> SharedToroidalHoneycombMeshGenerator
  • HoneycombVertexMeshGenerator -> SharedHoneycombVertexMeshGenerator
  • CylindricalHoneycombVertexMeshGenerator -> SharedCylindricalHoneycombVertexMeshGenerator
  • ToroidalHoneycombVertexMeshGenerator -> SharedToroidalHoneycombVertexMeshGenerator
  • VoronoiVertexMeshGenerator -> SharedVoronoiVertexMeshGenerator
  • PottsMeshGenerator -> SharedPottsMeshGenerator

The customised mesh generators are modified to return shared pointers instead of the original raw pointers. For example:

--- a/CylindricalHoneycombVertexMeshGenerator.hpp
+++ b/SharedCylindricalHoneycombVertexMeshGenerator.hpp

-    MutableVertexMesh<2,2>* GetMesh();
+    boost::shared_ptr<MutableVertexMesh<2,2> > GetMesh();

-    Cylindrical2dVertexMesh* GetCylindricalMesh();
+    boost::shared_ptr<Cylindrical2dVertexMesh> GetCylindricalMesh();

It would be cleaner to have this implemented in upstream Chaste to avoid the workaround.

Related Issue

Fix visualisation crashes in notebooks

Description
PyChaste visualisations crash routinely in notebooks.

To Do

  • Reproduce problem.
  • Fix problem (if possible).
  • Recover gently from unavoidable crashes.
  • Add additional tests if necessary.

Add coverage testing

Description
Check how much of wrapper code is covered by current tests. Aim to increase coverage to 100%.

Housekeeping

Description
Tidy up repository.

To Do

  • Remove unused files/directories such as:
    • dynamic/wrapper_generators/generate_wrapper_code_old.py
    • dynamic/wrappers/preload/
    • .travis.yml
    • Everything in infra/conda except chaste, vtk, and xsd because most dependencies are now on conda-forge.
    • apps/
    • src/tutorial/
    • doc/tutorials/Python/TestCellSorting/results_from_time_0
    • doc/tutorials/.ipynb_checkpoints/
  • Clean up code:
    • Remove namespace py=pybind11 etc. from headers.
    • Add #include <pybind11/pybind11.h> in headers.
    • Group and sort includes.
    • Do code formatting.
    • Fix wrapper guard naming e.g. AbstractCaUpdateRule3_hpp__pyplusplus_wrapper doesn't correspond to filename AbstractCaUpdateRule3.cppwg.hpp, and pyplusplus is no longer used for wrapper generation.
    • To clarify purpose of typedefs, use only where required e.g. typedef AbstractCaUpdateRule<2> AbstractCaUpdateRule2 is necessary for the PYBIND11_OVERLOAD macro but not elsewhere.

Use templated wrappers

Description

Use templating to reduce number of generated wrapper files. Many wrappers only vary in template arguments and the rest of the code is exactly the same.

Aim to refactor this

register_AbstractCellPopulation2_2_class(m);
register_AbstractCellPopulation3_3_class(m);

into this

register_AbstractCellPopulation_class<2, 2>(m);
register_AbstractCellPopulation_class<3, 3>(m);

Release PyChaste 2024.1

Summary

  • Update PyChaste wrappers for Chaste release 2024.1.

TODO

  • Fix broken wrappers
  • Create new wrappers for Immersed Boundary code.
  • Create PyChaste Immersed Boundary tutorial.
  • Visualise outputs from Immersed Boundary tutorial.
  • Build conda packages for Python 3.8 to 3.11
  • Release PyChaste 2024.1

Barcelona Wrappers: Phase II

Description
Add missing wrappers, especially for:

  • CellVolumesWriter
  • CellPopulationAreaWriter
  • HeterotypicBoundaryLengthWriter

To Do

  • Make list of missing writers and dependencies.
  • Generate wrappers.
  • Manually add wrappers that can't be automatically generated.
  • Fix wrapper problems.
  • Build conda package.

Fix Conda Install Warnings

  • Fix warnings from mamba install -c pychaste -c conda-forge -c bioconda chaste
  • vtk package size SafetyError
  • future ClobberErrors
  • numpy ClobberErrors
  • fonttools ClobberErrors
  • superlu ClobberErrors

Move PyChaste website

Description
Move the PyChaste website to the Chaste organisation under chaste.github.io

Related PRs

To Do

Scene rendering is broken

Describe the bug
See PyChaste/issues/5:

Returning a VTK Renderer to Python is broken, causing failures in tutorials and breaking of rendering in Jupyter notebook.s

To Reproduce
Build and install PyChaste from source with VTK ==7.1.1, which is the oldest available version on Ubuntu 22.04.

In a Jupyter notebook:

import chaste 
chaste.init()
from chaste.visualization import JupyterNotebookManager, VtkScene2

scene = VtkScene2()
nbManager = JupyterNotebookManager()
nbManager.vtk_show(scene)

Error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: Unregistered type : vtkSmartPointer<vtkRenderer>

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 nbManager.vtk_show(scene)

File ~/Chaste/build/projects/PyChaste/python/chaste/visualization/fortests.py:134, in JupyterNotebookManager.vtk_show(self, scene, width, height, output_format, increment)
    132 renderWindow = vtk.vtkRenderWindow()
    133 renderWindow.SetOffScreenRendering(1)
--> 134 renderWindow.AddRenderer(scene.GetRenderer())
    135 renderWindow.SetSize(width, height)
    136 renderWindow.Render()

TypeError: Unable to convert function return value to a Python type! The signature was
	(self: chaste.visualization._chaste_project_PyChaste_visualization.VtkScene2) -> vtkSmartPointer<vtkRenderer>

Automated Conda Builds

Description
Add GitHub Actions to build these automatically and upload to the conda channel:

  • PyChaste
  • VTK
  • XSD

Test Chaste/PyChaste Diff

Summary
Add new tests:

  • Flag new classes/methods in Chaste C++ for wrapping in Python bindings (or added to an exclusion list).
  • Flag classes/methods that have been removed from Chaste for removal from PyChaste as well.
  • Flag modifications in Chaste (e.g. changed method signatures, scope changes from public to private etc.) as needing updates to PyChaste bindings.

Create a shareable Jupyter notebook for Chaste

Summary

  • Enable users to use PyChaste with only a browser, without having to install any additional software.
  • Make it easy to create and share Chaste tutorial notebooks for others to modify and experiment with.

Ublas vector wrapping support is broken

Describe the bug
See PyChaste/issues/4

It is currently not possible to return UBlas vectors from C++ to Python, which breaks some tests and tutorials.

To Reproduce
Install PyChaste from conda:

mamba install -c pychaste -c conda-forge -c bioconda chaste

In Python:

import numpy as np

import chaste
import chaste.cell_based

chaste.init()

generator = chaste.mesh.HoneycombVertexMeshGenerator(2, 2)
mesh = generator.GetMesh()

transit_type = chaste.cell_based.TransitCellProliferativeType()
cell_generator = chaste.cell_based.CellsGeneratorBiasedBernoulliTrialCellCycleModel_2()
cells = cell_generator.GenerateBasicRandom(mesh.GetNumElements(), transit_type)

cell_population = chaste.cell_based.VertexBasedCellPopulation2(mesh, cells)

point = np.array([0.0, 0.0])
normal = np.array([0.0, 1.0])
boundary_condition = chaste.cell_based.PlaneBoundaryCondition2_2(cell_population, point, normal)

Error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-12-3f9294ac1a2f>](https://sk6pcemouof-496ff2e9c6d22116-0-colab.googleusercontent.com/outputframe.html?vrz=colab-20230614-060133-RC01_540321000#) in <cell line: 14>()
     12 point = np.array([0.0, 0.0])
     13 normal = np.array([0.0, 1.0])
---> 14 boundary_condition = chaste.cell_based.PlaneBoundaryCondition2_2(cell_population, point, normal)

TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. chaste.cell_based._chaste_project_PyChaste_cell_based.PlaneBoundaryCondition2_2(pCellPopulation: AbstractCellPopulation<2u, 2u>, point: boost::numeric::ublas::c_vector<double, 2ul>, normal: boost::numeric::ublas::c_vector<double, 2ul>)

Invoked with: <chaste.cell_based._chaste_project_PyChaste_cell_based.VertexBasedCellPopulation2 object at 0x7f82c576bfb0>, array([0., 0.]), array([0., 1.])

Consider unifying Chaste and PyChaste docker images

Summary

Pros:

  • One docker image for everything Chaste.
  • Using dependencies from the Ubuntu repository that work together instead of trying to resolve conda-forge dependency conflicts for PyChaste (although this will still need to be done for the PyChaste conda package).

Cons:

  • Larger image: chaste-docker (~2.2 GB) + pychaste-docker(~700 MB) - overlapping dependencies.
  • Need to work out what happens when a container launches. For the PyChaste image, it automatically launches a Jupyter notebook.

Build conda packages for Python 3.8 - 3.12

Description
The conda package is currently only available for Python 3.10. To allow installation in a wider variety of environments, more packages should be built for other Python versions.

This will also require building a custom VTK7 package for multiple Python versions.

Add Bindings Tutorials

Summary
To facilitate merging into Chaste trunk (#46), we should create more documentation with lots of examples illustrating how to fix various issues that may arise when creating Python bindings for new Chaste code. This detailed documentation will make it easier for contributors to wrap new C++ functionality in Python.

Update wrappers to current Chaste develop branch

  • Add wrappers for new functionality introduced into Chaste trunk by Jack & Alex
  • List what needs wrapping
  • Update wrapper generation yml
  • Generate new wrappers with CPPWG
  • Manually add wrappers that cannot be autogenerated
  • Fix issues with automatically generated wrappers if necessary
  • Rebuild conda package

Versioning Releases

Description
Fix PyChaste versioning for releases and conda packages to:

  • Map PyChaste versions to Chaste release versions
  • Map PyChaste versions that track the Chaste develop branch to the appropriate commit

Proposal

  • Make a version branch for each Chaste release and use patch version numbers to indicate fixes to PyChaste wrappers. For example:
    • Chaste release 2021.1 will have a corresponding PyChaste branch 2021.1
    • Releases 2021.1.x will be made from this branch, where the patch version number x is incremented when fixes are added to the PyChaste wrappers on that branch.
  • Use a PyChaste develop version to track the Chaste develop branch.
    • Version release numbering for develop will be 2023.9.dev0, 2023.9.dev1 ...
    • Add the related Chaste commit for the develop version in the release notes.

Fix CI

Description
Currently, most failing tests are due to #11. After it is fixed, we should:

  • Add GitHub actions to run tests on subsequent PRs.
  • Include a ci:off tag to temporarily skip testing.
  • Fix any remaining tests that are still failing.
    • TestVertexBasedCellSimulationsPythonTutorial
    • TestPetscToolsPython

Update Wrappers

Description

Add wrappers for:

  • AbstractElement
  • MutableElement

Support conda-forge vtk binaries

Description
The PyChaste conda package currently depends on a custom-built VTK because:

  • PyChaste only supports VTK <= 7.x.x at the moment, but conda-forge binaries for VTK 7 are only available for Python2.
  • The VTK binaries from conda-forge use TBB instead of MPI.

Switching to the conda-forge pre-built VTK binaries would simplify dependencies for the PyChaste conda package.

It would also allow the use of OSMesa based VTK builds available from conda-forge, which would help remove reliance on the Xvfb workaround for off-screen rendering in notebooks. From #8:

Moving to an osmesa-based vtk build would be a cleaner future solution ...

To Do

  • #23
  • #24
  • Support VTK built with TBB
  • Support VTK built with OSMesa

Fix out-of-order crashes in notebooks

Description
Notebooks crash routinely when some cells are run out-of-order.

To Do

  • Reproduce problem.
  • Investigate possible solutions for preventing out-of-order execution e.g. group things together in functions.
  • Hide some functionality behind the scenes from users e.g. chaste.init(), SetupNotebookTest() etc.
  • Gently recover from errors if out-of-order crashes cannot be avoided.
  • Add additional tests if necessary.

Broken pychaste conda install

Summary

  • Recent changes in colab cause dependency resolution to fail during pychaste installation, resulting in the error below.
No package can be installed for pin: cudatoolkit 12.2.*

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/conda/exceptions.py", line 1124, in __call__
        return func(*args, **kwargs)
      File "/usr/local/lib/python3.10/site-packages/mamba/mamba.py", line 941, in exception_converter
        raise e
      File "/usr/local/lib/python3.10/site-packages/mamba/mamba.py", line 934, in exception_converter
        exit_code = _wrapped_main(*args, **kwargs)
      File "/usr/local/lib/python3.10/site-packages/mamba/mamba.py", line 892, in _wrapped_main
        result = do_call(parsed_args, p)
      File "/usr/local/lib/python3.10/site-packages/mamba/mamba.py", line 754, in do_call
        exit_code = install(args, parser, "install")
      File "/usr/local/lib/python3.10/site-packages/mamba/mamba.py", line 547, in install
        solver.add_pin(final_spec)
    RuntimeError: No package can be installed for pin: cudatoolkit 12.2.*

`$ /usr/local/bin/mamba install -y -q -c pychaste -c conda-forge -c bioconda chaste`

  environment variables:
                 CIO_TEST=<not set>
COLAB_DEBUG_ADAPTER_MUX_PATH=/usr/local/bin/dap_multiplexer
COLAB_LANGUAGE_SERVER_PROXY=<set>
               CONDA_ROOT=/usr/local
           CURL_CA_BUNDLE=<not set>
          LD_LIBRARY_PATH=/usr/local/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
               LD_PRELOAD=<not set>
             LIBRARY_PATH=/usr/local/cuda/lib64/stubs
                     PATH=/opt/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/us
                          r/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/tools/node/bin:/tools/googl
                          e-cloud-sdk/bin
               PYTHONPATH=/env/python
           PYTHONWARNINGS=ignore:::pip._internal.cli.base_command
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
               TCLLIBPATH=/usr/share/tcltk/tcllib1.20

     active environment : None
       user config file : /root/.condarc
 populated config files : /usr/local/.condarc
          conda version : 23.1.0
    conda-build version : not installed
         python version : 3.10.10.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.35=0
                          __linux=6.1.58=0
                          __unix=0=0
       base environment : /usr/local  (writable)
      conda av data dir : /usr/local/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/pychaste/linux-64
                          https://conda.anaconda.org/pychaste/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://conda.anaconda.org/bioconda/linux-64
                          https://conda.anaconda.org/bioconda/noarch
          package cache : /usr/local/pkgs
                          /root/.conda/pkgs
       envs directories : /usr/local/envs
                          /root/.conda/envs
               platform : linux-64
             user-agent : conda/23.1.0 requests/2.28.2 CPython/3.10.10 Linux/6.1.58+ ubuntu/22.04.3 glibc/2.35
                UID:GID : 0:0
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.

Move PyChaste Bindings into Chaste Trunk

Summary
It might be a good idea to consider moving the Python bindings into the main Chaste trunk as the bindings are tightly coupled to upstream Chaste source.

Advantages:

  • Easier to keep bindings in synch with develop branch and release versions.
  • Bindings tests can be added to the CI on PRs to check if bindings break when other parts of Chaste are updated.
  • Simpler to maintain a single documentation website.

Disadvantages:

  • All developers will need to learn some python and pybind11 as well to test changes to bindings?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.