Skip to content

Commit 3cb09be

Browse files
committed
🤖 start of Python CI-CD
1 parent 08caffd commit 3cb09be

File tree

9 files changed

+244
-80
lines changed

9 files changed

+244
-80
lines changed
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
name: CI tsdownsample
22

33
on:
4-
pull_request:
4+
pull_request: {}
55
push:
66
branches:
77
- main
8+
tags:
9+
- '**'
810

911
defaults:
1012
run:
1113
shell: bash
1214

1315
jobs:
14-
Check:
16+
17+
Lint & check:
1518
runs-on: ubuntu-latest
1619
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
21+
- uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.10'
24+
- run: pip install -r tests/requirements-linting.txt
1925

2026
- name: Install Rust toolchain
2127
uses: actions-rs/toolchain@v1
@@ -27,15 +33,11 @@ jobs:
2733
run: |
2834
rustup update nightly --no-self-update
2935
rustup default nightly
36+
- name: Cache rust
37+
uses: Swatinem/rust-cache@v2
3038

31-
- name: Rust toolchain info
32-
run: |
33-
cargo --version --verbose
34-
rustc --version
35-
cargo clippy --version
36-
cargo fmt --version
37-
38-
- name: check
39-
run: cargo check --verbose
40-
- name: formatting check
41-
run: cargo fmt --all -- --check
39+
- run: pip freeze
40+
- run: make lint # Lint Python & Rust
41+
- run: make mypy # Type check Python
42+
43+
# https://github.com/samuelcolvin/rtoml/blob/main/.github/workflows/ci.yml

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.DEFAULT_GOAL := all
2+
isort = isort tsdownsample tests
3+
black = black tsdownsample tests
4+
5+
6+
.PHONY: format
7+
format:
8+
$(isort)
9+
$(black)
10+
cargo fmt
11+
12+
.PHONY: lint-python
13+
lint-python:
14+
ruff tsdownsample tests
15+
$(isort) --check-only --df
16+
$(black) --check --diff
17+
18+
.PHONY: lint-rust
19+
lint-rust:
20+
cargo fmt --version
21+
cargo fmt --all -- --check
22+
cargo clippy --version
23+
cargo clippy -- -D warnings -A incomplete_features -W clippy::dbg_macro -W clippy::print_stdout
24+
25+
.PHONY: lint
26+
lint: lint-python lint-rust
27+
28+
.PHONY: mypy
29+
mypy:
30+
mypy tsdownsample
31+
32+
.PHONY: all
33+
all: lint mypy testcov
34+
35+
.PHONY: clean
36+
clean:
37+
rm -rf `find . -name __pycache__`
38+
rm -f `find . -type f -name '*.py[co]' `
39+
rm -f `find . -type f -name '*~' `
40+
rm -f `find . -type f -name '.*~' `
41+
rm -rf dist
42+
rm -rf build
43+
rm -rf target
44+
rm -rf .cache
45+
rm -rf .pytest_cache
46+
rm -rf .mypy_cache
47+
rm -rf htmlcov
48+
rm -rf *.egg-info
49+
rm -f .coverage
50+
rm -f .coverage.*
51+
rm -rf build
52+
rm -f tsdownsample/*.so
53+
python setup.py clean

pyproject.toml

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,71 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
2+
requires = ["setuptools", "wheel", "setuptools-rust"]
3+
4+
[project]
5+
name = "tsdownsample"
6+
version = "0.1.0a1"
7+
requires-python = ">=3.7"
8+
description = "Time series downsampling in rust"
9+
authors = [{name = "Jeroen Van Der Donckt"}]
10+
readme = "README.md"
11+
license = {text = "MIT"}
12+
keywords = ["time series", "downsampling", "rust", "data science", "visualization"]
13+
classifiers = [
14+
'Intended Audience :: Developers',
15+
'License :: OSI Approved :: MIT License',
16+
'Intended Audience :: Developers',
17+
'Programming Language :: Python :: 3',
18+
'Programming Language :: Python :: 3.6', # TODO?
19+
'Programming Language :: Python :: 3.7',
20+
'Programming Language :: Python :: 3.8',
21+
'Programming Language :: Python :: 3.9',
22+
'Programming Language :: Python :: 3.10',
23+
'Programming Language :: Python :: 3.11',
24+
'Operating System :: POSIX',
25+
'Operating System :: MacOS :: MacOS X',
26+
'Operating System :: Microsoft :: Windows'
27+
]
28+
29+
[project.urls]
30+
homepage = "https://github.com/predict-idlab/tsdownsample"
31+
repository = "https://github.com/predict-idlab/tsdownsample"
32+
33+
# Build Python bindings for rust
34+
[tool.maturin]
35+
bindings = "pyo3"
36+
37+
# Linting
38+
[tool.ruff]
39+
line-length = 88
40+
extend-select = ["Q"]
41+
ignore = ["E402", "F403"]
42+
43+
# Formatting
44+
[tool.black]
45+
color = true
46+
line-length = 88
47+
skip-string-normalization = true
48+
skip-magic-trailing-comma = true
49+
50+
# Sort imports
51+
[tool.isort]
52+
line_length = 88
53+
known_first_party = ["tsdownsample"]
54+
multi_line_output = 3
55+
include_trailing_comma = true
56+
force_grid_wrap = 0
57+
combine_as_imports = true
58+
color_output = true
59+
skip = "tests/toml_test.py"
60+
61+
# Static typing
62+
[tool.mypy]
63+
follow_imports = "normal"
64+
strict_optional = true
65+
warn_redundant_casts = true
66+
warn_unused_ignores = true
67+
check_untyped_defs = true
68+
no_implicit_reexport = true
69+
disallow_untyped_defs = true
70+
disallow_any_generics = false
71+
ignore_missing_imports = true

requirements.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
setuptools-rust
2-
setuptools
3-
wheel
41
numpy
5-
pandas
2+
pandas
3+
# Build dependencies
4+
setuptools_rust

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
from setuptools_rust import Binding, RustExtension
44

55
setup(
6-
rust_extensions=[RustExtension("tsdownsample._rust.tsdownsample_rs", binding=Binding.PyO3)],
7-
)
6+
rust_extensions=[
7+
RustExtension("tsdownsample._rust.tsdownsample_rs", binding=Binding.PyO3)
8+
],
9+
)

tests/requirements-linting.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
black
2+
ruff
3+
isort[colors]
4+
mypy

tsdownsample/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
__version__ = "0.1.0a1"
22
__author__ = "Jeroen Van Der Donckt"
33

4-
from .downsamplers import *
4+
from .downsamplers import *

tsdownsample/downsamplers.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
# ------------------ Rust Downsamplers ------------------
22
import tsdownsample._rust.tsdownsample_rs as tsdownsample_rs
3+
34
from .downsampling_interface import RustDownsamplingInterface
45

56
MinMaxDownsampler = RustDownsamplingInterface("MinMax", tsdownsample_rs.minmax)
67
M4Downsampler = RustDownsamplingInterface("M4", tsdownsample_rs.m4)
78
LTTBDownsampler = RustDownsamplingInterface("LTTB", tsdownsample_rs.lttb)
8-
MinMaxLTTBDownsampler = RustDownsamplingInterface("MinMaxLTTB", tsdownsample_rs.minmaxlttb)
9+
MinMaxLTTBDownsampler = RustDownsamplingInterface(
10+
"MinMaxLTTB", tsdownsample_rs.minmaxlttb
11+
)
912

1013
# ------------------ Function Downsamplers ------------------
1114
import numpy as np
15+
1216
from .downsampling_interface import FuncDownsamplingInterface
1317

1418
MeanDownsampler = FuncDownsamplingInterface("Mean", np.mean)
1519
MedianDownsampler = FuncDownsamplingInterface("Median", np.median)
1620

1721
# ------------------ EveryNth Downsampler ------------------
1822
import math
23+
1924
import pandas as pd
25+
2026
from .downsampling_interface import DownsampleInterface
2127

22-
class _EveryNthDownsampler(DownsampleInterface):
2328

29+
class _EveryNthDownsampler(DownsampleInterface):
2430
def __init__(self) -> None:
25-
super().__init__(f"EveryNth")
26-
31+
super().__init__("EveryNth")
32+
2733
def downsample(self, s: pd.Series, n_out: int, parallel: bool = False) -> pd.Series:
2834
return s[:: max(1, math.ceil(len(s) / n_out))]
2935

30-
EveryNthDownsampler = _EveryNthDownsampler()
36+
37+
EveryNthDownsampler = _EveryNthDownsampler()

0 commit comments

Comments
 (0)