aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-12-18 12:01:38 +0300
committerFrederick Muriuki Muriithi2023-12-18 12:01:38 +0300
commitd4e45e5bf9877957c36b8e0a537ba3819a674614 (patch)
tree1850dbe6d2733497501db09e22f9f53daa0f9943 /scripts
parent096ab99a2d961e864f340c39252b4c8eecc72191 (diff)
downloadgn-uploader-d4e45e5bf9877957c36b8e0a537ba3819a674614.tar.gz
Samples: Hook-up external async script to upload the samples.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/insert_samples.py12
1 files changed, 7 insertions, 5 deletions
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,