Skip to content

Commit

Permalink
Cleanup old oct2020 references and remove backward compat code (#164)
Browse files Browse the repository at this point in the history
* cleanup old oct2020 references and remove backward compat code

* fix formatting
  • Loading branch information
gijzelaerr committed Dec 29, 2021
1 parent 6ff0c9d commit 8c51e97
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 63 deletions.
17 changes: 9 additions & 8 deletions Makefile
@@ -1,9 +1,9 @@

GITHUB_WORKSPACE=/build
DOCKER_IMAGE= monetdb/dev-builds:Oct2020

TEST_IMAGE = monetdb/dev-builds:Oct2020
WHEEL_IMAGE = monetdb/dev-builds:Oct2020_manylinux
STABLE_BRANCH = Jul2021
TEST_IMAGE = monetdb/dev-builds:$(STABLE_BRANCH)
WHEEL_IMAGE = monetdb/dev-builds:$(STABLE_BRANCH)_manylinux


all: test
Expand All @@ -25,13 +25,14 @@ test: venv/bin/pytest
venv/bin/pytest

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

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

docker-mypy:
docker run -v `pwd`:$(GITHUB_WORKSPACE) ${TEST_IMAGE} sh -c "cd $(GITHUB_WORKSPACE); scripts/mypy.sh"
Expand Down
8 changes: 0 additions & 8 deletions monetdbe/__init__.py
@@ -1,11 +1,3 @@
from monetdbe.compat import (
create,
make_connection,
init,
insert,
shutdown,
sql
)

from monetdbe.converters import register_adapter
from monetdbe.monetize import PrepareProtocol
Expand Down
3 changes: 1 addition & 2 deletions monetdbe/_cffi/builder.py
Expand Up @@ -22,7 +22,6 @@
f.write(f"newer_then_jul2021 = {newer_then_jul2021}\n")


default = monetdb_branch.lower() in ("default", "jul2021", "jan2022")
win32 = platform == 'win32'

with open(Path(__file__).resolve().parent / "native_utilities.c") as f:
Expand All @@ -37,7 +36,7 @@
with open(embed_path, 'r') as f:
content = f.read()
template = Template(content)
cdef = template.render(win32=win32, default=default, newer_then_jul2021=newer_then_jul2021)
cdef = template.render(win32=win32, newer_then_jul2021=newer_then_jul2021)
ffibuilder.cdef(cdef)


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -31,7 +31,7 @@

setup(
name="monetdbe",
version="0.10.1",
version="0.11",
author="Gijs Molenaar",
author_email="gijs@pythonic.nl",
description="MonetDBe - the Python embedded MonetDB",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_lite/conftest.py
Expand Up @@ -7,7 +7,7 @@
@pytest.fixture(scope="function")
def monetdbe_empty_cursor(request, tmp_path):
test_dbfarm = tmp_path.resolve().as_posix()
connection = monetdbe.make_connection(test_dbfarm)
connection = monetdbe.connect(test_dbfarm)

def finalizer():
if tmp_path.is_dir():
Expand All @@ -23,7 +23,7 @@ def finalizer():
def monetdbe_cursor(request, tmp_path):
test_dbfarm = tmp_path.resolve().as_posix()

connection = monetdbe.make_connection(test_dbfarm)
connection = monetdbe.connect(test_dbfarm)

def finalizer():
if tmp_path.is_dir():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_lite/test_dbapi03.py
Expand Up @@ -16,7 +16,7 @@ def test_commited_on_restart(self, monetdbe_cursor_autocommit):
cursor.commit()
context.connection.close()

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

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

context.connection = monetdbe.make_connection(context.dbfarm)
context.connection = monetdbe.connect(context.dbfarm)
connection = context.connection
connection.set_autocommit(True)
cursor = connection.cursor()
Expand Down
71 changes: 36 additions & 35 deletions tests/test_lite/test_pylite00.py
@@ -1,6 +1,7 @@
from unittest import TestCase, skip

import numpy
import numpy as np
import pandas as pd
import pytest

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

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

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

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

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

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

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

def test_non_existent_table(self, ):
# select from non-existent table
with pytest.raises(monetdbe.DatabaseError):
monetdbe.sql('select * from nonexistenttable')
monetdbe.connect().execute('select * from nonexistenttable')

def test_invalid_connection_object(self):
# invalid connection object
with pytest.raises(TypeError):
monetdbe.sql('select * from tables', client=33)
monetdbe.connect().execute('select * from tables', client=33)

def test_invalid_colnames(self):
# invalid colnames
with pytest.raises(monetdbe.DatabaseError):
monetdbe.create('pylite06', {33: []})
monetdbe.connect().cursor().create('pylite06', {33: []})

def test_empty_colnames(self):
# empty colnames
with pytest.raises(monetdbe.DatabaseError):
monetdbe.create('pylite07', {'': []})
monetdbe.connect().cursor().create('pylite07', {'': []})

def test_invalid_key_dict(self):
# dictionary with invalid keys
d = dict()
d[33] = 44
with pytest.raises(monetdbe.ProgrammingError):
monetdbe.create('pylite08', d)
monetdbe.connect().cursor().create('pylite08', d)

def test_missing_dict_key(self):
# missing dict key in insert
cur = monetdbe.create('pylite09', dict(a=[], b=[], c=[]))
cur = monetdbe.connect().cursor().create('pylite09', dict(a=[], b=[], c=[]))
with pytest.raises(monetdbe.DatabaseError):
cur.insert('pylite09', dict(a=33, b=44))

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

def test_many_sql_statements(self):
for i in range(5): # FIXME 1000
conn = monetdbe.connect()
cur = conn.execute('CREATE TABLE pylite11 (i INTEGER)')
cur.insert('pylite11', {'i': numpy.arange(10).astype(numpy.int32)})
result = cur.execute('SELECT * FROM pylite11').fetchdf()
assert result['i'][0] == 0, "Invalid result"
monetdbe.sql('DROP TABLE pylite11', client=conn)
monetdbe.sql('ROLLBACK', client=conn)
del conn
with monetdbe.connect() as conn:
cur = conn.execute('CREATE TABLE pylite11 (i INTEGER)')
cur.insert('pylite11', {'i': numpy.arange(10).astype(numpy.int32)})
result = cur.execute('SELECT * FROM pylite11').fetchdf()
assert result['i'][0] == 0, "Invalid result"
conn.execute('DROP TABLE pylite11')
conn.execute('ROLLBACK')

def test_null_string_insertion_bug(self):
con = monetdbe.connect()
monetdbe.sql("CREATE TABLE pylite12 (s varchar(2))", client=con)
monetdbe.insert('pylite12', {'s': ['a', None]}, client=con)
result = monetdbe.sql("SELECT * FROM pylite12", client=con)
expected = numpy.ma.masked_array(['a', 'a'], mask=[0, 1])
numpy.testing.assert_array_equal(result['s'], expected)
with monetdbe.connect() as con:
cur = con.execute("CREATE TABLE pylite12 (s varchar(2))")
cur.insert('pylite12', {'s': np.array(['a', None])})
result = cur.execute("SELECT * FROM pylite12").fetchnumpy()
expected = numpy.ma.masked_array(['a', 'a'], mask=[0, 1])
numpy.testing.assert_array_equal(result['s'], expected)
4 changes: 0 additions & 4 deletions tests/test_regression.py
Expand Up @@ -33,9 +33,6 @@
import pandas as pd

import monetdbe as monetdbe
from monetdbe._cffi.branch import monetdb_branch

OCT2020 = monetdb_branch == "Oct2020"


class RegressionTests(unittest.TestCase):
Expand Down Expand Up @@ -529,7 +526,6 @@ def test_issue118_explain(self):
print(tbl)
conn.close()

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

0 comments on commit 8c51e97

Please sign in to comment.