From 71da19d9d5737684334bc670cea94578109ba4e4 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 13 Feb 2025 10:32:56 +0000 Subject: [PATCH 1/6] Remove unused logs module --- MANIFEST.in | 1 - pyproject.toml | 5 -- s2fft/default-logging-config.yaml | 58 -------------------- s2fft/logs.py | 91 ------------------------------- tests/test_logs.py | 19 ------- 5 files changed, 174 deletions(-) delete mode 100644 s2fft/default-logging-config.yaml delete mode 100644 s2fft/logs.py delete mode 100644 tests/test_logs.py diff --git a/MANIFEST.in b/MANIFEST.in index 1f1b5611..16d86348 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,7 +6,6 @@ include .pip_readme.rst include README.rst include pytest.ini include LICENCE.txt -include s2fft/default-logging-config.yaml exclude .coveragerc exclude *.log diff --git a/pyproject.toml b/pyproject.toml index 6a2c310b..75746ed4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,8 +28,6 @@ classifiers = [ description = "Differentiable and accelerated spherical transforms with JAX" dependencies = [ "numpy>=1.20,<2", - "colorlog", - "pyyaml", "jax>=0.3.13", "jaxlib", "torch", @@ -150,9 +148,6 @@ lint.pep8-naming.classmethod-decorators = [ [tool.setuptools] packages = ["s2fft"] -[tool.setuptools.package-data] -s2fft = ["default-logging-config.yaml"] - [tool.setuptools_scm] local_scheme = "no-local-version" write_to = "s2fft/_version.py" diff --git a/s2fft/default-logging-config.yaml b/s2fft/default-logging-config.yaml deleted file mode 100644 index 30a45ce4..00000000 --- a/s2fft/default-logging-config.yaml +++ /dev/null @@ -1,58 +0,0 @@ -# ============================================================= -# Logging setup for S2fft Software package (2023) -# ============================================================= - -version: 1 -disable_existing_loggers: False -formatters: - simple: - format: "[%(asctime)s] [%(name)s] [%(levelname)s]: %(message)s" - colored: - (): "colorlog.ColoredFormatter" - datefmt: "%Y-%m-%d %H:%M:%S" - format: "%(log_color)s[%(asctime)s] [%(name)s] [%(levelname)s]: %(message)s%(reset)s" - log_colors: - DEBUG: blue - INFO: cyan - WARNING: purple - ERROR: orange - CRITICAL: red - -handlers: - console: - class: logging.StreamHandler - level: INFO - formatter: colored - stream: ext://sys.stdout - - info_file_handler: - class: logging.FileHandler - level: INFO - formatter: simple - filename: info.log - encoding: utf8 - - debug_file_handler: - class: logging.FileHandler - level: DEBUG - formatter: simple - filename: debug.log - encoding: utf8 - - critical_file_handler: - class: logging.FileHandler - level: CRITICAL - formatter: simple - filename: critical.log - encoding: utf8 - -loggers: - s2fft: - level: DEBUG - handlers: [console, critical_file_handler, info_file_handler, debug_file_handler] - propagate: no - -root: - level: INFO - handlers: [console, info_file_handler, debug_file_handler] -... \ No newline at end of file diff --git a/s2fft/logs.py b/s2fft/logs.py deleted file mode 100644 index a4124dfb..00000000 --- a/s2fft/logs.py +++ /dev/null @@ -1,91 +0,0 @@ -import logging -import logging.config -import os -from pathlib import Path - -import yaml - -import s2fft - - -def setup_logging(custom_yaml_path: str = None): - """ - Initialise and configure logging. - - Should be called at the beginning of code to initialise and configure the - desired logging level. Logging levels can be ints in [0,50] where 10 is - debug logging and 50 is critical logging. - - Args: - custom_yaml_path (string): Complete pathname of desired yaml logging - configuration. If empty will provide default logging config. - - Raises: - ValueError: Raised if logging.yaml is not in ./logs/ directory. - - """ - if "LOG_CFG" in os.environ: - path = Path(os.environ["LOG_CFG"]) - elif custom_yaml_path is None: - path = Path(s2fft.__file__).parent / "default-logging-config.yaml" - else: - path = Path(custom_yaml_path) - if not path.exists(): - raise ValueError(f"Logging config path {path} does not exist.") - with open(path) as f: - config = yaml.safe_load(f.read()) - if custom_yaml_path is None: - config["handlers"]["info_file_handler"]["filename"] = "info.log" - config["handlers"]["debug_file_handler"]["filename"] = "debug.log" - config["handlers"]["critical_file_handler"]["filename"] = "critical.log" - logging.config.dictConfig(config) - - -def debug_log(message: str): - """ - Log a debug message (e.g. for background logs to assist debugging). - - Args: - message (str): Message to log. - - """ - logger = logging.getLogger("s2fft") - logger.debug(message) - - -def warning_log(message: str): - """ - Log a warning (e.g. for internal code warnings such as large dynamic - ranges). - - Args: - message (str): Warning to log. - - """ - logger = logging.getLogger("s2fft") - logger.warning(message) - - -def critical_log(message: str): - """ - Log a critical message (e.g. core code failures etc). - - Args: - message (str): Message to log. - - """ - logger = logging.getLogger("s2fft") - logger.critical(message) - - -def info_log(message: str): - """ - Log an information message (e.g. evidence value printing, run completion - etc). - - Args: - message (str): Message to log. - - """ - logger = logging.getLogger("s2fft") - logger.info(message) diff --git a/tests/test_logs.py b/tests/test_logs.py deleted file mode 100644 index a44baec9..00000000 --- a/tests/test_logs.py +++ /dev/null @@ -1,19 +0,0 @@ -import pytest - -import s2fft.logs as lg - - -def test_incorrect_log_yaml_path(): - dir_name = "random/incorrect/filepath/" - - # Check cannot add samples with different ndim. - with pytest.raises(ValueError): - lg.setup_logging(custom_yaml_path=dir_name) - - -def test_general_logging(): - lg.setup_logging() - lg.critical_log("A random critical message") - lg.debug_log("A random debug message") - lg.warning_log("A random warning message") - lg.info_log("A random warning message") From 8d68f96547594125626b6dfa1d3db3f3d432402d Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 13 Feb 2025 10:40:12 +0000 Subject: [PATCH 2/6] Remove unused config files --- .gitmodules | 0 .style.yapf | 2 -- 2 files changed, 2 deletions(-) delete mode 100644 .gitmodules delete mode 100644 .style.yapf diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e69de29b..00000000 diff --git a/.style.yapf b/.style.yapf deleted file mode 100644 index fdd07237..00000000 --- a/.style.yapf +++ /dev/null @@ -1,2 +0,0 @@ -[style] -based_on_style = yapf From fc2bb218fa69755fce7c7deef7994391ae5d32cf Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 13 Feb 2025 10:41:08 +0000 Subject: [PATCH 3/6] Update manifest to fix changed file extension and removed file --- MANIFEST.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 16d86348..59a202ce 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,8 +3,7 @@ graft tests graft docs include .pip_readme.rst -include README.rst -include pytest.ini +include README.md include LICENCE.txt exclude .coveragerc From 023730beeb54d37c4c954c6cb20e6f20b6b637a4 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 13 Feb 2025 10:52:03 +0000 Subject: [PATCH 4/6] Additional logs module related clean up --- docs/api/utility/logs.rst | 7 ------- s2fft/__init__.py | 1 - 2 files changed, 8 deletions(-) delete mode 100644 docs/api/utility/logs.rst diff --git a/docs/api/utility/logs.rst b/docs/api/utility/logs.rst deleted file mode 100644 index 1c56cf1b..00000000 --- a/docs/api/utility/logs.rst +++ /dev/null @@ -1,7 +0,0 @@ -:html_theme.sidebar_secondary.remove: - -************************** -logs -************************** -.. automodule:: s2fft.logs - :members: diff --git a/s2fft/__init__.py b/s2fft/__init__.py index c7606c7d..445f5719 100644 --- a/s2fft/__init__.py +++ b/s2fft/__init__.py @@ -2,7 +2,6 @@ import jax -from . import logs from .recursions.price_mcewen import ( generate_precomputes, generate_precomputes_jax, From 881337e1495434389e2e6f029de41de28e5ac7a7 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Thu, 13 Feb 2025 10:52:19 +0000 Subject: [PATCH 5/6] Removing reference to logs docs page --- docs/api/utility/index.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/api/utility/index.rst b/docs/api/utility/index.rst index f5ca6065..ae76052c 100644 --- a/docs/api/utility/index.rst +++ b/docs/api/utility/index.rst @@ -141,5 +141,4 @@ Utility Functions healpix_ffts utils rotation - logs \ No newline at end of file From 82f5c329437936868f13ff5634b745dca327f541 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Mon, 24 Feb 2025 09:08:07 +0000 Subject: [PATCH 6/6] Relax codecov threshold slightly to avoid spurious fails --- codecov.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 codecov.yml diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..112c1632 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: auto + threshold: 0.1%