Commit 6054beb5 authored by Jeremie Hallal's avatar Jeremie Hallal
Browse files

Merge branch 'master' into dask_parameters

parents 37c50d1d f4172ec7
Pipeline #47179 passed with stage
in 33 seconds
import logging
from typing import Optional
from datetime import datetime
from azure.keyvault.secrets import SecretClient
......@@ -6,6 +8,8 @@ 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:
......
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
......
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):
"""
......@@ -47,10 +50,13 @@ class AzureAioBlobStorage(BlobStorageBase):
@staticmethod
def _get_credentials():
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):
......@@ -62,6 +68,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()
......
# osdu core lib main python
--extra-index-url \
https://community.opengroup.org/api/v4/projects/465/packages/pypi/simple/
osdu-core-lib-python==1.1.0
osdu-core-lib-python~=1.1.0
Markdown is supported
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