Skip to content

Commit b18a434

Browse files
committed
Added doc strings to functions
Also added timeouts to requests get responses
1 parent 7878540 commit b18a434

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Diff for: cwl_utils/inputs_schema_gen.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,11 @@ def cwl_to_jsonschema(cwl_obj: Union[Workflow, CommandLineTool]) -> Any:
370370

371371
# Traverse the properties and return all definitions that are used
372372
def _recursive_search(json_data, target_key, result=None):
373+
"""
374+
Function for slim_definitions.
375+
376+
Given a target key return all instances of a key in a json object.
377+
"""
373378
if result is None:
374379
result = []
375380

@@ -388,6 +393,11 @@ def _recursive_search(json_data, target_key, result=None):
388393

389394
# Get all the property dependencies
390395
def _get_all_ref_attributes(json_object):
396+
"""
397+
Function get slim_definitions.
398+
399+
Given a json object, return all the reference attributes.
400+
"""
391401
return _recursive_search(json_object, "$ref")
392402

393403

@@ -396,6 +406,11 @@ def get_property_dependencies(
396406
input_json_schema: Dict,
397407
existing_property_dependencies: List = None,
398408
) -> List[str]:
409+
"""
410+
Function for get slim_definitions.
411+
412+
Recursively collect all dependencies for a property (so we don't remove them from the schema).
413+
"""
399414
# Initialise return list
400415
if existing_property_dependencies is None:
401416
existing_property_dependencies = []
@@ -485,7 +500,7 @@ def get_cwl_url(url: str) -> str:
485500
return url
486501
else:
487502
# urlparse(url).scheme not in ['file']:
488-
response = requests.get(url)
503+
response = requests.get(url, timeout=20)
489504
if response.status_code != 200:
490505
logging.error("The CWL URL is invalid.")
491506
raise FileNotFoundError

Diff for: cwl_utils/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def load_schema_from_uri(uri_input: str) -> InputRecordSchema:
457457
else:
458458
# On the internet somewhere!
459459
file_path = temp_file_obj.name
460-
response = requests.get(uri_input)
460+
response = requests.get(uri_input, timeout=20)
461461
with open(temp_file_obj.name, "w") as file_h:
462462
file_h.write(response.text)
463463

0 commit comments

Comments
 (0)