Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to broker to private projects #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/add_ext_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from ebi_eva_internal_pyutils.pg_utils import get_all_results_for_query, execute_query
from retry import retry

from eva_submission.eload_utils import check_project_exists_in_evapro, check_existing_project_in_ena
from eva_submission.eload_utils import check_project_exists_in_evapro, \
check_existing_public_project_in_ena
from eva_submission.submission_config import load_config

logger = log_cfg.get_logger(__name__)
Expand Down Expand Up @@ -110,7 +111,7 @@ def main():
if not check_project_exists_in_evapro(args.project_accession):
logger.error(f'{args.project_accession} does not exist in EVAPRO')
return 1
if not check_existing_project_in_ena(args.project_accession):
if not check_existing_public_project_in_ena(args.project_accession):
logger.error(f'{args.project_accession} does not exist or is not public in ENA')
return 1
if _curie_exist(args.source_database + ":" + args.identifier):
Expand Down
4 changes: 2 additions & 2 deletions bin/broker_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def ENA_Project(project):


def main():
# Load the config_file from default location
load_config()
argparse = ArgumentParser(description='Broker validated ELOAD to BioSamples and ENA')
argparse.add_argument('--eload', required=True, type=int, help='The ELOAD number for this submission')
argparse.add_argument('--debug', action='store_true', default=False,
Expand All @@ -61,8 +63,6 @@ def main():
if args.debug:
log_cfg.set_log_level(logging.DEBUG)

# Load the config_file from default location
load_config()
# Optionally Set the valid VCF and metadata file
with EloadBrokering(args.eload, args.vcf_files, args.metadata_file) as brokering:
brokering.upgrade_config_if_needed()
Expand Down
21 changes: 20 additions & 1 deletion eva_submission/eload_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,12 @@ def check_project_format(project_accession):
return re.match(r'^PRJ(EB|NA)', project_accession)


@retry(tries=4, delay=2, backoff=1.2, jitter=(1, 3))
def check_existing_project_in_ena(project_accession):
return check_existing_public_project_in_ena(project_accession) or \
check_existing_private_project_in_ena(project_accession)


def check_existing_public_project_in_ena(project_accession):
"""
Check if a project accession exists and is public in ENA
:param project_accession:
Expand All @@ -176,6 +180,21 @@ def check_existing_project_in_ena(project_accession):
return True


def check_existing_private_project_in_ena(project_accession):
"""
Check if a project accession exists and is private in ENA
:param project_accession:
:return:
"""
try:
response = requests.get(f'https://www.ebi.ac.uk/ena/submit/drop-box/cli/reference/project/{project_accession}',
auth=HTTPBasicAuth(cfg.query('ena', 'username'), cfg.query('ena', 'password')))
response.raise_for_status()
except requests.exceptions.HTTPError:
return False
return True


# Create the databases if they do not exists. Then shard them.
collections_shard_key_map = {
"variants_2_0": (["chr", "start"], False),
Expand Down
Loading