Skip to content

Commit

Permalink
Add monitoring image to workflow options (#189)
Browse files Browse the repository at this point in the history
* Add monitoring image to wf options

* Update unit tests

* Fix adding monitoring image to options
  • Loading branch information
samanehsan authored Oct 21, 2019
1 parent f5c5b7e commit 144f9cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lira/lira_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,18 @@ def compose_config_options(cromwell_options_file, lira_config):
cromwell_options_file = cromwell_options_file.decode()
options_json = json.loads(cromwell_options_file)

# If a monitoring image is defined in the config, add it to the options JSON
monitoring_image = getattr(lira_config, 'monitoring_image', None)
if monitoring_image:
options_json['monitoring_image'] = lira_config.monitoring_image

# Defer to value already in options file if it exists
# Docs on default runtime attributes: https://cromwell.readthedocs.io/en/latest/wf_options/Overview/
runtime_parameters = options_json.get('default_runtime_attributes', {})
if 'maxRetries' not in runtime_parameters.keys():
options_json['default_runtime_attributes'] = {
'maxRetries': lira_config.max_cromwell_retries
}

return json.dumps(options_json).encode('utf-8')


Expand Down
9 changes: 9 additions & 0 deletions lira/test/test_lira_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,15 @@ def test_max_retries_uses_value_from_lira_config_if_not_set_in_options(self):
max_retries = json.loads(options)['default_runtime_attributes']['maxRetries']
self.assertEqual(max_retries, expected_max_retries)

def test_monitoring_image_passed_from_config_to_workflow_options(self):
test_config = deepcopy(self.correct_test_config)
test_image_name = "gcr.io/test_project/test_image"
test_config['monitoring_image'] = test_image_name
config = lira_config.LiraConfig(test_config)
options = lira_utils.compose_config_options(self.options_json, config)
image_name = json.loads(options)['monitoring_image']
self.assertEqual(image_name, test_image_name)

def test_parse_github_resource_url(self):
"""Test if parse_github_resource_url can correctly parse Github resource urls."""
self.assertEqual(
Expand Down

0 comments on commit 144f9cb

Please sign in to comment.