Skip to content

Commit

Permalink
Reconcile v0.3.5 with changes in branch 0.3.4 (#135)
Browse files Browse the repository at this point in the history
* 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 <bethac07@users.noreply.github.com>
  • Loading branch information
d33bs and bethac07 authored Oct 10, 2024
1 parent a138e95 commit 596f9fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions cytominer_database/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import tempfile
import sqlalchemy.exc
from sqlalchemy import create_engine
from sqlalchemy.pool import NullPool

import cytominer_database.utils

Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ testpaths =

[build_sphinx]
project = 'cytominer_database'
version = 0.3.3
version = 0.3.5

0 comments on commit 596f9fc

Please sign in to comment.