Skip to content
Snippets Groups Projects
Commit 7d78ec00 authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Not comparing pipeline versions if they're bogus

parent ec4a6d2a
No related branches found
No related tags found
3 merge requests!1706merge 2.8.4 to main,!1696Catch 2.8.5-DEVELOPMENT up with the latest 2.8.4,!1695CASA matrix testing fixes
......@@ -94,6 +94,24 @@ def natural_sort(in_list: list, reverse: bool = False) -> list:
return sorted(in_list, key=alphanum_key, reverse=reverse)
def versions_match(db_ver: str, dir_ver: str) -> bool:
"""
Compares CASA+pipeline version formats stored in the database vs. those installed.
:param db_ver: Version coming from the database
:param dir_ver: Version coming from a directory path
:return: True if the CASA+pipeline versions match
"""
if db_ver == dir_ver:
return True
# Ignore comparing pipeline versions if they don't exist in the installed version's name
if dir_ver.split("|")[1] == "default":
return db_ver.split("|")[0] == dir_ver.split("|")[0]
return False
class CasaMatrixService(CasaMatrixServiceIF):
"""
Service that enables clients to access the CASA Version Matrix.
......@@ -253,16 +271,17 @@ class CasaMatrixService(CasaMatrixServiceIF):
# Put the requested version as first in the list if it's valid
for v in versions:
if v["version"] == version:
# TODO: This needs to be converted if the pipeline number is missing from the directory name like 5.1.1-5
if versions_match(version, v["version"]):
versions.insert(0, versions.pop(versions.index(v)))
# If the requested version is invalid, put the default as first in the list
# If the default is invalid, the newest version will be first in the list
if versions and versions[0]["version"] != version:
if versions and versions_match(version, versions[0]["version"]):
default = self.get_default_version(capability, telescope)
if default:
for v in versions:
if v["version"] == default:
if versions_match(default, v["version"]):
versions.insert(0, versions.pop(versions.index(v)))
logger.debug(f"Found CASA versions for {capability}: {versions}")
......
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