From 596f9fc394794e018309bf74392d6c8b410fd39b Mon Sep 17 00:00:00 2001 From: Dave Bunten Date: Thu, 10 Oct 2024 14:21:48 -0600 Subject: [PATCH] Reconcile `v0.3.5` with changes in branch `0.3.4` (#135) * Move database connection from `into` to `seed`, close connection * Update setup.py * Update setup.cfg * Update conf.py * Update setup.py * bump cfg version * formatting --------- Co-authored-by: Beth Cimini --- cytominer_database/ingest.py | 11 +++++++++-- setup.cfg | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cytominer_database/ingest.py b/cytominer_database/ingest.py index 544aa5e..7691270 100644 --- a/cytominer_database/ingest.py +++ b/cytominer_database/ingest.py @@ -47,6 +47,7 @@ import tempfile import sqlalchemy.exc from sqlalchemy import create_engine +from sqlalchemy.pool import NullPool import cytominer_database.utils @@ -58,7 +59,7 @@ def __format__(name, header): return "{}_{}".format(name, header) -def into(input, output, name, identifier, skip_table_prefix=False): +def into(input, output, name, identifier, con, skip_table_prefix=False): """Ingest a CSV file into a table in a database. :param input: Input CSV file. @@ -132,6 +133,9 @@ def seed(source, target, config_path, skip_image_prefix=True): # list the subdirectories that contain CSV files directories = sorted(list(cytominer_database.utils.find_directories(source))) + engine = create_engine(target, poolclass=NullPool) + con = engine.connect() + for directory in directories: # get the image CSV and the CSVs for each of the compartments try: @@ -158,7 +162,8 @@ def seed(source, target, config_path, skip_image_prefix=True): output=target, name=name.capitalize(), identifier=identifier, - skip_table_prefix=skip_image_prefix, + con=con, + skip_table_prefix=skip_image_prefix ) except sqlalchemy.exc.DatabaseError as e: click.echo(e) @@ -173,4 +178,6 @@ def seed(source, target, config_path, skip_image_prefix=True): output=target, name=name.capitalize(), identifier=identifier, + con=con ) + con.close() diff --git a/setup.cfg b/setup.cfg index e412fc4..6523c96 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,4 +11,4 @@ testpaths = [build_sphinx] project = 'cytominer_database' -version = 0.3.3 +version = 0.3.5