Skip to content

Commit

Permalink
Merge pull request #143 from glatard/develop
Browse files Browse the repository at this point in the history
Fixed example1 and made minor updates in validator
  • Loading branch information
gkiar committed Sep 18, 2017
2 parents 52d1246 + 5bff791 commit 415ce62
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 85 deletions.
2 changes: 2 additions & 0 deletions examples/example1/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM centos:latest
ADD exampleTool1 /bin
183 changes: 104 additions & 79 deletions examples/example1/example1.json
Original file line number Diff line number Diff line change
@@ -1,82 +1,107 @@
{
"name" : "Example Boutiques Tool",
"tool-version" : "0.0.1",
"description" : "This property describes the tool or application",
"command-line" : "exampleTool1 [STRING_INPUT] [FILE_INPUT] [ENUM_INPUT] | exampleTool2 [FLAG_INPUT] [NUMBER_INPUT] >> [LOG]",
"tool-version": "0.0.1",
"name": "Example Boutiques Tool",
"command-line": "exampleTool1 [STRING_INPUT] [FILE_INPUT] [FLAG_INPUT] [NUMBER_INPUT] [ENUM_INPUT] &> [LOG]",
"inputs": [
{
"command-line-flag": "-i",
"description": "Describe the use and meaning of the parameter",
"default-value": "aStringValue",
"value-key": "[STRING_INPUT]",
"type": "String",
"list": true,
"max-list-entries": 3,
"optional": false,
"id": "str_input",
"min-list-entries": 1,
"name": "A string input"
},
{
"command-line-flag": "-n",
"name": "A number input",
"value-key": "[NUMBER_INPUT]",
"type": "Number",
"exclusive-maximum": false,
"maximum": 1,
"minimum": 0,
"command-line-flag-separator": "=",
"integer": false,
"exclusive-minimum": true,
"optional": true,
"id": "num_input"
},
{
"value-key": "[FILE_INPUT]",
"optional": true,
"type": "File",
"id": "file_input",
"name": "A file input"
},
{
"name": "An enum input",
"value-key": "[ENUM_INPUT]",
"optional": true,
"value-choices": [
"val1",
"val2",
"val3"
],
"type": "String",
"id": "enum_input"
},
{
"command-line-flag": "-f",
"name": "A flag input",
"value-key": "[FLAG_INPUT]",
"optional": true,
"requires-inputs": [
"file_input"
],
"disables-inputs": [
"num_input"
],
"type": "Flag",
"id": "flag_input"
}
],
"container-image": {
"type": "docker",
"image": "boutiques/examples"
},
"schema-version" : "0.4",
"inputs" : [{
"id" : "str_input",
"name" : "A string input",
"type" : "String",
"description" : "Describe the use and meaning of the parameter",
"optional" : false,
"command-line-flag" : "-i",
"value-key" : "[STRING_INPUT]",
"list" : true,
"min-list-entries" : 1,
"max-list-entries" : 3,
"default-value" : "aStringValue"
}, {
"id" : "num_input",
"name" : "A number input",
"type" : "Number",
"value-key" : "[NUMBER_INPUT]",
"optional" : true,
"command-line-flag" : "-n",
"command-line-separator" : "=",
"minimum" : 0,
"maximum" : 1,
"exclusive-minimum" : true,
"exclusive-maximum" : false,
"integer" : false
}, {
"id" : "file_input",
"name" : "A file input",
"type" : "File",
"optional" : true,
"value-key" : "[FILE_INPUT]"
}, {
"id" : "enum_input",
"name" : "An enum input",
"type" : "Enum",
"enum-value-choices" : ["val1","val2","val3"],
"value-key" : "[ENUM_INPUT]",
"optional": true
}, {
"id" : "flag_input",
"name" : "A flag input",
"type" : "Flag",
"command-line-flag" : "-f",
"value-key" : "[FLAG_INPUT]",
"requires-inputs" : ["file_input"],
"disables-inputs" : ["num_input"],
"optional": true
}],
"output-files" : [{
"id" : "logfile",
"name" : "Log file",
"description" : "The output log file from the example tool",
"path-template" : "log-[STRING_INPUT].txt",
"value-key" : "[LOG]",
"path-template-stripped-extensions" : [".txt", ".csv"],
"optional" : false
}, {
"id" : "output_files",
"name" : "outfiles",
"list" : true,
"path-template" : "output/*_exampleOutputTag.resultType",
"optional" : true
}],
"groups" : [{
"id" : "an_example_group",
"name" : "Example group 1",
"description" : "This group forces us to choose exactly one of the file or the enum input to use.",
"members" : ["file_input", "enum_input"],
"mutually-exclusive" : true,
"one-is-required" : true
}]
"image": "boutiques/examples",
"type": "docker"
},
"schema-version": "0.5",
"groups": [
{
"description": "This group forces us to choose exactly one of the file or the enum input to use.",
"one-is-required": true,
"mutually-exclusive": true,
"members": [
"file_input",
"enum_input"
],
"id": "an_example_group",
"name": "Example group 1"
}
],
"output-files": [
{
"description": "The output log file from the example tool",
"value-key": "[LOG]",
"id": "logfile",
"optional": false,
"path-template": "log-[STRING_INPUT].txt",
"path-template-stripped-extensions": [
".txt",
".csv"
],
"name": "Log file"
},
{
"path-template": "output/*_exampleOutputTag.resultType",
"optional": true,
"list": true,
"id": "output_files",
"name": "outfiles"
}
],
"description": "This property describes the tool or application"
}
5 changes: 5 additions & 0 deletions examples/example1/exampleTool1
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#!/bin/bash

set -e
set -u

test -f $3 || echo "$3 does not exist"

echo $*
5 changes: 0 additions & 5 deletions examples/example1/exampleTool2

This file was deleted.

9 changes: 9 additions & 0 deletions examples/example1/invocation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"inputs" : [
{ "str_input" : "foo" },
{ "num_input" : 4 },
{ "file_input" : "test.txt" },
{ "enum_input" : "val1" }
]
}

3 changes: 2 additions & 1 deletion tools/python/boutiques/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def validate_json(json_file):
validate(descriptor, schema)
except ValidationError as e:
print("JSON Validation error (Rigorous Boutiques validation not yet performed)")
print(str(e))
raise ValidationError(e)

# Helper get-function
Expand Down Expand Up @@ -122,7 +123,7 @@ def validate_json(json_file):
msg_template = " InputError: \"{}\" must have a command-line flag"
errors += [msg_template.format(inp["id"])] if "command-line-flag" not in inp.keys() else []

msg_template = " InputError: \"{}\" should not be required"
msg_template = " InputError: \"{}\" is of type Flag, it has to be optional"
errors += [msg_template.format(inp["id"])] if inp["optional"] is False else []

# Verify number-type inputs min/max are sensible
Expand Down

0 comments on commit 415ce62

Please sign in to comment.