Skip to content

Commit

Permalink
Remove backports.tempfile for Python compatibility and bump version (
Browse files Browse the repository at this point in the history
…#134)

* remove backports.tempfile; add deps; bump version

* pin csvkit

* set a range for csvkit

* update test for pandas syntax
  • Loading branch information
d33bs authored Oct 10, 2024
1 parent 62f13b3 commit a138e95
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ authors:
given-names: "Anne"
orcid: "https://orcid.org/0000-0003-1555-8261"
title: "cytominer-database"
version: 0.3.4
version: 0.3.5
url: "https://github.com/cytomining/cytominer-database"
2 changes: 1 addition & 1 deletion cytominer_database/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import zlib

import pandas as pd
import backports.tempfile
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine

Expand Down
2 changes: 1 addition & 1 deletion cytominer_database/ingest_variable_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import click
import zlib
import pandas as pd
import backports.tempfile
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine
import pyarrow
Expand Down
2 changes: 1 addition & 1 deletion cytominer_database/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings
import zlib
import pandas as pd
import backports.tempfile
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine
import pyarrow
Expand Down
2 changes: 1 addition & 1 deletion cytominer_database/tableSchema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import warnings
import zlib
import pandas as pd
import backports.tempfile
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine
import pyarrow
Expand Down
2 changes: 1 addition & 1 deletion cytominer_database/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import warnings
import zlib
import pandas as pd
import backports.tempfile
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine
import pyarrow
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import setuptools

project = "cytominer_database"
version = "0.3.3"
version = "0.3.5"

# Note about authors:
# setuptools makes it difficult to have multiple authors
Expand Down Expand Up @@ -30,11 +30,11 @@
packages=setuptools.find_packages(exclude=["tests", "doc"]),
include_package_data=True,
install_requires=[
"backports.tempfile>=1.0rc1",
"click>=6.7",
"configparser>=3.5.0",
"csvkit>=1.0.2",
"csvkit>=1.0.2,<2",
"pandas>=0.20.3",
"pyarrow",
],
license="BSD",
url="https://github.com/cytomining/cytominer-database",
Expand Down
20 changes: 10 additions & 10 deletions tests/commands/test_command_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import pytest
import click.testing
import backports.tempfile
import tempfile
from sqlalchemy import create_engine

import cytominer_database.command
Expand Down Expand Up @@ -34,7 +34,7 @@ def test_run(dataset, runner):

opts += [dataset["data_dir"]]

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
sqlite_file = os.path.join(temp_dir, "test.db")

opts += ["sqlite:///{}".format(sqlite_file)]
Expand All @@ -50,7 +50,7 @@ def test_run(dataset, runner):
engine = create_engine(target)
con = engine.connect()

df = pd.read_sql(sql=table_name, con=con, index_col=0)
df = pd.read_sql(sql=f"SELECT * FROM {table_name}", con=con)

assert df.shape[0] == blob["nrows"]
assert df.shape[1] == blob["ncols"] + 1
Expand All @@ -68,7 +68,7 @@ def test_run_variable_engine_default(dataset, runner):
# SOURCE
opts = [dataset["data_dir"]]

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
# TARGET
sqlite_file = os.path.join(temp_dir, "test.db")
opts += ["sqlite:///{}".format(sqlite_file)]
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_run_variable_engine_default(dataset, runner):
engine = create_engine(target)
con = engine.connect()

df = pd.read_sql(sql=table_name, con=con, index_col=0)
df = pd.read_sql(sql=f"SELECT * FROM {table_name}", con=con)

assert df.shape[0] == blob["nrows"]
assert df.shape[1] == blob["ncols"] + 1
Expand All @@ -112,7 +112,7 @@ def test_run_variable_engine_sqlite(dataset, runner):
CONFIG_CHOICE = "config_SQLite.ini"
# SOURCE
opts = [dataset["data_dir"]]
with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
# TARGET
sqlite_file = os.path.join(temp_dir, "test.db")
opts += ["sqlite:///{}".format(sqlite_file)]
Expand All @@ -139,7 +139,7 @@ def test_run_variable_engine_sqlite(dataset, runner):
engine = create_engine(target)
con = engine.connect()

df = pd.read_sql(sql=table_name, con=con, index_col=0)
df = pd.read_sql(sql=f"SELECT * FROM {table_name}", con=con)

assert df.shape[0] == blob["nrows"]
assert df.shape[1] == blob["ncols"] + 1
Expand All @@ -156,7 +156,7 @@ def test_run_variable_engine_parquet(dataset, runner):
# SOURCE
opts = [dataset["data_dir"]]

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
# TARGET
# create output directory
target = os.path.join(temp_dir, "test_parquet_output")
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_run_defaults(cellpainting, runner):

opts += [cellpainting["data_dir"]]

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
sqlite_file = os.path.join(temp_dir, "test.db")

opts += ["sqlite:///{}".format(sqlite_file)]
Expand All @@ -227,7 +227,7 @@ def test_run_defaults(cellpainting, runner):
engine = create_engine(target)
con = engine.connect()

df = pd.read_sql(sql=table_name, con=con, index_col=0)
df = pd.read_sql(sql=f"SELECT * FROM {table_name}", con=con)

assert df.shape[0] == blob["nrows"]
assert df.shape[1] == blob["ncols"] + 1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ingest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os.path

import pandas as pd
import backports.tempfile
import tempfile
from sqlalchemy import create_engine

import cytominer_database.ingest
Expand All @@ -27,7 +27,7 @@ def test_seed(dataset):
if munge:
cytominer_database.munge.munge(config_file, data_dir)

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
sqlite_file = os.path.join(temp_dir, "test.db")

cytominer_database.ingest.seed(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ingest_variable_engine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

import pandas as pd
import backports.tempfile
import tempfile
from sqlalchemy import create_engine

# import cytominer_database.ingest
Expand All @@ -24,7 +24,7 @@ def test_seed(dataset, config_choice):
if munge:
cytominer_database.munge.munge(config_path, data_dir)

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
# set up
if engine_type == "Parquet":
# create output directory
Expand Down
8 changes: 4 additions & 4 deletions tests/test_munge.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os.path

import backports.tempfile
import tempfile
import cytominer_database.munge
import pandas as pd
import pandas.util.testing
from pandas.testing import assert_frame_equal


def test_munge(dataset):
Expand All @@ -12,7 +12,7 @@ def test_munge(dataset):

config_file = os.path.join(dataset["data_dir"], "config.ini")

with backports.tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
valid_directories = cytominer_database.munge.munge(
config_path=config_file, source=dataset["data_dir"], target=temp_dir
)
Expand All @@ -32,4 +32,4 @@ def test_munge(dataset):
)
)

pandas.util.testing.assert_frame_equal(input_csv, output_csv)
assert_frame_equal(input_csv, output_csv)

0 comments on commit a138e95

Please sign in to comment.