Commit Graph

9 Commits

Author SHA1 Message Date
Nikolay Bogoychev
6cefc4302d Latest and greatest clang-format 2023-01-18 12:48:53 +00:00
Jerin Philip
84c761bacd
Python: Work offline if models are available (#431)
Try to check if models.json is downloaded first, if it is use it. 
If not, fall back to attempting to fetch it from the network.

Fixes: #430
2022-06-25 18:32:50 +01:00
Jerin Philip
61d2c35dbd
Set up python packaging for pypi distribution (#424)
Old GitHub CI using Ubuntu and MacOS explicitly and building wheels have
been removed in favour of the more portable pypa specified builds. These
wheels should work just as well across a wider range of distributions.

pybind11:CMakeLists.txt requires Development.Module instead of
Development.* to avoid Embed from getting in the way of manylinux
builds.

manylinux_x86_64 builds are added for cp3.6 - 3.10. The linux build
uses an old image via docker.  Since the docker images are able to use
shared ccache folder, builds quite fast on warm starts.

ccache usage in setup.py is now triggered by an environment variable.
This allows for builds not to fail if ccache not present.

On tag pushes corresponding to versions, CI is configured to deliver
built wheels to PyPI, reading from repository secrets.

Improves setup.py including documentation and some formatting, and
additional links to source.

Fixes: #315
2022-06-20 14:35:29 +01:00
Jerin Philip
96b0f82343
Simplify cache config and bind for use in JS (#359)
Deprecates cacheEnabled parameter to be replaced with cacheSize=0.
Python bindings, Documentation in comments and tests updated to reflect
this change.

Exposes the fields corresponding to cache via embind as a value object.
The equivalent object-based syntax in worker.js allows propagation
from JS.

Fixes: #351
See also: mozilla/firefox-translations#96
2022-02-23 13:25:12 +00:00
Jerin Philip
9f55fb4756
Improve cache (#347)
Hide `cache-mutex-buckets` from the user. Now configured to be equal to number
of workers. Python bindings which had exposed these are modified to reflect
the API change. `std::optional` enabled on cache, constructed only if enabled.
Pointers used are replaced with an equivalent `std::optional.`

Fixes: #317
2022-02-15 11:04:07 +00:00
Kenneth Heafield
f6d9233dc4 Revert "Revert "Make default throw exception on abort for python (#333)""
This reverts commit 62ff781ed4.

Sorry I should have realized Jerin was only amending python and
therefore this didn't break WASM.

Apologies to Jerin on this.
2022-02-07 14:28:31 +00:00
Kenneth Heafield
62ff781ed4 Revert "Make default throw exception on abort for python (#333)"
This reverts commit 97bd6e36db.

As discussed, we need messages for debugging in -fno-exceptions.
2022-02-05 17:26:16 +00:00
Jerin Philip
97bd6e36db
Make default throw exception on abort for python (#333)
This also allows conversion of exiting aborts into runtime errors in python, 
providing informative messages to the user via pybind11 existing tooling.
2022-02-05 17:25:29 +00:00
Jerin Philip
c0f311a8c0
Batteries included python package (#310)
Imports python bindings and associated sources incubated in
https://github.com/jerinphilip/lemonade to bergamot-translator. Adds
 a pybind11 dependency for python bindings.

Following the import, the python build is integrated into the existing 
CMake based build system here. There is a command-line application 
provided through python which provides the ability to fetch and prepare 
models from model-repositories (like browsermt/students or OPUS).

Wheels built for a few common operating systems are provided via GitHub
releases through automated actions configured to run at tagged semantic
versions and pushes to main.

The documentation for python is also integrated into our existing
documentation setup. Previous documentation GitHub action is now
configured to run behind python builds in Ubuntu 18.04 Python3.7,
in order to pick up the packaged as a wheel bergamot module and the
sphinx documentation using the python module.

Formatting checks of black, isort with profile black and a pytype type
checker is configured for the python component residing in this repository.
2022-01-26 20:33:43 +00:00