1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! [![Orkhon](https://raw.githubusercontent.com/vertexclique/orkhon/master/doc/logo/orkhon.png)](https://github.com/vertexclique/orkhon)
//!
//!
//! # Orkhon: ML Inference Framework and Server Runtime
//!
//! ## What is it?
//! 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.
//!
//! ## Main features
//!
//! * Sync & Async API for models.
//! * Easily embeddable engine for well-known Rust web frameworks.
//! * API contract for interacting with Python code.
//! * High processing throughput
//!
//! ## Installation
//!
//! You can include Orkhon into your project with;
//!
//! ```toml
//! [dependencies]
//! orkhon = "*"
//! ```
//!
//! ## Dependencies
//! 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
//!
//! Python API contract is hook based. If you want to call a method for prediction you should write
//! Python code with `args` and `**kwargs`.
//!
//! ```python
//! def model_hook(args, **kwargs):
//!     print("Doing prediction...")
//!     return args
//! ```
//!
//! #### Python Hook Input
//! 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
//! 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
//! ```rust
//! 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.
//!
//! ## Examples
//! #### Creating Orkhon
//!
//! ```
//! # #[macro_use] extern crate orkhon;
//! # use orkhon::orkhon::Orkhon;
//! # use orkhon::config::OrkhonConfig;
//! # use std::path::PathBuf;
//! Orkhon::new()
//!    .config(OrkhonConfig::new())
//!    .pymodel("model_which_will_be_tested", // Unique identifier of the model
//!             "tests/pymodels",             // Python module directory
//!             "model_test",                 // Python module file name
//!        "model_hook"                       // Hook(Python method) that will be called by Orkhon
//!    )
//!    .build();
//! ```
//!
//! #### Requesting to Orkhon
//!
//! ```
//! # #[macro_use] extern crate orkhon;
//! # use orkhon::orkhon::Orkhon;
//! # use orkhon::config::OrkhonConfig;
//! # use std::path::PathBuf;
//! # use std::collections::HashMap;
//! # use orkhon::reqrep::{ORequest, PyModelRequest};
//! #
//! # Orkhon::new()
//! #    .config(OrkhonConfig::new())
//! #    .pymodel("model_which_will_be_tested", // Unique identifier of the model
//! #             "tests/pymodels",             // Python module directory
//! #             "model_test",                 // Python module file name
//! #        "model_hook"                       // Hook(Python method) that will be called by Orkhon
//! #    )
//! #    .build();
//! // Args for the request hook
//! let mut request_args = HashMap::new();
//! request_args.insert("is", 10);
//! request_args.insert("are", 6);
//! request_args.insert("you", 5);
//!
//! // Kwargs for the request hook
//! let mut request_kwargs = HashMap::<&str, &str>::new();
//!
//! // Future handle (await over it... if you want)
//! 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
//!
//! License is [MIT]
//!
//! ## Discussion and Development
//! 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!
//!
//! ## Contributing to Orkhon [![Open Source Helpers](https://www.codetriage.com/vertexclique/orkhon/badges/users.svg)](https://www.codetriage.com/vertexclique/orkhon)
//!
//! 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.
//!
//!
//! [PyO3 bindings]: https://github.com/PyO3/pyo3
//! [`HashSet`]: https://doc.rust-lang.org/std/collections/struct.HashSet.html
//! [`PyObject`]: https://docs.rs/pyo3/0.7.0/pyo3/struct.PyObject.html
//! [MIT]: https://github.com/vertexclique/orkhon/blob/master/LICENSE
//! [CONTRIBUTING guide]: https://github.com/vertexclique/orkhon/blob/master/.github/CONTRIBUTING.md
//! [Gitter]: https://gitter.im/orkhonml/community

#![doc(html_logo_url = "https://raw.githubusercontent.com/vertexclique/orkhon/master/doc/logo/icon.png")]

#![feature(async_await)]
#[macro_use]
extern crate error_chain;

pub mod config;
pub mod pooled;
pub mod reqrep;
pub mod service;
pub mod tensorflow;

#[macro_use]
mod service_macros;
pub mod errors;

pub mod orkhon;