Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1882ca3

Browse files
authored
handle model deploy when no metrics to compare (#1289)
1 parent651f204 commit1882ca3

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

‎pgml-extension/src/api.rs‎

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -264,37 +264,55 @@ fn train_joint(
264264
);
265265

266266
letmut deploy =true;
267+
267268
match automatic_deploy{
268-
// Deploy only if metrics are better than previous model.
269+
// Deploy only if metrics are better than previous model, or if its the first model
269270
Some(true) |None =>{
270271
ifletOk(Some(deployed_metrics)) = deployed_metrics{
271-
let deployed_metrics = deployed_metrics.0.as_object().unwrap();
272-
let deployed_metric = deployed_metrics
273-
.get(&project.task.default_target_metric())
274-
.unwrap()
275-
.as_f64()
276-
.unwrap();
277-
info!(
278-
"Comparing to deployed model {}: {:?}",
279-
project.task.default_target_metric(),
280-
deployed_metric
281-
);
282-
if project.task.value_is_better(
283-
deployed_metric,
284-
new_metrics
285-
.get(&project.task.default_target_metric())
286-
.unwrap()
287-
.as_f64()
288-
.unwrap(),
289-
){
272+
ifletSome(deployed_metrics_obj) = deployed_metrics.0.as_object(){
273+
let default_target_metric = project.task.default_target_metric();
274+
let deployed_metric = deployed_metrics_obj
275+
.get(&default_target_metric)
276+
.and_then(|v| v.as_f64());
277+
info!(
278+
"Comparing to deployed model {}: {:?}",
279+
default_target_metric, deployed_metric
280+
);
281+
let new_metric = new_metrics.get(&default_target_metric).and_then(|v| v.as_f64());
282+
283+
match(deployed_metric, new_metric){
284+
(Some(deployed),Some(new)) =>{
285+
// only compare metrics when both new and old model have metrics to compare
286+
if project.task.value_is_better(deployed, new){
287+
warning!(
288+
"New model's {} is not better than current model. New: {}, Current {}",
289+
&default_target_metric,
290+
new,
291+
deployed
292+
);
293+
deploy =false;
294+
}
295+
}
296+
(None,None) =>{
297+
warning!("No metrics available for both deployed and new model. Deploying new model.")
298+
}
299+
(Some(_deployed),None) =>{
300+
warning!("No metrics for new model. Retaining old model.");
301+
deploy =false;
302+
}
303+
(None,Some(_new)) =>warning!("No metrics for deployed model. Deploying new model."),
304+
}
305+
}else{
306+
warning!("Failed to parse deployed model metrics. Check data types of model metadata on pgml.models.metrics");
290307
deploy =false;
291308
}
292309
}
293310
}
294-
295-
Some(false) => deploy =false,
311+
Some(false) =>{
312+
warning!("Automatic deployment disabled via configuration.");
313+
deploy =false;
314+
}
296315
};
297-
298316
if deploy{
299317
project.deploy(model.id,Strategy::new_score);
300318
}else{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp