Skip to content

Seperate tests and example db population #455

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pgml-extension/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ panic = "unwind"
opt-level = 3
lto = "fat"
codegen-units = 1

[profile.test]
opt-level = 3
4 changes: 1 addition & 3 deletions pgml-extension/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ echo "Creating user and database..."
(createdb -U postgres -h 127.0.0.1 pgml_development 2> /dev/null) || true

echo "Installing pgml extension..."
psql -U postgres -h 127.0.0.1 pgml_development -c 'CREATE EXTENSION IF NOT EXISTS pgml'

psql -U postgres -h 127.0.0.1 pgml_development -f tests/test.sql -P pager
psql -U postgres -h 127.0.0.1 pgml_development -f sql/setup_examples.sql -P pager

echo "Ready!"
if [[ ! -z $@ ]]; then
Expand Down
5 changes: 4 additions & 1 deletion pgml-extension/examples/binary_classification.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on

SELECT pgml.load_dataset('breast_cancer');

Expand Down Expand Up @@ -45,7 +46,8 @@ SELECT malignant, pgml.predict(
"worst fractal dimension"
]
) AS prediction
FROM pgml.breast_cancer
FROM pgml.breast_cancer
ORDER BY random()
LIMIT 10;

-- view raw class probabilities
Expand Down Expand Up @@ -85,6 +87,7 @@ SELECT malignant, pgml.predict_proba(
]
) AS prediction
FROM pgml.breast_cancer
ORDER BY random()
LIMIT 10;

--
Expand Down
1 change: 1 addition & 0 deletions pgml-extension/examples/image_classification.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on

SELECT pgml.load_dataset('digits');

Expand Down
1 change: 1 addition & 0 deletions pgml-extension/examples/joint_regression.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on

SELECT pgml.load_dataset('linnerud');

Expand Down
1 change: 1 addition & 0 deletions pgml-extension/examples/multi_classification.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on

SELECT pgml.load_dataset('iris');

Expand Down
2 changes: 1 addition & 1 deletion pgml-extension/examples/regression.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing
\timing on

SELECT pgml.load_dataset('diabetes');

Expand Down
2 changes: 2 additions & 0 deletions pgml-extension/examples/transformers.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on


SELECT pgml.transform(
'translation_en_to_fr',
Expand Down
2 changes: 2 additions & 0 deletions pgml-extension/examples/vectors.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- Exit on error (psql)
\set ON_ERROR_STOP true
\timing on

-- Elementwise arithmetic w/ constants
SELECT pgml.add(ARRAY[1.0, 2.0, 3.0], 3);
Expand Down
28 changes: 28 additions & 0 deletions pgml-extension/sql/setup_examples.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
--- Create the extension and load sample data into a database.
---
--- Usage:
---
--- $ cargo pgx run --release
--- $ psql -P pager-off -h localhost -p 28813 -d pgml -f sql/setup_examples.sql
---
\set ON_ERROR_STOP true
\timing on

-- The intention is to only allow setup_examples.sql to run on a database that
-- has not had example data installed before, e.g. docker run. This should
-- error and stop the process if the extension is already present.
CREATE EXTENSION pgml;

SELECT pgml.load_dataset('breast_cancer');
SELECT pgml.load_dataset('diabetes');
SELECT pgml.load_dataset('digits');
SELECT pgml.load_dataset('iris');
SELECT pgml.load_dataset('linnerud');
SELECT pgml.load_dataset('wine');

\i examples/binary_classification.sql
\i examples/image_classification.sql
\i examples/joint_regression.sql
\i examples/multi_classification.sql
\i examples/regression.sql
11 changes: 10 additions & 1 deletion pgml-extension/tests/test.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
---
--- Test our functions.
---
--- Usage:
---
--- $ cargo pgx run --release
--- $ psql -P pager-off -h localhost -p 28813 -d pgml -f tests/test.sql
---
\set ON_ERROR_STOP true
\timing on

\timing
-- Reset the test database to a clean state on each run.
DROP EXTENSION IF EXISTS pgml CASCADE;
DROP SCHEMA IF EXISTS pgml CASCADE;
CREATE EXTENSION pgml;

SELECT pgml.load_dataset('breast_cancer');
SELECT pgml.load_dataset('diabetes');
Expand Down
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