diff --git a/cytominer_database/ingest.py b/cytominer_database/ingest.py index c391af9..4665b26 100644 --- a/cytominer_database/ingest.py +++ b/cytominer_database/ingest.py @@ -99,12 +99,11 @@ def into(input, output, name, identifier, skip_table_prefix=False): # deprecated, use inspect.signature() or inspect.getfullargspec() warnings.simplefilter("ignore", category=DeprecationWarning) - target = "{}::{}".format(output, name) - engine = create_engine(target) + engine = create_engine(output) con = engine.connect() df = pd.read_csv(source, index_col=0) - df.to_sql(name=target, con=con, if_exists="append") + df.to_sql(name=name, con=con, if_exists="append") def checksum(pathname, buffer_size=65536): """ diff --git a/tests/commands/test_command_ingest.py b/tests/commands/test_command_ingest.py index 71493d2..ed198d3 100644 --- a/tests/commands/test_command_ingest.py +++ b/tests/commands/test_command_ingest.py @@ -45,11 +45,11 @@ def test_run(dataset, runner): for blob in dataset["ingest"]: table_name = blob["table"].capitalize() - target = "sqlite:///{}::{}".format(str(sqlite_file), table_name) + target = "sqlite:///{}".format(str(sqlite_file)) engine = create_engine(target) con = engine.connect() - df = pd.read_sql(target, con=con, index_col=0) + df = pd.read_sql(sql=table_name, con=con, index_col=0) assert df.shape[0] == blob["nrows"] assert df.shape[1] == blob["ncols"] + 1 @@ -80,11 +80,11 @@ def test_run_defaults(cellpainting, runner): for blob in cellpainting["ingest"]: table_name = blob["table"].capitalize() - target = "sqlite:///{}::{}".format(str(sqlite_file), table_name) + target = "sqlite:///{}".format(str(sqlite_file)) engine = create_engine(target) con = engine.connect() - df = pd.read_sql(target, con=con, index_col=0) + df = pd.read_sql(sql=table_name, con=con, index_col=0) assert df.shape[0] == blob["nrows"] assert df.shape[1] == blob["ncols"] + 1 diff --git a/tests/conftest.py b/tests/conftest.py index 37c1984..21871e0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,6 +18,12 @@ def pytest_generate_tests(metafunc): @pytest.fixture def cellpainting(): + """ + Return configuration for a Cell Painting dataset. + - 3 compartments CSVs: Cells, Cytoplasm, Nuclei + - 1 image CSV + - No object.csv and therefore no munging + """ return { "config": "config.ini", "data_dir": "tests/data_b", @@ -49,6 +55,12 @@ def cellpainting(): @pytest.fixture def htqc(): + """ + Return configuration for a 3-channel image-based profiling dataset. + - 1 object CSV that comprises Cells, Cytoplasm, Nuclei + - 1 image CSV + - munging required + """ return { "config": "config.ini", "data_dir": "tests/data_a", @@ -82,6 +94,11 @@ def htqc(): @pytest.fixture def qc(): + """ + Return configuration for a QC dataset (only image table, no objects). + - 1 image CSV + - No object.csv and therefore no munging + """ return { "config": None, "data_dir": "tests/data_c", diff --git a/tests/test_ingest.py b/tests/test_ingest.py index e5adf5d..3585218 100644 --- a/tests/test_ingest.py +++ b/tests/test_ingest.py @@ -27,14 +27,16 @@ def test_seed(dataset): target="sqlite:///{}".format(str(sqlite_file)) ) + assert os.path.exists(str(sqlite_file)) + for blob in ingest: table_name = blob["table"].capitalize() - target = "sqlite:///{}::{}".format(str(sqlite_file), table_name) + target = "sqlite:///{}".format(str(sqlite_file)) engine = create_engine(target) con = engine.connect() - df = pd.read_sql(target, con=con, index_col=0) + df = pd.read_sql(sql=table_name, con=con, index_col=0) assert df.shape[0] == blob["nrows"] assert df.shape[1] == blob["ncols"] + 1