- Notifications
You must be signed in to change notification settings - Fork352
Dan product left nav update#1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
b01f9d78122f774bcb252dcd197eb04416388ce70bd5d1ac7c1664d179d0a747656600444219266bda1d0d815fe12725e32f14bbf5d282afc9f03540ecac2a2bdd96b9fb64b0082e94251a01ef1e49bc5File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| use rocket::route::Route; | ||
| use sailfish::TemplateOnce; | ||
| use crate::{ | ||
| guards::ConnectedCluster, | ||
| responses::{Error, ResponseOk}, | ||
| }; | ||
| use crate::templates::{components::NavLink, *}; | ||
| use crate::models; | ||
| use crate::templates; | ||
| use crate::utils::tabs; | ||
| use crate::utils::urls; | ||
| use std::collections::HashMap; | ||
| // Returns models page | ||
| #[get("/models")] | ||
| pub async fn deployment_models(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> { | ||
| let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); | ||
| layout.breadcrumbs(vec![NavLink::new("Models", &urls::deployment_models()).active()]); | ||
| let tabs = vec![tabs::Tab { | ||
| name: "Models", | ||
| content: ModelsTab {}.render_once().unwrap(), | ||
| }]; | ||
| let nav_tabs = tabs::Tabs::new(tabs, Some("Models"), Some("Models"))?; | ||
| Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs }))) | ||
| } | ||
| // Returns models page | ||
| #[get("/models/<model_id>")] | ||
| pub async fn model(cluster: ConnectedCluster<'_>, model_id: i64) -> Result<ResponseOk, Error> { | ||
| let model = models::Model::get_by_id(cluster.pool(), model_id).await?; | ||
| let project = models::Project::get_by_id(cluster.pool(), model.project_id).await?; | ||
| let mut layout = crate::templates::WebAppBase::new("Dashboard", &cluster.inner.context); | ||
| layout.breadcrumbs(vec![ | ||
| NavLink::new("Models", &urls::deployment_models()), | ||
| NavLink::new(&project.name, &urls::deployment_project_by_id(project.id)), | ||
| NavLink::new(&model.algorithm, &urls::deployment_model_by_id(model.id)).active(), | ||
| ]); | ||
| let tabs = vec![tabs::Tab { | ||
| name: "Model", | ||
| content: ModelTab { model_id }.render_once().unwrap(), | ||
| }]; | ||
| let nav_tabs = tabs::Tabs::new(tabs, Some("Models"), Some("Models"))?; | ||
| Ok(ResponseOk(layout.render(templates::Dashboard { tabs: nav_tabs }))) | ||
| } | ||
| #[get("/models_turboframe")] | ||
| pub async fn models_index(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> { | ||
| let projects = models::Project::all(cluster.pool()).await?; | ||
| let mut models = HashMap::new(); | ||
| // let mut max_scores = HashMap::new(); | ||
| // let mut min_scores = HashMap::new(); | ||
| for project in &projects { | ||
| let project_models = models::Model::get_by_project_id(cluster.pool(), project.id).await?; | ||
| // let mut key_metrics = project_models | ||
| // .iter() | ||
| // .map(|m| m.key_metric(project).unwrap_or(0.)) | ||
| // .collect::<Vec<f64>>(); | ||
| // key_metrics.sort_by(|a, b| a.partial_cmp(b).unwrap()); | ||
| // max_scores.insert(project.id, key_metrics.iter().last().unwrap_or(&0.).clone()); | ||
| // min_scores.insert(project.id, key_metrics.iter().next().unwrap_or(&0.).clone()); | ||
| models.insert(project.id, project_models); | ||
| } | ||
| Ok(ResponseOk( | ||
| templates::Models { | ||
| projects, | ||
| models, | ||
| // min_scores, | ||
| // max_scores, | ||
| } | ||
| .render_once() | ||
| .unwrap(), | ||
| )) | ||
| } | ||
| #[get("/models_turboframe/<id>")] | ||
| pub async fn models_get(cluster: ConnectedCluster<'_>, id: i64) -> Result<ResponseOk, Error> { | ||
| let model = models::Model::get_by_id(cluster.pool(), 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( | ||
| templates::Model { | ||
| deployed: model.deployed(cluster.pool()).await?, | ||
| model, | ||
| snapshot, | ||
| project, | ||
| } | ||
| .render_once() | ||
| .unwrap(), | ||
| )) | ||
| } | ||
| pub fn routes() -> Vec<Route> { | ||
| routes![deployment_models, model, models_index, models_get,] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| use rocket::route::Route; | ||
| use sailfish::TemplateOnce; | ||
| use crate::{ | ||
| guards::ConnectedCluster, | ||
| responses::{Error, ResponseOk}, | ||
| }; | ||
| use crate::models; | ||
| use crate::templates; | ||
| use std::collections::HashMap; | ||
| pub mod deployment_models; | ||
| pub mod notebooks; | ||
| pub mod projects; | ||
| pub mod snapshots; | ||
| pub mod uploader; | ||
| #[get("/deployments")] | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This conflicts with our cloud route. ContributorAuthor
| ||
| pub async fn deployments_index(cluster: ConnectedCluster<'_>) -> Result<ResponseOk, Error> { | ||
| let projects = models::Project::all(cluster.pool()).await?; | ||
| let mut deployments = HashMap::new(); | ||
| for project in projects.iter() { | ||
| deployments.insert( | ||
| project.id, | ||
| models::Deployment::get_by_project_id(cluster.pool(), project.id).await?, | ||
| ); | ||
| } | ||
| Ok(ResponseOk( | ||
| templates::Deployments { projects, deployments }.render_once().unwrap(), | ||
| )) | ||
| } | ||
| #[get("/deployments/<id>")] | ||
| pub async fn deployments_get(cluster: ConnectedCluster<'_>, id: i64) -> Result<ResponseOk, Error> { | ||
| let deployment = models::Deployment::get_by_id(cluster.pool(), id).await?; | ||
| let project = models::Project::get_by_id(cluster.pool(), deployment.project_id).await?; | ||
| let model = models::Model::get_by_id(cluster.pool(), deployment.model_id).await?; | ||
| Ok(ResponseOk( | ||
| templates::Deployment { | ||
| project, | ||
| deployment, | ||
| model, | ||
| } | ||
| .render_once() | ||
| .unwrap(), | ||
| )) | ||
| } | ||
| pub fn routes() -> Vec<Route> { | ||
| let mut routes = routes![deployments_index, deployments_get,]; | ||
| routes.extend(deployment_models::routes()); | ||
| routes.extend(notebooks::routes()); | ||
| routes.extend(projects::routes()); | ||
| routes.extend(snapshots::routes()); | ||
| routes.extend(uploader::routes()); | ||
| routes | ||
| } | ||
Uh oh!
There was an error while loading.Please reload this page.