Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
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
Container 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
713
Mentat
mentat-test
Commits
0c476c43
Commit
0c476c43
authored
2 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Report extra detectors. (Redmine issue:
#7577
)
parent
4c0f3e18
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mentat/module/detmngr.py
+22
-1
22 additions, 1 deletion
lib/mentat/module/detmngr.py
with
22 additions
and
1 deletion
lib/mentat/module/detmngr.py
+
22
−
1
View file @
0c476c43
...
@@ -219,7 +219,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -219,7 +219,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
:return: Structure containing information about changes.
:return: Structure containing information about changes.
:rtype: dict
:rtype: dict
"""
"""
result
=
{
'
create
'
:
[],
'
delete
'
:
{}
,
'
update
'
:
{}}
result
=
{
'
create
'
:
[],
'
delete
'
:
[]
,
'
update
'
:
{}}
det_db
=
{}
det_db
=
{}
det_file
=
self
.
c
(
self
.
CONFIG_DETECTORS_FILE
)
det_file
=
self
.
c
(
self
.
CONFIG_DETECTORS_FILE
)
...
@@ -235,6 +235,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -235,6 +235,7 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
det_db
[
detector
.
name
]
=
detector
det_db
[
detector
.
name
]
=
detector
self
.
_detectors_create_missing
(
det_db
,
det_file_data
,
det_file_type
,
result
,
status_only
)
self
.
_detectors_create_missing
(
det_db
,
det_file_data
,
det_file_type
,
result
,
status_only
)
self
.
_detectors_report_extra
(
det_db
,
det_file_data
,
det_file_type
,
result
,
status_only
)
return
result
return
result
def
_load_detectors_file
(
self
,
detectors_file
):
def
_load_detectors_file
(
self
,
detectors_file
):
...
@@ -302,3 +303,23 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
...
@@ -302,3 +303,23 @@ class MentatDetmngrScript(mentat.script.fetcher.FetcherScript):
self
.
logger
.
warning
(
"'
%s
'
Creating new detector.
"
,
gkey
)
self
.
logger
.
warning
(
"'
%s
'
Creating new detector.
"
,
gkey
)
self
.
sqlservice
.
session
.
add
(
sqldet
)
self
.
sqlservice
.
session
.
add
(
sqldet
)
self
.
sqlservice
.
session
.
commit
()
self
.
sqlservice
.
session
.
commit
()
def
_detectors_report_extra
(
self
,
det_db
,
det_file_data
,
det_file_type
,
result
,
status_only
):
"""
Report extra detectors from database.
:param dict det_db: Detectors loaded from the database.
:param dict det_file_data: Detectors loaded from the reference detectors file.
:param str det_file_type: Source of the detectors in the reference detectors file.
:param dict result: Structure containing processing log, will be appended to script runlog.
:param bool status_only: Do not actually perform any database operations, just report status.
"""
for
detector_name
in
sorted
(
det_db
.
keys
()):
det
=
det_db
[
detector_name
]
# For deletion consider only detectors with the same origin (source) as
# the loaded detectors file.
if
det
.
source
==
det_file_type
and
detector_name
not
in
det_file_data
:
detkey
=
'
{}::{}
'
.
format
(
det
.
name
,
det
.
source
)
result
[
'
delete
'
].
append
(
detkey
)
self
.
logger
.
warning
(
"'
%s
'
Detector was not found in the loaded detectors file, consider deletion.
"
,
detkey
)
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