Skip to content

Commit 06d99bd

Browse files
authored
Seperate tests and example db population (#455)
1 parent 12b6168 commit 06d99bd

File tree

11 files changed

+54
-6
lines changed

11 files changed

+54
-6
lines changed

pgml-extension/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,6 @@ panic = "unwind"
5757
opt-level = 3
5858
lto = "fat"
5959
codegen-units = 1
60+
61+
[profile.test]
62+
opt-level = 3

pgml-extension/docker/entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ echo "Creating user and database..."
1313
(createdb -U postgres -h 127.0.0.1 pgml_development 2> /dev/null) || true
1414

1515
echo "Installing pgml extension..."
16-
psql -U postgres -h 127.0.0.1 pgml_development -c 'CREATE EXTENSION IF NOT EXISTS pgml'
17-
18-
psql -U postgres -h 127.0.0.1 pgml_development -f tests/test.sql -P pager
16+
psql -U postgres -h 127.0.0.1 pgml_development -f sql/setup_examples.sql -P pager
1917

2018
echo "Ready!"
2119
if [[ ! -z $@ ]]; then

pgml-extension/examples/binary_classification.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- Exit on error (psql)
22
\set ON_ERROR_STOP true
3+
\timing on
34

45
SELECT pgml.load_dataset('breast_cancer');
56

@@ -45,7 +46,8 @@ SELECT malignant, pgml.predict(
4546
"worst fractal dimension"
4647
]
4748
) AS prediction
48-
FROM pgml.breast_cancer
49+
FROM pgml.breast_cancer
50+
ORDER BY random()
4951
LIMIT 10;
5052

5153
-- view raw class probabilities
@@ -85,6 +87,7 @@ SELECT malignant, pgml.predict_proba(
8587
]
8688
) AS prediction
8789
FROM pgml.breast_cancer
90+
ORDER BY random()
8891
LIMIT 10;
8992

9093
--

pgml-extension/examples/image_classification.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
-- Exit on error (psql)
1313
\set ON_ERROR_STOP true
14+
\timing on
1415

1516
SELECT pgml.load_dataset('digits');
1617

pgml-extension/examples/joint_regression.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
-- Exit on error (psql)
66
\set ON_ERROR_STOP true
7+
\timing on
78

89
SELECT pgml.load_dataset('linnerud');
910

pgml-extension/examples/multi_classification.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- Exit on error (psql)
22
\set ON_ERROR_STOP true
3+
\timing on
34

45
SELECT pgml.load_dataset('iris');
56

pgml-extension/examples/regression.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
-- Exit on error (psql)
1313
\set ON_ERROR_STOP true
14-
\timing
14+
\timing on
1515

1616
SELECT pgml.load_dataset('diabetes');
1717

pgml-extension/examples/transformers.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-- Exit on error (psql)
22
\set ON_ERROR_STOP true
3+
\timing on
4+
35

46
SELECT pgml.transform(
57
'translation_en_to_fr',

pgml-extension/examples/vectors.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
-- Exit on error (psql)
12
\set ON_ERROR_STOP true
3+
\timing on
24

35
-- Elementwise arithmetic w/ constants
46
SELECT pgml.add(ARRAY[1.0, 2.0, 3.0], 3);

pgml-extension/sql/setup_examples.sql

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
--- Create the extension and load sample data into a database.
3+
---
4+
--- Usage:
5+
---
6+
--- $ cargo pgx run --release
7+
--- $ psql -P pager-off -h localhost -p 28813 -d pgml -f sql/setup_examples.sql
8+
---
9+
\set ON_ERROR_STOP true
10+
\timing on
11+
12+
-- The intention is to only allow setup_examples.sql to run on a database that
13+
-- has not had example data installed before, e.g. docker run. This should
14+
-- error and stop the process if the extension is already present.
15+
CREATE EXTENSION pgml;
16+
17+
SELECT pgml.load_dataset('breast_cancer');
18+
SELECT pgml.load_dataset('diabetes');
19+
SELECT pgml.load_dataset('digits');
20+
SELECT pgml.load_dataset('iris');
21+
SELECT pgml.load_dataset('linnerud');
22+
SELECT pgml.load_dataset('wine');
23+
24+
\i examples/binary_classification.sql
25+
\i examples/image_classification.sql
26+
\i examples/joint_regression.sql
27+
\i examples/multi_classification.sql
28+
\i examples/regression.sql

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