Skip to content

Commit 3398097

Browse files
committed
consolidate development docs
1 parent 33e8ebf commit 3398097

File tree

11 files changed

+202
-163
lines changed

11 files changed

+202
-163
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ The dashboard makes it easy to compare different algorithms or hyperparameters a
4444
See it in action — <a href="https://cloud.postgresml.org/" target="_blank">cloud.postgresml.org</a>
4545
</h2>
4646

47+
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.
48+
4749
## What's in the box
4850
See the documentation for a complete **[list of functionality](https://postgresml.org/)**.
4951

pgml-dashboard/README.md

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,4 @@
22

33
PostgresML provides a dashboard with analytical views of the training data and model performance, as well as integrated notebooks for rapid iteration. It is primarily written in Rust using [Rocket](https://rocket.rs/) as a lightweight web framework and [SQLx](https://github.com/launchbadge/sqlx) to interact with the database.
44

5-
Please see the [online documentation](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. This document is intended to help developers set up a local copy of the dashboard.
6-
7-
## Requirements
8-
9-
The dashboard requires a Postgres database with the [pgml-extension](https://github.com/postgresml/postgresml/tree/master/pgml-extension) to generate the core schema. See that subproject for developer setup.
10-
11-
We develop and test this web application on Linux, OS X, and Windows using WSL2.
12-
13-
## Build process
14-
15-
You'll need to specify a database url for the extension to interact with via an environment variable:
16-
17-
```commandline
18-
export DATABASE_URL=postgres://user_name:password@localhost:5432/database_name
19-
```
20-
21-
Build and run:
22-
23-
```commandline
24-
cargo run
25-
```
26-
27-
Incremental and automatic compilation for development cycles is supported with:
28-
29-
```commandline
30-
cargo watch --exec run
31-
```
32-
33-
Run tests:
34-
```commandline
35-
cargo test
36-
```
5+
Please see the [quick start instructions](https://postgresml.org/user_guides/setup/quick_start_with_docker/) for general information on installing or deploying PostgresML. A [developer guide](https://postgresml.org/developer_guide/overview/) is also available for those who would like to contribute.

pgml-dashboard/src/guards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ impl<'r> FromRequest<'r> for Cluster {
5656
pub fn default_database_url() -> String {
5757
match var("DATABASE_URL") {
5858
Ok(val) => val,
59-
Err(_) => "postgres:///dashboard".to_string(),
59+
Err(_) => "postgres:///pgml".to_string(),
6060
}
6161
}

pgml-dashboard/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod templates;
2222

2323
use guards::Cluster;
2424
use responses::{BadRequest, ResponseOk};
25+
use sqlx::Executor;
2526

2627
/// This struct contains information specific to the cluster being displayed in the dashboard.
2728
///
@@ -50,6 +51,10 @@ impl Clusters {
5051
.max_connections(5)
5152
.idle_timeout(std::time::Duration::from_millis(15_000))
5253
.min_connections(0)
54+
.after_connect(|conn, _meta| Box::pin(async move {
55+
conn.execute("SET application_name = 'pgml_dashboard';").await?;
56+
Ok(())
57+
}))
5358
.connect_lazy(database_url)?;
5459

5560
pools.insert(cluster_id, pool.clone());

pgml-dashboard/src/models.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub struct Notebook {
8686
impl Notebook {
8787
pub async fn get_by_id(pool: &PgPool, id: i64) -> anyhow::Result<Notebook> {
8888
Ok(
89-
sqlx::query_as!(Notebook, "SELECT * FROM notebooks WHERE id = $1", id,)
89+
sqlx::query_as!(Notebook, "SELECT * FROM pgml.notebooks WHERE id = $1", id,)
9090
.fetch_one(pool)
9191
.await?,
9292
)
@@ -95,23 +95,23 @@ impl Notebook {
9595
pub async fn create(pool: &PgPool, name: &str) -> anyhow::Result<Notebook> {
9696
Ok(sqlx::query_as!(
9797
Notebook,
98-
"INSERT INTO notebooks (name) VALUES ($1) RETURNING *",
98+
"INSERT INTO pgml.notebooks (name) VALUES ($1) RETURNING *",
9999
name,
100100
)
101101
.fetch_one(pool)
102102
.await?)
103103
}
104104

105105
pub async fn all(pool: &PgPool) -> anyhow::Result<Vec<Notebook>> {
106-
Ok(sqlx::query_as!(Notebook, "SELECT * FROM notebooks")
106+
Ok(sqlx::query_as!(Notebook, "SELECT * FROM pgml.notebooks")
107107
.fetch_all(pool)
108108
.await?)
109109
}
110110

111111
pub async fn cells(&self, pool: &PgPool) -> anyhow::Result<Vec<Cell>> {
112112
Ok(sqlx::query_as!(
113113
Cell,
114-
"SELECT * FROM notebook_cells
114+
"SELECT * FROM pgml.notebook_cells
115115
WHERE notebook_id = $1
116116
AND deleted_at IS NULL
117117
ORDER BY cell_number",
@@ -123,7 +123,7 @@ impl Notebook {
123123

124124
pub async fn reset(&self, pool: &PgPool) -> anyhow::Result<()> {
125125
let _ = sqlx::query!(
126-
"UPDATE notebook_cells
126+
"UPDATE pgml.notebook_cells
127127
SET
128128
execution_time = NULL,
129129
rendering = NULL
@@ -189,15 +189,15 @@ impl Cell {
189189
"
190190
WITH
191191
lock AS (
192-
SELECT * FROM notebooks WHERE id = $1 FOR UPDATE
192+
SELECT * FROM pgml.notebooks WHERE id = $1 FOR UPDATE
193193
),
194194
max_cell AS (
195195
SELECT COALESCE(MAX(cell_number), 0) AS cell_number
196-
FROM notebook_cells
196+
FROM pgml.notebook_cells
197197
WHERE notebook_id = $1
198198
AND deleted_at IS NULL
199199
)
200-
INSERT INTO notebook_cells
200+
INSERT INTO pgml.notebook_cells
201201
(notebook_id, cell_type, contents, cell_number, version)
202202
VALUES
203203
($1, $2, $3, (SELECT cell_number + 1 FROM max_cell), 1)
@@ -231,7 +231,7 @@ impl Cell {
231231
cell_number,
232232
version,
233233
deleted_at
234-
FROM notebook_cells
234+
FROM pgml.notebook_cells
235235
WHERE id = $1
236236
",
237237
id,
@@ -250,7 +250,7 @@ impl Cell {
250250
self.contents = contents.to_string();
251251

252252
let _ = sqlx::query!(
253-
"UPDATE notebook_cells
253+
"UPDATE pgml.notebook_cells
254254
SET
255255
cell_type = $1,
256256
contents = $2,
@@ -269,7 +269,7 @@ impl Cell {
269269
pub async fn delete(&self, pool: &PgPool) -> anyhow::Result<Cell> {
270270
Ok(sqlx::query_as!(
271271
Cell,
272-
"UPDATE notebook_cells
272+
"UPDATE pgml.notebook_cells
273273
SET deleted_at = NOW()
274274
WHERE id = $1
275275
RETURNING id,
@@ -337,7 +337,7 @@ impl Cell {
337337
};
338338

339339
sqlx::query!(
340-
"UPDATE notebook_cells SET rendering = $1 WHERE id = $2",
340+
"UPDATE pgml.notebook_cells SET rendering = $1 WHERE id = $2",
341341
rendering,
342342
self.id
343343
)
@@ -797,7 +797,7 @@ impl UploadedFile {
797797
pub async fn create(pool: &PgPool) -> anyhow::Result<UploadedFile> {
798798
Ok(sqlx::query_as!(
799799
UploadedFile,
800-
"INSERT INTO uploaded_files (id, created_at) VALUES (DEFAULT, DEFAULT)
800+
"INSERT INTO pgml.uploaded_files (id, created_at) VALUES (DEFAULT, DEFAULT)
801801
RETURNING id, created_at"
802802
)
803803
.fetch_one(pool)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy