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
d07f3d7b
Commit
d07f3d7b
authored
10 months ago
by
Daniel Nemergut
Browse files
Options
Downloads
Patches
Plain Diff
Fixed associated capability additions, updates, and deletes
parent
0b3de348
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1706
merge 2.8.4 to main
,
!1670
WS-1405 CASA matrix service
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/workspaces/workspaces/system/services/casa_matrix_service.py
+25
-8
25 additions, 8 deletions
...kspaces/workspaces/system/services/casa_matrix_service.py
with
25 additions
and
8 deletions
shared/workspaces/workspaces/system/services/casa_matrix_service.py
+
25
−
8
View file @
d07f3d7b
...
...
@@ -21,11 +21,12 @@ import re
import
shutil
from
pycapo
import
CapoConfig
from
sqlalchemy
import
insert
from
sqlalchemy.exc
import
SQLAlchemyError
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm
import
Session
from
workspaces.capability.schema
import
Capability
,
CasaMatrixCasaVersion
from
workspaces.capability.schema
import
Capability
,
CasaMatrixCasaVersion
,
matrix_capabilities
from
workspaces.system.services.interfaces
import
CasaMatrixServiceIF
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -312,6 +313,19 @@ class CasaMatrixService(CasaMatrixServiceIF):
self
.
session
.
add
(
entity
)
self
.
session
.
flush
()
def
save_capabilities
(
self
,
version
:
str
,
capabilities
:
list
[
str
]):
"""
Saves the given version + capabilities to the casa_matrix_capabilities table.
:param version: CASA matrix version to look up
:param capabilities: List of capability names to associate to the given version
"""
matrix_version
=
self
.
session
.
query
(
CasaMatrixCasaVersion
).
filter_by
(
casa_version
=
version
).
first
()
mc
=
[{
'
matrix_id
'
:
matrix_version
.
matrix_id
,
'
capability_name
'
:
c
}
for
c
in
capabilities
]
self
.
session
.
execute
(
insert
(
matrix_capabilities
),
mc
)
self
.
session
.
flush
()
def
add_version
(
self
,
version
:
str
,
capabilities
:
list
[
str
]
=
None
,
is_cluster_compatible
:
bool
=
True
)
->
bool
:
"""
Adds a new CASA version to the matrix using the provided version string and capability name list.
...
...
@@ -322,11 +336,13 @@ class CasaMatrixService(CasaMatrixServiceIF):
matrix_version
=
CasaMatrixCasaVersion
(
casa_version
=
version
,
is_cluster_compatible
=
is_cluster_compatible
,
capabilities
=
capabilities
if
capabilities
else
[],
)
try
:
self
.
save_entity
(
matrix_version
)
if
capabilities
:
# Link the given capabilities to the new matrix version, wasn't sure how to do this in one go
self
.
save_capabilities
(
version
,
capabilities
)
return
True
except
SQLAlchemyError
as
e
:
logger
.
critical
(
f
"
Unable to add CASA version
{
version
}
: %s
"
,
e
)
...
...
@@ -338,16 +354,15 @@ class CasaMatrixService(CasaMatrixServiceIF):
:return: True if updated successfully
"""
logger
.
info
(
f
"
Full list =
{
capabilities
}
"
)
for
thing
in
capabilities
:
logger
.
info
(
f
"
Thing =
{
thing
}
"
)
try
:
self
.
session
.
query
(
CasaMatrixCasaVersion
).
filter_by
(
casa_version
=
version
).
update
({
'
casa_version
'
:
version
,
'
is_cluster_compatible
'
:
is_cluster_compatible
,
'
capabilities
'
:
capabilities
if
capabilities
else
[],
})
self
.
session
.
flush
()
if
capabilities
:
# Link the given capabilities to the new matrix version, wasn't sure how to do this in one go
self
.
save_capabilities
(
version
,
capabilities
)
return
True
except
SQLAlchemyError
as
e
:
logger
.
critical
(
f
"
Unable to update CASA version
{
version
}
%s
"
,
e
)
...
...
@@ -355,12 +370,14 @@ class CasaMatrixService(CasaMatrixServiceIF):
def
delete_version
(
self
,
version
:
str
)
->
bool
:
"""
Deletes a CASA version from the matrix.
Deletes a CASA version
and its capability links
from the matrix.
:return: True if deleted successfully
"""
try
:
self
.
session
.
query
(
CasaMatrixCasaVersion
).
filter_by
(
casa_version
=
version
).
delete
()
matrix_version
=
self
.
session
.
query
(
CasaMatrixCasaVersion
).
filter_by
(
casa_version
=
version
).
first
()
matrix_version
.
capabilities
=
[]
self
.
session
.
delete
(
matrix_version
)
self
.
session
.
flush
()
return
True
except
SQLAlchemyError
as
e
:
...
...
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