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

Merge branch 'fix-matrix-default-symlinks' into '2.8.4-DEVELOPMENT'

fix default determination to handle symlinked casa installs

See merge request !1684
parents 8669dd3d e6c5eea6
No related branches found
No related tags found
2 merge requests!1706merge 2.8.4 to main,!1684fix default determination to handle symlinked casa installs
Pipeline #16130 passed
......@@ -17,6 +17,7 @@
#
import logging
import os
import pathlib
import re
import shutil
......@@ -58,10 +59,19 @@ def casa_version_from_path(path: str) -> str:
casa_version, pipeline_version = "unknown", "default"
cv_search = re.search(CASA_VERSION_REGEX, path)
if cv_search is None:
# this is probably a default link, make sure we use the actual version path
path2 = pathlib.Path(path)
if path2.is_symlink():
path = str(path2.readlink())
cv_search = re.search(CASA_VERSION_REGEX, path)
pv_search = re.search(PIPELINE_VERSION_REGEX, path)
if cv_search:
# Replace last '-' in the directory name with '.' to match versions stored in the database
casa_version = '.'.join(cv_search.group(1).rsplit('-', 1))
casa_version = ".".join(cv_search.group(1).rsplit("-", 1))
if pv_search:
# Strip el* from the release name (used to be a thing)
pipeline_version = re.sub(EL_SUFFIX_REGEX, "", pv_search.group(1))
......@@ -80,7 +90,7 @@ def natural_sort(in_list: list, reverse: bool = False) -> list:
:return: A naturally sorted list
"""
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
alphanum_key = lambda key: [convert(c) for c in re.split("([0-9]+)", key)]
return sorted(in_list, key=alphanum_key, reverse=reverse)
......@@ -93,7 +103,7 @@ class CasaMatrixService(CasaMatrixServiceIF):
self.session = session
# Used for linking and looking up linked CASA versions
self.env_dir = str(CapoConfig().profile).replace('dsoc-', '')
self.env_dir = str(CapoConfig().profile).replace("dsoc-", "")
# A valid version will cross-check installed versions in the casa_root against allowed versions in the database
self.installed_versions = []
......@@ -199,10 +209,7 @@ class CasaMatrixService(CasaMatrixServiceIF):
return ret
def get_version(
self,
version: str | None = None,
capability: str | None = None,
telescope: str | None = None
self, version: str | None = None, capability: str | None = None, telescope: str | None = None
) -> dict[str, str]:
"""
Returns the CASA version that is valid for processing.
......@@ -219,10 +226,7 @@ class CasaMatrixService(CasaMatrixServiceIF):
return versions[0] if versions else {}
def get_versions(
self,
version: str | None = None,
capability: str | None = None,
telescope: str | None = None
self, version: str | None = None, capability: str | None = None, telescope: str | None = None
) -> list[dict[str, str]]:
"""
Returns the CASA versions that are valid for processing as a dict.
......@@ -283,7 +287,7 @@ class CasaMatrixService(CasaMatrixServiceIF):
return None
# Some capabilities have different paths per telescope (looking at you ALMA)
if len(keys) > 1 and telescope and telescope.lower() == 'alma':
if len(keys) > 1 and telescope and telescope.lower() == "alma":
key = keys[1]
else:
key = keys[0]
......
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