@@ -513,6 +513,7 @@ def get_resource_allocation_info(self):
513
513
part = f'{ days } -{ str (td )} '
514
514
else :
515
515
part = str (td )
516
+ part = part .split ('.' )[0 ]
516
517
else :
517
518
part = naturalsize (
518
519
value , gnu = True , format = '%.0f' )
@@ -1305,11 +1306,17 @@ def _complete_artifact_definition(self, artifact_data):
1305
1306
an = None
1306
1307
data_type = 'Job Output Folder'
1307
1308
1308
- qdb .artifact .Artifact .create (
1309
+ artifact = qdb .artifact .Artifact .create (
1309
1310
filepaths , atype , prep_template = pt , analysis = an ,
1310
1311
data_type = data_type , name = job_params ['name' ])
1311
1312
self ._set_status ('success' )
1312
1313
1314
+ # we need to update the children jobs to replace the input
1315
+ # for the newly created artifact via the validator
1316
+ for c in self .children :
1317
+ self ._helper_update_children ({atype : artifact .id })
1318
+ c .submit ()
1319
+
1313
1320
def _complete_artifact_transformation (self , artifacts_data ):
1314
1321
"""Performs the needed steps to complete an artifact transformation job
1315
1322
@@ -1678,6 +1685,42 @@ def validator_jobs(self):
1678
1685
for jid in qdb .sql_connection .TRN .execute_fetchflatten ():
1679
1686
yield ProcessingJob (jid )
1680
1687
1688
+ def _helper_update_children (self , new_map ):
1689
+ ready = []
1690
+ sql = """SELECT command_parameters, pending
1691
+ FROM qiita.processing_job
1692
+ WHERE processing_job_id = %s"""
1693
+ sql_update = """UPDATE qiita.processing_job
1694
+ SET command_parameters = %s,
1695
+ pending = %s
1696
+ WHERE processing_job_id = %s"""
1697
+ sql_link = """INSERT INTO qiita.artifact_processing_job
1698
+ (artifact_id, processing_job_id)
1699
+ VALUES (%s, %s)"""
1700
+
1701
+ for c in self .children :
1702
+ qdb .sql_connection .TRN .add (sql , [c .id ])
1703
+ params , pending = qdb .sql_connection .TRN .execute_fetchflatten ()
1704
+ for pname , out_name in pending [self .id ].items ():
1705
+ a_id = new_map [out_name ]
1706
+ params [pname ] = str (a_id )
1707
+ del pending [self .id ]
1708
+ # Link the input artifact with the child job
1709
+ qdb .sql_connection .TRN .add (sql_link , [a_id , c .id ])
1710
+
1711
+ # Force to insert a NULL in the DB if pending is empty
1712
+ pending = pending if pending else None
1713
+ qdb .sql_connection .TRN .add (sql_update ,
1714
+ [dumps (params ), pending , c .id ])
1715
+ qdb .sql_connection .TRN .execute ()
1716
+
1717
+ if pending is None :
1718
+ # The child already has all the parameters
1719
+ # Add it to the ready list
1720
+ ready .append (c )
1721
+
1722
+ return ready
1723
+
1681
1724
def _update_children (self , mapping ):
1682
1725
"""Updates the children of the current job to populate the input params
1683
1726
@@ -1691,7 +1734,6 @@ def _update_children(self, mapping):
1691
1734
list of qiita_db.processing_job.ProcessingJob
1692
1735
The list of childrens that are ready to be submitted
1693
1736
"""
1694
- ready = []
1695
1737
with qdb .sql_connection .TRN :
1696
1738
sql = """SELECT command_output_id, name
1697
1739
FROM qiita.command_output
@@ -1701,37 +1743,7 @@ def _update_children(self, mapping):
1701
1743
res = qdb .sql_connection .TRN .execute_fetchindex ()
1702
1744
new_map = {name : mapping [oid ] for oid , name in res }
1703
1745
1704
- sql = """SELECT command_parameters, pending
1705
- FROM qiita.processing_job
1706
- WHERE processing_job_id = %s"""
1707
- sql_update = """UPDATE qiita.processing_job
1708
- SET command_parameters = %s,
1709
- pending = %s
1710
- WHERE processing_job_id = %s"""
1711
- sql_link = """INSERT INTO qiita.artifact_processing_job
1712
- (artifact_id, processing_job_id)
1713
- VALUES (%s, %s)"""
1714
- for c in self .children :
1715
- qdb .sql_connection .TRN .add (sql , [c .id ])
1716
- params , pending = qdb .sql_connection .TRN .execute_fetchflatten ()
1717
- for pname , out_name in pending [self .id ].items ():
1718
- a_id = new_map [out_name ]
1719
- params [pname ] = str (a_id )
1720
- del pending [self .id ]
1721
- # Link the input artifact with the child job
1722
- qdb .sql_connection .TRN .add (sql_link , [a_id , c .id ])
1723
-
1724
- # Force to insert a NULL in the DB if pending is empty
1725
- pending = pending if pending else None
1726
- qdb .sql_connection .TRN .add (sql_update ,
1727
- [dumps (params ), pending , c .id ])
1728
- qdb .sql_connection .TRN .execute ()
1729
-
1730
- if pending is None :
1731
- # The child already has all the parameters
1732
- # Add it to the ready list
1733
- ready .append (c )
1734
- return ready
1746
+ return self ._helper_update_children (new_map )
1735
1747
1736
1748
def _update_and_launch_children (self , mapping ):
1737
1749
"""Updates the children of the current job to populate the input params
0 commit comments