Commit 168a98e1 authored by David Trudgian's avatar David Trudgian
Browse files

Support parameter substitutions

parent 1400a1f9
...@@ -101,7 +101,7 @@ parameter file that you should correct before submitting to the cluster. ...@@ -101,7 +101,7 @@ parameter file that you should correct before submitting to the cluster.
The example below includes documentation of each parameter, and can be The example below includes documentation of each parameter, and can be
used as a starting point for your own parameter files used as a starting point for your own parameter files
```yaml ``` yaml
# The command to run, including any arguments that always stay the same, # The command to run, including any arguments that always stay the same,
# and will not be explored by the runner. # and will not be explored by the runner.
...@@ -162,7 +162,7 @@ time_limit: 3-00:00 ...@@ -162,7 +162,7 @@ time_limit: 3-00:00
# #
# For each parameter the following properties are required: # For each parameter the following properties are required:
# #
# type: 'int_range' A range of integers -or- # type: 'int_range' A range of integers -or-
# 'real_range' A range of real numbers -or- # 'real_range' A range of real numbers -or-
# 'choice' A list of string options # 'choice' A list of string options
# #
...@@ -172,6 +172,10 @@ time_limit: 3-00:00 ...@@ -172,6 +172,10 @@ time_limit: 3-00:00
# flag: '--example' A flag which should proceed the value of the paremeter # flag: '--example' A flag which should proceed the value of the paremeter
# optional: true If true, we consider combinations excluding this parameter # optional: true If true, we consider combinations excluding this parameter
# #
# substitution: '%1' If substitution is specfied, the parameter value
# optional: true will replace the placeholder supplied in the
# command, instead of being appended to the command
#
# int_range and real_range types take paremeters: # int_range and real_range types take paremeters:
# #
# min: 10 Minimum value for the parameter # min: 10 Minimum value for the parameter
...@@ -230,4 +234,4 @@ parameters: ...@@ -230,4 +234,4 @@ parameters:
- sigmoid - sigmoid
description: Activation function description: Activation function
``` ```
\ No newline at end of file
...@@ -236,11 +236,13 @@ class ParamFile(object): ...@@ -236,11 +236,13 @@ class ParamFile(object):
current_param = params[param_idx] current_param = params[param_idx]
current_id = current_param['id'] current_id = current_param['id']
current_flag = current_param.get('flag', None) current_flag = current_param.get('flag', None)
current_sub = current_param.get('substitution', None)
num_values = len(current_param['range']) num_values = len(current_param['range'])
for val_idx in range(num_values): for val_idx in range(num_values):
current_value = current_param['range'][val_idx] current_value = current_param['range'][val_idx]
current_combination[current_id] = {'flag': current_flag, current_combination[current_id] = {'flag': current_flag,
'substitution': current_sub,
'value': current_value} 'value': current_value}
all_combinations = self.__recurse_arg_combns(param_idx + 1, all_combinations = self.__recurse_arg_combns(param_idx + 1,
deepcopy( deepcopy(
...@@ -264,11 +266,19 @@ class ParamFile(object): ...@@ -264,11 +266,19 @@ class ParamFile(object):
for arg in arg_combn.values(): for arg in arg_combn.values():
if arg['flag'] and arg['value'] is not None:
cmd_str += arg['flag'] + ' '
if arg['value'] is not None: # In substitution mode we replace a placeholder in the command string
cmd_str += str(arg['value']) + ' ' if arg['substitution'] is not None:
cmd_str = cmd_str.replace(arg['substitution'], arg['value'])
# Otherwise we append args, possibly prefixed with specified flags
else:
if arg['flag'] and arg['value'] is not None:
cmd_str += arg['flag'] + ' '
if arg['value'] is not None:
cmd_str += str(arg['value']) + ' '
return cmd_str.rstrip(' ') return cmd_str.rstrip(' ')
......
...@@ -132,6 +132,9 @@ ...@@ -132,6 +132,9 @@
}, },
"description":{ "description":{
"type":"string" "type":"string"
},
"substitution":{
"type":"string"
} }
}, },
"required":[ "required":[
...@@ -174,6 +177,9 @@ ...@@ -174,6 +177,9 @@
}, },
"description":{ "description":{
"type":"string" "type":"string"
},
"substitution":{
"type":"string"
} }
}, },
"required":[ "required":[
...@@ -211,6 +217,9 @@ ...@@ -211,6 +217,9 @@
}, },
"description":{ "description":{
"type":"string" "type":"string"
},
"substitution":{
"type":"string"
} }
}, },
"required":[ "required":[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment