Skip to content

Commit

Permalink
add support for 'example_item_id' in config file
Browse files Browse the repository at this point in the history
update example config file
  • Loading branch information
bkersbergen committed May 9, 2022
1 parent 3636217 commit f71b74e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
Binary file modified assets/example/example.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions src/bin/serving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async fn main() -> std::io::Result<()> {
let max_items_in_session = config.model.max_items_in_session;
let qty_workers = config.server.num_workers;
let enable_business_logic = config.logic.enable_business_logic;
let example_item_id = config.logic.example_item_id;

let training_data_path = Path::new(&config.data.training_data_path);
let vmis_index = if training_data_path.is_dir() {
Expand Down Expand Up @@ -69,6 +70,7 @@ async fn main() -> std::io::Result<()> {
qty_workers,
db_compaction_ttl_in_secs: session_ttl.as_secs() as usize,
enable_business_logic,
example_item_id,
};

App::new()
Expand Down
6 changes: 6 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct ModelConfig {

pub struct LogicConfig {
pub enable_business_logic: bool,
pub example_item_id: usize,
}

pub struct HyperparamConfig {
Expand Down Expand Up @@ -191,6 +192,11 @@ impl LogicConfig {
.trim()
.value()
.unwrap(),
example_item_id: conf
.get(path.push("example_item_id"))
.trim()
.value()
.unwrap_or(0),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/dataframeutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct SharedHandlesAndConfig {
pub qty_workers: usize,
pub db_compaction_ttl_in_secs: usize,
pub enable_business_logic: bool,
pub example_item_id: usize,
}

pub struct TrainingDataStats {
Expand Down
4 changes: 3 additions & 1 deletion src/endpoints/index_resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ pub async fn internal(config: Data<SharedHandlesAndConfig>) -> HttpResponse {
html.push_str(&config.max_items_in_session.to_string());
html.push_str("<br />Qty items to recommend: ");
html.push_str(&config.num_items_to_recommend.to_string());
html.push_str("<br /><a href=\"/v1/recommend?session_id=144&user_consent=true&item_id=1001004010971015\">v1 endpoint of our model</a>");
html.push_str("<br /><a href=\"/v1/recommend?session_id=144&user_consent=true&item_id=");
html.push_str(&config.example_item_id.to_string());
html.push_str("\">v1 endpoint of our model</a>");
html.push_str("<h3>Machine instance</h3>");
html.push_str("<br />Qty CPU's detected: ");
html.push_str(&*sys_info::cpu_num().unwrap_or(0).to_string());
Expand Down

0 comments on commit f71b74e

Please sign in to comment.