Skip to content

Commit

Permalink
Support multiple status
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed May 22, 2024
1 parent 01f5329 commit 73721ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,23 @@ def get_release_inventory_info_for_assembly(taxonomy_id, assembly_accession, rel
return results[0][0]


def get_release_pending(release_species_inventory_table, metadata_connection_handle):
results = get_all_results_for_query(metadata_connection_handle,
"select taxonomy, assembly_accession, release_version from {0} "
"where should_be_released "
"and num_rs_to_release > 0"
"ORDER BY release_version, taxonomy, assembly_accession"
.format(release_species_inventory_table))
def get_release_pending(release_species_inventory_table, metadata_connection_handle, status=None):
def format_status(status_list):
return f"({str(status_list).strip('[]')})"

if 'Pending' in status:
status.remove('Pending')
if status:
status_statement = f"and (release_status in {format_status(status)} or release_status is null)"
else:
status_statement = f"and release_status is null"
else:
status_statement = f"and release_status in {format_status(status)}"

query = (f"select taxonomy, assembly_accession, release_version from {release_species_inventory_table} "
"where should_be_released "
"and num_rs_to_release > 0 "
f"{status_statement}" if status_statement else ''
"ORDER BY release_version, taxonomy, assembly_accession")
results = get_all_results_for_query(metadata_connection_handle, query)
yield results
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ def run_release_for_species(taxonomy_id, release_assemblies, release_version, re
run_command_with_output(f"Running workflow file {workflow_file_path}", workflow_command)


def list_pending_release():
def list_pending_release(status):
private_config_xml_file = cfg.query("maven", "settings_file")
profile = cfg.query("maven", "environment")
release_species_inventory_table = cfg.query('release', 'inventory_table')
with get_metadata_connection_handle(profile, private_config_xml_file) as metadata_connection_handle:
header = ['taxonomy', 'assembly_accession', 'release_version']
table = []
for taxonomy, assembly_accession, release_version in get_release_pending(release_species_inventory_table,
metadata_connection_handle):
metadata_connection_handle, status):
table.append((taxonomy, assembly_accession, release_version))
pretty_print(header, table)

Expand All @@ -129,7 +129,9 @@ def load_config(*args):

def main():
argparse = ArgumentParser()
argparse.add_argument("--list", help="Generate the list of species and assembly that needs to be released", action='store_true', default=False)
argparse.add_argument("--list", nargs='+',
help="Generate the list of species and assembly that needs to be released",
choices=['Pending', 'Started', 'Completed'])
argparse.add_argument("--taxonomy_id", help="ex: 9913", required=True)
argparse.add_argument("--assembly_accessions", nargs='+', help="ex: GCA_000003055.3")
argparse.add_argument("--release_version", required=True)
Expand All @@ -139,7 +141,7 @@ def main():
load_config()
logging_config.add_stdout_handler()
if args.list:
list_pending_release()
list_pending_release(args.list)
else:
run_release_for_species(args.taxonomy_id, args.assembly_accessions, args.release_version, args.resume)

Expand Down

0 comments on commit 73721ec

Please sign in to comment.