Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Wellbore
Lib
Wellbore-cloud
Wellbore-azure-lib
Commits
32398e6f
Commit
32398e6f
authored
Jun 07, 2021
by
Yannick
Browse files
logging + cache extended to 1h
parent
d330c770
Pipeline
#44979
passed with stage
in 41 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
osdu_az/partition/partition_service.py
View file @
32398e6f
import
logging
from
os
import
environ
import
uuid
from
osdu_az.opendes.fake_partition_client
import
FakePartitionClient
from
osdu_az.opendes.partition_client
import
PartitionClient
...
...
@@ -26,12 +27,13 @@ PARTITION_ID = 'id'
class
PartitionService
:
partition_client
=
None
scope
=
''
_id
=
str
(
uuid
.
uuid4
())
@
staticmethod
async
def
get_partition
(
data_partition_id
:
str
)
->
PartitionInfo
:
partition_info
=
PartitionsCache
.
get
(
data_partition_id
)
if
partition_info
is
None
:
_LOGGER
.
info
(
f
'Partition info "
{
data_partition_id
}
" not cached => fetch it'
)
_LOGGER
.
info
(
f
'
[id
{
PartitionService
.
_id
}
]
Partition info "
{
data_partition_id
}
" not cached => fetch it'
)
partition_info
=
await
PartitionService
.
_partition_client
().
get_partition
(
data_partition_id
)
if
partition_info
:
_LOGGER
.
info
(
f
'PartitionService fetching partition info for "
{
data_partition_id
}
"'
)
...
...
osdu_az/partition/partitions_cache.py
View file @
32398e6f
import
logging
from
cachetools
import
TTLCache
import
uuid
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
PartitionsCache
:
partitions_cache
=
TTLCache
(
maxsize
=
100
,
ttl
=
300
)
partitions_cache
=
TTLCache
(
maxsize
=
100
,
ttl
=
3600
)
_id
=
str
(
uuid
.
uuid4
())
@
staticmethod
def
get
(
data_partition_id
:
str
):
...
...
@@ -13,7 +15,7 @@ class PartitionsCache:
@
staticmethod
def
set
(
data_partition_id
:
str
,
partition_info
):
_LOGGER
.
info
(
f
"
set in p
artition
c
ache
{
P
artition
sC
ache
}
info fr
om
'
{
data_partition_id
}
'"
)
_LOGGER
.
info
(
f
"
[cache id
{
P
artition
sC
ache
.
_id
}
] set in p
artition
c
ache info f
o
r '
{
data_partition_id
}
'"
)
PartitionsCache
.
partitions_cache
[
data_partition_id
]
=
partition_info
@
staticmethod
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment