Skip to content

Commit ab0fc68

Browse files
authored
Fix analysis protocol linking issue (#96)
* Fix the linking step by passing in the correct url to analysis_protocol entity. * Switch to use self than protocol to get the analysis protocol url from the Ingest response. * Update docker tags in WDLs to prepare for releases.
1 parent c1df3ec commit ab0fc68

File tree

6 files changed

+86
-32
lines changed

6 files changed

+86
-32
lines changed

adapter_pipelines/Optimus/adapter.wdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ workflow AdapterOptimus {
127127
Int max_cromwell_retries = 0
128128
Boolean add_md5s = false
129129

130-
String pipeline_tools_version = "v0.36.0"
130+
String pipeline_tools_version = "v0.38.0"
131131

132132
call GetInputs as prep {
133133
input:

adapter_pipelines/cellranger/adapter.wdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ workflow Adapter10xCount {
150150
Int max_cromwell_retries = 0
151151
Boolean add_md5s = false
152152

153-
String pipeline_tools_version = "v0.37.0"
153+
String pipeline_tools_version = "v0.38.0"
154154

155155
call GetInputs {
156156
input:

adapter_pipelines/ss2_single_sample/adapter.wdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ workflow AdapterSmartSeq2SingleCell{
8383
Int max_cromwell_retries = 0
8484
Boolean add_md5s = false
8585

86-
String pipeline_tools_version = "v0.36.0"
86+
String pipeline_tools_version = "v0.38.0"
8787

8888
call GetInputs as prep {
8989
input:

pipeline_tools/create_envelope.py

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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

245254
def 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

266275
def add_input_bundles(input_bundles_url, auth_headers, analysis_process, http_requests):
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"content" : {
3+
"computational_method" : "SmartSeq2SingleCell",
4+
"describedBy" : "http://schema.integration.data.humancellatlas.org/type/protocol/analysis/8.0.3/analysis_protocol",
5+
"protocol_core" : {
6+
"protocol_id" : "smartseq2_v2.1.0"
7+
},
8+
"protocol_type" : {
9+
"text" : "analysis"
10+
},
11+
"schema_type" : "protocol"
12+
},
13+
"submissionDate" : "2018-10-20T21:00:39.156Z",
14+
"updateDate" : "2018-10-20T21:00:39.156Z",
15+
"user" : null,
16+
"lastModifiedUser" : null,
17+
"uuid" : null,
18+
"events" : [ ],
19+
"accession" : null,
20+
"validationState" : "Draft",
21+
"validationErrors" : null,
22+
"_links" : {
23+
"self" : {
24+
"href" : "http://api.ingest.integration.data.humancellatlas.org/protocols/5bcb9777593d3c0007227a54"
25+
},
26+
"protocol" : {
27+
"href" : "http://api.ingest.integration.data.humancellatlas.org/protocols/5bcb9777593d3c0007227a54",
28+
"title" : "A single protocol"
29+
},
30+
"validating" : {
31+
"href" : "http://api.ingest.integration.data.humancellatlas.org/protocols/5bcb9777593d3c0007227a54/validatingEvent"
32+
},
33+
"submissionEnvelopes" : {
34+
"href" : "http://api.ingest.integration.data.humancellatlas.org/protocols/5bcb9777593d3c0007227a54/submissionEnvelopes",
35+
"title" : "Access or create new submission envelopes"
36+
}
37+
}
38+
}

pipeline_tools/tests/test_create_envelope.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class Data:
2727
with open('{0}analysis_protocol.json'.format(data_dir)) as f:
2828
analysis_protocol = json.load(f)
2929

30+
with open('{0}add_protocol_response.json'.format(data_dir)) as f:
31+
add_analysis_protocol_response = json.load(f)
32+
3033
analysis_protocol_id = analysis_protocol['protocol_core']['protocol_id']
3134
analysis_process_id = analysis_process['process_core']['process_id']
3235

@@ -43,6 +46,10 @@ def test_get_subject_url_for_protocols(self, test_data):
4346
entity_url = submit.get_subject_url(test_data.links_json, 'protocols')
4447
assert entity_url == 'http://api.ingest.dev.data.humancellatlas.org/protocols'
4548

49+
def test_get_subject_url_for_protocol_entity(self, test_data):
50+
entity_url = submit.get_subject_url(test_data.add_analysis_protocol_response, 'self')
51+
assert entity_url == 'http://api.ingest.integration.data.humancellatlas.org/protocols/5bcb9777593d3c0007227a54'
52+
4653
def test_get_subject_url_for_envelopes(self, test_data):
4754
entity_url = submit.get_subject_url(test_data.links_json, 'submissionEnvelopes')
4855
assert entity_url == 'http://api.ingest.dev.data.humancellatlas.org/submissionEnvelopes'

0 commit comments

Comments
 (0)