Skip to content
GitLab
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 Management Services
Wellbore
Lib
Wellbore-cloud
Wellbore-azure-lib
Commits
ad4202ae
Commit
ad4202ae
authored
Jun 04, 2021
by
Yannick
Browse files
Merge branch 'logging' into 'master'
Logging See merge request
!18
parents
a95216c4
5e71a7f1
Pipeline
#44784
failed with stages
in 1 minute and 47 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
osdu_az/__init__.py
View file @
ad4202ae
__version__
=
'1.0.
1
'
__version__
=
'1.0.
2
'
osdu_az/partition/partition_info.py
View file @
ad4202ae
import
logging
from
typing
import
Optional
from
azure.keyvault.secrets
import
SecretClient
from
osdu_az
import
conf
from
osdu_az.identity.az_identity
import
AzureIdentity
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
PartitionInfo
():
def
__init__
(
self
,
partition_properties
:
dict
=
None
):
self
.
_partition_properties
=
partition_properties
...
...
@@ -23,7 +27,10 @@ class PartitionInfo():
return
secret
.
value
def
_get_secret
(
self
,
key
:
str
):
return
self
.
_get_secret_client
().
get_secret
(
key
)
ts
=
datetime
.
utcnow
()
secret
=
self
.
_get_secret_client
().
get_secret
(
key
)
_LOGGER
.
info
(
f
'PartitionInfo get secret took
{
(
datetime
.
utcnow
()
-
ts
).
total_seconds
()
}
ms'
)
return
secret
def
_get_secret_client
(
self
):
if
not
self
.
_secret_client
:
...
...
osdu_az/partition/partition_service.py
View file @
ad4202ae
import
logging
from
os
import
environ
from
osdu_az.opendes.fake_partition_client
import
FakePartitionClient
...
...
@@ -5,6 +6,8 @@ from osdu_az.opendes.partition_client import PartitionClient
from
osdu_az.partition.partition_info
import
PartitionInfo
from
osdu_az.partition.partitions_cache
import
PartitionsCache
_LOGGER
=
logging
.
getLogger
(
__name__
)
# KNOWN CORE PARTITION PROPERTIES
COSMOS_ENDPOINT
=
'cosmos-endpoint'
COSMOS_CONNECTION
=
'cosmos-connection'
...
...
@@ -30,6 +33,7 @@ class PartitionService:
if
not
partition_info
:
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
}
"'
)
PartitionsCache
.
set
(
data_partition_id
,
partition_info
)
return
partition_info
...
...
osdu_az/storage/blob_storage_az.py
View file @
ad4202ae
import
logging
from
typing
import
Optional
,
List
,
Any
from
azure.storage.blob.aio
import
BlobServiceClient
...
...
@@ -18,6 +19,8 @@ from osdu.core.api.storage.exceptions import (
from
osdu_az.partition.partition_service
import
PartitionService
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
AzureAioBlobStorage
(
BlobStorageBase
):
"""
...
...
@@ -46,10 +49,13 @@ class AzureAioBlobStorage(BlobStorageBase):
def
_get_credentials
(
self
):
if
AzureAioBlobStorage
.
Credentials
is
None
:
_LOGGER
.
info
(
f
"Acquire new Credentials using DefaultAzureCredential"
)
AzureAioBlobStorage
.
Credentials
=
DefaultAzureCredential
(
exclude_shared_token_cache_credential
=
True
,
exclude_visual_studio_code_credential
=
True
,
exclude_environment_credential
=
True
)
else
:
_LOGGER
.
info
(
f
"Using cached Credentials"
)
return
AzureAioBlobStorage
.
Credentials
async
def
_get_blob_service_client
(
self
,
tenant
):
...
...
@@ -61,6 +67,7 @@ class AzureAioBlobStorage(BlobStorageBase):
@
classmethod
async
def
close_credentials
(
cls
):
""" This cause to gracefully dispose credentials if any. Next calls will then initialize a new one """
_LOGGER
.
info
(
f
"Closing cached Credentials"
)
credentials_to_close
,
cls
.
Credentials
=
cls
.
Credentials
,
None
# swap
if
credentials_to_close
is
not
None
:
await
credentials_to_close
.
close
()
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment