Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cb-util
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
Christoph Alt
cb-util
Commits
7c1042d2
Commit
7c1042d2
authored
1 year ago
by
Christoph Alt
Browse files
Options
Downloads
Patches
Plain Diff
added more kadi helper functions
parent
de848b83
No related branches found
No related tags found
No related merge requests found
Pipeline
#58230
passed
1 year ago
Stage: test
Stage: deploy
Stage: trigger
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cbutil/kadi_helper.py
+66
-0
66 additions, 0 deletions
cbutil/kadi_helper.py
with
66 additions
and
0 deletions
cbutil/kadi_helper.py
+
66
−
0
View file @
7c1042d2
...
...
@@ -6,6 +6,8 @@ from kadi_apy import KadiManager
import
logging
import
builtins
import
re
from
typing
import
Iterable
logger
=
logging
.
getLogger
(
__file__
)
...
...
@@ -72,3 +74,67 @@ def create_kadi_record(manager: KadiManager, identifier: str, **kwargs):
create
=
True
,
**
kwargs
,
)
def
get_all_collection_ids
(
manager
:
KadiManager
,
parent_collection_id
:
int
)
->
Iterable
[
int
]:
meta_collection
=
manager
.
collection
(
id
=
parent_collection_id
,
create
=
False
)
page
=
1
while
True
:
collections
=
meta_collection
.
get_collections
(
page
=
page
)
collection_json
=
collections
.
json
()
for
item
in
collection_json
[
"
items
"
]:
yield
item
[
"
id
"
]
if
page
<=
collection_json
[
"
_pagination
"
][
"
total_pages
"
]:
page
+=
1
else
:
break
def
get_all_record_ids
(
manager
:
KadiManager
,
collection_id
:
int
)
->
Iterable
[
int
]:
meta_collection
=
manager
.
collection
(
id
=
collection_id
,
create
=
False
)
page
=
1
while
True
:
collections
=
meta_collection
.
get_records
(
page
=
page
)
collection_json
=
collections
.
json
()
for
item
in
collection_json
[
"
items
"
]:
yield
item
[
"
id
"
]
if
page
<=
collection_json
[
"
_pagination
"
][
"
total_pages
"
]:
page
+=
1
else
:
break
def
add_user_to_collection
(
manager
:
KadiManager
,
collection_id
:
int
,
user_id
:
int
,
*
,
role
=
"
admin
"
):
collection
=
manager
.
collection
(
id
=
collection_id
,
create
=
False
)
collection
.
add_user
(
user_id
=
user_id
,
role_name
=
role
)
def
get_records
(
manager
:
KadiManager
,
record_ids
:
Iterable
[
int
]):
for
r
in
record_ids
:
yield
manager
.
record
(
id
=
r
,
create
=
False
)
def
filter_record_after_title
(
records
,
pattern
):
for
r
in
records
:
if
re
.
match
(
pattern
,
r
.
meta
[
"
title
"
]):
yield
r
def
connect_logs
(
records
):
meta_logs
=
filter_record_after_title
(
records
,
r
"
fe2ti.*\.o[0-9]+
"
)
for
meta_log
in
meta_logs
:
name_start
=
meta_log
.
meta
[
"
title
"
].
split
(
'
.
'
)[
0
]
for
pl
in
filter_record_after_title
(
records
,
f
"
{
name_start
}
_.*
"
):
logger
.
info
(
f
"
Linking
{
meta_log
.
id
}
with
{
pl
.
id
}
"
)
logger
.
debug
(
f
"
Linking
{
meta_log
.
meta
[
'
title
'
]
}
with
{
pl
.
meta
[
'
title
'
]
}
"
)
pl
.
link_record
(
meta_log
.
id
,
"
application call
"
)
def
connect_likwid_files
(
records
):
programm_logs
=
filter_record_after_title
(
records
,
"
fe2ti.*_[6-8]_1e-[4,6,8]
"
)
for
p_log
in
programm_logs
:
likwid_log
=
list
(
filter_record_after_title
(
records
,
f
"
likwid_MEM_DP_
{
p_log
.
meta
[
'
title
'
]
}
"
))
assert
len
(
likwid_log
)
==
1
,
"
found more than one likwid log
"
logger
.
info
(
f
"
Linking
{
p_log
.
id
}
with
{
likwid_log
[
0
].
id
}
"
)
logger
.
info
(
f
"
Linking
{
p_log
.
meta
[
'
title
'
]
}
with
{
likwid_log
[
0
].
meta
[
'
title
'
]
}
"
)
likwid_log
[
0
].
link_record
(
p_log
.
id
,
"
hardware performance counter
"
)
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