Skip to content

Commit

Permalink
Check that the copy to remote mongo actually copied anything
Browse files Browse the repository at this point in the history
  • Loading branch information
tcezard committed Mar 28, 2024
1 parent 7f50d68 commit 947bcca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eva-accession-release-automation/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ebi_eva_common_pyutils==0.5.6
ebi_eva_common_pyutils[internal]==0.6.5
click==7.1.2
pytz==2022.6
pyyaml==5.3.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
import traceback

from ebi_eva_common_pyutils.command_utils import run_command_with_output
from ebi_eva_common_pyutils.config_utils import get_mongo_uri_for_eva_profile
from ebi_eva_common_pyutils.metadata_utils import get_metadata_connection_handle
from ebi_eva_common_pyutils.mongo_utils import copy_db
Expand Down Expand Up @@ -47,6 +48,13 @@
"submittedVariantOperationEntity": "inactiveObjects.tax"
}

def remote_db_is_empty(local_forwarded_port, assembly_accession, destination_db_name):
logger.info(f"check if: {assembly_accession} has been copied")
command = f"mongosh --eval 'use {destination_db_name}' --eval 'db.stats()' --port {local_forwarded_port} " \
"| grep 'dataSize' | awk '{print substr($2,1,length($2)-1)}'"
output = run_command_with_output(command)
return output.strip() == '0'


def mongo_data_copy_to_remote_host(local_forwarded_port, private_config_xml_file, profile, assembly_accession,
taxonomy_id, collections_to_copy_map, dump_dir, destination_db_name):
Expand Down Expand Up @@ -119,6 +127,8 @@ def copy_accessioning_collections_to_embassy(private_config_xml_file, profile, t
mongo_data_copy_to_remote_host(mongo_port, private_config_xml_file, profile, assembly_accession,
taxonomy_id, collections_to_copy_map, dump_dir, destination_db_name)
exit_code = 0
if remote_db_is_empty(mongo_port, assembly_accession, destination_db_name):
raise Exception
except Exception as ex:
logger.error("Encountered an error while copying species data to Embassy for assemblies in "
+ release_info["tempmongo_instance"] + "\n" + traceback.format_exc())
Expand Down

0 comments on commit 947bcca

Please sign in to comment.