-
Charlotte Hausman authoredCharlotte Hausman authored
291edd508557_add_std_calibration_script.py 1.45 KiB
"""add std calibration script
Revision ID: 291edd508557
Revises: 16b40772e51a
Create Date: 2021-04-22 16:02:06.543907
"""
from alembic import op
import sqlalchemy as sa
from pycapo import CapoConfig
# revision identifiers, used by Alembic.
revision = '291edd508557'
down_revision = '16b40772e51a'
branch_labels = None
depends_on = None
def get_script_location() -> str:
return CapoConfig().settings("edu.nrao.archive.workspaces.ProcessingSettings").scriptLocation
def upgrade():
path = get_script_location()
script_body = """#!/bin/sh
export PATH=$PATH:""" + path + """
framework.sh -d .
cd rawdata/
datafetcher --product-locator $1
cd ../
casa_envoy --standard-cal $3 $4
deliver -r ./products --prefix $2
"""
op.execute(
"""
INSERT INTO workflow_templates (filename, content, workflow_name)
VALUES ('std_calibration.sh', E'""" + script_body + """' , 'std_calibration')
"""
)
op.execute(
"""
UPDATE workflow_templates
SET content = E'executable = std_calibration.sh
arguments = {{product_locator}} {{request_id}} metadata.json PPR.xml
error = std_calibration.err
log = std_calibration.log
queue'
WHERE filename = 'std_calibration.condor'
"""
)
def downgrade():
op.execute(
"""
DELETE FROM workflow_templates WHERE filename = 'std_calibration.sh'
"""
)