diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e92053a..7485e40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,30 +2,20 @@ default_language_version: python: python3 repos: - - repo: https://github.com/pre-commit/pre-commit-hooks + - repo: "https://github.com/pre-commit/pre-commit-hooks" rev: v4.4.0 hooks: - # list of supported hooks: https://pre-commit.com/hooks.html - - id: trailing-whitespace + # Supported hooks: https://pre-commit.com/hooks.html - id: end-of-file-fixer - - id: debug-statements - id: detect-private-key - # python code formatting/linting - - repo: https://github.com/charliermarsh/ruff-pre-commit - # Ruff version. - rev: "v0.0.260" + - repo: "https://github.com/astral-sh/ruff-pre-commit" + rev: v0.6.4 hooks: + # Run the linter and fix problems. + # * Must be run before ruff-format! - id: ruff - args: [--fix] - - repo: https://github.com/psf/black - rev: 23.3.0 - hooks: - - id: black - args: [--line-length, "100"] - # yaml formatting - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.6 - hooks: - - id: prettier - types: [yaml] + args: [ --fix ] + # Run the formatter. + - id: ruff-format + diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c737446..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Open Climate Fix - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index ab30e9a..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1 +0,0 @@ -include *.txt diff --git a/README.md b/README.md index 1d31d59..05d51b0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,100 @@ -# OCF Template Repository -Template Repository for OCF Projects +# OCF Template -## Usage +**Starting point for OCF projects** -Do the following to customize the repo to the project: +[![contributors badge](https://img.shields.io/github/contributors/openclimatefix/ocf-template?color=FFFFFF)](https://github.com/openclimatefix/ocf-template/graphs/contributors) +[![workflows badge](https://img.shields.io/github/actions/workflow/status/openclimatefix/ocf-template/ci.yml?branch=maine&color=FFD053)](https://github.com/openclimatefix/ocf-template/actions/workflows/ci.yml) +[![issues badge](https://img.shields.io/github/issues/openclimatefix/ocf-template?color=FFAC5F)](https://github.com/openclimatefix/ocf-template/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) +[![tags badge](https://img.shields.io/github/v/tag/openclimatefix/ocf-template?include_prereleases&sort=semver&color=7BCDF3)](https://github.com/openclimatefix/ocf-template/tags) +[![pypi badge](https://img.shields.io/pypi/v/ocf-template?&color=086788)](https://pypi.org/project/ocf-template) +[![documentation badge](https://img.shields.io/badge/docs-latest-333333)](https://openclimatefix.github.io/ocf-template/) -- Replace `src` with name of the library/project -- Update `setup.py` with the proper info -- Change `commit` to `True` in `.bumpversion.cfg` if you want the minor version - to increment on every commit. -- Add PyPi access token to release to PyPi -- Update name of folder in the test workflow +This section of the README should contain a brief description of the project. +Perhaps give a short amount of context around why it exists; the problem it solves. +By the end of reading this short paragraph, a contributor should not be confused +as to the purpose of the repository and its role in the organisation. + +They might even have an idea of how it could be useful to them! + +> [!Note] +> Any important callouts (informing visitors this repository is in early +> design stages, or not for general use, or requires a lot of prerequisite +> knowledge or infrastructure) should be placed in a note like this. +> Like: This repository does not hold template workflows, contributing +> guides, etc - head to +> [OCF's .github repository](https://github.com/openclimatefix/.github) +> for those. + +## Installation + +How to install the project for *general use* - **not** for development: +"`pip install x`", or "pull the latest checkpoint from `y`", +not "clone the repo and run `make install`". +For example, to "install" this template as the basis of a new repository, +do the following: + +1. Click **Use this template** (in green) above the upper right of this file +2. Select **Create a new repository** +3. Create the new repository as desired + +## Example usage + +One or two short examples of using the project to solve a problem. +Quick happy-path examples that show the project in action or outline a +common use case. + +> [!Note] +> If the project does not have a clear usage pattern, consider informing the +> user as such in the first callout. Then you can skip *Installation* and +> *Example usage* - perhaps replacing them with a *Quickstart* section - +> or just moving straight on to *Development*. + +Once you have installed the project into a new GitHub repository, +`git clone` it and `cd` into the created directory. + +**For a Python project:** + +Modify the `pyproject.toml` +file, updating the name, description, authors, and dependencies as needed. +Install the project in editable mode (in a new virtual environment!) +with `pip install -e .`. + +Also, importantly, update this README! + +**For other projects:** + +Simply delete `src` and `pyproject.toml`, and just use the README part of the template. + +*For more information, head to the [Documentation](#documentation).* + +## Documentation + +Link to the project's documentation, if it exists. Also consider internal +linking to parts of interest of the documentation, such as **Development**, +**API**, **Configuration** and so on. + +## Development + +Anything specific to getting set up for development on the project: required libraries, +infrastructure, extra tools that may be desired ([MyPy](https://mypy.readthedocs.io/en/stable/), +[pre-commit](https://pre-commit.com/), etc). Also, how to run tests! + +Make sure you have the most up to date drivers for your 32 GPU array to use this template! + +> [!Note] +> The development section might be contained within the documentation, in which case +> remove the *Development* section, and instead specify links to the relevant parts +> of the documentation in the *Documentation* section. + +## Contributing and community + +- PR's are welcome! See the [OCF Organisation Repo](https://github.com/openclimatefix) for details on contributing +- Find out more about OCF in the [Meta Repo](https://github.com/openclimatefix/ocf-meta-repo) +- Check out the OCF blog at https://openclimatefix.org/blog for updates +- Follow OCF on [Twitter](https://twitter.com/OpenClimateFix) + +[![OCF Logo](https://cdn.prod.website-files.com/62d92550f6774db58d441cca/6324a2038936ecda71599a8b_OCF_Logo_black_trans.png)](https://openclimatefix.org) + + + + diff --git a/environment.yml b/environment.yml deleted file mode 100644 index 96986b8..0000000 --- a/environment.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: ocf_template -channels: - - pytorch - - conda-forge - - defaults -dependencies: - - pip diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3f3b994 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,124 @@ +# --- PROJECT CONFIGURATION --- # + +[build-system] +requires = ["setuptools>=67", "wheel", "setuptools-git-versioning>=2.0,<3"] +build-backend = "setuptools.build_meta" + +# Metadata (see https://peps.python.org/pep-0621/) +[project] +name = "ocf-python-project" +dynamic = ["version"] # Set automtically using git: https://setuptools-git-versioning.readthedocs.io/en/stable/ +description = "Consise summary of project" +readme = {file = "README.md", content-type = "text/markdown"} +requires-python = ">=3.12.0" +license = {text = "MIT License"} +authors = [ + { name = "Open Climate Fix Team", email = "info@openclimatefix.org"} +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", +] +dependencies = [ + "numpy >= 1.23.2", +] + +[project.optional-dependencies] +test = [ + "unittest-xml-reporting == 3.2.0", # Used for XML test results in Actions +] +lint = [ + "mypy >= 1.11.0", + "ruff >= 0.6.4", +] +docs = [ + "pydoctor >= 24.3.0", +] +dev = [ + "ocf-python-project[test,lint,docs]", +] + +[project.scripts] +# Put entrypoints in here + +[project.urls] +repository = "https://github.com/openclimatefix/ocf-python-template" + +[tool.setuptools] +include-package-data = false + +[tool.setuptools-git-versioning] +enabled = true + +# --- LINTING AND TYPING CONFIGURATION --- # + +# MyPy configuration +# * See https://mypy.readthedocs.io/en/stable/index.html +[tool.mypy] +python_version = "3.12" +dmypy = true +strict = true +warn_unreachable = true +warn_return_any = true +disallow_untyped_defs = true +plugins = [ + "numpy.typing.mypy_plugin", +] + +# Ruff configuration +# * See https://beta.ruff.rs/docs/ +[tool.ruff] +line-length = 100 +indent-width = 4 +exclude = ["__init__.py"] + +[tool.ruff.lint] +fixable = ["ALL"] +ignore = ["ANN101", "ANN102"] +select = [ + "F", # pyflakes + "E", # pycodestyle + "W", # whitespace and newlines + "I", # isort + "UP", # modernize + "ANN", # flake8 type annotations + "S", # flake8 bandit + "B", # flake8 bugbear + "C4", # flake8 comprehensions + "COM", # flake8 commas + "T20", # flake8 print + "SIM", # flake8 simplify + "ARG", # flake8 unused arguments + "DTZ", # flake8 datetimes + "Q", # flake8 quotes + "TCH", # flake8 typecheck + "D", # pydocstyle + "RUF", # ruff-specific rules +] + +[tool.ruff.lint.per-file-ignores] +"test*" = ["D", "ANN"] + +[tool.ruff.lint.pydocstyle] +convention = "google" + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +line-ending = "auto" +docstring-code-format = true +docstring-code-line-length = 100 + +# --- DOCUMENTATION CONFIGURATION --- # + +[tool.pydoctor] +add-package = ["src/nwp_consumer"] +project-base-dir = "src/nwp_consumer" +docformat = "google" +html-output = "docs" +theme = "classic" +privacy = [ + "HIDDEN:**.test_*", +] + + diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e69de29..0000000 diff --git a/ruff.toml b/ruff.toml deleted file mode 100644 index 5df253f..0000000 --- a/ruff.toml +++ /dev/null @@ -1,57 +0,0 @@ -# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. -select = ["B", "E", "F", "D", "I"] -ignore = ["D200","D202","D210","D212","D415","D105",] - -# Allow autofix for all enabled rules (when `--fix`) is provided. -fixable = ["A", "B", "C", "D", "E", "F", "I"] -unfixable = [] - -# Exclude a variety of commonly ignored directories. -exclude = [ - ".bzr", - ".direnv", - ".eggs", - ".git", - ".hg", - ".mypy_cache", - ".nox", - ".pants.d", - ".pytype", - ".ruff_cache", - ".svn", - ".tox", - ".venv", - "__pypackages__", - "_build", - "buck-out", - "build", - "dist", - "node_modules", - "venv", - "tests", -] - -# Same as Black. -line-length = 100 - -# Allow unused variables when underscore-prefixed. -dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" - -# Assume Python 3.10. -target-version = "py310" -fix = false - -# Group violations by containing file. -format = "github" -ignore-init-module-imports = true - -[mccabe] -# Unlike Flake8, default to a complexity level of 10. -max-complexity = 10 - -[pydocstyle] -# Use Google-style docstrings. -convention = "google" - -[per-file-ignores] -"__init__.py" = ["F401", "E402"] diff --git a/setup.py b/setup.py deleted file mode 100644 index 17a0064..0000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -""" Usual setup file for package """ -# read the contents of your README file -from pathlib import Path - -from setuptools import find_packages, setup - -this_directory = Path(__file__).parent -long_description = (this_directory / "README.md").read_text() -install_requires = (this_directory / "requirements.txt").read_text().splitlines() - -setup( - name="cool_ocf_project", - version="0.0.1", - license="MIT", - description="Super cool OCF Repo", - author="Jacob Bieker, Jack Kelly, Peter Dudfield", - author_email="info@openclimatefix.org", - company="Open Climate Fix Ltd", - install_requires=install_requires, - long_description=long_description, - long_description_content_type="text/markdown", - include_package_data=True, - packages=find_packages(), -)