From 51aa9c86c76aaf62157f2b4b374c33f37eba0a5b Mon Sep 17 00:00:00 2001 From: Dobson Date: Mon, 4 Mar 2024 15:50:53 +0000 Subject: [PATCH 01/13] Implement loggers --- dev-requirements.txt | 5 +++++ pyproject.toml | 1 + requirements.txt | 5 +++++ swmmanywhere/graph_utilities.py | 3 ++- swmmanywhere/prepare_data.py | 12 ++++++----- swmmanywhere/preprocessing.py | 13 ++++++------ swmmanywhere/utils.py | 35 +++++++++++++++++++++++++++++++++ tests/test_utils.py | 33 +++++++++++++++++++++++++++++++ 8 files changed, 95 insertions(+), 12 deletions(-) create mode 100644 swmmanywhere/utils.py create mode 100644 tests/test_utils.py diff --git a/dev-requirements.txt b/dev-requirements.txt index f6235d0d..ad480a52 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -55,6 +55,7 @@ colorama==0.4.6 # via # build # click + # loguru # pytest # tqdm contourpy==1.2.0 @@ -116,6 +117,8 @@ lazy-loader==0.3 # via scikit-image llvmlite==0.41.1 # via numba +loguru==0.7.2 + # via swmmanywhere (pyproject.toml) matplotlib==3.8.2 # via # salib @@ -300,6 +303,8 @@ virtualenv==20.24.5 # via pre-commit wheel==0.41.3 # via pip-tools +win32-setctime==1.1.0 + # via loguru xarray==2023.12.0 # via # rioxarray diff --git a/pyproject.toml b/pyproject.toml index dedfb435..89ee1d5e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ dependencies = [ # TODO definitely don't need all of these "geopandas", "geopy", "GitPython", + "loguru", "matplotlib", "netcdf4", "networkx", diff --git a/requirements.txt b/requirements.txt index ca662511..c31fab18 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,6 +48,7 @@ cligj==0.7.2 colorama==0.4.6 # via # click + # loguru # tqdm contourpy==1.2.0 # via matplotlib @@ -94,6 +95,8 @@ lazy-loader==0.3 # via scikit-image llvmlite==0.41.1 # via numba +loguru==0.7.2 + # via swmmanywhere (pyproject.toml) matplotlib==3.8.2 # via # salib @@ -237,6 +240,8 @@ tzdata==2024.1 # via pandas urllib3==2.1.0 # via requests +win32-setctime==1.1.0 + # via loguru xarray==2023.12.0 # via # rioxarray diff --git a/swmmanywhere/graph_utilities.py b/swmmanywhere/graph_utilities.py index 1698417c..2ac75e0b 100644 --- a/swmmanywhere/graph_utilities.py +++ b/swmmanywhere/graph_utilities.py @@ -22,6 +22,7 @@ from swmmanywhere import geospatial_utilities as go from swmmanywhere import parameters +from swmmanywhere.utils import logger def load_graph(fid: Path) -> nx.Graph: @@ -940,7 +941,7 @@ def process_successors(G: nx.Graph, edge_diams[(node,ds_node,0)] = diam chamber_floor[ds_node] = surface_elevations[ds_node] - depth if ix > 0: - print('''a node has multiple successors, + logger.warning('''a node has multiple successors, not sure how that can happen if using shortest path to derive topology''') diff --git a/swmmanywhere/prepare_data.py b/swmmanywhere/prepare_data.py index fdc68fb2..5f86dda7 100644 --- a/swmmanywhere/prepare_data.py +++ b/swmmanywhere/prepare_data.py @@ -18,7 +18,9 @@ import yaml from geopy.geocoders import Nominatim -# Some minor comment (to remove) +from swmmanywhere.utils import logger + +logger = logger.get_logger() def get_country(x: float, y: float) -> dict[int, str]: @@ -85,9 +87,9 @@ def download_buildings(file_address: Path, # Save data to the specified file address with file_address.open("wb") as file: file.write(response.content) - print(f"Data downloaded and saved to {file_address}") + logger.info(f"Data downloaded and saved to {file_address}") else: - print(f"Error downloading data. Status code: {response.status_code}") + logger.error(f"Error downloading data. Status code: {response.status_code}") return response.status_code def download_street(bbox: tuple[float, float, float, float]) -> nx.MultiDiGraph: @@ -176,10 +178,10 @@ def download_elevation(fid: Path, with fid.open('wb') as rast_file: shutil.copyfileobj(r.raw, rast_file) - print('Elevation data downloaded successfully.') + logger.info('Elevation data downloaded successfully.') except requests.exceptions.RequestException as e: - print(f'Error downloading elevation data: {e}') + logger.error(f'Error downloading elevation data: {e}') return r.status_code diff --git a/swmmanywhere/preprocessing.py b/swmmanywhere/preprocessing.py index 123c0469..ccbec638 100644 --- a/swmmanywhere/preprocessing.py +++ b/swmmanywhere/preprocessing.py @@ -16,6 +16,7 @@ from swmmanywhere import geospatial_utilities as go from swmmanywhere import graph_utilities as gu from swmmanywhere import parameters, prepare_data +from swmmanywhere.utils import logger def next_directory(keyword: str, directory: Path) -> int: @@ -161,7 +162,7 @@ def prepare_precipitation(bbox: tuple[float, float, float, float], """Download and reproject precipitation data.""" if addresses.precipitation.exists(): return - print(f'downloading precipitation to {addresses.precipitation}') + logger.info(f'downloading precipitation to {addresses.precipitation}') precip = prepare_data.download_precipitation(bbox, api_keys['cds_username'], api_keys['cds_api_key']) @@ -179,7 +180,7 @@ def prepare_elvation(bbox: tuple[float, float, float, float], """Download and reproject elevation data.""" if addresses.elevation.exists(): return - print(f'downloading elevation to {addresses.elevation}') + logger.info(f'downloading elevation to {addresses.elevation}') with tempfile.TemporaryDirectory() as temp_dir: fid = Path(temp_dir) / 'elevation.tif' prepare_data.download_elevation(fid, @@ -198,12 +199,12 @@ def prepare_building(bbox: tuple[float, float, float, float], return if not addresses.national_building.exists(): - print(f'downloading buildings to {addresses.national_building}') + logger.info(f'downloading buildings to {addresses.national_building}') prepare_data.download_buildings(addresses.national_building, bbox[0], bbox[1]) - print(f'trimming buildings to {addresses.building}') + logger.info(f'trimming buildings to {addresses.building}') national_buildings = gpd.read_parquet(addresses.national_building) buildings = national_buildings.cx[bbox[0]:bbox[2], bbox[1]:bbox[3]] # type: ignore @@ -217,7 +218,7 @@ def prepare_street(bbox: tuple[float, float, float, float], """Download and reproject street graph.""" if addresses.street.exists(): return - print(f'downloading street network to {addresses.street}') + logger.info(f'downloading street network to {addresses.street}') street_network = prepare_data.download_street(bbox) street_network = go.reproject_graph(street_network, source_crs, @@ -231,7 +232,7 @@ def prepare_river(bbox: tuple[float, float, float, float], """Download and reproject river graph.""" if addresses.river.exists(): return - print(f'downloading river network to {addresses.river}') + logger.info(f'downloading river network to {addresses.river}') river_network = prepare_data.download_river(bbox) river_network = go.reproject_graph(river_network, source_crs, diff --git a/swmmanywhere/utils.py b/swmmanywhere/utils.py new file mode 100644 index 00000000..b4296b10 --- /dev/null +++ b/swmmanywhere/utils.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +"""Created on 2024-03-04. + +@author: Barney +""" +import os +import sys + +import loguru + + +def get_logger(verbose: bool = False) -> loguru.logger: + """Get a logger.""" + logger = loguru.logger + logger.configure( + handlers=[ + { + "sink": sys.stdout, + "colorize": True, + "format": " | ".join( + [ + "{time:YYYY/MM/DD HH:mm:ss}", + "{message}", + ] + ), + } + ] + ) + if os.getenv("PACKAGE_NAME_VERBOSE", str(verbose)).lower() == "true": + logger.enable("package_name") + else: + logger.disable("package_name") + return logger + +logger = get_logger() \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 00000000..c931419e --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +"""Created on 2024-01-26. + +@author: Barney +""" +from pathlib import Path +from tempfile import NamedTemporaryFile + +from swmmanywhere.utils import logger + + +def test_logger(): + """Test the get_logger function.""" + assert logger is not None + logger.debug("This is a debug message.") + logger.info("This is an info message.") + logger.warning("This is a warning message.") + logger.error("This is an error message.") + logger.critical("This is a critical message.") + + with NamedTemporaryFile(suffix='.log', + mode = 'w+b', + delete=False) as temp_file: + fid = Path(temp_file.name) + logger.add(fid) + logger.debug("This is a debug message.") + logger.info("This is an info message.") + logger.warning("This is a warning message.") + logger.error("This is an error message.") + logger.critical("This is a critical message.") + assert temp_file.read() != b"" + logger.remove() + fid.unlink() \ No newline at end of file From bde7e860e3c85267ca0539821eae87f65e2d9986 Mon Sep 17 00:00:00 2001 From: Dobson Date: Mon, 4 Mar 2024 15:55:42 +0000 Subject: [PATCH 02/13] Logger error --- swmmanywhere/prepare_data.py | 1 - 1 file changed, 1 deletion(-) diff --git a/swmmanywhere/prepare_data.py b/swmmanywhere/prepare_data.py index 5f86dda7..8d7e2721 100644 --- a/swmmanywhere/prepare_data.py +++ b/swmmanywhere/prepare_data.py @@ -20,7 +20,6 @@ from swmmanywhere.utils import logger -logger = logger.get_logger() def get_country(x: float, y: float) -> dict[int, str]: From 62457a8e55e97a57588c6553113b86adc4b46922 Mon Sep 17 00:00:00 2001 From: Dobson Date: Tue, 5 Mar 2024 13:59:41 +0000 Subject: [PATCH 03/13] Test global behaviour of logger --- swmmanywhere/utils.py | 12 +++++------- tests/test_utils.py | 37 ++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/swmmanywhere/utils.py b/swmmanywhere/utils.py index b4296b10..f92a9ee1 100644 --- a/swmmanywhere/utils.py +++ b/swmmanywhere/utils.py @@ -3,13 +3,12 @@ @author: Barney """ -import os import sys import loguru -def get_logger(verbose: bool = False) -> loguru.logger: +def get_logger() -> loguru.logger: """Get a logger.""" logger = loguru.logger logger.configure( @@ -26,10 +25,9 @@ def get_logger(verbose: bool = False) -> loguru.logger: } ] ) - if os.getenv("PACKAGE_NAME_VERBOSE", str(verbose)).lower() == "true": - logger.enable("package_name") - else: - logger.disable("package_name") + # Disable by default + logger.disable("swmmanywhere") return logger -logger = get_logger() \ No newline at end of file +logger = get_logger() +logger.test_logger = lambda : logger.info("This is a test message.") \ No newline at end of file diff --git a/tests/test_utils.py b/tests/test_utils.py index c931419e..5ae03030 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -10,24 +10,47 @@ def test_logger(): - """Test the get_logger function.""" + """Test logger.""" + logger.enable('swmmanywhere') assert logger is not None + logger.test_logger() logger.debug("This is a debug message.") logger.info("This is an info message.") logger.warning("This is a warning message.") logger.error("This is an error message.") logger.critical("This is a critical message.") - with NamedTemporaryFile(suffix='.log', mode = 'w+b', delete=False) as temp_file: fid = Path(temp_file.name) logger.add(fid) - logger.debug("This is a debug message.") - logger.info("This is an info message.") - logger.warning("This is a warning message.") - logger.error("This is an error message.") - logger.critical("This is a critical message.") + logger.test_logger() assert temp_file.read() != b"" logger.remove() + fid.unlink() + +def test_logger_disable(): + """Test the disable function.""" + with NamedTemporaryFile(suffix='.log', + mode = 'w+b', + delete=False) as temp_file: + fid = Path(temp_file.name) + logger.disable('swmmanywhere') + logger.add(fid) + logger.test_logger() + assert temp_file.read() == b"" + logger.remove() + fid.unlink() + +def test_logger_reimport(): + """Reimport logger to check that changes from disable are persistent.""" + from swmmanywhere.utils import logger + with NamedTemporaryFile(suffix='.log', + mode = 'w+b', + delete=False) as temp_file: + fid = Path(temp_file.name) + logger.add(fid) + logger.test_logger() + assert temp_file.read() == b"" + logger.remove() fid.unlink() \ No newline at end of file From e25b3f5aa96db0eec8ac6a1328c02925074b0522 Mon Sep 17 00:00:00 2001 From: Dobson Date: Tue, 5 Mar 2024 14:01:18 +0000 Subject: [PATCH 04/13] Rename utils to logging --- swmmanywhere/graph_utilities.py | 2 +- swmmanywhere/{utils.py => logging.py} | 0 swmmanywhere/preprocessing.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename swmmanywhere/{utils.py => logging.py} (100%) diff --git a/swmmanywhere/graph_utilities.py b/swmmanywhere/graph_utilities.py index 2ac75e0b..02843105 100644 --- a/swmmanywhere/graph_utilities.py +++ b/swmmanywhere/graph_utilities.py @@ -22,7 +22,7 @@ from swmmanywhere import geospatial_utilities as go from swmmanywhere import parameters -from swmmanywhere.utils import logger +from swmmanywhere.logging import logger def load_graph(fid: Path) -> nx.Graph: diff --git a/swmmanywhere/utils.py b/swmmanywhere/logging.py similarity index 100% rename from swmmanywhere/utils.py rename to swmmanywhere/logging.py diff --git a/swmmanywhere/preprocessing.py b/swmmanywhere/preprocessing.py index ccbec638..30c9abf3 100644 --- a/swmmanywhere/preprocessing.py +++ b/swmmanywhere/preprocessing.py @@ -16,7 +16,7 @@ from swmmanywhere import geospatial_utilities as go from swmmanywhere import graph_utilities as gu from swmmanywhere import parameters, prepare_data -from swmmanywhere.utils import logger +from swmmanywhere.logging import logger def next_directory(keyword: str, directory: Path) -> int: From e8129fb11910683f0a50b34b526522b6ad2476a5 Mon Sep 17 00:00:00 2001 From: Dobson Date: Tue, 5 Mar 2024 14:01:45 +0000 Subject: [PATCH 05/13] Update test_utils.py --- tests/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 5ae03030..54c804a1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -6,7 +6,7 @@ from pathlib import Path from tempfile import NamedTemporaryFile -from swmmanywhere.utils import logger +from swmmanywhere.logging import logger def test_logger(): @@ -44,7 +44,7 @@ def test_logger_disable(): def test_logger_reimport(): """Reimport logger to check that changes from disable are persistent.""" - from swmmanywhere.utils import logger + from swmmanywhere.logging import logger with NamedTemporaryFile(suffix='.log', mode = 'w+b', delete=False) as temp_file: From a8c5d913d7ef6dfecb45e9d7a4e0833f01eca9e4 Mon Sep 17 00:00:00 2001 From: Dobson Date: Tue, 5 Mar 2024 14:07:01 +0000 Subject: [PATCH 06/13] rename test_utils to testlogging --- tests/{test_utils.py => test_logging.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{test_utils.py => test_logging.py} (100%) diff --git a/tests/test_utils.py b/tests/test_logging.py similarity index 100% rename from tests/test_utils.py rename to tests/test_logging.py From e8e98f720d91398a77d85bd41fe5d05a8ffb5290 Mon Sep 17 00:00:00 2001 From: Dobson Date: Tue, 5 Mar 2024 14:14:53 +0000 Subject: [PATCH 07/13] Update prepare_data.py --- swmmanywhere/prepare_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swmmanywhere/prepare_data.py b/swmmanywhere/prepare_data.py index 8d7e2721..45bea2aa 100644 --- a/swmmanywhere/prepare_data.py +++ b/swmmanywhere/prepare_data.py @@ -18,7 +18,7 @@ import yaml from geopy.geocoders import Nominatim -from swmmanywhere.utils import logger +from swmmanywhere.logging import logger def get_country(x: float, From cfa0218343187a0b6ba0e1b17952ad62d3951607 Mon Sep 17 00:00:00 2001 From: Dobson Date: Wed, 6 Mar 2024 11:15:57 +0000 Subject: [PATCH 08/13] Add filter to enable global --- swmmanywhere/logging.py | 31 ++++++++++++++++++++++++++++--- tests/test_logging.py | 18 ++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/swmmanywhere/logging.py b/swmmanywhere/logging.py index f92a9ee1..77c874c4 100644 --- a/swmmanywhere/logging.py +++ b/swmmanywhere/logging.py @@ -3,11 +3,19 @@ @author: Barney """ +import os import sys import loguru +def dynamic_filter(record): + """A dynamic filter.""" + print(os.getenv("SWMMANYWHERE_VERBOSE", "false").lower()) + if os.getenv("SWMMANYWHERE_VERBOSE", "false").lower() == "true": + return True + return False + def get_logger() -> loguru.logger: """Get a logger.""" logger = loguru.logger @@ -15,6 +23,7 @@ def get_logger() -> loguru.logger: handlers=[ { "sink": sys.stdout, + "filter" : dynamic_filter, "colorize": True, "format": " | ".join( [ @@ -25,9 +34,25 @@ def get_logger() -> loguru.logger: } ] ) - # Disable by default - logger.disable("swmmanywhere") return logger +# Get the logger logger = get_logger() -logger.test_logger = lambda : logger.info("This is a test message.") \ No newline at end of file + +# Add a test_logger method to the logger +logger.test_logger = lambda : logger.info("This is a test message.") + +# Store the original add method +original_add = logger.add + +# Define a new function that wraps the original add method +def new_add(sink, **kwargs): + """A new add method to wrap existing one but with the filter.""" + # Include the dynamic filter in the kwargs if not already specified + if 'filter' not in kwargs: + kwargs['filter'] = dynamic_filter + # Call the original add method with the updated kwargs + return original_add(sink, **kwargs) + +# Replace the logger's add method with your new function +logger.add = new_add \ No newline at end of file diff --git a/tests/test_logging.py b/tests/test_logging.py index 54c804a1..f228ebfc 100644 --- a/tests/test_logging.py +++ b/tests/test_logging.py @@ -3,6 +3,7 @@ @author: Barney """ +import os from pathlib import Path from tempfile import NamedTemporaryFile @@ -11,7 +12,7 @@ def test_logger(): """Test logger.""" - logger.enable('swmmanywhere') + os.environ["SWMMANYWHERE_VERBOSE"] = "true" assert logger is not None logger.test_logger() logger.debug("This is a debug message.") @@ -35,7 +36,7 @@ def test_logger_disable(): mode = 'w+b', delete=False) as temp_file: fid = Path(temp_file.name) - logger.disable('swmmanywhere') + os.environ["SWMMANYWHERE_VERBOSE"] = "false" logger.add(fid) logger.test_logger() assert temp_file.read() == b"" @@ -53,4 +54,17 @@ def test_logger_reimport(): logger.test_logger() assert temp_file.read() == b"" logger.remove() + fid.unlink() + +def test_logger_again(): + """Test the logger after these changes to make sure still works.""" + os.environ["SWMMANYWHERE_VERBOSE"] = "true" + with NamedTemporaryFile(suffix='.log', + mode = 'w+b', + delete=False) as temp_file: + fid = Path(temp_file.name) + logger.add(fid) + logger.test_logger() + assert temp_file.read() != b"" + logger.remove() fid.unlink() \ No newline at end of file From bb9828b20b6f721f1b8e09e4b979de9a6cea8f1a Mon Sep 17 00:00:00 2001 From: Dobson Date: Wed, 6 Mar 2024 11:18:54 +0000 Subject: [PATCH 09/13] Update logging.py remove debug print --- swmmanywhere/logging.py | 1 - 1 file changed, 1 deletion(-) diff --git a/swmmanywhere/logging.py b/swmmanywhere/logging.py index 77c874c4..b3852875 100644 --- a/swmmanywhere/logging.py +++ b/swmmanywhere/logging.py @@ -11,7 +11,6 @@ def dynamic_filter(record): """A dynamic filter.""" - print(os.getenv("SWMMANYWHERE_VERBOSE", "false").lower()) if os.getenv("SWMMANYWHERE_VERBOSE", "false").lower() == "true": return True return False From cdebee2eba662d2ad129f4bc7e84746462430b74 Mon Sep 17 00:00:00 2001 From: Dobson Date: Wed, 6 Mar 2024 11:19:45 +0000 Subject: [PATCH 10/13] Update logging.py make it less obvious that chatgpt wrote this... --- swmmanywhere/logging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swmmanywhere/logging.py b/swmmanywhere/logging.py index b3852875..0bf7702c 100644 --- a/swmmanywhere/logging.py +++ b/swmmanywhere/logging.py @@ -53,5 +53,5 @@ def new_add(sink, **kwargs): # Call the original add method with the updated kwargs return original_add(sink, **kwargs) -# Replace the logger's add method with your new function +# Replace the logger's add method with new_add logger.add = new_add \ No newline at end of file From acd107957492e9e834ddd516544ebfef375bb369 Mon Sep 17 00:00:00 2001 From: barneydobson Date: Thu, 7 Mar 2024 08:23:20 +0000 Subject: [PATCH 11/13] Update logging.py --- swmmanywhere/logging.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/swmmanywhere/logging.py b/swmmanywhere/logging.py index 0bf7702c..4eff38e0 100644 --- a/swmmanywhere/logging.py +++ b/swmmanywhere/logging.py @@ -11,9 +11,7 @@ def dynamic_filter(record): """A dynamic filter.""" - if os.getenv("SWMMANYWHERE_VERBOSE", "false").lower() == "true": - return True - return False + return os.getenv("SWMMANYWHERE_VERBOSE", "false").lower() == "true" def get_logger() -> loguru.logger: """Get a logger.""" From b1ebd0c4275871e266d950a45eb2fb9c474b5589 Mon Sep 17 00:00:00 2001 From: barneydobson Date: Thu, 7 Mar 2024 08:38:04 +0000 Subject: [PATCH 12/13] Update pyproject.toml --- pyproject.toml | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 89ee1d5e..bac46007 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,34 +13,35 @@ authors = [ { name = "Imperial College London RSE Team", email = "ict-rse-team@imperial.ac.uk" } ] requires-python = ">=3.10" -dependencies = [ # TODO definitely don't need all of these - "cdsapi", - "fastparquet", - "fiona", - "geopandas", - "geopy", - "GitPython", - "loguru", - "matplotlib", - "netcdf4", - "networkx", - "numpy", - "osmnx", - "pandas", - "pyarrow", - "pydantic", - "pysheds", - "pyswmm", - "PyYAML", - "rasterio", - "rioxarray", - "SALib", - "SciPy", - "shapely", - "snkit", - "tqdm", - "xarray" - ] +dependencies = [ + # TODO definitely don't need all of these + "cdsapi", + "fastparquet", + "fiona", + "geopandas", + "geopy", + "GitPython", + "loguru", + "matplotlib", + "netcdf4", + "networkx", + "numpy", + "osmnx", + "pandas", + "pyarrow", + "pydantic", + "pysheds", + "pyswmm", + "PyYAML", + "rasterio", + "rioxarray", + "SALib", + "SciPy", + "shapely", + "snkit", + "tqdm", + "xarray", +] [project.optional-dependencies] dev = [ From 2ae41dae4b991b037537f68cca8d944cd372e24f Mon Sep 17 00:00:00 2001 From: barneydobson Date: Thu, 7 Mar 2024 08:48:15 +0000 Subject: [PATCH 13/13] Update pyproject.toml to avoid conflict --- pyproject.toml | 92 +++++++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 89ee1d5e..acbcd2f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ [build-system] -requires = ["setuptools", "setuptools-scm"] build-backend = "setuptools.build_meta" +requires = [ + "setuptools", + "setuptools-scm", +] [tool.setuptools.packages.find] exclude = ["htmlcov"] # Exclude the coverage report file from setuptools package finder @@ -13,45 +16,51 @@ authors = [ { name = "Imperial College London RSE Team", email = "ict-rse-team@imperial.ac.uk" } ] requires-python = ">=3.10" -dependencies = [ # TODO definitely don't need all of these - "cdsapi", - "fastparquet", - "fiona", - "geopandas", - "geopy", - "GitPython", - "loguru", - "matplotlib", - "netcdf4", - "networkx", - "numpy", - "osmnx", - "pandas", - "pyarrow", - "pydantic", - "pysheds", - "pyswmm", - "PyYAML", - "rasterio", - "rioxarray", - "SALib", - "SciPy", - "shapely", - "snkit", - "tqdm", - "xarray" - ] - +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + # TODO definitely don't need all of these + "cdsapi", + "fastparquet", + "fiona", + "geopandas", + "geopy", + "GitPython", + "loguru", + "matplotlib", + "netcdf4", + "networkx", + "numpy", + "osmnx", + "pandas", + "pyarrow", + "pydantic", + "pysheds", + "pyswmm", + "PyYAML", + "rasterio", + "rioxarray", + "SALib", + "SciPy", + "shapely", + "snkit", + "tqdm", + "xarray", +] [project.optional-dependencies] dev = [ - "ruff", - "mypy", - "pip-tools", - "pre-commit", - "pytest", - "pytest-cov", - "pytest-mypy", - "pytest-mock" + "mypy", + "pip-tools", + "pre-commit", + "pytest", + "pytest-cov", + "pytest-mock", + "pytest-mypy", + "ruff", ] [tool.mypy] @@ -77,3 +86,10 @@ select = ["D", "E", "F", "I"] # pydocstyle, pycodestyle, Pyflakes, isort [tool.ruff.pydocstyle] convention = "google" + +[tool.codespell] +skip = "swmmanywhere/defs/iso_converter.yml,*.inp" +ignore-words-list = "gage,gages" + +[tool.refurb] +ignore = [184]