Skip to content

Commit

Permalink
Merge pull request #645 from ia0/assets
Browse files Browse the repository at this point in the history
Use the new assets directory in Rust
  • Loading branch information
reyammer authored Aug 29, 2024
2 parents 3cfba4e + ce6d5db commit 05c8c41
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/rust-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ on:
pull_request:
paths:
- '.github/workflows/**'
- 'python/magika/config/**'
- 'python/magika/models/**'
- 'assets/**'
- 'rust/**'
- 'tests_data/**'

Expand Down
6 changes: 3 additions & 3 deletions rust/gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ This crate is for maintenance purposes only. It is used to update the Rust libra
There are 3 files in the Rust library that depend on the model:

- The model itself, `rust/lib/src/model.onnx`, which is a symbolic link to some model under
`python/magika/models`, controlled by the `rust/gen/model` symbolic link. Publishing the crate
will dereference this symbolic link.
`assets/models`, controlled by the `rust/gen/model` symbolic link. Publishing the crate will
dereference this symbolic link.
- The labels describing the model output, `rust/lib/src/model.rs`, which is generated from the model
configuration, `rust/gen/model/config.min.json`.
- The list of possible file types, `rust/lib/src/content.rs`, which is generated from the knowledge
base of content types, `python/magika/config/content_types_kb.min.json`.
base of content types, `assets/content_types_kb.min.json`.

The purpose of this crate is to generate the last two files. There is a test to make sure that they
are up-to-date. If the test fails, one simply needs to run `./sync.sh` from the `rust` directory to
Expand Down
2 changes: 1 addition & 1 deletion rust/gen/model
5 changes: 2 additions & 3 deletions rust/gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use anyhow::{Context, Result};
use serde::Deserialize;

fn main() -> Result<()> {
let content_types: BTreeMap<String, ContentType> = serde_json::from_reader(File::open(
"../../python/magika/config/content_types_kb.min.json",
)?)?;
let content_types: BTreeMap<String, ContentType> =
serde_json::from_reader(File::open("../../assets/content_types_kb.min.json")?)?;
let model_name = std::fs::read_link("model")?;
let model_name = model_name
.components()
Expand Down
2 changes: 1 addition & 1 deletion rust/lib/src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use crate::file::TypeInfo;

/// Model name (only comparable with equality).
pub const MODEL_NAME: &str = "standard_v2_0";
pub const MODEL_NAME: &str = "standard_v2";

pub(crate) static _3GP: TypeInfo = TypeInfo {
label: "3gp",
Expand Down

0 comments on commit 05c8c41

Please sign in to comment.