Commit ad4202ae authored by Yannick's avatar Yannick
Browse files

Merge branch 'logging' into 'master'


See merge request !18
parents a95216c4 5e71a7f1
Pipeline #44784 failed with stages
in 1 minute and 47 seconds
__version__ = '1.0.1'
__version__ = '1.0.2'
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)'PartitionInfo get secret took {(datetime.utcnow() - ts).total_seconds()} ms')
return secret
def _get_secret_client(self):
if not self._secret_client:
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__)
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:'PartitionService fetching partition info for "{data_partition_id}"')
PartitionsCache.set(data_partition_id, partition_info)
return partition_info
import logging
from typing import Optional, List, Any
from import BlobServiceClient
......@@ -18,6 +19,8 @@ from 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:"Acquire new Credentials using DefaultAzureCredential")
AzureAioBlobStorage.Credentials = DefaultAzureCredential(
else:"Using cached Credentials")
return AzureAioBlobStorage.Credentials
async def _get_blob_service_client(self, tenant):
......@@ -61,6 +67,7 @@ class AzureAioBlobStorage(BlobStorageBase):
async def close_credentials(cls):
""" This cause to gracefully dispose credentials if any. Next calls will then initialize a new one """"Closing cached Credentials")
credentials_to_close, cls.Credentials = cls.Credentials, None # swap
if credentials_to_close is not None:
await credentials_to_close.close()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment