CPP Wrapper Simple Single File

In this example we will show how we can wrap a simple CPP project with the default parameters, which will enable us to just provide a single CPP file.

If you want to wrap an existing library, or you have more complex requirements please refer to the "Build system override CPP Wrapper example".

You can read about how to configure your environment in the CPP Wrapper page.

CPP Wrapper

The only thing that we will need for this, is a single CPP file.

To ensure we align with the defaults, the name of our CPP file has to be SeldonPackage.cpp.

The contents of our file are quire minimal - namely:

%%writefile SeldonPackage.cpp
#include "seldon/SeldonModel.hpp"

class ModelClass : public seldon::SeldonModelBase {

    seldon::protos::SeldonMessage predict(seldon::protos::SeldonMessage &data) override {
        return data;
    }
};

SELDON_DEFAULT_BIND_MODULE()

In this file we basically have to note the following key points:

  • We import "seldon/SeldonModel.hpp" which is from the Seldon package

  • For the defaults the name of our class has to be "ModelClass"

  • We extend the SeldonModelBase class which processes the protos for us

  • We override the predict() function which provides the raw protos

  • We register our class as SELDON_DEFAULT_BIND_MODULE

Build Seldon Microservice

We can now build our seldon microservice using s2i:

Test our model locally by running docker

Send request (which should return the same value)

Clean up

Deploy to seldon

Last updated

Was this helpful?