Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mberacochea committed Aug 21, 2023
1 parent d69c6de commit 8ecfe60
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dump/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8ecfe60

Please sign in to comment.