Skip to content
Snippets Groups Projects
Commit 04cbaa37 authored by Charlotte Hausman's avatar Charlotte Hausman Committed by Charlotte Hausman
Browse files

fix vlass template errors found in 2.7 testing

parent 27d32c4c
No related branches found
No related tags found
4 merge requests!1195rebase 2.8,!1192Catch up with main 2.8,!1186Catch up with main 2.8,!1136fix vlass template errors found in 2.7 testing
Pipeline #7471 passed
"""fix vlass templates 2.7
Revision ID: 7dc5ab8aa24d
Revises: 0cc194239baf
Create Date: 2022-11-22 11:46:46.678712
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "7dc5ab8aa24d"
down_revision = "0cc194239baf"
branch_labels = None
depends_on = None
old_post = """deactivate
cd ../products
"""
new_post = """deactivate
cd ../products
export LANG=en_US.UTF-8
export HOME=/users/vlapipe
"""
fetch_logs = """output = fetch.out
error = fetch.err"""
envoy_logs = """output = envoy.out
error = envoy.err"""
post_logs = """output = post.out
error = post.err"""
convey_logs = """output = convey.out
error = convey.err"""
wf_fix_logs = [
"vlass_calibration",
"vlass_coarse",
"vlass_ql",
]
def create_old_log_entry(wf_name: str, stage: str) -> str:
if wf_name == "vlass_calibration":
name = "calibration"
elif wf_name == "vlass_ql":
name = "ql"
else:
name = wf_name
return f"""output = {name}_{stage}.out
error = {name}_{stage}.err"""
def upgrade():
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{old_post}', E'{new_post}')::bytea
WHERE filename IN ('vlass_seci_post.sh', 'vlass_coarse_post.sh')
"""
)
for wf in wf_fix_logs:
fetch_file_name = wf + "_fetch.condor"
envoy_file_name = wf + "_envoy.condor"
post_file_name = wf + "_convey.condor" if wf == "vlass_calibration" else wf + "_post.condor"
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{create_old_log_entry(wf, "fetch")}', E'{fetch_logs}')::bytea
WHERE filename = '{fetch_file_name}'
"""
)
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{create_old_log_entry(wf, "envoy")}', E'{envoy_logs}')::bytea
WHERE filename = '{envoy_file_name}'
"""
)
if wf == "vlass_calibration":
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{create_old_log_entry(wf, "convey")}', E'{convey_logs}')::bytea
WHERE filename = '{post_file_name}'
"""
)
else:
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{create_old_log_entry(wf, "post")}', E'{post_logs}')::bytea
WHERE filename = '{post_file_name}'
"""
)
def downgrade():
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{new_post}', E'{old_post}')::bytea
WHERE filename IN ('vlass_seci_post.sh', 'vlass_coarse_post.sh')
"""
)
for wf in wf_fix_logs:
fetch_file_name = wf + "_fetch.condor"
envoy_file_name = wf + "_envoy.condor"
post_file_name = wf + "_convey.condor" if wf == "vlass_calibration" else wf + "_post.condor"
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{fetch_logs}', E'{create_old_log_entry(wf, "fetch")}')::bytea
WHERE filename = '{fetch_file_name}'
"""
)
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{envoy_logs}', E'{create_old_log_entry(wf, "envoy")}')::bytea
WHERE filename = '{envoy_file_name}'
"""
)
if wf == "vlass_calibration":
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{convey_logs}', E'{create_old_log_entry(wf, "convey")}')::bytea
WHERE filename = '{post_file_name}'
"""
)
else:
op.execute(
f"""
UPDATE workflow_templates
SET content = replace(convert_from(content, 'utf8'), E'{post_logs}', E'{create_old_log_entry(wf, "post")}')::bytea
WHERE filename = '{post_file_name}'
"""
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment