|
23 | 23 |
|
24 | 24 | from .annotate import annotate_variants |
25 | 25 | from .connection import IprConnection |
26 | | -from .constants import DEFAULT_URL, TMB_SIGNATURE_HIGH_THRESHOLD |
| 26 | +from .constants import TMB_SIGNATURE_HIGH_THRESHOLD |
27 | 27 | from .inputs import ( |
28 | 28 | check_comparators, |
29 | 29 | check_variant_links, |
@@ -86,7 +86,7 @@ def command_interface() -> None: |
86 | 86 | "-c", "--content", required=True, type=file_path, help="Report Content as JSON" |
87 | 87 | ) |
88 | 88 |
|
89 | | - parser.add_argument("--ipr_url", default=os.environ.get("IPR_URL", DEFAULT_URL)) |
| 89 | + parser.add_argument("--ipr_url", default=os.environ.get("IPR_URL")) |
90 | 90 | parser.add_argument( |
91 | 91 | "--graphkb_username", |
92 | 92 | help="username to use connecting to graphkb if different from ipr", |
@@ -294,7 +294,7 @@ def ipr_report( |
294 | 294 | username: str, |
295 | 295 | password: str, |
296 | 296 | content: Dict, |
297 | | - ipr_url: str = DEFAULT_URL, |
| 297 | + ipr_url: str = '', |
298 | 298 | log_level: str = "info", |
299 | 299 | output_json_path: str = "", |
300 | 300 | always_write_output_json: bool = False, |
@@ -324,7 +324,7 @@ def ipr_report( |
324 | 324 | Args: |
325 | 325 | username: the username for connecting to GraphKB and IPR |
326 | 326 | password: the password for connecting to GraphKB and IPR |
327 | | - ipr_url: base URL to use in connecting to IPR |
| 327 | + ipr_url: base URL to use in connecting to IPR (eg. https://ipr-api.bcgsc.ca/api) |
328 | 328 | log_level: the logging level |
329 | 329 | content: report content |
330 | 330 | output_json_path: path to a JSON file to output the report upload body. |
@@ -358,13 +358,22 @@ def ipr_report( |
358 | 358 | ) |
359 | 359 |
|
360 | 360 | # IPR CONNECTION |
361 | | - ipr_conn = IprConnection(username, password, ipr_url) |
| 361 | + ipr_url = ipr_url if ipr_url else os.environ.get("IPR_URL", "") |
| 362 | + ipr_conn = None |
| 363 | + if ipr_url: |
| 364 | + ipr_conn = IprConnection(username, password, ipr_url) |
| 365 | + else: |
| 366 | + logger.warning("No ipr_url given") |
362 | 367 |
|
363 | 368 | if validate_json: |
| 369 | + if not ipr_conn: |
| 370 | + raise ValueError("ipr_url required to validate json") |
364 | 371 | ipr_result = ipr_conn.validate_json(content) |
365 | 372 | return ipr_result |
366 | 373 |
|
367 | 374 | if upload_json: |
| 375 | + if not ipr_conn: |
| 376 | + raise ValueError("ipr_url required to upload json") |
368 | 377 | ipr_result = ipr_conn.upload_report( |
369 | 378 | content, mins_to_wait, async_upload, ignore_extra_fields |
370 | 379 | ) |
@@ -492,6 +501,8 @@ def ipr_report( |
492 | 501 | comments_list.append(graphkb_comments) |
493 | 502 |
|
494 | 503 | if include_ipr_variant_text: |
| 504 | + if not ipr_conn: |
| 505 | + raise ValueError("ipr_url required to to include ipr variant text") |
495 | 506 | ipr_comments = get_ipr_analyst_comments( |
496 | 507 | ipr_conn, |
497 | 508 | gkb_matches, |
@@ -557,13 +568,16 @@ def ipr_report( |
557 | 568 | output['hrdScore'] = output['hrd']['score'] |
558 | 569 | output.pop('hrd') # kbmatches have already been made |
559 | 570 |
|
560 | | - ipr_spec = ipr_conn.get_spec() |
561 | | - output = clean_unsupported_content(output, ipr_spec) |
562 | 571 | ipr_result = {} |
563 | 572 | upload_error = None |
564 | 573 |
|
565 | 574 | # UPLOAD TO IPR |
| 575 | + |
566 | 576 | if ipr_upload: |
| 577 | + if not ipr_conn: |
| 578 | + raise ValueError("ipr_url required to upload report") |
| 579 | + ipr_spec = ipr_conn.get_spec() |
| 580 | + output = clean_unsupported_content(output, ipr_spec) |
567 | 581 | try: |
568 | 582 | logger.info(f"Uploading to IPR {ipr_conn.url}") |
569 | 583 | ipr_result = ipr_conn.upload_report( |
|
0 commit comments