From eda0d4cadf2c6f9aa797e495a82ffad778cd9055 Mon Sep 17 00:00:00 2001 From: "jason.regina" Date: Thu, 6 Jun 2024 20:07:49 +0000 Subject: [PATCH] use default factory for non standard types --- .../nwm_client_new/NWMClientDefaults.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/python/nwm_client_new/src/hydrotools/nwm_client_new/NWMClientDefaults.py b/python/nwm_client_new/src/hydrotools/nwm_client_new/NWMClientDefaults.py index 8baadede..a07acc0a 100644 --- a/python/nwm_client_new/src/hydrotools/nwm_client_new/NWMClientDefaults.py +++ b/python/nwm_client_new/src/hydrotools/nwm_client_new/NWMClientDefaults.py @@ -48,19 +48,20 @@ class NWMClientDefaults: DOWNLOAD_DIRECTORY: Local path to save downloaded NWM files. Default is class level object, not instance object. UNIT_SYSTEM: Default system of measurements. """ - STORE: ParquetStore = ParquetStore( - "hydrotools_data/nwm_store.parquet", - write_index=False, - compression="snappy" - ) - CATALOG: NWMFileCatalog = GCPFileCatalog() - SSL_CONTEXT: ssl.SSLContext = ssl.create_default_context() + STORE: ParquetStore = field( + default_factory=lambda: ParquetStore( + "hydrotools_data/nwm_store.parquet", + write_index=False, + compression="snappy" + )) + CATALOG: NWMFileCatalog = field(default_factory=GCPFileCatalog) + SSL_CONTEXT: ssl.SSLContext = field(default_factory=ssl.create_default_context) ROUTELINK_URL: str = "https://www.hydroshare.org/resource/e9fe66730d184bdfbaea19639bd7cb55/data/contents/RouteLink.h5" VARIABLES: List[str] = field(default_factory=lambda: ["streamflow"]) NWM_TO_SI_UNIT_MAPPING: Dict[str, str] = field(default_factory=lambda: {"m": "m", "m s-1": "m/s", "m3 s-1": "m^3/s"}) SI_TO_US_UNIT_MAPPING: Dict[str, str] = field(default_factory=lambda: {"m": "ft", "m/s": "ft/s", "m^3/s": "ft^3/s"}) DOWNLOAD_DIRECTORY: Path = Path("hydrotools_data/NWMFileClient_NetCDF_files") - UNIT_SYSTEM: MeasurementUnitSystem = MeasurementUnitSystem.SI + UNIT_SYSTEM: MeasurementUnitSystem = field(default_factory=lambda: MeasurementUnitSystem.SI) def _download_and_read_routelink_file(self) -> dd.DataFrame: """Retrieve NWM RouteLink data from URL and return a