Skip to content

Commit 8c51e97

Browse files
authored
Cleanup old oct2020 references and remove backward compat code (#164)
* cleanup old oct2020 references and remove backward compat code * fix formatting
1 parent 6ff0c9d commit 8c51e97

File tree

8 files changed

+52
-63
lines changed

8 files changed

+52
-63
lines changed

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
GITHUB_WORKSPACE=/build
3-
DOCKER_IMAGE= monetdb/dev-builds:Oct2020
43

5-
TEST_IMAGE = monetdb/dev-builds:Oct2020
6-
WHEEL_IMAGE = monetdb/dev-builds:Oct2020_manylinux
4+
STABLE_BRANCH = Jul2021
5+
TEST_IMAGE = monetdb/dev-builds:$(STABLE_BRANCH)
6+
WHEEL_IMAGE = monetdb/dev-builds:$(STABLE_BRANCH)_manylinux
77

88

99
all: test
@@ -25,13 +25,14 @@ test: venv/bin/pytest
2525
venv/bin/pytest
2626

2727
docker-wheels:
28-
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/make_wheel.sh 3.6"
29-
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/make_wheel.sh 3.7"
30-
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/make_wheel.sh 3.8"
31-
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/make_wheel.sh 3.9"
28+
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/make_wheel.sh 3.6"
29+
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/make_wheel.sh 3.7"
30+
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/make_wheel.sh 3.8"
31+
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/make_wheel.sh 3.9"
32+
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${WHEEL_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/make_wheel.sh 3.10"
3233

3334
docker-test:
34-
docker run -ti -v `pwd`:$(GITHUB_WORKSPACE) ${TEST_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/test.sh"
35+
docker run -ti -v `pwd`:$(GITHUB_WORKSPACE) ${TEST_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); MONETDB_BRANCH=$(STABLE_BRANCH) scripts/test.sh"
3536

3637
docker-mypy:
3738
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${TEST_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/mypy.sh"

monetdbe/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
from monetdbe.compat import (
2-
create,
3-
make_connection,
4-
init,
5-
insert,
6-
shutdown,
7-
sql
8-
)
91

102
from monetdbe.converters import register_adapter
113
from monetdbe.monetize import PrepareProtocol

monetdbe/_cffi/builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
f.write(f"newer_then_jul2021 = {newer_then_jul2021}\n")
2323

2424

25-
default = monetdb_branch.lower() in ("default", "jul2021", "jan2022")
2625
win32 = platform == 'win32'
2726

2827
with open(Path(__file__).resolve().parent / "native_utilities.c") as f:
@@ -37,7 +36,7 @@
3736
with open(embed_path, 'r') as f:
3837
content = f.read()
3938
template = Template(content)
40-
cdef = template.render(win32=win32, default=default, newer_then_jul2021=newer_then_jul2021)
39+
cdef = template.render(win32=win32, newer_then_jul2021=newer_then_jul2021)
4140
ffibuilder.cdef(cdef)
4241

4342

setup.py

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

3232
setup(
3333
name="monetdbe",
34-
version="0.10.1",
34+
version="0.11",
3535
author="Gijs Molenaar",
3636
author_email="gijs@pythonic.nl",
3737
description="MonetDBe - the Python embedded MonetDB",

tests/test_lite/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@pytest.fixture(scope="function")
88
def monetdbe_empty_cursor(request, tmp_path):
99
test_dbfarm = tmp_path.resolve().as_posix()
10-
connection = monetdbe.make_connection(test_dbfarm)
10+
connection = monetdbe.connect(test_dbfarm)
1111

1212
def finalizer():
1313
if tmp_path.is_dir():
@@ -23,7 +23,7 @@ def finalizer():
2323
def monetdbe_cursor(request, tmp_path):
2424
test_dbfarm = tmp_path.resolve().as_posix()
2525

26-
connection = monetdbe.make_connection(test_dbfarm)
26+
connection = monetdbe.connect(test_dbfarm)
2727

2828
def finalizer():
2929
if tmp_path.is_dir():

tests/test_lite/test_dbapi03.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_commited_on_restart(self, monetdbe_cursor_autocommit):
1616
cursor.commit()
1717
context.connection.close()
1818

19-
context.connection = monetdbe.make_connection(context.dbfarm)
19+
context.connection = monetdbe.connect(context.dbfarm)
2020
cursor = context.connection.cursor()
2121
cursor.execute('SELECT * FROM integers')
2222
assert result == [(0,), (1,), (2,)], "Incorrect result returned"
@@ -32,7 +32,7 @@ def test_transaction_aborted_on_shutdown(self, monetdbe_cursor_autocommit):
3232
assert result == [(0,), (1,), (2,)], "Incorrect result returned"
3333
context.connection.close()
3434

35-
context.connection = monetdbe.make_connection(context.dbfarm)
35+
context.connection = monetdbe.connect(context.dbfarm)
3636
cursor = context.connection.cursor()
3737
with pytest.raises(monetdbe.DatabaseError):
3838
cursor.execute('SELECT * FROM integers')
@@ -49,7 +49,7 @@ def test_many_shutdowns(self, monetdbe_cursor_autocommit):
4949
assert result == [(5,)], "Incorrect result returned"
5050
context.connection.close()
5151

52-
context.connection = monetdbe.make_connection(context.dbfarm)
52+
context.connection = monetdbe.connect(context.dbfarm)
5353
connection = context.connection
5454
connection.set_autocommit(True)
5555
cursor = connection.cursor()

tests/test_lite/test_pylite00.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest import TestCase, skip
22

33
import numpy
4+
import numpy as np
45
import pandas as pd
56
import pytest
67

@@ -12,27 +13,28 @@ def setUp(self) -> None:
1213
self.con = monetdbe.connect()
1314

1415
def test_regular_selection(self):
15-
con = monetdbe.connect()
16-
monetdbe.sql('CREATE TABLE pylite00 (i INTEGER)', client=con)
17-
con.execute('INSERT INTO pylite00 VALUES (1), (2), (3), (4), (5)')
18-
result = con.execute('SELECT * FROM pylite00').fetchdf()
19-
assert len(result['i']) == 5, "Incorrect result"
16+
with monetdbe.connect() as con:
17+
con.execute('CREATE TABLE pylite00 (i INTEGER)')
18+
con.execute('INSERT INTO pylite00 VALUES (1), (2), (3), (4), (5)')
19+
result = con.execute('SELECT * FROM pylite00').fetchdf()
20+
assert len(result['i']) == 5, "Incorrect result"
2021

2122
def test_monetdbe_create(self):
22-
cur = monetdbe.create('pylite01', {'i': numpy.arange(1000)})
23-
result = monetdbe.sql('select * from pylite01', client=cur.connection)
23+
cur = monetdbe.connect().cursor().create('pylite01', {'i': numpy.arange(1000)})
24+
result = cur.execute('select * from pylite01').fetchdf()
2425
assert len(result['i']) == 1000, "Incorrect result"
2526

2627
def test_monetdbe_insert(self):
27-
cur = monetdbe.create('pylite02', {'i': numpy.arange(1000)})
28+
cur = monetdbe.connect().cursor().create('pylite02', {'i': numpy.arange(1000)})
2829
cur.insert('pylite02', {'i': numpy.arange(1000)})
2930
result = cur.execute('select * from pylite02').fetchdf()
3031
assert len(result['i']) == 2000, "Incorrect result"
3132

3233
def test_monetdbe_create_multiple_columns(self):
3334
arrays = numpy.arange(100000).reshape((5, 20000))
34-
cur = monetdbe.create('pylite03',
35-
{'i': arrays[0], 'j': arrays[1], 'k': arrays[2], 'l': arrays[3], 'm': arrays[4]})
35+
cur = monetdbe.connect().cursor().create('pylite03',
36+
{'i': arrays[0], 'j': arrays[1], 'k': arrays[2], 'l': arrays[3],
37+
'm': arrays[4]})
3638
result = cur.execute('select * from pylite03').fetchnumpy()
3739
assert len(result) == 5, "Incorrect amount of columns"
3840
assert len(result['i']) == 20000, "Incorrect amount of rows"
@@ -61,72 +63,71 @@ def test_connections(self):
6163
cur.create('pylite05', {'i': numpy.arange(1000)})
6264

6365
# check that table was successfully created
64-
result = monetdbe.sql('SELECT MIN(i) AS minimum FROM pylite05', client=conn)
66+
result = monetdbe.connect().execute('SELECT MIN(i) AS minimum FROM pylite05', client=conn)
6567
assert result['minimum'][0] == 0, "Incorrect result"
6668
# attempt to query the table from another client
6769
with pytest.raises(monetdbe.DatabaseError):
68-
monetdbe.sql('SELECT * FROM pylite05', client=conn2)
70+
monetdbe.connect().execute('SELECT * FROM pylite05', client=conn2)
6971

7072
# now commit the table
71-
monetdbe.sql('COMMIT', client=conn)
73+
monetdbe.connect().execute('COMMIT', client=conn)
7274
# query the table again from the other client, this time it should be there
73-
result = monetdbe.sql('SELECT MIN(i) AS minimum FROM pylite05', client=conn2)
75+
result = monetdbe.connect().execute('SELECT MIN(i) AS minimum FROM pylite05', client=conn2)
7476
assert result['minimum'][0] == 0, "Incorrect result"
7577

7678
def test_non_existent_table(self, ):
7779
# select from non-existent table
7880
with pytest.raises(monetdbe.DatabaseError):
79-
monetdbe.sql('select * from nonexistenttable')
81+
monetdbe.connect().execute('select * from nonexistenttable')
8082

8183
def test_invalid_connection_object(self):
8284
# invalid connection object
8385
with pytest.raises(TypeError):
84-
monetdbe.sql('select * from tables', client=33)
86+
monetdbe.connect().execute('select * from tables', client=33)
8587

8688
def test_invalid_colnames(self):
8789
# invalid colnames
8890
with pytest.raises(monetdbe.DatabaseError):
89-
monetdbe.create('pylite06', {33: []})
91+
monetdbe.connect().cursor().create('pylite06', {33: []})
9092

9193
def test_empty_colnames(self):
9294
# empty colnames
9395
with pytest.raises(monetdbe.DatabaseError):
94-
monetdbe.create('pylite07', {'': []})
96+
monetdbe.connect().cursor().create('pylite07', {'': []})
9597

9698
def test_invalid_key_dict(self):
9799
# dictionary with invalid keys
98100
d = dict()
99101
d[33] = 44
100102
with pytest.raises(monetdbe.ProgrammingError):
101-
monetdbe.create('pylite08', d)
103+
monetdbe.connect().cursor().create('pylite08', d)
102104

103105
def test_missing_dict_key(self):
104106
# missing dict key in insert
105-
cur = monetdbe.create('pylite09', dict(a=[], b=[], c=[]))
107+
cur = monetdbe.connect().cursor().create('pylite09', dict(a=[], b=[], c=[]))
106108
with pytest.raises(monetdbe.DatabaseError):
107109
cur.insert('pylite09', dict(a=33, b=44))
108110

109111
def test_bad_column_number(self):
110112
# too few columns in insert
111-
cur = monetdbe.create('pylite10', dict(a=[], b=[], c=[]))
113+
cur = monetdbe.connect().cursor().create('pylite10', dict(a=[], b=[], c=[]))
112114
with pytest.raises(monetdbe.DatabaseError):
113115
cur.insert('pylite10', {'a': [33], 'b': [44]})
114116

115117
def test_many_sql_statements(self):
116118
for i in range(5): # FIXME 1000
117-
conn = monetdbe.connect()
118-
cur = conn.execute('CREATE TABLE pylite11 (i INTEGER)')
119-
cur.insert('pylite11', {'i': numpy.arange(10).astype(numpy.int32)})
120-
result = cur.execute('SELECT * FROM pylite11').fetchdf()
121-
assert result['i'][0] == 0, "Invalid result"
122-
monetdbe.sql('DROP TABLE pylite11', client=conn)
123-
monetdbe.sql('ROLLBACK', client=conn)
124-
del conn
119+
with monetdbe.connect() as conn:
120+
cur = conn.execute('CREATE TABLE pylite11 (i INTEGER)')
121+
cur.insert('pylite11', {'i': numpy.arange(10).astype(numpy.int32)})
122+
result = cur.execute('SELECT * FROM pylite11').fetchdf()
123+
assert result['i'][0] == 0, "Invalid result"
124+
conn.execute('DROP TABLE pylite11')
125+
conn.execute('ROLLBACK')
125126

126127
def test_null_string_insertion_bug(self):
127-
con = monetdbe.connect()
128-
monetdbe.sql("CREATE TABLE pylite12 (s varchar(2))", client=con)
129-
monetdbe.insert('pylite12', {'s': ['a', None]}, client=con)
130-
result = monetdbe.sql("SELECT * FROM pylite12", client=con)
131-
expected = numpy.ma.masked_array(['a', 'a'], mask=[0, 1])
132-
numpy.testing.assert_array_equal(result['s'], expected)
128+
with monetdbe.connect() as con:
129+
cur = con.execute("CREATE TABLE pylite12 (s varchar(2))")
130+
cur.insert('pylite12', {'s': np.array(['a', None])})
131+
result = cur.execute("SELECT * FROM pylite12").fetchnumpy()
132+
expected = numpy.ma.masked_array(['a', 'a'], mask=[0, 1])
133+
numpy.testing.assert_array_equal(result['s'], expected)

tests/test_regression.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
import pandas as pd
3434

3535
import monetdbe as monetdbe
36-
from monetdbe._cffi.branch import monetdb_branch
37-
38-
OCT2020 = monetdb_branch == "Oct2020"
3936

4037

4138
class RegressionTests(unittest.TestCase):
@@ -529,7 +526,6 @@ def test_issue118_explain(self):
529526
print(tbl)
530527
conn.close()
531528

532-
@unittest.skipIf(OCT2020, "This issue was not fixed on Oct2020")
533529
def test_issue_136_bigint_result(self):
534530
con = monetdbe.connect(':memory:')
535531
cur = con.execute("""

0 commit comments

Comments
 (0)