From b9ccc0eefdfd89831c6707c2fad6e07484e98e50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 17:38:54 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v5.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.286 → v0.9.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.286...v0.9.2) - [github.com/psf/black: 23.7.0 → 24.10.0](https://github.com/psf/black/compare/23.7.0...24.10.0) - [github.com/pre-commit/mirrors-prettier: v3.0.2 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.2...v4.0.0-alpha.8) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e191b290..ecc10906 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: # list of supported hooks: https://pre-commit.com/hooks.html - id: trailing-whitespace @@ -14,18 +14,18 @@ repos: # python code formatting/linting - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: "v0.0.286" + rev: "v0.9.2" hooks: - id: ruff args: [--fix] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 24.10.0 hooks: - id: black args: [--line-length, "100"] # yaml formatting - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.2 + rev: v4.0.0-alpha.8 hooks: - id: prettier types: [yaml] From 933c6ea0fa3761a2b9ed75d89cf8887cd1123032 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 17:39:07 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pvnet/__init__.py | 1 + pvnet/callbacks.py | 1 + pvnet/data/__init__.py | 1 + pvnet/data/base.py | 1 + pvnet/data/pv_site_datamodule.py | 1 + pvnet/data/utils.py | 1 + pvnet/data/wind_datamodule.py | 1 + pvnet/load_model.py | 1 + pvnet/models/base_model.py | 1 + pvnet/models/baseline/single_value.py | 1 + pvnet/models/ensemble.py | 1 + pvnet/models/multimodal/encoders/basic_blocks.py | 1 + pvnet/models/multimodal/encoders/encoders3d.py | 1 + pvnet/models/multimodal/linear_networks/basic_blocks.py | 1 + pvnet/models/multimodal/linear_networks/networks.py | 1 + pvnet/models/multimodal/multimodal_base.py | 1 + pvnet/models/multimodal/site_encoders/basic_blocks.py | 1 + pvnet/training.py | 1 + pvnet/utils.py | 1 + scripts/save_batches.py | 1 + scripts/save_concurrent_batches.py | 1 + 21 files changed, 21 insertions(+) diff --git a/pvnet/__init__.py b/pvnet/__init__.py index 6df1ae46..edf1965b 100644 --- a/pvnet/__init__.py +++ b/pvnet/__init__.py @@ -1,2 +1,3 @@ """PVNet""" + __version__ = "3.0.64" diff --git a/pvnet/callbacks.py b/pvnet/callbacks.py index 0455d774..14cc15bf 100644 --- a/pvnet/callbacks.py +++ b/pvnet/callbacks.py @@ -1,5 +1,6 @@ """Custom callbacks """ + from lightning.pytorch import Trainer from lightning.pytorch.callbacks import BaseFinetuning, EarlyStopping, LearningRateFinder from lightning.pytorch.trainer.states import TrainerFn diff --git a/pvnet/data/__init__.py b/pvnet/data/__init__.py index 5d763df0..7f3aa89f 100644 --- a/pvnet/data/__init__.py +++ b/pvnet/data/__init__.py @@ -1,2 +1,3 @@ """Data parts""" + from .utils import BatchSplitter diff --git a/pvnet/data/base.py b/pvnet/data/base.py index b53c4ee8..43019876 100644 --- a/pvnet/data/base.py +++ b/pvnet/data/base.py @@ -1,4 +1,5 @@ """ Data module for pytorch lightning """ + from datetime import datetime from lightning.pytorch import LightningDataModule diff --git a/pvnet/data/pv_site_datamodule.py b/pvnet/data/pv_site_datamodule.py index 4c45eaec..1c5deb3f 100644 --- a/pvnet/data/pv_site_datamodule.py +++ b/pvnet/data/pv_site_datamodule.py @@ -1,4 +1,5 @@ """ Data module for pytorch lightning """ + import glob from ocf_datapipes.batch import BatchKey, batch_to_tensor, stack_np_examples_into_batch diff --git a/pvnet/data/utils.py b/pvnet/data/utils.py index b4441c14..5a942ec6 100644 --- a/pvnet/data/utils.py +++ b/pvnet/data/utils.py @@ -1,4 +1,5 @@ """Utils common between Wind and PV datamodules""" + from ocf_datapipes.batch import BatchKey, unstack_np_batch_into_examples from torch.utils.data import IterDataPipe, functional_datapipe diff --git a/pvnet/data/wind_datamodule.py b/pvnet/data/wind_datamodule.py index 0c11d31d..a6df2712 100644 --- a/pvnet/data/wind_datamodule.py +++ b/pvnet/data/wind_datamodule.py @@ -1,4 +1,5 @@ """ Data module for pytorch lightning """ + import glob from ocf_datapipes.batch import BatchKey, batch_to_tensor, stack_np_examples_into_batch diff --git a/pvnet/load_model.py b/pvnet/load_model.py index ba6de363..e38ed639 100644 --- a/pvnet/load_model.py +++ b/pvnet/load_model.py @@ -1,4 +1,5 @@ """ Load a model from its checkpoint directory """ + import glob import os diff --git a/pvnet/models/base_model.py b/pvnet/models/base_model.py index 24ce5bfc..d7d5fe15 100644 --- a/pvnet/models/base_model.py +++ b/pvnet/models/base_model.py @@ -1,4 +1,5 @@ """Base model for all PVNet submodels""" + import json import logging import os diff --git a/pvnet/models/baseline/single_value.py b/pvnet/models/baseline/single_value.py index 980feb95..44ac2061 100644 --- a/pvnet/models/baseline/single_value.py +++ b/pvnet/models/baseline/single_value.py @@ -1,4 +1,5 @@ """Average value model""" + import torch from ocf_datapipes.batch import BatchKey from torch import nn diff --git a/pvnet/models/ensemble.py b/pvnet/models/ensemble.py index ef90d8fb..85e88835 100644 --- a/pvnet/models/ensemble.py +++ b/pvnet/models/ensemble.py @@ -1,4 +1,5 @@ """Model which uses mutliple prediction heads""" + from typing import Optional import torch diff --git a/pvnet/models/multimodal/encoders/basic_blocks.py b/pvnet/models/multimodal/encoders/basic_blocks.py index 2173267e..db641e6c 100644 --- a/pvnet/models/multimodal/encoders/basic_blocks.py +++ b/pvnet/models/multimodal/encoders/basic_blocks.py @@ -1,4 +1,5 @@ """Basic blocks for image sequence encoders""" + from abc import ABCMeta, abstractmethod import torch diff --git a/pvnet/models/multimodal/encoders/encoders3d.py b/pvnet/models/multimodal/encoders/encoders3d.py index b0df28ab..91f3a517 100644 --- a/pvnet/models/multimodal/encoders/encoders3d.py +++ b/pvnet/models/multimodal/encoders/encoders3d.py @@ -1,5 +1,6 @@ """Encoder modules for the satellite/NWP data based on 3D concolutions. """ + from typing import List, Union import torch diff --git a/pvnet/models/multimodal/linear_networks/basic_blocks.py b/pvnet/models/multimodal/linear_networks/basic_blocks.py index c115c9fb..084b585a 100644 --- a/pvnet/models/multimodal/linear_networks/basic_blocks.py +++ b/pvnet/models/multimodal/linear_networks/basic_blocks.py @@ -1,4 +1,5 @@ """Basic blocks for the lienar networks""" + from abc import ABCMeta, abstractmethod from collections import OrderedDict diff --git a/pvnet/models/multimodal/linear_networks/networks.py b/pvnet/models/multimodal/linear_networks/networks.py index 69c21d82..486a7a28 100644 --- a/pvnet/models/multimodal/linear_networks/networks.py +++ b/pvnet/models/multimodal/linear_networks/networks.py @@ -1,4 +1,5 @@ """Linear networks used for the fusion model""" + from torch import nn, rand from pvnet.models.multimodal.linear_networks.basic_blocks import ( diff --git a/pvnet/models/multimodal/multimodal_base.py b/pvnet/models/multimodal/multimodal_base.py index dbab8556..60daa473 100644 --- a/pvnet/models/multimodal/multimodal_base.py +++ b/pvnet/models/multimodal/multimodal_base.py @@ -1,4 +1,5 @@ """Base model class for multimodal model and unimodal teacher""" + from ocf_datapipes.batch import BatchKey, NWPBatchKey from torchvision.transforms.functional import center_crop diff --git a/pvnet/models/multimodal/site_encoders/basic_blocks.py b/pvnet/models/multimodal/site_encoders/basic_blocks.py index b20835f1..66f4fb46 100644 --- a/pvnet/models/multimodal/site_encoders/basic_blocks.py +++ b/pvnet/models/multimodal/site_encoders/basic_blocks.py @@ -1,4 +1,5 @@ """Basic blocks for PV-site encoders""" + from abc import ABCMeta, abstractmethod from torch import nn diff --git a/pvnet/training.py b/pvnet/training.py index cafcdac4..187a8999 100644 --- a/pvnet/training.py +++ b/pvnet/training.py @@ -1,4 +1,5 @@ """Training""" + import os import shutil from typing import Optional diff --git a/pvnet/utils.py b/pvnet/utils.py index b2c4d99a..2fc5c513 100644 --- a/pvnet/utils.py +++ b/pvnet/utils.py @@ -1,4 +1,5 @@ """Utils""" + import logging import warnings from collections.abc import Sequence diff --git a/scripts/save_batches.py b/scripts/save_batches.py index 953e7244..ebda1da5 100644 --- a/scripts/save_batches.py +++ b/scripts/save_batches.py @@ -20,6 +20,7 @@ ``` if wanting to override these values for example """ + # This is needed to get multiprocessing/multiple workers to behave try: import torch.multiprocessing as mp diff --git a/scripts/save_concurrent_batches.py b/scripts/save_concurrent_batches.py index 37833b9e..c8aa95cf 100644 --- a/scripts/save_concurrent_batches.py +++ b/scripts/save_concurrent_batches.py @@ -15,6 +15,7 @@ ``` """ + # This is needed to get multiprocessing/multiple workers to behave try: import torch.multiprocessing as mp