Skip to content

Commit

Permalink
feat(template): Better template README, use ruff instead of black, us…
Browse files Browse the repository at this point in the history
…e pyproject.toml
  • Loading branch information
devsjc committed Sep 13, 2024
1 parent 9ec9ab7 commit 56532f2
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 140 deletions.
30 changes: 10 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

107 changes: 97 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)




7 changes: 0 additions & 7 deletions environment.yml

This file was deleted.

124 changes: 124 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}
]
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_*",
]


Empty file removed requirements.txt
Empty file.
57 changes: 0 additions & 57 deletions ruff.toml

This file was deleted.

24 changes: 0 additions & 24 deletions setup.py

This file was deleted.

0 comments on commit 56532f2

Please sign in to comment.