• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dbmi-bgm / SubmitCGAP / 4851692537

pending completion
4851692537

push

github

GitHub
Merge pull request #37 from dbmi-bgm/dmichaels_from_kmp_submit_cgap_for_fourfront_via_s3

227 of 227 new or added lines in 9 files covered. (100.0%)

2476 of 2506 relevant lines covered (98.8%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.43
/submit_cgap/scripts/submit_ontology.py
1
import argparse
1✔
2
import json
1✔
3
import io
1✔
4
import os
1✔
5
from dcicutils.common import APP_FOURFRONT, ORCHESTRATED_APPS
1✔
6
from dcicutils.command_utils import ScriptFailure
1✔
7
from dcicutils.misc_utils import get_error_message
1✔
8
from ..submission import submit_any_ingestion, SubmissionProtocol, SUBMISSION_PROTOCOLS
1✔
9
from ..utils import script_catch_errors, show
1✔
10

11

12
EPILOG = __doc__
1✔
13

14

15
def main(simulated_args_for_testing=None):
1✔
16
    parser = argparse.ArgumentParser(  # noqa - PyCharm wrongly thinks the formatter_class is invalid
1✔
17
        description="Submits an ontology",
18
        epilog=EPILOG,
19
        formatter_class=argparse.RawDescriptionHelpFormatter
20
    )
21
    parser.add_argument('ontology_filename', help='a file of ontology data')
1✔
22
    parser.add_argument('--lab', '-l', '-L', help='lab identifier', default=None)
1✔
23
    parser.add_argument('--award', '-a', help='award identifier', default=None)
1✔
24
    parser.add_argument('--server', '-s', help="an http or https address of the server to use", default=None)
1✔
25
    parser.add_argument('--env', '-e', help="a CGAP beanstalk environment name for the server to use", default=None)
1✔
26
    parser.add_argument('--validate-only', '-v', action="store_true",
1✔
27
                        help="whether to stop after validating without submitting", default=False)
28
    parser.add_argument('--app', choices=ORCHESTRATED_APPS, default=APP_FOURFRONT,
1✔
29
                        help=f"An application (default {APP_FOURFRONT!r}. Only for debugging."
30
                             f" Normally this should not be given.")
31
    parser.add_argument('--submission_protocol', '--submission-protocol', '-sp',
1✔
32
                        choices=SUBMISSION_PROTOCOLS, default=SubmissionProtocol.S3,
33
                        help=f"the submission protocol (default {SubmissionProtocol.S3!r})")
34
    args = parser.parse_args(args=simulated_args_for_testing)
1✔
35

36
    with script_catch_errors():
1✔
37

38
        verify_ontology_file(args.ontology_filename)
1✔
39

40
        return submit_any_ingestion(
1✔
41
                ingestion_filename=args.ontology_filename,
42
                ingestion_type='ontology',
43
                lab=args.lab,
44
                award=args.award,
45
                server=args.server,
46
                env=args.env,
47
                validate_only=args.validate_only,
48
                app=args.app,
49
                submission_protocol=args.submission_protocol,
50
        )
51

52

53
def verify_ontology_file(ontology_filename: str) -> bool:
1✔
54
    if not os.path.exists(ontology_filename):
1✔
55
        raise ScriptFailure(f"Specified ontology file does not exist: {ontology_filename}")
×
56
    try:
1✔
57
        with io.open(ontology_filename, "r") as f:
1✔
58
            ontology_json = json.load(f)
1✔
59
            ontology_term_count = len(ontology_json["ontology_term"])  # xyzzy
1✔
60
    except Exception as e:
×
61
        raise ScriptFailure(f"Cannot load specified ontology (JSON) file: {ontology_filename} | {get_error_message(e)}")
×
62
    show(f"Verified specified ontology (JSON) file: {ontology_filename} (ontology terms: {ontology_term_count})")
1✔
63
    return True
1✔
64

65

66
if __name__ == '__main__':
67
    main()
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc