This is an example model. Here you should describe what the model does.
This particular model generates a Fibonacci sequence. e.g.:
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...]
You can set three inputs:
- SEQUENCE_LENGTH - Dictates the count of numbers in the generated sequence
- SEQUENCE_F0 - The first number to start the Fibonacci sequence with.
- SEQUENCE_F1 - The second number to start the Fibonacci sequence with.
The model generates a JSON file containing the sequence:
{
"sequence": [0, 1, 1, 2, 3, 5]
}
This model pulls in several environment variables and passes them into a piece of Python code. The Python code is built into a Docker image using the provided Dockerfile.
There are five files here:
- main.py - This is the file initially called by DAFNI. It is referenced in the Dockerfile.
- work.py - This contains the main code for the model. Here, as an example, it is a simple Fibonacci generator
- Dockerfile - Builds the container that will be run by DAFNI
- model_definition.yaml - A machine-readable file used to define the model. This information will be shown to other users who may wish to use your model.
- README.md - This helpful file. It should contain detailed information about the model.
This model requires Python and Docker to be installed in order to build and run locally.
You can run this example model from within the "simple-example" folder by doing the following:
python ./src/main.py
You can also run this model using Docker from within the same folder by doing:
docker build -t fibonacci-model .
docker run fibonacci-model
You don't need to run the build step every time you want to run the model, you only need to re-run it if changes are made to the Dockerfile or any of the files that go into the Docker image.
You can adjust the way it runs with the environment variables:
docker run -e SEQUENCE_LENGTH=50 fibonacci-model
or
docker run -e SEQUENCE_LENGTH=50 -e SEQUENCE_F0=1 -e SEQUENCE_F1=3 fibonacci-model
You will need to create a file from your docker image to upload it. Check out the detailed instructions online at Docs but you can create it with:
docker save -o fibonacci-model.tar fibonacci-model
You can then also compress it before uploading:
gzip example-model.tar