@@ -108,6 +108,7 @@ def command_interface() -> None:
108108 parser .add_argument (
109109 "-o" ,
110110 "--output_json_path" ,
111+ default = f"pori_python_report_{ timestamp ()} .json" ,
111112 help = "path to a JSON to output the report upload body" ,
112113 )
113114 parser .add_argument (
@@ -134,6 +135,24 @@ def command_interface() -> None:
134135 action = "store_true" ,
135136 help = "True to include matches to multivariant statements where not all variants are present" ,
136137 )
138+ parser .add_argument (
139+ "--upload_json" ,
140+ default = False ,
141+ action = "store_true" ,
142+ help = "True to skip all the preprocessing and just submit a json to ipr" ,
143+ )
144+ parser .add_argument (
145+ "--validate_json" ,
146+ default = False ,
147+ action = "store_true" ,
148+ help = "True if only need to validate the json" ,
149+ )
150+ parser .add_argument (
151+ "--ignore_extra_fields" ,
152+ default = False ,
153+ action = "store_true" ,
154+ help = "True if ignore extra fields in json" ,
155+ )
137156 args = parser .parse_args ()
138157
139158 with open (args .content , "r" ) as fh :
@@ -155,6 +174,9 @@ def command_interface() -> None:
155174 async_upload = args .async_upload ,
156175 mins_to_wait = args .mins_to_wait ,
157176 allow_partial_matches = args .allow_partial_matches ,
177+ upload_json = args .upload_json ,
178+ validate_json = args .validate_json ,
179+ ignore_extra_fields = args .ignore_extra_fields ,
158180 )
159181
160182
@@ -288,6 +310,9 @@ def ipr_report(
288310 include_nonspecific_project : bool = False ,
289311 include_nonspecific_template : bool = False ,
290312 allow_partial_matches : bool = False ,
313+ upload_json : bool = False ,
314+ validate_json : bool = False ,
315+ ignore_extra_fields : bool = False ,
291316 tmb_high : float = TMB_SIGNATURE_HIGH_THRESHOLD ,
292317) -> Dict :
293318 """Run the matching and create the report JSON for upload to IPR.
@@ -327,6 +352,20 @@ def ipr_report(
327352 format = "%(asctime)s %(name)s %(levelname)s %(message)s" ,
328353 datefmt = "%m-%d-%y %H:%M:%S" ,
329354 )
355+
356+ # IPR CONNECTION
357+ ipr_conn = IprConnection (username , password , ipr_url )
358+
359+ if validate_json :
360+ ipr_result = ipr_conn .validate_json (content )
361+ return ipr_result
362+
363+ if upload_json :
364+ ipr_result = ipr_conn .upload_report (
365+ content , mins_to_wait , async_upload , ignore_extra_fields
366+ )
367+ return ipr_result
368+
330369 # validate the JSON content follows the specification
331370 try :
332371 validate_report_content (content )
@@ -365,10 +404,6 @@ def ipr_report(
365404 small_mutations , expression_variants , copy_variants , structural_variants
366405 )
367406
368- # IPR CONNECTION
369- ipr_conn = IprConnection (username , password , ipr_url )
370- ipr_spec = ipr_conn .get_spec ()
371-
372407 # GKB CONNECTION
373408 if graphkb_url :
374409 logger .info (f"connecting to graphkb: { graphkb_url } " )
@@ -509,6 +544,7 @@ def ipr_report(
509544 )
510545 output .setdefault ("images" , []).extend (select_expression_plots (gkb_matches , all_variants ))
511546
547+ ipr_spec = ipr_conn .get_spec ()
512548 output = clean_unsupported_content (output , ipr_spec )
513549 ipr_result = None
514550 upload_error = None
@@ -517,19 +553,20 @@ def ipr_report(
517553 if ipr_upload :
518554 try :
519555 logger .info (f"Uploading to IPR { ipr_conn .url } " )
520- ipr_result = ipr_conn .upload_report (output , mins_to_wait , async_upload )
556+ ipr_result = ipr_conn .upload_report (
557+ output , mins_to_wait , async_upload , ignore_extra_fields
558+ )
521559 logger .info (ipr_result )
522560 output .update (ipr_result )
523561 except Exception as err :
524562 upload_error = err
525563 logger .error (f"ipr_conn.upload_report failed: { err } " , exc_info = True )
526564
527565 # SAVE TO JSON FILE
528- if output_json_path :
529- if always_write_output_json or not ipr_result :
530- logger .info (f"Writing IPR upload json to: { output_json_path } " )
531- with open (output_json_path , "w" ) as fh :
532- fh .write (json .dumps (output ))
566+ if always_write_output_json :
567+ logger .info (f"Writing IPR upload json to: { output_json_path } " )
568+ with open (output_json_path , "w" ) as fh :
569+ fh .write (json .dumps (output ))
533570
534571 logger .info (f"made { graphkb_conn .request_count } requests to graphkb" )
535572 logger .info (f"average load { int (graphkb_conn .load or 0 )} req/s" )
0 commit comments