diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf5b5dfc..a6e1b4c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,18 +14,18 @@ repos: # python code formatting/linting - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: "v0.1.6" + rev: "v0.3.2" hooks: - id: ruff args: [--fix] - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 24.2.0 hooks: - id: black args: [--line-length, "100"] # yaml formatting - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 + rev: v4.0.0-alpha.8 hooks: - id: prettier types: [yaml] diff --git a/.ruff.toml b/.ruff.toml index 591515f6..e675595d 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -41,12 +41,9 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" target-version = "py311" fix = false # Group violations by containing file. -format = "github" +output-format = "github" ignore-init-module-imports = true -[format] -docstring-code-format = true - [mccabe] # Unlike Flake8, default to a complexity level of 10. max-complexity = 10 diff --git a/graph_weather/__init__.py b/graph_weather/__init__.py index 82f9a13c..1758fd49 100644 --- a/graph_weather/__init__.py +++ b/graph_weather/__init__.py @@ -1,3 +1,4 @@ """Main import for the complete models""" + from .models.analysis import GraphWeatherAssimilator from .models.forecast import GraphWeatherForecaster diff --git a/graph_weather/models/__init__.py b/graph_weather/models/__init__.py index be71b526..a18cda87 100644 --- a/graph_weather/models/__init__.py +++ b/graph_weather/models/__init__.py @@ -1,4 +1,5 @@ """Models""" + from .layers.assimilator_decoder import AssimilatorDecoder from .layers.assimilator_encoder import AssimilatorEncoder from .layers.decoder import Decoder diff --git a/graph_weather/models/analysis.py b/graph_weather/models/analysis.py index d5550136..d44abc11 100644 --- a/graph_weather/models/analysis.py +++ b/graph_weather/models/analysis.py @@ -1,4 +1,5 @@ """Model for forecasting weather from NWP states""" + import torch from huggingface_hub import PyTorchModelHubMixin diff --git a/graph_weather/models/forecast.py b/graph_weather/models/forecast.py index 0ed7a992..267bc950 100644 --- a/graph_weather/models/forecast.py +++ b/graph_weather/models/forecast.py @@ -1,4 +1,5 @@ """Model for forecasting weather from NWP states""" + from typing import Optional import torch diff --git a/graph_weather/models/layers/assimilator_decoder.py b/graph_weather/models/layers/assimilator_decoder.py index 80c51e8d..938011e6 100644 --- a/graph_weather/models/layers/assimilator_decoder.py +++ b/graph_weather/models/layers/assimilator_decoder.py @@ -13,6 +13,7 @@ more complex dynamics) """ + import einops import h3 import numpy as np diff --git a/graph_weather/models/layers/assimilator_encoder.py b/graph_weather/models/layers/assimilator_encoder.py index 226bff69..ac372740 100644 --- a/graph_weather/models/layers/assimilator_encoder.py +++ b/graph_weather/models/layers/assimilator_encoder.py @@ -21,6 +21,7 @@ """ + from typing import Tuple import einops diff --git a/graph_weather/models/layers/decoder.py b/graph_weather/models/layers/decoder.py index b5aec39c..31bf197d 100644 --- a/graph_weather/models/layers/decoder.py +++ b/graph_weather/models/layers/decoder.py @@ -13,6 +13,7 @@ more complex dynamics) """ + import torch from graph_weather.models.layers.assimilator_decoder import AssimilatorDecoder diff --git a/graph_weather/models/layers/encoder.py b/graph_weather/models/layers/encoder.py index 916a6523..04312afb 100644 --- a/graph_weather/models/layers/encoder.py +++ b/graph_weather/models/layers/encoder.py @@ -21,6 +21,7 @@ """ + from typing import Tuple import einops diff --git a/graph_weather/models/layers/graph_net_block.py b/graph_weather/models/layers/graph_net_block.py index 8ef5efc0..4be21121 100644 --- a/graph_weather/models/layers/graph_net_block.py +++ b/graph_weather/models/layers/graph_net_block.py @@ -4,6 +4,7 @@ This code is taken from https://github.com/CCSI-Toolset/MGN which is available under the US Government License """ + from typing import Optional, Tuple import torch diff --git a/graph_weather/models/layers/processor.py b/graph_weather/models/layers/processor.py index 07dd0ff4..9ed8b381 100644 --- a/graph_weather/models/layers/processor.py +++ b/graph_weather/models/layers/processor.py @@ -7,6 +7,7 @@ and its immediate neighbors. There are residual connections between each round of processing. """ + import torch from graph_weather.models.layers.graph_net_block import GraphProcessor diff --git a/graph_weather/models/losses.py b/graph_weather/models/losses.py index e36c65cf..c0d8035d 100644 --- a/graph_weather/models/losses.py +++ b/graph_weather/models/losses.py @@ -1,4 +1,5 @@ """Weather loss functions""" + import numpy as np import torch diff --git a/setup.py b/setup.py index 792b847f..03cb03c1 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """Setup""" + from pathlib import Path from setuptools import find_packages, setup diff --git a/train/pl_graph_weather.py b/train/pl_graph_weather.py index 40ed7f21..d2588435 100644 --- a/train/pl_graph_weather.py +++ b/train/pl_graph_weather.py @@ -1,4 +1,5 @@ """PyTorch Lightning training script for the weather forecasting model""" + import click import datasets import numpy as np diff --git a/train/run_fulll.py b/train/run_fulll.py index cebf7f71..0acac1a3 100644 --- a/train/run_fulll.py +++ b/train/run_fulll.py @@ -1,4 +1,5 @@ """Training script for training the weather forecasting model""" + import json import os import sys