Skip to content

Commit

Permalink
Last bits
Browse files Browse the repository at this point in the history
  • Loading branch information
josenavas committed Sep 27, 2016
1 parent a1df204 commit c86d37d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 4 additions & 2 deletions qiita_db/handlers/plugin.py
Expand Up @@ -100,15 +100,17 @@ def post(self, name, version):
cmd_desc = self.get_argument('description')
req_params = loads(self.get_argument('required_parameters'))
opt_params = loads(self.get_argument('optional_parameters'))
outputs = self.get_argument('outputs', None)
if outputs:
outputs = loads(outputs)
dflt_param_set = loads(self.get_argument('default_parameter_sets'))

parameters = req_params
parameters.update(opt_params)

cmd = qdb.software.Command.create(
plugin, cmd_name, cmd_desc, parameters)
plugin, cmd_name, cmd_desc, parameters, outputs)

# params = opt_params
if dflt_param_set is not None:
for name, vals in dflt_param_set.items():
qdb.software.DefaultParameters.create(name, cmd, **vals)
Expand Down
1 change: 1 addition & 0 deletions qiita_db/handlers/tests/test_plugin.py
Expand Up @@ -77,6 +77,7 @@ def test_post(self):
'optional_parameters': dumps({'param1': ['string', ''],
'param2': ['float', '1.5'],
'param3': ['boolean', 'True']}),
'outputs': dumps({'out1': 'BIOM'}),
'default_parameter_sets': dumps(
{'dflt1': {'param1': 'test',
'param2': '2.4',
Expand Down
21 changes: 11 additions & 10 deletions qiita_db/software.py
Expand Up @@ -147,7 +147,7 @@ def exists(cls, software, name):
return qdb.sql_connection.TRN.execute_fetchlast()

@classmethod
def create(cls, software, name, description, parameters, outputs):
def create(cls, software, name, description, parameters, outputs=None):
r"""Creates a new command in the system
The supported types for the parameters are:
Expand Down Expand Up @@ -175,7 +175,7 @@ def create(cls, software, name, description, parameters, outputs):
format is: {parameter_name: (parameter_type, default)},
where parameter_name, parameter_type and default are strings. If
default is None.
outputs : dict
outputs : dict, optional
The description of the outputs that this command generated. The
format is: {output_name: artifact_type}
Expand Down Expand Up @@ -285,14 +285,15 @@ def create(cls, software, name, description, parameters, outputs):
qdb.sql_connection.TRN.add(sql_type, sql_params, many=True)

# Add the outputs to the command
sql = """INSERT INTO qiita.command_output
(name, command_id, artifact_type_id)
VALUES (%s, %s, %s)"""
sql_args = [
[pname, c_id, qdb.util.convert_to_id(at, 'artifact_type')]
for pname, at in outputs.items()]
qdb.sql_connection.TRN.add(sql, sql_args, many=True)
qdb.sql_connection.TRN.execute()
if outputs:
sql = """INSERT INTO qiita.command_output
(name, command_id, artifact_type_id)
VALUES (%s, %s, %s)"""
sql_args = [
[pname, c_id, qdb.util.convert_to_id(at, 'artifact_type')]
for pname, at in outputs.items()]
qdb.sql_connection.TRN.add(sql, sql_args, many=True)
qdb.sql_connection.TRN.execute()

return cls(c_id)

Expand Down

0 comments on commit c86d37d

Please sign in to comment.