Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
python-common
Commits
38eb0706
Commit
38eb0706
authored
9 years ago
by
Mohamed, Fawzi Roberto (fawzi)
Browse files
Options
Downloads
Patches
Plain Diff
adding PreOpened caching levels to cleanly cope with ancillary parsers
parent
0ebeec98
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/python/nomadcore/caching_backend.py
+17
-11
17 additions, 11 deletions
common/python/nomadcore/caching_backend.py
with
17 additions
and
11 deletions
common/python/nomadcore/caching_backend.py
+
17
−
11
View file @
38eb0706
...
@@ -15,6 +15,8 @@ class CachingLevel(object):
...
@@ -15,6 +15,8 @@ class CachingLevel(object):
Cache
=
2
Cache
=
2
ForwardAndCache
=
3
ForwardAndCache
=
3
Ignore
=
4
Ignore
=
4
PreOpenedCache
=
5
PreOpenedIgnore
=
6
@classmethod
@classmethod
def
toText
(
cls
,
cl
):
def
toText
(
cls
,
cl
):
...
@@ -26,6 +28,10 @@ class CachingLevel(object):
...
@@ -26,6 +28,10 @@ class CachingLevel(object):
return
"
Cache
"
return
"
Cache
"
elif
cl
==
cls
.
Ignore
:
elif
cl
==
cls
.
Ignore
:
return
"
Ignore
"
return
"
Ignore
"
elif
cl
==
cls
.
PreOpenedIgnore
:
return
"
PreOpenedIgnore
"
elif
cl
==
cls
.
PreOpenedCache
:
return
"
PreOpenedIgnore
"
else
:
else
:
return
"
CachingLevel(%s)
"
%
cl
return
"
CachingLevel(%s)
"
%
cl
...
@@ -273,7 +279,7 @@ class ActiveBackend(object):
...
@@ -273,7 +279,7 @@ class ActiveBackend(object):
sectionManagers
[
ik
.
name
]
=
CachingSectionManager
(
sectionManagers
[
ik
.
name
]
=
CachingSectionManager
(
metaInfo
=
ik
,
metaInfo
=
ik
,
parentSectionNames
=
parentS
,
parentSectionNames
=
parentS
,
storeInSuper
=
(
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
),
storeInSuper
=
(
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
),
forwardOpenClose
=
(
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
),
forwardOpenClose
=
(
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
),
onClose
=
onClose
.
get
(
ik
.
name
,
[]),
onClose
=
onClose
.
get
(
ik
.
name
,
[]),
onOpen
=
onOpen
.
get
(
ik
.
name
,
[]))
onOpen
=
onOpen
.
get
(
ik
.
name
,
[]))
...
@@ -395,10 +401,10 @@ class ActiveBackend(object):
...
@@ -395,10 +401,10 @@ class ActiveBackend(object):
a gIndex of -1 means the latest section
"""
a gIndex of -1 means the latest section
"""
dataManager
=
self
.
dataManagers
[
metaName
]
dataManager
=
self
.
dataManagers
[
metaName
]
cachingLevel
=
dataManager
.
cachingLevel
cachingLevel
=
dataManager
.
cachingLevel
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
:
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
if
self
.
superBackend
:
if
self
.
superBackend
:
self
.
superBackend
.
addValue
(
metaName
,
value
,
gIndex
)
self
.
superBackend
.
addValue
(
metaName
,
value
,
gIndex
)
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
:
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
dataManager
.
superSectionManager
.
addValue
(
dataManager
.
metaInfo
,
value
,
gIndex
)
dataManager
.
superSectionManager
.
addValue
(
dataManager
.
metaInfo
,
value
,
gIndex
)
def
addRealValue
(
self
,
metaName
,
value
,
gIndex
=
-
1
,
unit
=
None
):
def
addRealValue
(
self
,
metaName
,
value
,
gIndex
=
-
1
,
unit
=
None
):
...
@@ -410,10 +416,10 @@ class ActiveBackend(object):
...
@@ -410,10 +416,10 @@ class ActiveBackend(object):
dataManager
=
self
.
dataManagers
[
metaName
]
dataManager
=
self
.
dataManagers
[
metaName
]
cachingLevel
=
dataManager
.
cachingLevel
cachingLevel
=
dataManager
.
cachingLevel
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
:
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
if
self
.
superBackend
:
if
self
.
superBackend
:
self
.
superBackend
.
addRealValue
(
metaName
,
value
,
gIndex
)
self
.
superBackend
.
addRealValue
(
metaName
,
value
,
gIndex
)
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
:
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
dataManager
.
superSectionManager
.
addRealValue
(
dataManager
.
metaInfo
,
value
,
gIndex
)
dataManager
.
superSectionManager
.
addRealValue
(
dataManager
.
metaInfo
,
value
,
gIndex
)
def
addArray
(
self
,
metaName
,
shape
,
gIndex
=
-
1
):
def
addArray
(
self
,
metaName
,
shape
,
gIndex
=
-
1
):
...
@@ -423,10 +429,10 @@ class ActiveBackend(object):
...
@@ -423,10 +429,10 @@ class ActiveBackend(object):
the array is unitialized
"""
the array is unitialized
"""
dataManager
=
self
.
dataManagers
[
metaName
]
dataManager
=
self
.
dataManagers
[
metaName
]
cachingLevel
=
dataManager
.
cachingLevel
cachingLevel
=
dataManager
.
cachingLevel
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
:
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
if
self
.
superBackend
:
if
self
.
superBackend
:
self
.
superBackend
.
addArray
(
metaName
,
shape
,
gIndex
)
self
.
superBackend
.
addArray
(
metaName
,
shape
,
gIndex
)
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
:
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
dataManager
.
superSectionManager
.
addArray
(
dataManager
.
metaInfo
,
shape
,
gIndex
)
dataManager
.
superSectionManager
.
addArray
(
dataManager
.
metaInfo
,
shape
,
gIndex
)
def
setArrayValues
(
self
,
metaName
,
values
,
offset
=
None
,
gIndex
=
-
1
,
unit
=
None
):
def
setArrayValues
(
self
,
metaName
,
values
,
offset
=
None
,
gIndex
=
-
1
,
unit
=
None
):
...
@@ -436,10 +442,10 @@ class ActiveBackend(object):
...
@@ -436,10 +442,10 @@ class ActiveBackend(object):
dataManager
=
self
.
dataManagers
[
metaName
]
dataManager
=
self
.
dataManagers
[
metaName
]
cachingLevel
=
dataManager
.
cachingLevel
cachingLevel
=
dataManager
.
cachingLevel
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
:
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
if
self
.
superBackend
:
if
self
.
superBackend
:
self
.
superBackend
.
setArrayValues
(
metaName
,
values
,
offset
,
gIndex
)
self
.
superBackend
.
setArrayValues
(
metaName
,
values
,
offset
,
gIndex
)
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
:
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
dataManager
.
superSectionManager
.
setArrayValues
(
dataManager
.
metaInfo
,
values
,
offset
,
gIndex
)
dataManager
.
superSectionManager
.
setArrayValues
(
dataManager
.
metaInfo
,
values
,
offset
,
gIndex
)
def
addArrayValues
(
self
,
metaName
,
values
,
gIndex
=
-
1
,
unit
=
None
):
def
addArrayValues
(
self
,
metaName
,
values
,
gIndex
=
-
1
,
unit
=
None
):
...
@@ -449,10 +455,10 @@ class ActiveBackend(object):
...
@@ -449,10 +455,10 @@ class ActiveBackend(object):
values
=
self
.
convert_unit
(
metaName
,
values
,
unit
)
values
=
self
.
convert_unit
(
metaName
,
values
,
unit
)
dataManager
=
self
.
dataManagers
[
metaName
]
dataManager
=
self
.
dataManagers
[
metaName
]
cachingLevel
=
dataManager
.
cachingLevel
cachingLevel
=
dataManager
.
cachingLevel
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
:
if
cachingLevel
==
CachingLevel
.
Forward
or
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
if
self
.
superBackend
:
if
self
.
superBackend
:
self
.
superBackend
.
addArrayValues
(
metaName
,
values
,
gIndex
)
self
.
superBackend
.
addArrayValues
(
metaName
,
values
,
gIndex
)
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
:
if
cachingLevel
==
CachingLevel
.
ForwardAndCache
or
cachingLevel
==
CachingLevel
.
Cache
or
cachingLevel
==
CachingLevel
.
PreOpenedCache
:
dataManager
.
superSectionManager
.
addArrayValues
(
dataManager
.
metaInfo
,
values
,
gIndex
)
dataManager
.
superSectionManager
.
addArrayValues
(
dataManager
.
metaInfo
,
values
,
gIndex
)
def
convertScalarStringValue
(
self
,
metaName
,
strValue
):
def
convertScalarStringValue
(
self
,
metaName
,
strValue
):
...
...
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