From 8ecfe608a375c71de145781b10f2cd49a0a4624c Mon Sep 17 00:00:00 2001 From: Martin Beracochea Date: Mon, 21 Aug 2023 23:50:34 +0100 Subject: [PATCH] Small fix --- dump/cli.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dump/cli.py b/dump/cli.py index e6f4938..b4d76fa 100644 --- a/dump/cli.py +++ b/dump/cli.py @@ -36,11 +36,8 @@ def create_database(db: str) -> Engine: def copy_assembly(assembly: Assembly, session: Session): - if assembly.ready: - print(f"Assembly {assembly.accession} completed") - assembly.status = CopyStatus.COMPLETED - session.add(assembly) - session.commit() + if assembly.status == CopyStatus.COMPLETED: + print(f"Assembly {assembly} completed.. ignoring") return if not os.path.exists(assembly.dest_folder): @@ -88,10 +85,17 @@ def copy_all(database: str): assemblies: ScalarResult[Assembly] = session.exec( select(Assembly).where(Assembly.status == CopyStatus.PENDING) ) - for assembly in track(assemblies, description="Copying..."): + for assembly in assemblies: try: print(f"Copying assembly {assembly.accession}") - copy_assembly(assembly) + copy_assembly(assembly, session) + session.refresh(assembly) + if assembly.ready: + print(f"Assembly {assembly.accession} completed") + assembly.status = CopyStatus.COMPLETED + session.add(assembly) + session.commit() + except Exception as ex: print(ex, file=sys.stderr) assembly.status = CopyStatus.ERROR