The Babelizer
The Babelizer: language interoperability for model coupling in the geosciences - Published in JOSS (2022)
Science Score: 98.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 4 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org -
✓Committers with academic emails
1 of 3 committers (33.3%) from academic institutions -
✓Institutional organization owner
Organization csdms has institutional domain (csdms.colorado.edu) -
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
Scientific Fields
Repository
Transform BMI-wrapped models into Python packages
Basic Info
- Host: GitHub
- Owner: csdms
- License: mit
- Language: Python
- Default Branch: develop
- Homepage: https://babelizer.readthedocs.io
- Size: 898 KB
Statistics
- Stars: 5
- Watchers: 6
- Forks: 3
- Open Issues: 18
- Releases: 2
Topics
Metadata Files
README.rst
.. image:: https://joss.theoj.org/papers/10.21105/joss.03344/status.svg
:target: https://doi.org/10.21105/joss.03344
.. image:: https://github.com/csdms/babelizer/workflows/Build/Test%20CI/badge.svg
:target: https://github.com/csdms/babelizer/actions?query=workflow%3A%22Build%2FTest+CI%22
.. image:: https://anaconda.org/conda-forge/babelizer/badges/version.svg
:target: https://anaconda.org/conda-forge/babelizer
.. image:: https://readthedocs.org/projects/babelizer/badge/?version=latest
:target: https://babelizer.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/csdms/babelizer
.. image:: https://coveralls.io/repos/github/csdms/babelizer/badge.svg?branch=develop
:target: https://coveralls.io/github/csdms/babelizer?branch=develop
The Babelizer: Wrap BMI libraries with Python bindings
======================================================
The *babelizer* is a utility for wrapping a library that exposes a `Basic Model Interface`_ (BMI) so that it can be
imported as a Python package.
Supported languages include:
* C
* C++
* Fortran
* Python
The Babelizer is part of the CSDMS Workbench
--------------------------------------------
The *babelizer* is an element of the `CSDMS Workbench`_,
an integrated system of software tools, technologies, and standards
for building and coupling models. The Workbench provides two Python
frameworks for model coupling, *pymt* and *landlab*.
The *babelizer* was written to bring models written in other languages into
these frameworks.
However, as long as your model
satisfies the requirements below, you can use the *babelizer*
to bring your model into Python without having to use any of the
other tools in the Workbench.
Should I use the babelizer?
---------------------------
To determine if the
*babelizer* is right for you, first be aware of a few requirements.
1. Your model must be written in C, C++, Fortran, or Python
2. Your model must provide a shared library
3. Your model must expose a `Basic Model Interface`_ through this library
The most difficult of the three requirements is the last--implementing a BMI. This
involves adding a series of functions with prescribed names,
arguments, and return values for querying and controlling your model. We have created
several resources to help you understand the BMI and to guide you
through the implementation process.
BMI resources
^^^^^^^^^^^^^
* The `Basic Model Interface`_ documentation provides an overview of the BMI as well
as a detailed description of all of the BMI functions.
* The following provide a BMI specification for each of the supported languages:
* `C spec `_
* `C++ spec `_
* `Fortran spec `_
* `Python spec `_
* The following give examples of a BMI implementation for each of the supported languages:
* `C example `_
* `C++ example `_
* `Fortran example `_
* `Python example `_
Note
^^^^
There are lots of other good reasons to create a BMI for
your model--not just so you can bring it into Python with the *babelizer*!
Read all about them in the `Basic Model Interface`_ documentation.
Requirements
------------
The *babelizer* requires Python >=3.10.
Apart from Python, the *babelizer* has a number of other requirements, all of which
can be obtained through either *pip* or *conda*, that will be automatically
installed when you install the *babelizer*.
To see a full listing of the requirements, have a look at the project's
*requirements.txt* file.
If you are a developer of the *babelizer* you will also want to install
additional dependencies for running the *babelizer*'s tests to make sure
that things are working as they should. These dependencies are listed
in *requirements-testing.txt*.
Installation
------------
To install the *babelizer*, first create a new environment.
Although this isn't strictly necessary, it
isolates the installation to avoid conflicts with your
base Python installation. This can be done with *conda*:
.. code:: bash
$ conda create -n babelizer python=3
$ conda activate babelizer
Stable Release
^^^^^^^^^^^^^^
The *babelizer* and its dependencies are best installed with *conda*:
.. code:: bash
$ conda install babelizer -c conda-forge
From Source
^^^^^^^^^^^
After downloading the the *babelizer* source code, run the following from
*babelizer*'s top-level directory (the one that contains *setup.py*) to
install *babelizer* into the current environment:
.. code:: bash
$ pip install -e .
or using *conda*:
.. code:: bash
$ conda install --file=requirements.txt -c conda-forge
Input file
----------
The *babelizer* requires a single *toml*-formatted input file that describes
the library to wrap. This file is typically named *babel.toml*.
An example of a blank *babel.toml* file:
.. code:: toml
[library]
[library.""]
language = "c"
library = ""
header = ""
entry_point = ""
[build]
undef_macros = []
define_macros = []
libraries = []
library_dirs = []
include_dirs = []
extra_compile_args = []
[package]
name = ""
requirements = []
[info]
github_username = "pymt-lab"
package_author = "csdms"
package_author_email = "csdms@colorado.edu"
package_license = "MIT"
summary = ""
[ci]
python_version = ["3.9"]
os = ["linux", "mac", "windows"]
You can generate *babel.toml* files using the *babelize generate* command.
For example, the above *babel.toml* was generated with:
.. code:: bash
$ babelize generate > babel.toml
Library section
^^^^^^^^^^^^^^^
The *library* section specifies information about the library being babelized.
Name
""""
The name of the babelized class.
This will be a Python class,
so it should follow Python naming conventions such as camel-case typing.
Language
""""""""
The programming language of the library (possible values are "c", "c++",
"fortran", and "python").
.. code:: toml
[library]
language = "c"
Library
"""""""
The name of the BMI library to wrap.
This is the text passed to the linker through the `-l` option;
for example, use "foo" for a library *libfoo.a*.
Header
""""""
The name of the header file (*.h*, *.hxx*) declaring the BMI class.
This option is only needed when wrapping C and C++ libraries.
Entry point
"""""""""""
The name of the BMI entry point into the library.
For object-oriented languages,
this is typically the name of a class that implements the BMI.
For procedural languages,
this is typically a function.
An example of a C++ library (*bmi_child*), exposing a class *BmiChild* (which
implements a BMI) might look like the following:
.. code:: toml
[library]
[library.Child]
language = "c++"
library = "bmi_child"
header = "bmi_child.hxx"
entry_point = "BmiChild"
whereas a C library (*bmi_cem*), exposing a function *register_bmi_cem* (which
implements a BMI) might look like:
.. code:: toml
[library]
[library.Cem]
language = "c"
library = "bmi_cem"
header = "bmi_cem.h"
entry_point = "register_bmi_cem"
Build section
^^^^^^^^^^^^^
In the build section the user can specify flags to pass to the compiler
when building the extension.
Package section
^^^^^^^^^^^^^^^
Name and extra requirements needed to build the babelized library.
Name
""""
Name to use for the wrapped package. This is used when creating the new
package **. For example, the following will create
a new package, *pymt_foo*.
.. code:: toml
[package]
name = "pymt_foo"
Requirements
""""""""""""
List of packages required by the library being wrapped. For example, the
following indicates that the packages *foo* and *bar* are dependencies
for the package.
.. code:: toml
[package]
requirements = [ "foo", "bar",]
Info section
^^^^^^^^^^^^
Descriptive information about the package.
Github username
"""""""""""""""
The GitHub username or organization where this package will be hosted. This
is used in generating links to the CI, docs, etc.
Author
""""""
Author of the wrapped package. Note that this is not the author of the
library being wrapped, just the code generated by the *babelizer*.
Email
"""""
Contact email to use for the wrapped package.
License
"""""""
Specify the Open Source license for the wrapped package. Note that this is not the
license for the library being wrapped, just for the code generated by the *babelizer*.
Summary
"""""""
A short description of the wrapped library.
Ci section
^^^^^^^^^^
Information about how to set up continuous integration.
.. code:: toml
[ci]
python_version = ["3.7", "3.8", "3.9"]
os = ["linux", "mac", "windows"]
Python version
""""""""""""""
A list of Python versions to build and test the generated project with.
Operating system
""""""""""""""""
A list of operating systems to build the generate project on. Supported values are
*linux*, *mac*, and *windows*.
Example babel.toml
^^^^^^^^^^^^^^^^^^
Below is an example of a *babel.toml* file that describes a shared library,
written in C. In this example, the library, *bmi_hydrotrend*, exposes the
function *register_bmi_hydrotrend* that implements a BMI for a component
called *hydrotrend*.
.. code:: toml
[library]
[library.Hydrotrend]
language = "c"
library = "bmi_hydrotrend"
header = "bmi_hydrotrend.h"
entry_point = "register_bmi_hydrotrend"
[build]
undef_macros = []
define_macros = []
libraries = []
library_dirs = []
include_dirs = []
extra_compile_args = []
[package]
name = "pymt_hydrotrend"
requirements = ["hydrotrend"]
[info]
github_username = "pymt-lab"
package_author = "csdms"
package_author_email = "csdms@colorado.edu"
package_license = "MIT"
summary = "PyMT plugin for hydrotrend"
[ci]
python_version = ["3.7", "3.8", "3.9"]
os = ["linux", "mac", "windows"]
You can use the ``babelize sample-config`` command to generate
a sample *babel.toml* file to get you started. For example,
the above *babel.toml* can be generated with the following,
.. code:: bash
babelize sample-config
Use
---
Generate Python bindings for a library that implements a BMI,
sending output to the current directory
.. code:: bash
babelize init babel.toml
Update an existing repository
.. code:: bash
babelize update
For a complete example of using the *babelizer*
to wrap a C library exposing a BMI,
see the User Guide of the `documentation`_.
.. Links:
.. _Basic Model Interface: https://bmi.readthedocs.io/
.. _CSDMS Workbench: https://csdms.colorado.edu/wiki/Workbench
.. _documentation: https://babelizer.readthedocs.io/
.. _BMI C: https://github.com/csdms/bmi-c/
.. _BMI C++: https://github.com/csdms/bmi-cxx/
.. _BMI Fortran: https://github.com/csdms/bmi-fortran/
.. _BMI Python: https://github.com/csdms/bmi-python/
.. _BMI example C: https://github.com/csdms/bmi-example-c/
.. _BMI example C++: https://github.com/csdms/bmi-example-cxx/
.. _BMI example Fortran: https://github.com/csdms/bmi-example-fortran/
.. _BMI example Python: https://github.com/csdms/bmi-example-python/
Owner
- Name: Community Surface Dynamics Modeling System
- Login: csdms
- Kind: organization
- Email: csdms@colorado.edu
- Website: http://csdms.colorado.edu
- Twitter: csdms
- Repositories: 65
- Profile: https://github.com/csdms
Cyberinfrastructure for the quantitative modeling of earth and planetary surface processes
JOSS Publication
The Babelizer: language interoperability for model coupling in the geosciences
Authors
Tags
C++ geosciences modeling interfaceGitHub Events
Total
- Watch event: 1
- Delete event: 2
- Push event: 16
- Pull request event: 4
- Create event: 1
Last Year
- Watch event: 1
- Delete event: 2
- Push event: 16
- Pull request event: 4
- Create event: 1
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| mcflugen | m****n@g****m | 227 |
| Mark Piper | m****r@c****u | 45 |
| Sam Harrison | s****g@g****m | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 33
- Total pull requests: 80
- Average time to close issues: 8 months
- Average time to close pull requests: about 1 month
- Total issue authors: 6
- Total pull request authors: 4
- Average comments per issue: 1.88
- Average comments per pull request: 1.15
- Merged pull requests: 71
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 1
- Pull requests: 4
- Average time to close issues: N/A
- Average time to close pull requests: 34 minutes
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mdpiper (18)
- aufdenkampe (5)
- lheagy (4)
- cheginit (2)
- mcflugen (2)
- Volk3rJ (2)
Pull Request Authors
- mcflugen (48)
- mdpiper (43)
- samharrison7 (4)
- pre-commit-ci[bot] (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 2
- Total versions: 9
conda-forge.org: babelizer
The babelizer is an easy-to-use command line tool that automatically wraps BMI libraries, written in C, C++ or Fortran, so that they can be imported and used as Python packages. Within Python, models, regardless of their core language, appear as classes that expose a BMI. Users are then able to run models interactively through the Python command line, through Python scripts or Jupyter Notebooks, and to use Python-based BMI tools such as the bmi-tester, pymt, or landlab.
- Homepage: https://csdms.colorado.edu/wiki/Babelizer
- License: MIT
-
Latest release: 0.3.9
published almost 4 years ago
Rankings
Dependencies
- bmi-c *
- bmi-cxx *
- bmi-fortran *
- bmi-tester >=0.5.4
- bmipy *
- c-compiler *
- cmake *
- cxx-compiler *
- fortran-compiler *
- pkg-config *
- black * development
- flake8 * development
- flake8-bugbear * development
- isort * development
- pre-commit * development
- sphinx >=1.5.1,<3
- sphinx-click *
- coverage * test
- coveralls * test
- pytest * test
- pytest-cov * test
- pytest-datadir * test
- black *
- click *
- cookiecutter *
- gitpython *
- isort >=5
- pyyaml *
- tomlkit *
- actions/checkout v3 composite
- actions/checkout v2 composite
- conda-incubator/setup-miniconda v2 composite
- actions/checkout v2 composite
- actions/setup-python v2 composite
- AndreMiras/coveralls-python-action v20201129 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- AndreMiras/coveralls-python-action v20201129 composite
- actions/checkout v3 composite
- conda-incubator/setup-miniconda v2 composite
- black *
- click *
- cookiecutter *
- gitpython *
- importlib-resources python_version < '3.12'
- isort >=5
- logoizer @ git+https://github.com/mcflugen/logoizer
- pyyaml *
- tomli python_version < '3.11'
- tomli-w *
- bmi-c *
- bmi-cxx *
- bmi-fortran *
- c-compiler *
- cxx-compiler *
- fortran-compiler *
- bmi-tester >=0.5.4 test
- numpy *
