Browse Source

Add task_uuid and populate with Celery id

Matthias Vogelgesang 7 years ago
parent
commit
738f37b24a
3 changed files with 34 additions and 7 deletions
  1. 30 0
      migrations/versions/1d40d3fc3d0c_.py
  2. 2 0
      nova/models.py
  3. 2 7
      nova/views.py

+ 30 - 0
migrations/versions/1d40d3fc3d0c_.py

@@ -0,0 +1,30 @@
+"""Added task_uuid to Process
+
+Revision ID: 1d40d3fc3d0c
+Revises: ff16bb058061
+Create Date: 2016-10-04 10:07:08.038082
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '1d40d3fc3d0c'
+down_revision = 'ff16bb058061'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('processes', schema=None) as batch_op:
+        batch_op.add_column(sa.Column('task_uuid', sa.String(), nullable=True))
+
+    ### end Alembic commands ###
+
+
+def downgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('processes', schema=None) as batch_op:
+        batch_op.drop_column('task_uuid')
+
+    ### end Alembic commands ###

+ 2 - 0
nova/models.py

@@ -239,6 +239,8 @@ class Process(db.Model):
     id = db.Column(db.Integer, primary_key=True)
     type = db.Column(db.String(50))
 
+    task_uuid = db.Column(db.String)
+
     source_id = db.Column(db.Integer, db.ForeignKey('datasets.id'))
     destination_id = db.Column(db.Integer, db.ForeignKey('datasets.id'))
 

+ 2 - 7
nova/views.py

@@ -398,17 +398,12 @@ def share(dataset_id, user_id=None):
 def process(dataset_id):
     parent = Dataset.query.filter(Dataset.id == dataset_id).first()
     child = logic.create_dataset(models.Volume, request.form['name'], current_user, parent.collection, slices=request.form['outname'])
-    db.session.add(Process(source=parent, destination=child))
 
-    tasks.reconstruct.delay(current_user.token, child.id, parent.id,
+    result = tasks.reconstruct.delay(current_user.token, child.id, parent.id,
         request.form['flats'], request.form['darks'], request.form['projections'],
         request.form['outname'])
 
-    # if process == 'copy':
-    #     tasks.copy.delay(current_user.token, name, parent.id)
-
-    # if process == 'run':
-    #     tasks.run_command.delay(current_user.token, name, parent.id, request.form)
+    db.session.add(Process(source=parent, destination=child, task_uuid=result.id))
 
     return redirect(url_for('index'))