@@ -46,21 +46,23 @@ def build_envelope(submit_url, analysis_protocol_path, analysis_process_path, ra
4646 with open (analysis_protocol_path ) as f :
4747 analysis_protocol_dict = json .load (f )
4848
49+ # URL for getting and creating the analysis protocol, e.g.
50+ # http://api.ingest.{deployment}.data.humancellatlas.org/submissionEnvelopes/{envelope_id}/protocols
4951 analysis_protocol_url = get_subject_url (endpoint_dict = envelope_dict , subject = 'protocols' )
5052
5153 # Check if an analysis_protocol already exists in the submission envelope from a previous attempt
5254 pipeline_version = analysis_protocol_dict ['protocol_core' ]['protocol_id' ]
53- analysis_protocol = get_analysis_protocol (analysis_protocol_url = analysis_protocol_url ,
54- auth_headers = auth_headers ,
55- protocol_id = pipeline_version ,
56- http_requests = http_requests )
55+ analysis_protocol_response = get_analysis_protocol (analysis_protocol_url = analysis_protocol_url ,
56+ auth_headers = auth_headers ,
57+ protocol_id = pipeline_version ,
58+ http_requests = http_requests )
5759
5860 # Create analysis_protocol if this is the first attempt
59- if not analysis_protocol :
60- _analysis_protocol = add_analysis_protocol (analysis_protocol_url = analysis_protocol_url ,
61- auth_headers = auth_headers ,
62- analysis_protocol = analysis_protocol_dict ,
63- http_requests = http_requests )
61+ if not analysis_protocol_response :
62+ analysis_protocol_response = add_analysis_protocol (analysis_protocol_url = analysis_protocol_url ,
63+ auth_headers = auth_headers ,
64+ analysis_protocol = analysis_protocol_dict ,
65+ http_requests = http_requests )
6466
6567 # === 4. Create analysis_process ===
6668 with open (analysis_process_path ) as f :
@@ -70,35 +72,40 @@ def build_envelope(submit_url, analysis_protocol_path, analysis_process_path, ra
7072
7173 # Check if an analysis_process already exists in the submission envelope from a previous attempt
7274 analysis_workflow_id = analysis_process_dict ['process_core' ]['process_id' ]
73- analysis_process = get_analysis_process (analysis_process_url = analysis_process_url ,
74- auth_headers = auth_headers ,
75- process_id = analysis_workflow_id ,
76- http_requests = http_requests )
75+ analysis_process_response = get_analysis_process (analysis_process_url = analysis_process_url ,
76+ auth_headers = auth_headers ,
77+ process_id = analysis_workflow_id ,
78+ http_requests = http_requests )
7779
7880 # Create analysis_process if this is the first attempt
79- if not analysis_process :
80- analysis_process = add_analysis_process (analysis_process_url = analysis_process_url ,
81- auth_headers = auth_headers ,
82- analysis_process = analysis_process_dict ,
83- http_requests = http_requests )
81+ if not analysis_process_response :
82+ analysis_process_response = add_analysis_process (analysis_process_url = analysis_process_url ,
83+ auth_headers = auth_headers ,
84+ analysis_process = analysis_process_dict ,
85+ http_requests = http_requests )
8486
8587 # === 5. Link analysis_protocol to analysis_process ===
86- link_url = get_subject_url (endpoint_dict = analysis_process , subject = 'protocols' )
87- print ('Linking analysis_protocol to analysis_process at {0}' .format (link_url ))
88+ link_url = get_subject_url (endpoint_dict = analysis_process_response , subject = 'protocols' )
89+
90+ # URL for linking the analysis protocol to analysis process, e.g.
91+ # http://api.ingest.integration.data.humancellatlas.org/protocols/{protocol_document_id}
92+ analysis_protocol_entity_url = get_subject_url (analysis_protocol_response , 'self' )
93+
94+ print ('Linking analysis_protocol {0} to analysis_process at {1}' .format (analysis_protocol_entity_url , link_url ))
8895 link_analysis_protocol_to_analysis_process (link_url = link_url ,
89- analysis_protocol_url = analysis_protocol_url ,
96+ analysis_protocol_url = analysis_protocol_entity_url ,
9097 http_requests = http_requests )
9198
9299 # === 6. Add input bundle references ===
93- input_bundles_url = get_subject_url (endpoint_dict = analysis_process , subject = 'add-input-bundles' )
100+ input_bundles_url = get_subject_url (endpoint_dict = analysis_process_response , subject = 'add-input-bundles' )
94101 print ('Adding input bundles at {0}' .format (input_bundles_url ))
95102 add_input_bundles (input_bundles_url = input_bundles_url ,
96103 auth_headers = auth_headers ,
97104 analysis_process = analysis_process_dict ,
98105 http_requests = http_requests )
99106
100107 # === 7. Add file references ===
101- file_refs_url = get_subject_url (endpoint_dict = analysis_process , subject = 'add-file-reference' )
108+ file_refs_url = get_subject_url (endpoint_dict = analysis_process_response , subject = 'add-file-reference' )
102109 print ('Adding file references at {0}' .format (file_refs_url ))
103110 output_files = get_output_files (analysis_process = analysis_process_dict ,
104111 raw_schema_url = raw_schema_url ,
@@ -191,6 +198,8 @@ def get_analysis_protocol(analysis_protocol_url, auth_headers, protocol_id, http
191198 print ('Found existing analysis_protocol for pipeline version {0} in {1}' .format (
192199 protocol_id , analysis_protocol_url ))
193200 return protocol
201+
202+ print ("Cannot find any existing analysis_protocol with id: {0}" .format (protocol_id ))
194203 return None
195204
196205
@@ -231,15 +240,15 @@ def add_analysis_protocol(analysis_protocol_url, auth_headers, analysis_protocol
231240 http_requests (http_requests.HttpRequests): The HttpRequests object to use for talking to Ingest.
232241
233242 Returns:
234- analysis_protocol (dict): A dict represents the JSON response from adding the analysis protocol.
243+ analysis_protocol_response (dict): A dict represents the JSON response from adding the analysis protocol.
235244
236245 Raises:
237246 requests.HTTPError: For 4xx errors or 5xx errors beyond timeout.
238247 """
239248 print ('Adding analysis_protocol at {0}' .format (analysis_protocol_url ))
240249 response = http_requests .post (analysis_protocol_url , headers = auth_headers , json = analysis_protocol )
241- analysis_protocol = response .json ()
242- return analysis_protocol
250+ analysis_protocol_response = response .json ()
251+ return analysis_protocol_response
243252
244253
245254def add_analysis_process (analysis_process_url , auth_headers , analysis_process , http_requests ):
@@ -252,15 +261,15 @@ def add_analysis_process(analysis_process_url, auth_headers, analysis_process, h
252261 http_requests (http_requests.HttpRequests): The HttpRequests object to use for talking to Ingest.
253262
254263 Returns:
255- analysis_process (dict): A dict represents the JSON response from adding the analysis process.
264+ analysis_process_response (dict): A dict represents the JSON response from adding the analysis process.
256265
257266 Raises:
258267 requests.HTTPError: For 4xx errors or 5xx errors beyond timeout.
259268 """
260269 print ('Adding analysis_process at {0}' .format (analysis_process_url ))
261270 response = http_requests .post (analysis_process_url , headers = auth_headers , json = analysis_process )
262- analysis_process = response .json ()
263- return analysis_process
271+ analysis_process_response = response .json ()
272+ return analysis_process_response
264273
265274
266275def add_input_bundles (input_bundles_url , auth_headers , analysis_process , http_requests ):
0 commit comments