Orkhon is Rust framework for Machine Learning to run/use inference/prediction code written in Python, frozen models and process unseen data. It is mainly focused on serving models and processing unseen data in a performant manner. Instead of using Python directly and having scalability problems for servers this framework tries to solve them with built-in async API.

Sync & Async API for models.

Easily embeddable engine for well-known Rust web frameworks.

API contract for interacting with Python code.

High processing throughput

You can include Orkhon into your project with;

[dependencies] orkhon = "*"

You will need:

Rust Nightly needed (for now. until async support fully lands in)

Python dev dependencies installed and have proper python runtime to use Orkhon with your project.

Point out your PYTHONHOME environment variable to your Python installation.

Python API contract is hook based. If you want to call a method for prediction you should write Python code with args and **kwargs .

def model_hook(args, **kwargs): print("Doing prediction...") return args

Both args and kwargs are HashSet s. args can take any acceptable hashset key and passes down to python level. But kwargs keys are restricted to [ &str ] for keeping it only for option passing. args can contain your data for making prediction. Input contract is opinionated for making interpreter work without unknown type conversions.

Python hook output is passed up without downcasting or casting. Python bindings are still exposed to make sure you get the type you wanted. By default; python passes PyObject to Rust interface. You can extract the type from the object that Python passed with

pyobj . extract () ?

This api uses PyO3 bindings for Python <-> Rust. You can look for PyO3's documentation to make conversions. Auto conversion methods soon will be added.

Orkhon :: new () . config ( OrkhonConfig :: new ()) . pymodel ( "model_which_will_be_tested" , "tests/pymodels" , "model_test" , "model_hook" ) . build ();

let mut request_args = HashMap :: new (); request_args . insert ( "is" , 10 ); request_args . insert ( "are" , 6 ); request_args . insert ( "you" , 5 ); let mut request_kwargs = HashMap :: < & str , & str > :: new (); let handle = o . pymodel_request_async ( "model_which_will_be_tested" , ORequest :: with_body ( PyModelRequest :: new () . with_args ( request_args ) . with_kwargs ( request_kwargs ) ) );

License is MIT

We use Gitter for development discussions. Also please don't hesitate to open issues on GitHub ask for features, report bugs, comment on design and more! More interaction and more ideas are better!

All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.

A detailed overview on how to contribute can be found in the CONTRIBUTING guide on GitHub.