From b7a26731f68ba14c0badc434ee65b737a460f092 Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Wed, 30 Aug 2023 09:53:39 -0700 Subject: [PATCH 1/2] Dashboard fix for 2.7.8 --- pgml-dashboard/src/lib.rs | 7 ++++++- pgml-dashboard/src/models.rs | 2 +- pgml-dashboard/src/templates/mod.rs | 2 +- .../templates/content/dashboard/panels/model.html | 6 ++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pgml-dashboard/src/lib.rs b/pgml-dashboard/src/lib.rs index 18900f1e7..4d0f7cf89 100644 --- a/pgml-dashboard/src/lib.rs +++ b/pgml-dashboard/src/lib.rs @@ -367,7 +367,12 @@ pub async fn models_index(cluster: ConnectedCluster<'_>) -> Result")] pub async fn models_get(cluster: ConnectedCluster<'_>, id: i64) -> Result { let model = models::Model::get_by_id(cluster.pool(), id).await?; - let snapshot = models::Snapshot::get_by_id(cluster.pool(), model.snapshot_id).await?; + let snapshot = if let Some(snapshot_id) = model.snapshot_id { + Some(models::Snapshot::get_by_id(cluster.pool(), snapshot_id).await?) + } else { + None + }; + let project = models::Project::get_by_id(cluster.pool(), model.project_id).await?; Ok(ResponseOk( diff --git a/pgml-dashboard/src/models.rs b/pgml-dashboard/src/models.rs index b4aa48a0b..649455247 100644 --- a/pgml-dashboard/src/models.rs +++ b/pgml-dashboard/src/models.rs @@ -444,7 +444,7 @@ pub enum Runtime { pub struct Model { pub id: i64, pub project_id: i64, - pub snapshot_id: i64, + pub snapshot_id: Option, pub num_features: i32, pub algorithm: String, pub runtime: Option, diff --git a/pgml-dashboard/src/templates/mod.rs b/pgml-dashboard/src/templates/mod.rs index b1bb25fb7..e38b275f6 100644 --- a/pgml-dashboard/src/templates/mod.rs +++ b/pgml-dashboard/src/templates/mod.rs @@ -397,7 +397,7 @@ pub struct Models { pub struct Model { pub model: models::Model, pub project: models::Project, - pub snapshot: models::Snapshot, + pub snapshot: Option, pub deployed: bool, } diff --git a/pgml-dashboard/templates/content/dashboard/panels/model.html b/pgml-dashboard/templates/content/dashboard/panels/model.html index d60de69aa..dc1b392d0 100644 --- a/pgml-dashboard/templates/content/dashboard/panels/model.html +++ b/pgml-dashboard/templates/content/dashboard/panels/model.html @@ -13,8 +13,10 @@

model_training
Project
<%= project.name %>
-
Snapshot
-
<%= snapshot.relation_name %>
+ <% if let Some(snapshot) = snapshot { %> +
Snapshot
+
<%= snapshot.relation_name %>
+ <% } %>
Created
From b726a77a2ecceda6d4916872fe15b92cbb78a5bd Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Wed, 30 Aug 2023 09:54:20 -0700 Subject: [PATCH 2/2] Offline mode may not be a good idea --- pgml-dashboard/sqlx-data.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pgml-dashboard/sqlx-data.json b/pgml-dashboard/sqlx-data.json index 11e7eb7ac..43e46d4a9 100644 --- a/pgml-dashboard/sqlx-data.json +++ b/pgml-dashboard/sqlx-data.json @@ -566,7 +566,7 @@ "nullable": [ false, false, - false, + true, false, false, null, @@ -864,7 +864,7 @@ "nullable": [ false, false, - false, + true, false, false, null, @@ -1113,7 +1113,7 @@ "nullable": [ false, false, - false, + true, false, false, null,