From d4e45e5bf9877957c36b8e0a537ba3819a674614 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 18 Dec 2023 12:01:38 +0300 Subject: Samples: Hook-up external async script to upload the samples. --- scripts/insert_samples.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/insert_samples.py b/scripts/insert_samples.py index 43c6a38..6b6faf1 100644 --- a/scripts/insert_samples.py +++ b/scripts/insert_samples.py @@ -42,21 +42,25 @@ def insert_samples(conn: mdb.Connection,# pylint: disable=[too-many-arguments] firstlineheading: bool, quotechar: str): """Insert the samples into the database.""" + print("Checking for errors:") species = species_by_id(conn, speciesid) if not bool(species): logging.error("Species with id '%s' does not exist.", str(speciesid)) return 1 + print(f"\tSpecies with ID '{speciesid}' found") population = population_by_id(conn, populationid) if not bool(population): logging.error("Population with id '%s' does not exist.", str(populationid)) return 1 - logging.info("Inserting samples ...") + print(f"\tPopulations with ID '{populationid}' found") + print("No errors found. Continuing...") + print("\nInserting samples ...") save_samples_data( conn, speciesid, read_samples_file(samplesfile, separator, firstlineheading)) - logging.info("Cross-referencing samples with their populations.") + print("Cross-referencing samples with their populations.") cross_reference_samples( conn, speciesid, @@ -66,7 +70,7 @@ def insert_samples(conn: mdb.Connection,# pylint: disable=[too-many-arguments] separator, firstlineheading, quotechar=quotechar))) - + print("Samples upload successfully completed.") return 0 if __name__ == "__main__": @@ -133,8 +137,6 @@ if __name__ == "__main__": with (Redis.from_url(args.redisuri, decode_responses=True) as rconn, database_connection(args.databaseuri) as dbconn): - print("We got here...") - print(args) return insert_samples(dbconn, rconn, args.speciesid, -- cgit v1.2.3