Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
athena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Sherwood
athena
Commits
421fc11f
Commit
421fc11f
authored
6 years ago
by
Tomasz Bold
Browse files
Options
Downloads
Patches
Plain Diff
Added simple script allowing to print athena configuration from a pickle file
Former-commit-id:
85fe7791
parent
4cdb1e07
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Control/AthenaConfiguration/CMakeLists.txt
+1
-0
1 addition, 0 deletions
Control/AthenaConfiguration/CMakeLists.txt
Control/AthenaConfiguration/share/confTool.py
+58
-0
58 additions, 0 deletions
Control/AthenaConfiguration/share/confTool.py
with
59 additions
and
0 deletions
Control/AthenaConfiguration/CMakeLists.txt
+
1
−
0
View file @
421fc11f
...
...
@@ -13,3 +13,4 @@ atlas_install_python_modules( python/*.py )
atlas_install_runtime
(
python/*.pkl
)
atlas_add_test
(
ComponentAccumulatorTest SCRIPT python -m AthenaConfiguration.ComponentAccumulator
)
atlas_install_scripts
(
share/confTool.py
)
This diff is collapsed.
Click to expand it.
Control/AthenaConfiguration/share/confTool.py
0 → 100755
+
58
−
0
View file @
421fc11f
#!/usr/bin/env python
#
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
import
pickle
import
pprint
import
json
import
sys
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'
Utility to transform/display athena configurations
'
)
parser
.
add_argument
(
'
--print
'
,
dest
=
"
pr
"
,
action
=
'
store_true
'
,
help
=
'
Prints
'
)
parser
.
add_argument
(
'
--toJSON
'
,
help
=
'
Convert to JSON file
'
)
parser
.
add_argument
(
'
--toPKL
'
,
help
=
'
Convert to python pickle format file
'
)
parser
.
add_argument
(
'
file
'
,
nargs
=
1
,
help
=
'
File to work with
'
)
args
=
parser
.
parse_args
()
conf
=
None
if
args
.
file
[
0
].
endswith
(
"
.pkl
"
):
input_file
=
file
(
args
.
file
[
0
]
)
conf
=
[]
while
True
:
try
:
conf
.
append
(
pickle
.
load
(
input_file
)
)
except
EOFError
:
break
print
"
Red
"
,
len
(
conf
),
"
items
"
if
args
.
file
[
0
].
endswith
(
"
.json
"
):
def
__keepPlainStrings
(
element
):
if
isinstance
(
element
,
unicode
):
return
str
(
element
)
if
isinstance
(
element
,
list
):
return
[
__keepPlainStrings
(
x
)
for
x
in
element
]
if
isinstance
(
element
,
dict
):
return
dict
(
[
(
__keepPlainStrings
(
key
),
__keepPlainStrings
(
value
))
for
key
,
value
in
element
.
iteritems
()
]
)
return
element
conf
=
json
.
load
(
file
(
args
.
file
[
0
]
),
object_hook
=
__keepPlainStrings
)
if
args
.
pr
:
for
n
,
c
in
enumerate
(
conf
):
print
"
Item
"
,
n
,
"
*
"
*
80
pprint
.
pprint
(
dict
(
c
))
if
args
.
toJSON
:
oFile
=
open
(
args
.
toJSON
,
"
w
"
)
json
.
dump
(
conf
,
oFile
,
indent
=
2
,
ensure_ascii
=
True
)
oFile
.
close
()
if
args
.
toPKL
:
oFile
=
open
(
args
.
toPKL
,
"
w
"
)
pickle
.
dump
(
conf
,
oFile
)
oFile
.
close
()
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