1717
1818
1919def py3_compatible (filePath : str ) -> bool :
20- """Determines if a python file is 3.x compatible by seeing if it compiles in a subprocess"""
20+ """
21+ Check file for Python 3.x compatibity.
22+
23+ (By seeing if it compiles in a subprocess)
24+ """
2125 try :
2226 check_call (
2327 [sys .executable , "-m" , "py_compile" , os .path .normpath (filePath )],
@@ -29,7 +33,7 @@ def py3_compatible(filePath: str) -> bool:
2933
3034
3135def get_version (extension : str , workflow_file : str ) -> str :
32- """Determines the version of a .py, .wdl, or .cwl file."""
36+ """Determine the version of a .py, .wdl, or .cwl file."""
3337 if extension == "py" and py3_compatible (workflow_file ):
3438 return "3"
3539 elif extension == "cwl" :
@@ -49,14 +53,13 @@ def get_version(extension: str, workflow_file: str) -> str:
4953
5054def wf_info (workflow_path : str ) -> Tuple [str , str ]:
5155 """
52- Returns the version of the file and the file extension.
56+ Return the version of the file and the file extension.
5357
5458 Assumes that the file path is to the file directly ie, ends with a valid
5559 file extension. Supports checking local files as well as files at http://
5660 and https:// locations. Files at these remote locations are recreated locally to
5761 enable our approach to version checking, then removed after version is extracted.
5862 """
59-
6063 supported_formats = ["py" , "wdl" , "cwl" ]
6164 file_type = workflow_path .lower ().split ("." )[- 1 ] # Grab the file extension
6265 workflow_path = workflow_path if ":" in workflow_path else "file://" + workflow_path
@@ -185,6 +188,7 @@ def build_wes_request(
185188
186189
187190def expand_globs (attachments : Optional [Union [List [str ], str ]]) -> Set [str ]:
191+ """Expand any globs present in the attachment list."""
188192 expanded_list = []
189193 if attachments is None :
190194 attachments = []
@@ -200,7 +204,8 @@ def expand_globs(attachments: Optional[Union[List[str], str]]) -> Set[str]:
200204 return set (expanded_list )
201205
202206
203- def wes_reponse (postresult : requests .Response ) -> Dict [str , Any ]:
207+ def wes_response (postresult : requests .Response ) -> Dict [str , Any ]:
208+ """Convert a Response object to JSON text."""
204209 if postresult .status_code != 200 :
205210 error = str (json .loads (postresult .text ))
206211 logging .error (error )
@@ -210,7 +215,10 @@ def wes_reponse(postresult: requests.Response) -> Dict[str, Any]:
210215
211216
212217class WESClient :
218+ """WES client."""
219+
213220 def __init__ (self , service : Dict [str , Any ]):
221+ """Initialize the cliet with the provided credentials and endpoint."""
214222 self .auth = service ["auth" ]
215223 self .proto = service ["proto" ]
216224 self .host = service ["host" ]
@@ -232,7 +240,7 @@ def get_service_info(self) -> Dict[str, Any]:
232240 f"{ self .proto } ://{ self .host } /ga4gh/wes/v1/service-info" ,
233241 headers = self .auth ,
234242 )
235- return wes_reponse (postresult )
243+ return wes_response (postresult )
236244
237245 def list_runs (self ) -> Dict [str , Any ]:
238246 """
@@ -249,7 +257,7 @@ def list_runs(self) -> Dict[str, Any]:
249257 postresult = requests .get ( # nosec B113
250258 f"{ self .proto } ://{ self .host } /ga4gh/wes/v1/runs" , headers = self .auth
251259 )
252- return wes_reponse (postresult )
260+ return wes_response (postresult )
253261
254262 def run (
255263 self , wf : str , jsonyaml : str , attachments : Optional [List [str ]]
@@ -273,7 +281,7 @@ def run(
273281 files = parts ,
274282 headers = self .auth ,
275283 )
276- return wes_reponse (postresult )
284+ return wes_response (postresult )
277285
278286 def cancel (self , run_id : str ) -> Dict [str , Any ]:
279287 """
@@ -289,7 +297,7 @@ def cancel(self, run_id: str) -> Dict[str, Any]:
289297 f"{ self .proto } ://{ self .host } /ga4gh/wes/v1/runs/{ run_id } /cancel" ,
290298 headers = self .auth ,
291299 )
292- return wes_reponse (postresult )
300+ return wes_response (postresult )
293301
294302 def get_run_log (self , run_id : str ) -> Dict [str , Any ]:
295303 """
@@ -305,7 +313,7 @@ def get_run_log(self, run_id: str) -> Dict[str, Any]:
305313 f"{ self .proto } ://{ self .host } /ga4gh/wes/v1/runs/{ run_id } " ,
306314 headers = self .auth ,
307315 )
308- return wes_reponse (postresult )
316+ return wes_response (postresult )
309317
310318 def get_run_status (self , run_id : str ) -> Dict [str , Any ]:
311319 """
@@ -321,4 +329,4 @@ def get_run_status(self, run_id: str) -> Dict[str, Any]:
321329 f"{ self .proto } ://{ self .host } /ga4gh/wes/v1/runs/{ run_id } /status" ,
322330 headers = self .auth ,
323331 )
324- return wes_reponse (postresult )
332+ return wes_response (postresult )
0 commit comments