Skip to content
Snippets Groups Projects
VIPS Logo

ReferenceModel

This VIPS model is an example only, without any actual agronomic value. It provides examples of how you create your own pest prediction model that can be deployed to a VIPSCore-Python server deployment. This model is using the VipsCore-Python-Common package, where you can find general information about how to implement a VIPS Model in Python. The current project is a proof-of-concept, demonstrating best practices.

How to deploy this model

See the VIPSCore-Python README for how to make it available on that server. Please remember that this model should not be available to the public :-)

Testing

The tests are located in the tests folder, and we're using Pytest

To run the unit tests, move to the root folder of the project, and execute:

pytest -v

Using bumpver

For developers: When you want to publish a new version, use

# Increment the PATCH version when you make backwards compatible bug fixes.
bumpver update --patch
# Increment the MINOR version when you add functionality in a backwards compatible manner.
bumpver update --minor
# Increment the MAJOR version when you make incompatible API changes.
bumpver update --major

(Source)

References

We used this excellent guide for packaging: https://realpython.com/pypi-publish-python-package/

Translations

We're using a simple dictionary translation system, with a module translations.py, where we simply define some dictionaries with language codes as property, looking like this:

name = {
    "en":   "Reference Model",
    "nb":   "Referansemodell",
}

This is used in the main module like this:

[...]
from . import translations
[...]
def get_model_name(self, language = VIPSModel.default_language) -> str:
        """Returns the model name in the specified language (<a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO-639-2</a>)"""
        return translations.name.get(language, translations.name.get(VIPSModel.default_language, "NOT FOUND"))  
[...]