From 74d7543f0f987901b1c64ec3b062a61116719d14 Mon Sep 17 00:00:00 2001
From: Daniel Nemergut <dnemergu@nrao.edu>
Date: Mon, 27 Nov 2023 09:31:42 -0500
Subject: [PATCH] Added instantclient to the curator condor file for CV nodes
 and bumped the instantclient version for other workflows

---
 .../49b7c8150e72_workflows_oracle_update.py   | 100 ++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100644 shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py

diff --git a/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py b/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py
new file mode 100644
index 000000000..2f6ffb8c6
--- /dev/null
+++ b/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py
@@ -0,0 +1,100 @@
+"""workflows oracle update
+
+Revision ID: 49b7c8150e72
+Revises: f2a76d224984
+Create Date: 2023-11-22 14:26:55.355861
+
+"""
+from alembic import op
+import sqlalchemy as sa
+
+
+# revision identifiers, used by Alembic.
+revision = '49b7c8150e72'
+down_revision = 'f2a76d224984'
+branch_labels = None
+depends_on = None
+
+
+# Add instantclient_21_1 to the path for CV nodes
+old_curator_condor = """executable = curator.sh
+arguments = metadata.json {{curator_type}}
+
+output = curator.out
+error = curator.err
+log = condor.log
+
+should_transfer_files = NO
++WantIOProxy = True
+request_memory = {{ramInGb}}
+getenv = True
+environment = "CAPO_PATH=/home/casa/capo"
+requirements = HasLustre == True
+
+queue
+
+"""
+
+new_curator_condor = """executable = curator.sh
+arguments = metadata.json {{curator_type}}
+
+output = curator.out
+error = curator.err
+log = condor.log
+
+should_transfer_files = NO
++WantIOProxy = True
+request_memory = {{ramInGb}}
+{{^remote-cv}}
+getenv = True
+environment = "CAPO_PATH=/home/casa/capo"
+
+requirements = HasLustre == True
+{{/remote-cv}}
+{{#remote-cv}}
+environment = "CAPO_PATH=. CAPO_PROFILE={{profile}} LD_LIBRARY_PATH=/home/ssa/share/oracle/instantclient_21_1"
+
+requirements = HasLustre == True && (CVPOST == True)
++partition = "CVPOST"
+{{/remote-cv}}
+
+queue
+
+"""
+
+
+def upgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{new_curator_condor}'
+        WHERE filename='curator.condor'
+        """
+    )
+
+    # Use instantclient_21_1 in the other templates
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content= regexp_replace(convert_from(content, 'utf-8'), E'instantclient_12_1', E'instantclient_21_1', 'g')::bytea
+        WHERE filename='download.condor' OR filename='ingest_cal.condor'
+        """
+    )
+
+
+def downgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{old_curator_condor}'
+        WHERE filename='curator.condor'
+        """
+    )
+
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content= regexp_replace(convert_from(content, 'utf-8'), E'instantclient_21_1', E'instantclient_12_1', 'g')::bytea
+        WHERE filename='download.condor' OR filename='ingest_cal.condor'
+        """
+    )
-- 
GitLab