Skip to content

Commit

Permalink
CI (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyboardAnt authored Jun 12, 2024
1 parent 4bfd8df commit 89bed72
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 32 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python tests

on:
pull_request:
branches: [ "main" ]

jobs:
ci:
strategy:
fail-fast: false
matrix:
python-version: ["3.10.14"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry
uses: snok/install-poetry@v1
- name: Install poetry extras
run: |
poetry install --all-extras
- name: Lint with Ruff
run: |
poetry run ruff check --output-format=github .
- uses: isort/isort-action@master
- uses: psf/black@stable
with:
options: "--check --verbose"
jupyter: true
- name: Test with pytest
run: |
poetry run pytest
55 changes: 31 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
- repo: https://github.com/pre-commit/pre-commit-hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: double-quote-string-fixer
- id: pretty-format-json
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.7
hooks:
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
- id: check-added-large-files
- id: check-ast
- id: check-builtin-literals
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: detect-private-key
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.8
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The code used in the [paper](https://arxiv.org/abs/2405.14105).

## Installation
## Installation

1. Install poetry ([official documentation](https://python-poetry.org/docs/#installation)).
2. Install this project's environment: `poetry install`
Expand Down
2 changes: 0 additions & 2 deletions dsi/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""The main entrypoint for the CLI."""


from dsi.main import main


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions dsi/analytic/si.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

from dsi.schemas.results import ResultSI
from dsi.schemas.run import Run

Expand Down
6 changes: 3 additions & 3 deletions dsi/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""The main entrypoint for the CLI."""

import logging
import os

import hydra
from matplotlib import pyplot as plt
from omegaconf import OmegaConf

from dsi.config import Config, SimulationType
from dsi.analytic.si import RunSI
import logging

from dsi.config import Config, SimulationType
from dsi.schemas.results import ResultSI
from dsi.vis.iters_dist import PlotIters

Expand Down
1 change: 1 addition & 0 deletions dsi/schemas/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import dataclass, field

from dsi.config import ConfigRun
from dsi.utils import set_random_seed

Expand Down
2 changes: 1 addition & 1 deletion dsi/vis/cost_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def _plot_total_costs(self, ax: plt.Axes) -> None:

def _plot_mean(self, ax: plt.Axes, val: float) -> None:
ax.axvline(x=val, color="black", linestyle="--")
ax.text(val, 0.02, f"Mean: {val:.2f}", color="black", fontsize=8)
ax.text(val, 0.02, f"Mean: {val:.2f}", color="black", fontsize=8)
119 changes: 118 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hydra-core = "^1.3.2"
[tool.poetry.group.dev.dependencies]
ruff = "^0.4.8"
pytest = "^8.2.2"
pre-commit = "^3.7.1"

[build-system]
requires = ["poetry-core"]
Expand Down

0 comments on commit 89bed72

Please sign in to comment.