Skip to content

Commit 9cb8b64

Browse files
Workflows GUI (#3078)
* fix #3076 * addressing @ElDeveloper comments * adding workflows GUI * improve HTML * db changes and improvements * comment out new db changes * rm default_workflows from PluginHandler.get * Apply suggestions from code review [skip ci] Co-authored-by: Yoshiki Vázquez Baeza <yoshiki@ucsd.edu> Co-authored-by: Yoshiki Vázquez Baeza <yoshiki@ucsd.edu>
1 parent a6578bc commit 9cb8b64

File tree

17 files changed

+854
-524
lines changed

17 files changed

+854
-524
lines changed

.github/workflows/qiita-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ jobs:
174174
COVER_PACKAGE: ${{ matrix.cover_package }}
175175
run: |
176176
conda activate qiita
177-
bash -c 'source /home/runner/.profile; conda activate qtp-biom; start_biom --help'
178177
export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt
179178
export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test.cfg
180179
export REDBIOM_HOST="http://localhost:7379"

qiita_db/handlers/plugin.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def get(self, name, version):
8383
'commands': [c.name for c in plugin.commands],
8484
'publications': [{'DOI': doi, 'PubMed': pubmed}
8585
for doi, pubmed in plugin.publications],
86-
'default_workflows': [w.name
87-
for w in plugin.default_workflows],
8886
'type': plugin.type,
8987
'active': plugin.active}
9088
self.write(response)

qiita_db/handlers/tests/test_plugin.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ def test_get(self):
6161
'Single Rarefaction'],
6262
'publications': [{'DOI': '10.1038/nmeth.f.303',
6363
'PubMed': '20383131'}],
64-
'default_workflows': ['FASTQ upstream workflow',
65-
'FASTA upstream workflow',
66-
'Per sample FASTQ upstream workflow'],
6764
'type': 'artifact transformation',
6865
'active': False}
6966
self.assertEqual(loads(obs.body), exp)

qiita_db/processing_job.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,10 +1912,13 @@ def from_default_workflow(cls, user, dflt_wf, req_params, name=None,
19121912
# [0] in_degrees returns a tuple, where [0] is the element we want
19131913
all_nodes = {}
19141914
roots = {}
1915+
19151916
for node, position in in_degrees:
1917+
dp = node.default_parameter
1918+
cmd = dp.command
19161919
if position == 0:
1917-
roots[node] = (node.command, node.parameters)
1918-
all_nodes[node] = (node.command, node.parameters)
1920+
roots[node] = (cmd, dp)
1921+
all_nodes[node] = (cmd, dp)
19191922

19201923
# Check that we have all the required parameters
19211924
root_cmds = set(c for c, _ in roots.values())

qiita_db/software.py

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,24 +1232,6 @@ def start_script(self):
12321232
qdb.sql_connection.TRN.add(sql, [self.id])
12331233
return qdb.sql_connection.TRN.execute_fetchlast()
12341234

1235-
@property
1236-
def default_workflows(self):
1237-
"""Returns the default workflows attached to the current software
1238-
1239-
Returns
1240-
-------
1241-
generator of qiita_db.software.DefaultWorkflow
1242-
The defaultworkflows attached to the software
1243-
"""
1244-
with qdb.sql_connection.TRN:
1245-
sql = """SELECT default_workflow_id
1246-
FROM qiita.default_workflow
1247-
WHERE software_id = %s
1248-
ORDER BY default_workflow_id"""
1249-
qdb.sql_connection.TRN.add(sql, [self.id])
1250-
for wf_id in qdb.sql_connection.TRN.execute_fetchflatten():
1251-
yield DefaultWorkflow(wf_id)
1252-
12531235
@property
12541236
def type(self):
12551237
"""Returns the type of the software
@@ -1764,23 +1746,7 @@ class DefaultWorkflowNode(qdb.base.QiitaObject):
17641746
_table = "default_workflow_node"
17651747

17661748
@property
1767-
def command(self):
1768-
"""The command to execute in this node
1769-
1770-
Returns
1771-
-------
1772-
qiita_db.software.Command
1773-
"""
1774-
with qdb.sql_connection.TRN:
1775-
sql = """SELECT command_id
1776-
FROM qiita.default_workflow_node
1777-
WHERE default_workflow_node_id = %s"""
1778-
qdb.sql_connection.TRN.add(sql, [self.id])
1779-
cmd_id = qdb.sql_connection.TRN.execute_fetchlast()
1780-
return qdb.software.Command(cmd_id)
1781-
1782-
@property
1783-
def parameters(self):
1749+
def default_parameter(self):
17841750
"""The default parameter set to use in this node
17851751
17861752
Returns
@@ -1839,6 +1805,58 @@ class DefaultWorkflow(qdb.base.QiitaObject):
18391805
"""
18401806
_table = "default_workflow"
18411807

1808+
@classmethod
1809+
def iter(cls, active=True):
1810+
"""Iterates over all active DefaultWorkflow
1811+
1812+
Parameters
1813+
----------
1814+
active : bool, optional
1815+
If True will only return active software
1816+
1817+
Returns
1818+
-------
1819+
list of qiita_db.software.DefaultWorkflow
1820+
The DefaultWorkflow objects
1821+
"""
1822+
sql = """SELECT default_workflow_id
1823+
FROM qiita.default_workflow {0}
1824+
ORDER BY default_workflow_id""".format(
1825+
'WHERE active = True' if active else '')
1826+
with qdb.sql_connection.TRN:
1827+
qdb.sql_connection.TRN.add(sql)
1828+
for s_id in qdb.sql_connection.TRN.execute_fetchflatten():
1829+
yield cls(s_id)
1830+
1831+
@property
1832+
def active(self):
1833+
"""Retrieves active status of the default workflow
1834+
1835+
Retruns
1836+
----------
1837+
active : bool
1838+
active value
1839+
"""
1840+
with qdb.sql_connection.TRN:
1841+
sql = """SELECT active
1842+
FROM qiita.default_workflow
1843+
WHERE default_workflow_id = %s"""
1844+
qdb.sql_connection.TRN.add(sql, [self.id])
1845+
return qdb.sql_connection.TRN.execute_fetchlast()
1846+
1847+
@active.setter
1848+
def active(self, active):
1849+
"""Changes active status of the default workflow
1850+
1851+
Parameters
1852+
----------
1853+
active : bool
1854+
New active value
1855+
"""
1856+
sql = """UPDATE qiita.default_workflow SET active = %s
1857+
WHERE default_workflow_id = %s"""
1858+
qdb.sql_connection.perform_as_transaction(sql, [active, self._id])
1859+
18421860
@property
18431861
def name(self):
18441862
with qdb.sql_connection.TRN:
@@ -1848,6 +1866,23 @@ def name(self):
18481866
qdb.sql_connection.TRN.add(sql, [self.id])
18491867
return qdb.sql_connection.TRN.execute_fetchlast()
18501868

1869+
@property
1870+
def data_type(self):
1871+
"""Retrieves all the data_types the workflow accepts
1872+
1873+
Returns
1874+
----------
1875+
list of str
1876+
The data types
1877+
"""
1878+
with qdb.sql_connection.TRN:
1879+
sql = """SELECT data_type
1880+
FROM qiita.default_workflow_data_type
1881+
LEFT JOIN qiita.data_type USING (data_type_id)
1882+
WHERE default_workflow_id = %s"""
1883+
qdb.sql_connection.TRN.add(sql, [self.id])
1884+
return qdb.sql_connection.TRN.execute_fetchflatten()
1885+
18511886
@property
18521887
def graph(self):
18531888
"""Returns the graph that represents the workflow

qiita_db/support_files/patches/81.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,37 @@
33

44
ALTER TABLE qiita.prep_template ADD creation_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
55
ALTER TABLE qiita.prep_template ADD modification_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
6+
7+
8+
9+
-- Feb 23, 2021
10+
11+
-- a. Removing software_id from qiita.default_workflow and replacing it by a
12+
-- table which will like different data_types with the default_workflow +
13+
-- adding an active flag in case we need to deprecate default_workflows
14+
ALTER TABLE qiita.default_workflow DROP software_id;
15+
CREATE TABLE qiita.default_workflow_data_type (
16+
default_workflow_id BIGINT NOT NULL,
17+
data_type_id BIGINT NOT NULL,
18+
CONSTRAINT fk_default_workflow_id FOREIGN KEY ( default_workflow_id ) REFERENCES qiita.default_workflow( default_workflow_id ),
19+
CONSTRAINT fk_data_type_id FOREIGN KEY ( data_type_id ) REFERENCES qiita.data_type ( data_type_id ),
20+
PRIMARY KEY(default_workflow_id, data_type_id)
21+
);
22+
ALTER TABLE qiita.default_workflow ADD active BOOL DEFAULT TRUE;
23+
24+
-- b. Removing command_id from qiita.default_workflow_node and default_parameter_set as this information
25+
-- can be accessed via the default_parameter object (the info is duplicated)
26+
ALTER TABLE qiita.default_workflow_node DROP command_id;
27+
28+
-- c. Linking some of the data_types with the default_workflows; note that this
29+
-- is fine for the test database but we are going to need to clean up and
30+
-- insert the most up to date recommendations directly in qiita.ucsd.edu
31+
INSERT INTO qiita.default_workflow_data_type (default_workflow_id, data_type_id) VALUES
32+
-- data types:
33+
-- 1 | 16S
34+
-- 2 | 18S
35+
-- 3 | ITS
36+
(1, 1),
37+
(1, 2),
38+
(2, 2),
39+
(3, 3);

qiita_db/support_files/qiita-db.dbs

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -524,20 +524,27 @@
524524
</table>
525525
<table name="default_workflow" >
526526
<column name="default_workflow_id" type="bigserial" jt="-5" mandatory="y" />
527-
<column name="software_id" type="bigint" jt="-5" mandatory="y" />
528527
<column name="name" type="varchar" jt="12" mandatory="y" />
528+
<column name="active" type="boolean" jt="-7" />
529529
<index name="pk_default_workflow" unique="PRIMARY_KEY" >
530530
<column name="default_workflow_id" />
531531
</index>
532532
<index name="idx_default_workflow" unique="UNIQUE_KEY" >
533-
<column name="software_id" />
534533
<column name="name" />
535534
</index>
536-
<index name="idx_default_workflow" unique="NORMAL" >
537-
<column name="software_id" />
535+
</table>
536+
<table name="default_workflow_data_type" prior="tbl" >
537+
<column name="default_workflow_id" type="bigint" jt="-5" mandatory="y" />
538+
<column name="data_type_id" type="bigint" jt="-5" mandatory="y" />
539+
<index name="pk_default_workflow_data_type" unique="PRIMARY_KEY" >
540+
<column name="default_workflow_id" />
541+
<column name="data_type_id" />
538542
</index>
539-
<fk name="fk_default_workflow_software" to_schema="qiita" to_table="software" >
540-
<fk_column name="software_id" pk="software_id" />
543+
<fk name="fk_default_workflow_id" to_schema="qiita" to_table="default_workflow" >
544+
<fk_column name="default_workflow_id" pk="default_workflow_id" />
545+
</fk>
546+
<fk name="fk_data_type_id" to_schema="qiita" to_table="data_type" >
547+
<fk_column name="data_type_id" pk="data_type_id" />
541548
</fk>
542549
</table>
543550
<table name="default_workflow_edge" >
@@ -591,11 +598,7 @@
591598
<table name="default_workflow_node" >
592599
<column name="default_workflow_node_id" type="bigserial" jt="-5" mandatory="y" />
593600
<column name="default_workflow_id" type="bigint" jt="-5" mandatory="y" />
594-
<column name="command_id" type="bigint" jt="-5" mandatory="y" />
595601
<column name="default_parameter_set_id" type="bigint" jt="-5" mandatory="y" />
596-
<index name="idx_default_workflow_command" unique="NORMAL" >
597-
<column name="command_id" />
598-
</index>
599602
<index name="idx_default_workflow_command" unique="NORMAL" >
600603
<column name="default_parameter_set_id" />
601604
</index>
@@ -605,9 +608,6 @@
605608
<index name="pk_default_workflow_command" unique="PRIMARY_KEY" >
606609
<column name="default_workflow_node_id" />
607610
</index>
608-
<fk name="fk_default_workflow_command" to_schema="qiita" to_table="software_command" >
609-
<fk_column name="command_id" pk="command_id" />
610-
</fk>
611611
<fk name="fk_default_workflow_command_0" to_schema="qiita" to_table="default_parameter_set" >
612612
<fk_column name="default_parameter_set_id" pk="default_parameter_set_id" />
613613
</fk>
@@ -1696,24 +1696,25 @@ Controlled Vocabulary]]></comment>
16961696
<entity schema="qiita" name="archive_merging_scheme" color="B2CDF7" x="1248" y="1472" />
16971697
<entity schema="qiita" name="artifact" color="B2CDF7" x="1200" y="880" />
16981698
<entity schema="qiita" name="artifact_filepath" color="B2CDF7" x="1040" y="960" />
1699-
<entity schema="qiita" name="artifact_output_processing_job" color="B2CDF7" x="1760" y="1376" />
1700-
<entity schema="qiita" name="artifact_processing_job" color="B2CDF7" x="1728" y="1280" />
1699+
<entity schema="qiita" name="artifact_output_processing_job" color="B2CDF7" x="1760" y="1392" />
1700+
<entity schema="qiita" name="artifact_processing_job" color="B2CDF7" x="1760" y="1296" />
17011701
<entity schema="qiita" name="artifact_type" color="D0DEF5" x="1408" y="880" />
17021702
<entity schema="qiita" name="artifact_type_filepath_type" color="B2CDF7" x="1376" y="736" />
17031703
<entity schema="qiita" name="checksum_algorithm" color="B2CDF7" x="736" y="960" />
17041704
<entity schema="qiita" name="column_controlled_vocabularies" color="D0DEF5" x="272" y="1168" />
17051705
<entity schema="qiita" name="column_ontology" color="D0DEF5" x="272" y="1424" />
1706-
<entity schema="qiita" name="command_output" color="B2CDF7" x="1728" y="1136" />
1707-
<entity schema="qiita" name="command_parameter" color="B2CDF7" x="2192" y="960" />
1706+
<entity schema="qiita" name="command_output" color="B2CDF7" x="1760" y="1152" />
1707+
<entity schema="qiita" name="command_parameter" color="B2CDF7" x="2192" y="896" />
17081708
<entity schema="qiita" name="controlled_vocab" color="D0DEF5" x="48" y="1168" />
17091709
<entity schema="qiita" name="controlled_vocab_values" color="D0DEF5" x="48" y="1296" />
17101710
<entity schema="qiita" name="data_directory" color="B2CDF7" x="576" y="928" />
17111711
<entity schema="qiita" name="data_type" color="D0DEF5" x="704" y="1120" />
17121712
<entity schema="qiita" name="default_parameter_set" color="B2CDF7" x="2416" y="1104" />
1713-
<entity schema="qiita" name="default_workflow" color="B2CDF7" x="2656" y="1040" />
1714-
<entity schema="qiita" name="default_workflow_edge" color="B2CDF7" x="2640" y="1232" />
1715-
<entity schema="qiita" name="default_workflow_edge_connections" color="B2CDF7" x="2384" y="1376" />
1716-
<entity schema="qiita" name="default_workflow_node" color="B2CDF7" x="2416" y="1232" />
1713+
<entity schema="qiita" name="default_workflow" color="B2CDF7" x="2672" y="1136" />
1714+
<entity schema="qiita" name="default_workflow_data_type" color="C1D8EE" x="2640" y="1008" />
1715+
<entity schema="qiita" name="default_workflow_edge" color="B2CDF7" x="2656" y="1248" />
1716+
<entity schema="qiita" name="default_workflow_edge_connections" color="B2CDF7" x="2576" y="1408" />
1717+
<entity schema="qiita" name="default_workflow_node" color="B2CDF7" x="2416" y="1264" />
17171718
<entity schema="qiita" name="ebi_run_accession" color="B2CDF7" x="1344" y="1104" />
17181719
<entity schema="qiita" name="environmental_package" color="B2CDF7" x="2176" y="176" />
17191720
<entity schema="qiita" name="filepath" color="C0D4F3" x="640" y="752" />
@@ -1727,42 +1728,42 @@ Controlled Vocabulary]]></comment>
17271728
<entity schema="qiita" name="oauth_identifiers" color="B7C8E3" x="2352" y="688" />
17281729
<entity schema="qiita" name="oauth_software" color="B2CDF7" x="2192" y="688" />
17291730
<entity schema="qiita" name="ontology" color="D0DEF5" x="576" y="1408" />
1730-
<entity schema="qiita" name="parameter_artifact_type" color="B2CDF7" x="1728" y="1040" />
1731+
<entity schema="qiita" name="parameter_artifact_type" color="B2CDF7" x="1760" y="1056" />
17311732
<entity schema="qiita" name="parent_artifact" color="B2CDF7" x="1040" y="848" />
1732-
<entity schema="qiita" name="parent_processing_job" color="B2CDF7" x="2016" y="1392" />
1733+
<entity schema="qiita" name="parent_processing_job" color="B2CDF7" x="2032" y="1376" />
17331734
<entity schema="qiita" name="per_study_tags" color="B2CDF7" x="2192" y="528" />
17341735
<entity schema="qiita" name="portal_type" color="C0D4F3" x="768" y="560" />
17351736
<entity schema="qiita" name="prep_template" color="B2CDF7" x="1232" y="464" />
17361737
<entity schema="qiita" name="prep_template_filepath" color="B2CDF7" x="1024" y="416" />
1737-
<entity schema="qiita" name="prep_template_processing_job" color="B2CDF7" x="1728" y="928" />
1738+
<entity schema="qiita" name="prep_template_processing_job" color="B2CDF7" x="1760" y="928" />
17381739
<entity schema="qiita" name="prep_template_sample" color="D0DEF5" x="1152" y="304" />
17391740
<entity schema="qiita" name="prep_y" color="D0DEF5" x="992" y="304" />
1740-
<entity schema="qiita" name="processing_job" color="B2CDF7" x="1968" y="1072" />
1741-
<entity schema="qiita" name="processing_job_resource_allocation" color="C1D8EE" x="2656" y="1376" />
1742-
<entity schema="qiita" name="processing_job_status" color="B2CDF7" x="1728" y="1504" />
1743-
<entity schema="qiita" name="processing_job_validator" color="B2CDF7" x="2192" y="1392" />
1744-
<entity schema="qiita" name="processing_job_workflow" color="B2CDF7" x="2192" y="1504" />
1745-
<entity schema="qiita" name="processing_job_workflow_root" color="B2CDF7" x="2448" y="1504" />
1746-
<entity schema="qiita" name="publication" color="B2CDF7" x="1936" y="688" />
1741+
<entity schema="qiita" name="processing_job" color="B2CDF7" x="1984" y="1088" />
1742+
<entity schema="qiita" name="processing_job_resource_allocation" color="C1D8EE" x="2256" y="1408" />
1743+
<entity schema="qiita" name="processing_job_status" color="B2CDF7" x="1760" y="1504" />
1744+
<entity schema="qiita" name="processing_job_validator" color="B2CDF7" x="2224" y="1312" />
1745+
<entity schema="qiita" name="processing_job_workflow" color="B2CDF7" x="2224" y="1552" />
1746+
<entity schema="qiita" name="processing_job_workflow_root" color="B2CDF7" x="2496" y="1552" />
1747+
<entity schema="qiita" name="publication" color="B2CDF7" x="1936" y="656" />
17471748
<entity schema="qiita" name="qiita_user" color="D0DEF5" x="704" y="288" />
1748-
<entity schema="qiita" name="reference" color="C0D4F3" x="2016" y="1504" />
1749+
<entity schema="qiita" name="reference" color="C0D4F3" x="2032" y="1488" />
17491750
<entity schema="qiita" name="restrictions" color="B2CDF7" x="1584" y="400" />
17501751
<entity schema="qiita" name="sample_template_filepath" color="B2CDF7" x="1008" y="560" />
17511752
<entity schema="qiita" name="sample_x" color="D0DEF5" x="1568" y="288" />
17521753
<entity schema="qiita" name="severity" color="C0D4F3" x="1120" y="1296" />
17531754
<entity schema="qiita" name="software" color="B2CDF7" x="2432" y="896" />
1754-
<entity schema="qiita" name="software_artifact_type" color="B2CDF7" x="1984" y="944" />
1755-
<entity schema="qiita" name="software_command" color="B2CDF7" x="2192" y="1184" />
1756-
<entity schema="qiita" name="software_publication" color="B2CDF7" x="1920" y="784" />
1757-
<entity schema="qiita" name="software_type" color="B2CDF7" x="2640" y="912" />
1755+
<entity schema="qiita" name="software_artifact_type" color="B2CDF7" x="2000" y="976" />
1756+
<entity schema="qiita" name="software_command" color="B2CDF7" x="2208" y="1104" />
1757+
<entity schema="qiita" name="software_publication" color="B2CDF7" x="1904" y="768" />
1758+
<entity schema="qiita" name="software_type" color="B2CDF7" x="2640" y="896" />
17581759
<entity schema="qiita" name="stats_daily" color="B2CDF7" x="2464" y="400" />
17591760
<entity schema="qiita" name="study" color="D0DEF5" x="1776" y="208" />
17601761
<entity schema="qiita" name="study_artifact" color="B2CDF7" x="1600" y="720" />
17611762
<entity schema="qiita" name="study_environmental_package" color="B2CDF7" x="2176" y="80" />
17621763
<entity schema="qiita" name="study_person" color="C0D4F3" x="2000" y="224" />
17631764
<entity schema="qiita" name="study_portal" color="A8C4EF" x="1920" y="80" />
17641765
<entity schema="qiita" name="study_prep_template" color="D0DEF5" x="1536" y="560" />
1765-
<entity schema="qiita" name="study_publication" color="B2CDF7" x="1792" y="688" />
1766+
<entity schema="qiita" name="study_publication" color="B2CDF7" x="1776" y="672" />
17661767
<entity schema="qiita" name="study_sample" color="D0DEF5" x="1376" y="288" />
17671768
<entity schema="qiita" name="study_tags" color="B2CDF7" x="2176" y="416" />
17681769
<entity schema="qiita" name="study_users" color="D0DEF5" x="1776" y="96" />

0 commit comments

Comments
 (0)