Update read_azure_data

parent 99830b0f
......@@ -8,6 +8,10 @@ from pathlib import Path
import psycopg2
import os
import logging
import random
from ilens_sdk import Component
from ilens_sdk import logger
postgres_database = os.environ.get('postgres_database', default='ilens_jubilant')
postgre_user = os.environ.get('postgre_user', default='ilens')
......@@ -20,9 +24,6 @@ blob_container = os.environ.get('blob_container', 'jubilant')
job_id = os.environ.get('JOB_ID', 'job_6')
LOCAL_BLOB_PATH = os.environ.get('LOCAL_PATH', '/mnt/ilens/prod/jubilant')
# start_date = os.environ.get('start_date', '2021/07/06')
# end_date = os.environ.get('end_date', '2021/07/09')
start_date = os.environ.get('start_date', '')
end_date = os.environ.get('end_date', '')
date_lis = []
......@@ -47,6 +48,7 @@ class AzureBlobDownloaderHistorical:
self.engine_data = 'postgresql+psycopg2://{}:{}@{}:{}/{}'.format(postgre_user, postgre_password,
postgre_host,
postgre_port, postgres_database)
self.engine = create_engine(self.engine_data)
print("Intializing AzureBlobFileDownloader")
self.blob_service_client = BlobServiceClient.from_connection_string(my_connection_string)
......@@ -187,6 +189,7 @@ class AzureBlobDownloader:
self.engine_data = 'postgresql+psycopg2://{}:{}@{}:{}/{}'.format(postgre_user, postgre_password,
postgre_host,
postgre_port, postgres_database)
self.engine = create_engine(self.engine_data)
print("Intializing AzureBlobFileDownloader")
self.blob_service_client = BlobServiceClient.from_connection_string(my_connection_string)
......@@ -297,11 +300,20 @@ class AzureBlobDownloader:
except Exception as e:
logging.error(e)
class AzureDownloader(Component):
def __init__(self):
logger.info("starting component")
super().__init__()
if start_date != '' and end_date != '':
def run(self):
if start_date != '' and end_date != '':
azure_blob_file_downloader_historical = AzureBlobDownloaderHistorical()
azure_blob_file_downloader_historical.download_all_blobs_in_container()
else:
else:
azure_blob_file_downloader = AzureBlobDownloader()
azure_blob_file_downloader.download_all_blobs_in_container()
if __name__ == "__main__":
object = AzureDownloader()
object.start()
\ No newline at end of file
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