Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
4e8b04e1
Commit
4e8b04e1
authored
9 months ago
by
Daniel Nemergut
Browse files
Options
Downloads
Patches
Plain Diff
Corrected version comparison logic to ignore morse code
parent
7d78ec00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!1706
merge 2.8.4 to main
,
!1696
Catch 2.8.5-DEVELOPMENT up with the latest 2.8.4
,
!1695
CASA matrix testing fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/workspaces/workspaces/system/services/casa_matrix_service.py
+18
-17
18 additions, 17 deletions
...kspaces/workspaces/system/services/casa_matrix_service.py
with
18 additions
and
17 deletions
shared/workspaces/workspaces/system/services/casa_matrix_service.py
+
18
−
17
View file @
4e8b04e1
...
...
@@ -44,6 +44,7 @@ DEV_CASA_REGEX = r"^casa-[0-9\.\-]*(pipeline-)?[^tp]"
CASA_VERSION_REGEX
=
r
"
[a-zA-Z\-]+([\d]+(\.[\d]+){2}(-[\d]+){0,1}).*
"
PIPELINE_VERSION_REGEX
=
r
"
.*([\d]{4}(\.[\d]+){3}).*
"
EL_SUFFIX_REGEX
=
r
"
[\.\-]el[0-9]+$
"
IGNORE_REGEX
=
r
"
\.|\-
"
def
casa_version_from_path
(
path
:
str
)
->
str
:
...
...
@@ -70,8 +71,7 @@ def casa_version_from_path(path: str) -> str:
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
=
cv_search
.
group
(
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
))
...
...
@@ -94,22 +94,23 @@ 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_v
er
:
str
)
->
bool
:
def
versions_match
(
req_v
:
str
,
dir_v
:
str
)
->
bool
:
"""
Compares CASA+pipeline version formats stored in the
database vs. those
installed.
Compares CASA+pipeline version formats stored in the
request vs
installed.
:param
db_ver
: Version coming from the
database
:param dir_v
er
: Version coming from a directory path
:param
req_v
: Version coming from the
request
:param dir_v: Version coming from a directory path
:return: True if the CASA+pipeline versions match
"""
if
db_ver
==
dir_ver
:
return
True
req_cv
,
req_pv
=
req_v
.
split
(
"
|
"
)
dir_cv
,
dir_pv
=
dir_v
.
split
(
"
|
"
)
# 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
]
# Ignore comparing
'.' and '-' characters because they like to be used interchangeably
req_cv
=
re
.
sub
(
IGNORE_REGEX
,
""
,
req_cv
)
dir_cv
=
re
.
sub
(
IGNORE_REGEX
,
""
,
dir_cv
)
return
False
# Ignore comparing pipeline versions if they don't exist in the installed version's name
return
req_cv
==
dir_cv
and
(
dir_pv
==
"
default
"
or
req_pv
==
dir_pv
)
class
CasaMatrixService
(
CasaMatrixServiceIF
):
...
...
@@ -270,14 +271,14 @@ class CasaMatrixService(CasaMatrixServiceIF):
versions
.
append
(
installed_version
)
# Put the requested version as first in the list if it's valid
f
or
v
in
version
s
:
# 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
)))
i
f
version
:
for
v
in
versions
:
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_match
(
version
,
versions
[
0
][
"
version
"
]):
if
versions
and
(
not
version
or
not
versions_match
(
version
,
versions
[
0
][
"
version
"
])
)
:
default
=
self
.
get_default_version
(
capability
,
telescope
)
if
default
:
for
v
in
versions
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment