From e9bda4ea49bea43391c34c3217a025af2d32e32c Mon Sep 17 00:00:00 2001
From: Sam Kagan <skagan@nrao.edu>
Date: Thu, 27 Jun 2024 08:55:42 -0600
Subject: [PATCH] Updated restore_cms' deliver.sh for new deliver CLI

---
 ...21c8fe2_update_restore_cms_deliver_call.py | 58 +++++++++++++++++++
 .../restore_cms/deliver_sh_2.8.5.txt          |  8 +++
 2 files changed, 66 insertions(+)
 create mode 100644 shared/workspaces/alembic/versions/2b9f521c8fe2_update_restore_cms_deliver_call.py
 create mode 100644 shared/workspaces/alembic/versions/templates/restore_cms/deliver_sh_2.8.5.txt

diff --git a/shared/workspaces/alembic/versions/2b9f521c8fe2_update_restore_cms_deliver_call.py b/shared/workspaces/alembic/versions/2b9f521c8fe2_update_restore_cms_deliver_call.py
new file mode 100644
index 000000000..6aa7b9030
--- /dev/null
+++ b/shared/workspaces/alembic/versions/2b9f521c8fe2_update_restore_cms_deliver_call.py
@@ -0,0 +1,58 @@
+# Copyright (C) 2023 Associated Universities, Inc. Washington DC, USA.
+#
+# This file is part of NRAO Workspaces.
+#
+# Workspaces is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Workspaces is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Workspaces.  If not, see <https://www.gnu.org/licenses/>.
+#
+"""update restore_cms' deliver call
+
+Revision ID: 2b9f521c8fe2
+Revises: 5a1e335e6c13
+Create Date: 2024-06-27 08:39:14.566875
+
+"""
+from pathlib import Path
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "2b9f521c8fe2"
+down_revision = "5a1e335e6c13"
+branch_labels = None
+depends_on = None
+
+
+def set_content(wf_name: str, filename: str) -> str:
+    return (Path.cwd() / "versions" / "templates" / wf_name / filename).read_text()
+
+
+def upgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{set_content("restore_cms", "deliver_sh_2.8.5.txt")}'
+        WHERE filename='restore_cms_deliver.sh'
+        """
+    )
+
+
+def downgrade():
+    op.execute(
+        f"""
+        UPDATE workflow_templates
+        SET content=E'{set_content("restore_cms", "lustre_only_deliver_sh_2.7.txt")}'
+        WHERE filename='restore_cms_deliver.sh'
+        """
+    )
diff --git a/shared/workspaces/alembic/versions/templates/restore_cms/deliver_sh_2.8.5.txt b/shared/workspaces/alembic/versions/templates/restore_cms/deliver_sh_2.8.5.txt
new file mode 100644
index 000000000..693444d9b
--- /dev/null
+++ b/shared/workspaces/alembic/versions/templates/restore_cms/deliver_sh_2.8.5.txt
@@ -0,0 +1,8 @@
+#!/bin/sh
+set -o errexit
+
+export HOME={{spool_dir}}
+
+SBIN_PATH=/lustre/aoc/cluster/pipeline/$CAPO_PROFILE/workspaces/sbin
+
+$SBIN_PATH/deliver --restore --prefix $1 $2
-- 
GitLab