Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reprocess_job_id to PrepTemplate #3396

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions qiita_db/metadata_template/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,3 +1107,28 @@ def current_human_filtering(self, current_human_filtering):
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [current_human_filtering, self.id])
qdb.sql_connection.TRN.execute()

@property
def reprocess_job_id(self):
"""The job that was created to reprocess this prep info file

Returns
-------
bool or None
The reprocess_job_id of the prep file info
"""
with qdb.sql_connection.TRN:
sql = """SELECT reprocess_job_id
FROM qiita.prep_template
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [self.id])
return qdb.sql_connection.TRN.execute_fetchlast()

@reprocess_job_id.setter
def reprocess_job_id(self, reprocess_job_id):
with qdb.sql_connection.TRN:
sql = """UPDATE qiita.prep_template
SET reprocess_job_id = %s
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [reprocess_job_id, self.id])
qdb.sql_connection.TRN.execute()
15 changes: 15 additions & 0 deletions qiita_db/metadata_template/test/test_prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,21 @@ def test_current_human_filtering(self):
pt.current_human_filtering = False
self.assertFalse(pt.current_human_filtering)

def test_reprocess_job_id(self):
pt = qdb.metadata_template.prep_template.PrepTemplate(1)
# by default it should be None
self.assertIsNone(pt.reprocess_job_id)
# it should not accept an external_job_id
with self.assertRaises(ValueError):
pt.reprocess_job_id = '124567'
# but it should work fine with an uuid
jid = '6d368e16-2242-4cf8-87b4-a5dc40bb890b'
pt.reprocess_job_id = jid
self.assertEqual(pt.reprocess_job_id, jid)
# and it should be fine to return to its default value
pt.reprocess_job_id = None
self.assertIsNone(pt.reprocess_job_id)


EXP_PREP_TEMPLATE = (
'sample_name\tbarcode\tcenter_name\tcenter_project_name\t'
Expand Down
5 changes: 5 additions & 0 deletions qiita_db/support_files/patches/92.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ ALTER TABLE qiita.slurm_resource_allocations
-- Apr 21, 2024
-- Adding a new column: current_human_filtering to qiita.prep_template
ALTER TABLE qiita.prep_template ADD current_human_filtering boolean DEFAULT False;

-- Apr 22, 2024
-- Adding a new column: reprocess_job_id to qiita.prep_template to keep track of
-- the job that reprocessed this prep
ALTER TABLE qiita.prep_template ADD reprocess_job_id uuid DEFAULT NULL;
9 changes: 6 additions & 3 deletions qiita_db/support_files/qiita-db.dbs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,9 +1001,12 @@
<column name="creation_job_id" type="uuid" jt="1111" >
<defo><![CDATA[NULL]]></defo>
</column>
<column name="current_human_filtering" type="boolean" jt="1111" >
<column name="current_human_filtering" type="boolean" jt="-7" >
<defo><![CDATA[false]]></defo>
</column>
<column name="reprocess_job_id" type="uuid" jt="1111" >
<defo><![CDATA[NULL]]></defo>
</column>
<index name="pk_prep_template" unique="PRIMARY_KEY" >
<column name="prep_template_id" />
</index>
Expand Down Expand Up @@ -2109,7 +2112,7 @@ $function$
<entity schema="qiita" name="parent_processing_job" color="F4DDBE" x="1152" y="1024" />
<entity schema="qiita" name="per_study_tags" color="D1BEF4" x="656" y="1376" />
<entity schema="qiita" name="portal_type" color="D1BEF4" x="944" y="176" />
<entity schema="qiita" name="prep_template" color="BEBEF4" x="1952" y="1312" />
<entity schema="qiita" name="prep_template" color="BEBEF4" x="1984" y="1264" />
<entity schema="qiita" name="prep_template_filepath" color="BEBEF4" x="2128" y="1104" />
<entity schema="qiita" name="prep_template_processing_job" color="BEBEF4" x="2672" y="864" />
<entity schema="qiita" name="prep_template_sample" color="BEBEF4" x="1648" y="1376" />
Expand Down Expand Up @@ -2157,4 +2160,4 @@ FROM
qiita.artifact t;]]></string>
</script>
</layout>
</project>
</project>
Loading
Loading