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

Commit80738a9

Browse files
committed
Merge branch 'master' into dan-docs
2 parentsa619a0c +9949cde commit80738a9

File tree

43 files changed

+4801
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4801
-98
lines changed

‎.github/workflows/package-extension.yml‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
workflow_dispatch:
55
inputs:
66
packageVersion:
7-
default:"2.4.4"
7+
default:"2.4.8"
88

99
jobs:
1010
build:
1111
strategy:
1212
matrix:
13-
os:["ubuntu-22.04"]
13+
os:["ubuntu-22.04", "buildjet-4vcpu-ubuntu-2204-arm"]
1414
runs-on:${{ matrix.os }}
1515
defaults:
1616
run:
@@ -130,14 +130,19 @@ jobs:
130130
for pg in {11..15}; do
131131
export PACKAGE_VERSION=${{ inputs.packageVersion }}
132132
export PGVERSION=${pg}
133-
export ARCH=amd64
133+
134+
if [[ $(arch) == "x86_64" ]]; then
135+
export ARCH=amd64
136+
else
137+
export ARCH=arm64
138+
fi
134139
135140
mkdir -p target/release/pgml-pg${pg}/DEBIAN
136141
(cat control | envsubst) > target/release/pgml-pg${pg}/DEBIAN/control
137-
dpkg-deb --root-owner-group --build target/release/pgml-pg${pg} postgresql-pgml-${pg}_${PACKAGE_VERSION}-ubuntu22.04-amd64.deb
142+
dpkg-deb --root-owner-group --build target/release/pgml-pg${pg} postgresql-pgml-${pg}_${PACKAGE_VERSION}-ubuntu22.04-${ARCH}.deb
138143
139144
deb-s3 upload \
140145
--bucket apt.postgresml.org \
141-
postgresql-pgml-${pg}_${PACKAGE_VERSION}-ubuntu22.04-amd64.deb \
146+
postgresql-pgml-${pg}_${PACKAGE_VERSION}-ubuntu22.04-${ARCH}.deb \
142147
--codename $(lsb_release -cs)
143148
done

‎pgml-dashboard/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name ="pgml-dashboard"
3-
version ="2.4.4"
3+
version ="2.4.8"
44
edition ="2021"
55
authors = ["PostgresML <team@postgresml.org>"]
66
license ="MIT"
@@ -43,6 +43,7 @@ time = "0.3"
4343
tokio = {version ="1",features = ["full"] }
4444
yaml-rust ="0.4"
4545
zoomies = {git="https://github.com/HyperparamAI/zoomies.git",branch="master" }
46+
pgvector = {version ="0.2.0",features = ["sqlx","postgres" ] }
4647

4748
[build-dependencies]
4849
md5 ="0.7"

‎pgml-dashboard/content/docs/guides/setup/developers.md‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ SELECT pgml.version();
123123

124124
=== "Output"
125125

126-
```
127-
postgres=# select pgml.version();
128-
version
129-
-------------------
130-
2.4.4
131-
(1 row)
132-
```
133-
134-
===
126+
```
127+
postgres=# select pgml.version();
128+
version
129+
-------------------
130+
2.4.8
131+
(1 row)
132+
```
135133

136134
Basic extension usage:
137135

‎pgml-dashboard/src/lib.rs‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub mod fairings;
1616
pubmod forms;
1717
pubmod guards;
1818
pubmod models;
19-
pubmod responses;
20-
pubmod templates;
21-
pubmod utils;
19+
mod responses;
20+
mod templates;
21+
mod utils;
2222

2323
usecrate::templates::{
2424
DeploymentsTab,Layout,ModelsTab,NotebooksTab,ProjectsTab,SnapshotsTab,UploaderTab,
@@ -28,6 +28,13 @@ use guards::Cluster;
2828
use responses::{BadRequest,Error,ResponseOk};
2929
use sqlx::Executor;
3030

31+
#[derive(Debug,Default,Clone)]
32+
pubstructClustersSettings{
33+
pubmax_connections:u32,
34+
pubidle_timeout:u64,
35+
pubmin_connections:u32,
36+
}
37+
3138
/// This struct contains information specific to the cluster being displayed in the dashboard.
3239
///
3340
/// The dashboard is built to manage multiple clusters, but the server itself by design is stateless.
@@ -49,13 +56,18 @@ pub struct Clusters {
4956
}
5057

5158
implClusters{
52-
pubfnadd(&self,cluster_id:i64,database_url:&str) -> anyhow::Result<PgPool>{
59+
pubfnadd(
60+
&self,
61+
cluster_id:i64,
62+
database_url:&str,
63+
settings:ClustersSettings,
64+
) -> anyhow::Result<PgPool>{
5365
letmut pools =self.pools.lock();
5466

5567
let pool =PgPoolOptions::new()
56-
.max_connections(5)
57-
.idle_timeout(std::time::Duration::from_millis(15_000))
58-
.min_connections(0)
68+
.max_connections(settings.max_connections)
69+
.idle_timeout(std::time::Duration::from_millis(settings.idle_timeout))
70+
.min_connections(settings.min_connections)
5971
.after_connect(|conn, _meta|{
6072
Box::pin(asyncmove{
6173
conn.execute("SET application_name = 'pgml_dashboard';")
@@ -511,6 +523,7 @@ pub async fn uploaded_index(cluster: Cluster, table_name: &str) -> ResponseOk {
511523
let sql = templates::Sql::new(
512524
cluster.pool(),
513525
&format!("SELECT * FROM {} LIMIT 10", table_name),
526+
true,
514527
)
515528
.await
516529
.unwrap();

‎pgml-dashboard/src/main.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,18 @@ async fn main() {
118118
markdown::SearchIndex::build().await.unwrap();
119119

120120
let clusters = pgml_dashboard::Clusters::new();
121+
let settings = pgml_dashboard::ClustersSettings{
122+
min_connections:0,
123+
max_connections:5,
124+
idle_timeout:15_000,
125+
};
126+
121127
clusters
122-
.add(-1,&pgml_dashboard::guards::default_database_url())
128+
.add(
129+
-1,
130+
&pgml_dashboard::guards::default_database_url(),
131+
settings,
132+
)
123133
.unwrap();
124134

125135
pgml_dashboard::migrate(&clusters.get(-1).unwrap())
@@ -159,6 +169,9 @@ mod test {
159169

160170
asyncfnrocket() ->Rocket<Build>{
161171
dotenv::dotenv().ok();
172+
let max_connections =5;
173+
let min_connections =1;
174+
let idle_timeout =15_000;
162175

163176
let clusters =Clusters::new();
164177
clusters

‎pgml-dashboard/src/models.rs‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,19 @@ impl Cell {
288288
pubasyncfnrender(&mutself,pool:&PgPool) -> anyhow::Result<()>{
289289
let cell_type:CellType =self.cell_type.into();
290290

291-
let rendering =match cell_type{
291+
let(rendering, execution_time) =match cell_type{
292292
CellType::Sql =>{
293-
let queries=self.contents.split(";");
293+
let queries:Vec<&str>=self.contents.split(';').filter(|q| !q.trim().is_empty()).collect();
294294
letmut rendering =String::new();
295+
letmut total_execution_duration = std::time::Duration::default();
296+
let render_individual_execution_duration = queries.len() >1;
295297

296298
for queryin queries{
297-
if query.trim().is_empty(){
298-
continue;
299-
}
300-
301-
let result =match templates::Sql::new(pool, query).await{
302-
Ok(sql) => sql.render_once()?,
299+
let result =match templates::Sql::new(pool, query, render_individual_execution_duration).await{
300+
Ok(sql) =>{
301+
total_execution_duration += sql.execution_duration;
302+
sql.render_once()?
303+
},
303304
Err(err) => templates::SqlError{
304305
error:format!("{:?}", err),
305306
}
@@ -309,7 +310,12 @@ impl Cell {
309310
rendering.push_str(&result);
310311
}
311312

312-
rendering
313+
let execution_time =PgInterval{
314+
months:0,
315+
days:0,
316+
microseconds: total_execution_duration.as_micros().try_into().unwrap_or(0)
317+
};
318+
(rendering,Some(execution_time))
313319
}
314320

315321
CellType::Markdown =>{
@@ -327,21 +333,23 @@ impl Cell {
327333
front_matter_delimiter:None,
328334
};
329335

330-
format!(
336+
(format!(
331337
"<div class=\"markdown-body\">{}</div>",
332338
markdown_to_html(&self.contents,&options)
333-
)
339+
),None)
334340
}
335341
};
336342

337343
sqlx::query!(
338-
"UPDATE pgml.notebook_cells SET rendering = $1WHERE id = $2",
344+
"UPDATE pgml.notebook_cells SET rendering = $1, execution_time = $2WHERE id = $3",
339345
rendering,
346+
execution_time,
340347
self.id
341348
)
342349
.execute(pool)
343350
.await?;
344351

352+
self.execution_time = execution_time;
345353
self.rendering =Some(rendering);
346354

347355
Ok(())

‎pgml-dashboard/src/templates/mod.rs‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,12 @@ pub struct Undo {
141141
pubstructSql{
142142
pubcolumns:Vec<String>,
143143
pubrows:Vec<Vec<String>>,
144+
pubexecution_duration: std::time::Duration,
145+
pubrender_execution_duration:bool,
144146
}
145147

146148
implSql{
147-
pubasyncfnnew(pool:&PgPool,query:&str) -> anyhow::Result<Sql>{
149+
pubasyncfnnew(pool:&PgPool,query:&str,render_execution_duration:bool) -> anyhow::Result<Sql>{
148150
let prepared_stmt = pool.prepare(query).await?;
149151
let cols = prepared_stmt.columns();
150152

@@ -153,7 +155,9 @@ impl Sql {
153155

154156
cols.iter().for_each(|c| columns.push(c.name().to_string()));
155157

158+
let now = std::time::Instant::now();
156159
let result = prepared_stmt.query().fetch_all(pool).await?;
160+
let execution_duration = now.elapsed();
157161

158162
for rowin result.iter(){
159163
letmut values =Vec::new();
@@ -267,6 +271,11 @@ impl Sql {
267271
serde_json::to_string(&value)?
268272
}
269273

274+
"vector" =>{
275+
let value: pgvector::Vector = row.try_get(i)?;
276+
format!("{:?}", value.to_vec())
277+
}
278+
270279
unknown =>{
271280
// TODO
272281
// Implement everything here: https://docs.rs/sqlx/latest/sqlx/postgres/types/index.html
@@ -280,7 +289,7 @@ impl Sql {
280289
rows.push(values);
281290
}
282291

283-
Ok(Sql{ columns, rows})
292+
Ok(Sql{ columns, rows, execution_duration, render_execution_duration})
284293
}
285294
}
286295

‎pgml-dashboard/src/utils.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pubfnformat_microseconds(microseconds:f64) ->String{
2+
if microseconds >=1000000.{
3+
format!("{}s", microseconds /1000000.)
4+
}elseif microseconds >=1000.{
5+
format!("{}ms", microseconds /1000.)
6+
}else{
7+
format!("{}μs", microseconds)
8+
}
9+
}

‎pgml-dashboard/templates/content/dashboard/panels/cell.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<divclass="notebook-duration">
7676
<divclass="markdown-body">
7777
<divclass="flex flex-row-reverse">
78-
<code>TODO</code>
78+
<code>Time:<%= crate::utils::format_microseconds(cell.execution_time.unwrap().microseconds as f64) %></code>
7979
</div>
8080
</div>
8181
</div>

‎pgml-dashboard/templates/content/sql.html‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<% } %>
2525
</tbody>
2626
</table>
27+
<% if render_execution_duration { %>
28+
<code>Time:<%= crate::utils::format_microseconds(execution_duration.as_micros() as f64) %></code>
29+
<% } %>
2730
</div>
2831

2932
<% } %>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp