From 01050f23ffc3c820cf94f1ee184fd0928c463847 Mon Sep 17 00:00:00 2001 From: Andrew Kapuscinski <akapusci@nrao.edu> Date: Thu, 1 Jul 2021 10:11:30 -0600 Subject: [PATCH] added schema revisions for workflow template scripts to fail when expections are throw from productfetcher --- schema/versions/12b2de18a383_.py | 24 ++++++++ ...dded_errexit_to_std_calibration_script_.py | 61 +++++++++++++++++++ ...pdate_download_workflow_script_to_fail_.py | 45 ++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 schema/versions/12b2de18a383_.py create mode 100644 schema/versions/2ac701610fc7_added_errexit_to_std_calibration_script_.py create mode 100644 schema/versions/7c1f6f0cef32_update_download_workflow_script_to_fail_.py diff --git a/schema/versions/12b2de18a383_.py b/schema/versions/12b2de18a383_.py new file mode 100644 index 000000000..b42f24ade --- /dev/null +++ b/schema/versions/12b2de18a383_.py @@ -0,0 +1,24 @@ +"""empty message + +Revision ID: 12b2de18a383 +Revises: 6231bb30d95d, 7c1f6f0cef32 +Create Date: 2021-07-01 16:04:19.731212 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '12b2de18a383' +down_revision = ('6231bb30d95d', '7c1f6f0cef32') +branch_labels = None +depends_on = None + + +def upgrade(): + pass + + +def downgrade(): + pass diff --git a/schema/versions/2ac701610fc7_added_errexit_to_std_calibration_script_.py b/schema/versions/2ac701610fc7_added_errexit_to_std_calibration_script_.py new file mode 100644 index 000000000..454c76857 --- /dev/null +++ b/schema/versions/2ac701610fc7_added_errexit_to_std_calibration_script_.py @@ -0,0 +1,61 @@ +"""added errexit to std_calibration script template + +Revision ID: 2ac701610fc7 +Revises: 12b2de18a383 +Create Date: 2021-07-01 16:04:31.042789 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '2ac701610fc7' +down_revision = '12b2de18a383' +branch_labels = None +depends_on = None + + +def upgrade(): + shell_script_content_std_calibration = """#!/bin/sh + +export HOME=$TMPDIR + +set -o errexit +./framework.sh -d . +chmod 770 . +cd rawdata/ +../productfetcher --product-locator $1 +cd ../ +./casa_envoy --standard-cal $3 $4 +./conveyor --deliver $3 + +""" + + op.execute( + "UPDATE workflow_templates " + f"SET content = E'{shell_script_content_std_calibration}' " + "WHERE filename = 'std_calibration.sh'" + ) + + +def downgrade(): + shell_script_content_std_calibration = """#!/bin/sh + +export HOME=$TMPDIR + +./framework.sh -d . +chmod 770 . +cd rawdata/ +../productfetcher --product-locator $1 +cd ../ +./casa_envoy --standard-cal $3 $4 +./conveyor --deliver $3 + +""" + + op.execute( + "UPDATE workflow_templates " + f"SET content = E'{shell_script_content_std_calibration}' " + "WHERE filename = 'std_calibration.sh'" + ) diff --git a/schema/versions/7c1f6f0cef32_update_download_workflow_script_to_fail_.py b/schema/versions/7c1f6f0cef32_update_download_workflow_script_to_fail_.py new file mode 100644 index 000000000..75fb25a24 --- /dev/null +++ b/schema/versions/7c1f6f0cef32_update_download_workflow_script_to_fail_.py @@ -0,0 +1,45 @@ +"""update download workflow script to fail on error + +Revision ID: 7c1f6f0cef32 +Revises: a832fcb74a8c +Create Date: 2021-06-30 22:56:03.478526 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '7c1f6f0cef32' +down_revision = 'a832fcb74a8c' +branch_labels = None +depends_on = None + + +def upgrade(): + shell_script_content = """#!/bin/sh +set -o errexit +chmod 770 . +./productfetcher --product-locator $1 +./deliver -r . --prefix $2 +""" + + op.execute( + "UPDATE workflow_templates " + f"SET content = E'{shell_script_content}' " + "WHERE filename = 'test_download.sh'" + ) + + +def downgrade(): + shell_script_content = """#!/bin/sh +chmod 770 . +./productfetcher --product-locator $1 +./deliver -r . --prefix $2 +""" + + op.execute( + "UPDATE workflow_templates " + f"SET content = E'{shell_script_content}' " + "WHERE filename = 'test_download.sh'" + ) -- GitLab