From 4def921e03389a1963be28e52d606b0b17e8df02 Mon Sep 17 00:00:00 2001 From: Simo Tukiainen Date: Wed, 1 Nov 2023 14:48:02 +0200 Subject: [PATCH] Add default session --- scripts/put-legacy-files.py | 2 +- src/data_processing/metadata_api.py | 2 +- src/data_processing/subcmds/create_images.py | 2 +- src/data_processing/subcmds/create_qc_reports.py | 2 +- src/data_processing/subcmds/freeze.py | 2 +- src/data_processing/subcmds/upload_to_dvas.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/put-legacy-files.py b/scripts/put-legacy-files.py index fdc214bd..120e3f3f 100755 --- a/scripts/put-legacy-files.py +++ b/scripts/put-legacy-files.py @@ -25,7 +25,7 @@ def main(ARGS: argparse.Namespace): logging.basicConfig(level="INFO") config = utils.read_main_conf() - md_api = MetadataApi(config, make_session()) + md_api = MetadataApi(config) storage_api = StorageApi(config, make_session()) pid_utils = PidUtils(config) ARGS.site = PurePath(ARGS.path[0]).name diff --git a/src/data_processing/metadata_api.py b/src/data_processing/metadata_api.py index 164c7710..cc36c2e5 100644 --- a/src/data_processing/metadata_api.py +++ b/src/data_processing/metadata_api.py @@ -12,7 +12,7 @@ class MetadataApi: """Class handling connection between Cloudnet files and database.""" - def __init__(self, config: dict, session: requests.Session): + def __init__(self, config: dict, session: requests.Session = utils.make_session()): self.config = config self.session = session self._url = config["DATAPORTAL_URL"] diff --git a/src/data_processing/subcmds/create_images.py b/src/data_processing/subcmds/create_images.py index e272221f..85687ca2 100755 --- a/src/data_processing/subcmds/create_images.py +++ b/src/data_processing/subcmds/create_images.py @@ -18,7 +18,7 @@ def main(args, storage_session: requests.Session | None = None): if storage_session is None: storage_session = make_session() config = read_main_conf() - md_api = metadata_api.MetadataApi(config, make_session()) + md_api = metadata_api.MetadataApi(config) storage_api = StorageApi(config, storage_session) metadata = md_api.find_product_metadata(args) temp_dir_root = utils.get_temp_dir(config) diff --git a/src/data_processing/subcmds/create_qc_reports.py b/src/data_processing/subcmds/create_qc_reports.py index 71706349..7a34eee3 100755 --- a/src/data_processing/subcmds/create_qc_reports.py +++ b/src/data_processing/subcmds/create_qc_reports.py @@ -19,7 +19,7 @@ def main(args, storage_session: requests.Session | None = None): if storage_session is None: storage_session = make_session() config = read_main_conf() - md_api = metadata_api.MetadataApi(config, make_session()) + md_api = metadata_api.MetadataApi(config) storage_api = StorageApi(config, storage_session) metadata = md_api.find_product_metadata(args, legacy_files=False) temp_dir_root = utils.get_temp_dir(config) diff --git a/src/data_processing/subcmds/freeze.py b/src/data_processing/subcmds/freeze.py index 4069a7a2..1503836f 100755 --- a/src/data_processing/subcmds/freeze.py +++ b/src/data_processing/subcmds/freeze.py @@ -32,7 +32,7 @@ def main(args, storage_session: requests.Session | None = None): config = read_main_conf() pid_utils = PidUtils(config) - md_api = metadata_api.MetadataApi(config, make_session()) + md_api = metadata_api.MetadataApi(config) storage_api = StorageApi(config, storage_session) metadata = md_api.find_files_to_freeze(args) logging.info(f"Found {len(metadata)} files to freeze.") diff --git a/src/data_processing/subcmds/upload_to_dvas.py b/src/data_processing/subcmds/upload_to_dvas.py index 6d017c4f..8ccd09f7 100755 --- a/src/data_processing/subcmds/upload_to_dvas.py +++ b/src/data_processing/subcmds/upload_to_dvas.py @@ -8,7 +8,7 @@ def main(args): config = utils.read_main_conf() - md_api = MetadataApi(config, utils.make_session()) + md_api = MetadataApi(config) if args.truncate: _truncate_clu_data(md_api)