Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre commit test #93

Merged
merged 26 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd20a4f
Added the pre-commit for developers
pavelvaz Mar 24, 2023
8a3101c
Added pre-commit dependency
pavelvaz Mar 24, 2023
ac8fbb7
Moved to 0.10.4
pavelvazquez Apr 24, 2023
2cc0397
Configured pre-commit setup to use GitHub (recommended setup)
sveinugu May 15, 2023
257e0a4
Added useful pre-commit hooks from poetry and pre-commit
sveinugu May 15, 2023
359b830
Updated GitHub actions to use pre-commit. Cleaned up names
sveinugu May 15, 2023
78d9157
Removed poetry dependencies now handled by pre-commit
sveinugu May 15, 2023
f2a25fa
Updated documentation with info on install, use, and development setup
sveinugu May 15, 2023
d349f8b
Attempt to fix run_precommit.yaml
sveinugu May 15, 2023
e2fb2f2
Added yaml autofix
sveinugu May 15, 2023
597af1c
Renamed GitHub actions workflows
sveinugu May 15, 2023
432cb72
Renamed workflow run_tests -> run-tests
sveinugu May 15, 2023
1d0874d
Config fix: Flake8 now reports all errors - not to quote errors
sveinugu May 15, 2023
a07b014
Fixed some flake8 errors
sveinugu May 15, 2023
4b10686
Added info on installing pre-commit git hooks
sveinugu May 15, 2023
8e96219
Fixing Copyright notice in license, and other typos
sveinugu May 20, 2023
f822c40
Fixed some Flake8 errors
pavelvazquez Aug 10, 2023
fdf02c0
Fixed some more flake8 errors
pavelvazquez Aug 14, 2023
2d856b2
Fixed rest of the flake8 errors
sveinugu Sep 29, 2023
d1a748c
typo
sveinugu Sep 29, 2023
c0cc1f6
Skipped failing test. Check out later
sveinugu Sep 29, 2023
91e0019
Fixed pre-commit autoupdate
sveinugu Sep 29, 2023
a96cc94
Updated docs with autoupdate
sveinugu Sep 29, 2023
8574daa
Fix last flake8 errors
sveinugu Sep 29, 2023
05ad025
Fix very last flake8 error
sveinugu Sep 29, 2023
3ca415a
Bumped to 0.10.5
sveinugu Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[flake8]
ignore = D203, W503
select = Q0
exclude =
# No need to traverse our git directory
.git,
# There's no value in checking cache directories
__pycache__,
max-complexity = 10
max-line-length = 100
avoid-escape = True
avoid-escape = True
37 changes: 0 additions & 37 deletions .github/workflows/format_and_lint.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/precommit_autoupdate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Adapted from https://github.com/browniebroke/browniebroke.com, Copyright (c) 2017 Bruno Allaname, available under the
# MIT license

on:
schedule:
- cron: '0 0 * * *'

jobs:
autoupdate-precommit:
runs-on: ubuntu-latest
strategy:
matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit autoupdate
run: pre-commit autoupdate

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.CPR_GITHUB_TOKEN }}
branch: update/pre-commit-autoupdate
title: Auto-update pre-commit hooks
commit-message: Auto-update pre-commit hooks
body: |
Update versions of tools in pre-commit
configs to latest version
labels: dependencies
29 changes: 29 additions & 0 deletions .github/workflows/run_precommit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Python package

on: [push, pull_request]

jobs:
run-precommit:
runs-on: ubuntu-latest
strategy:
matrix:
# python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install pre-commit
run: |
pip install pre-commit

- name: Run pre-commit autoupdate
run: pre-commit autoupdate

- name: Run pre-commit hooks with hook-stage "manual" (=checks only)
run: |
pre-commit run --hook-stage manual --all-files
3 changes: 1 addition & 2 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Python package
on: [push, pull_request]

jobs:
build:

run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Run TODO to Issue"
on: ["push"]
jobs:
build:
todo-to-issue:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v4"
uses: "alstr/todo-to-issue-action@v4"
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
types: [ yaml ]
- id: check-toml
types: [ toml ]
- id: check-merge-conflict
- id: check-ast
types: [ python ]
- repo: https://github.com/python-poetry/poetry
rev: 1.6.0
hooks:
- id: poetry-check
- repo: https://github.com/google/yapf
rev: v0.40.2
hooks:
- id: yapf
name: "yapf"
additional_dependencies: [toml]
args: [ '--style', 'pyproject.toml', '--parallel', '--in-place' ]
stages: [ commit ]
types: [ python ]
- id: yapf
name: "yapf (check)"
additional_dependencies: [toml]
args: [ '--style', 'pyproject.toml', '--parallel', '--diff' ]
stages: [ manual ]
types: [ python ]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
stages: [ commit ]
types: [ python ]
- id: isort
name: isort (check)
args: [ '--check-only' ]
stages: [ manual ]
types: [ python ]
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-quotes==3.3.2]
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Contributing to omnipy development

## Development setup

- Install Poetry:
- `curl -sSL https://install.python-poetry.org | python3 -`

- Configure locally installed virtualenv (under `.venv`):
- `poetry config virtualenvs.in-project true`

- Install dependencies:
- `poetry install --with dev --with docs`

- Update all dependencies:
- `poetry update`

- Update single dependency, e.g.:
- `poetry update prefect`

- If a dependency is not updated to the latest version available on Pypi, you might need to clear
the pip cache of poetry:
- `poetry cache clear pypi --all`

### For mypy support in PyCharm

- In PyCharm, install "Mypy" plugin (not "Mypy (Official)")
- `which mypy` to get path to mypy binary
- In the PyCharm settings for the mypy plugin:
- Select the mypy binary
- Select `pyproject.toml` as the mypy config file

### For automatic formatting and linting

The setup for automatic formatting and linting is rather complex. The main alternative is to use
black, which is easier to set up, but it does not have as many options and the main omnipy developer
is opinionated against the default black setup. The yapf config is not fully
defined.

- To install git hooks that automagically format and lint before every commit:
- `pre-commit install`

- To update pre-commit-managed dependencies to the latest repos' versions:
- `pre-commit autoupdate`

- In PyCharm -> File Watchers:
- Click arrow icon pointing down and to the left
- Select `pycharm_file_watchers.xml`
40 changes: 40 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Installation and usage of omnipy

## Installation

`pip install omnipy`


## Run example scripts:
- Install `omnipy-examples`:
- `pip install omnipy-examples`
- Example script:
- `omnipy-examples isajson`
- For help on the command line interface:
- `omnipy-examples --help`
- For help on a particular example:
- `omnipy-examples isajson --help`

### Output of flow runs

The output will by default appear in the `data` directory, with a timestamp.

- It is recommended to install a file viewer that are capable of browsing tar.gz files.
For instance, the "File Expander" plugin in PyCharm is excellent for this.
- To unpack the compressed files of a run on the command line
(just make sure to replace the datetime string from this example):

```
for f in $(ls data/2023_02_03-12_51_51/*.tar.gz); do mkdir ${f%.tar.gz}; tar xfzv $f -C ${f%.tar.gz}; done
```

### Run with the Prefect engine

Omnipy is integrated with the powerful [Prefect](https://prefect.io) data flow orchestration library.

- To run an example using the `prefect` engine, e.g.:
- `omnipy-examples --engine prefect isajson`
- After completion of some runs, you can check the flow logs and orchestration options in the Prefect UI:
- `prefect orion start`

More info on Prefect configuration will come soon...
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2023 Omnipy contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading