Skip to content

Commit c56e07c

Browse files
authored
Add Rust workflow
1 parent 1e78a5b commit c56e07c

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

.github/workflows/rust.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on: [push, pull_request]
2+
3+
name: CI
4+
5+
jobs:
6+
check:
7+
name: Check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- uses: dtolnay/rust-toolchain@1.75
12+
- run: cargo check
13+
working-directory: web_api
14+
15+
test:
16+
name: Tests
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: dtolnay/rust-toolchain@1.75
21+
- run: cargo test
22+
working-directory: web_api
23+
24+
fmt:
25+
name: Rustfmt
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: dtolnay/rust-toolchain@1.75
30+
- run: rustup component add rustfmt
31+
- run: cargo fmt --all -- --check
32+
working-directory: web_api
33+
34+
clippy:
35+
name: Clippy
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v3
39+
- uses: dtolnay/rust-toolchain@1.75
40+
- run: rustup component add clippy
41+
- run: cargo clippy -- -D warnings
42+
working-directory: web_api

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
![Build Status](https://github.com/deniskore/py-ml-to-rs/actions/workflows/rust.yml/badge.svg)
2+
13
# Intro
24
A friend of mine asked me to demonstrate how to load a model trained in Python into a Rust service. In response, this repository showcases the entire process of training a machine learning model to distinguish between various text encodings, achieving around 98.5% validation accuracy, using data sourced from the English Wiktionary.
35
Subsequently, the trained model is seamlessly integrated into a Rust-based microservice, utilizing the ntex-rs. This implementation is streamlined with minimal dependencies, ensuring a lightweight and efficient service.

web_api/src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ mod model;
1111
#[ntex::main]
1212
async fn main() -> std::io::Result<()> {
1313
let model = Arc::new(
14-
model::load_model("../../model/detector".to_string(), "predict_input", "predict_output")
15-
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?,
14+
model::load_model(
15+
"../../model/detector".to_string(),
16+
"predict_input",
17+
"predict_output",
18+
)
19+
.map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err))?,
1620
);
1721

1822
web::server(move || {

0 commit comments

Comments
 (0)