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

chore: format changes with black, and google python docstring, install script testing #289

Merged
merged 101 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
7156f8d
ran black
Mustaballer Jun 18, 2023
814f486
use poetry for install
Mustaballer Jun 18, 2023
4c665fa
Add caching to main.yml for faster github action checks
Mustaballer Jun 18, 2023
51f1632
Add missing job to main.yml
Mustaballer Jun 19, 2023
ab5f067
try ubuntu latest instead
Mustaballer Jun 19, 2023
aec2cc5
change readme type to string instead of array in pyproject.toml
Mustaballer Jun 19, 2023
a87300e
Update poetry version in main.yml
Mustaballer Jun 19, 2023
5394c0c
try macos
Mustaballer Jun 19, 2023
b8958e6
commented out tests
Mustaballer Jun 19, 2023
df7c898
see if black command works
Mustaballer Jun 19, 2023
9a4219f
see if black command runs properly
Mustaballer Jun 19, 2023
62efae6
use black github action
Mustaballer Jun 19, 2023
7ca3590
fix parsing
Mustaballer Jun 19, 2023
e442fcf
use supported black github action
Mustaballer Jun 19, 2023
650da6a
ignore venv as well
Mustaballer Jun 19, 2023
e296489
change args for flake8 action
Mustaballer Jun 19, 2023
2f19ef7
try flake8 exclude
Mustaballer Jun 19, 2023
2b16c4f
manually add and use flake8
Mustaballer Jun 19, 2023
060dc49
change docstring keyword
Mustaballer Jun 19, 2023
ee7a12f
Chain commands for installing flake8
Mustaballer Jun 19, 2023
20d8d36
exclude .venv
Mustaballer Jun 19, 2023
a99e58d
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jun 21, 2023
c82ac68
merged latest changes and add download instruction
Mustaballer Jun 21, 2023
f4a8a0a
remove import comment
Mustaballer Jun 21, 2023
f7b63fb
try python command with ubuntu
Mustaballer Jun 21, 2023
9ea4729
add tesseract-ocr
Mustaballer Jun 21, 2023
4cdb5f1
add homebrew option
Mustaballer Jun 21, 2023
119abad
add cache for tesseract
Mustaballer Jun 21, 2023
e4767a1
add ntlk command with poetry
Mustaballer Jun 21, 2023
732cfb8
ran black
Mustaballer Jun 21, 2023
cfa38c2
Add .flake8 and add flake8 to poetry
Mustaballer Jun 21, 2023
6d0c12f
Add max length to flake8, add windows job with new install script, an…
Mustaballer Jun 22, 2023
8c589ec
add some ignore errors in flake8
Mustaballer Jun 23, 2023
d3df418
Merge branch 'main' into formatting-changes
Mustaballer Jun 23, 2023
3cb3360
Adress more flake8 lint errors
Mustaballer Jun 25, 2023
7058116
Change max line length
Mustaballer Jun 25, 2023
ee9a904
ran black
Mustaballer Jun 25, 2023
3c8fde5
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jun 25, 2023
a64cd5f
Merge remote-tracking branch 'origin/formatting-changes' into formatt…
Mustaballer Jun 25, 2023
0f54842
resolve new changes and ran black
Mustaballer Jun 25, 2023
8f96385
Merge branch 'main' into formatting-changes
Mustaballer Jun 26, 2023
d4510a8
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jun 26, 2023
a400370
Merge remote-tracking branch 'origin/formatting-changes' into formatt…
Mustaballer Jun 26, 2023
02fcb0f
remove "import nltk; nltk.download('punkt')" command
Mustaballer Jun 26, 2023
b669df9
resolve lint errors in record.py
Mustaballer Jun 26, 2023
c6b2cea
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jun 27, 2023
1f9ad8a
remove unnecessary commas
Mustaballer Jun 27, 2023
d5f363b
Address D415, sentence/comma missing on first line error
Mustaballer Jun 27, 2023
d820598
Resolve F403
Mustaballer Jun 27, 2023
4c66ab7
Address D200, single line doctstrings
Mustaballer Jun 27, 2023
48ec58e
Addressed E731, F841, D205 errors
Mustaballer Jun 27, 2023
017db4c
resolve F401, unused imports
Mustaballer Jun 27, 2023
d53ac45
Address return type annotations
Mustaballer Jun 29, 2023
a6f5aa7
Add type annotations for function arguments
Mustaballer Jul 1, 2023
ad564aa
Merge branch 'main' into formatting-changes
Mustaballer Jul 1, 2023
bdf6455
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jul 1, 2023
4578716
Merge branch 'formatting-changes' of https://github.com/Mustaballer/p…
Mustaballer Jul 1, 2023
56a20cd
ran black
Mustaballer Jul 1, 2023
9a636da
Address 'Multi-line docstring summaries should start at the first line'
Mustaballer Jul 1, 2023
3b78035
Revert main.yml to test if all checks pass
Mustaballer Jul 1, 2023
638b03f
fix syntax issue in main.yml
Mustaballer Jul 1, 2023
d45e5ff
Merge branch 'main' into formatting-changes
Mustaballer Jul 3, 2023
59b0024
Use cache for install poetry dependencies
Mustaballer Jul 3, 2023
7edacc9
Merge branch 'main' into formatting-changes
Mustaballer Jul 3, 2023
ef7a3c9
Revert main.yml and convert black action to oneliner with poetry
Mustaballer Jul 3, 2023
07e75b1
Address lint errors for newly merged changes
Mustaballer Jul 3, 2023
4f42f13
Try caching tesseract install
Mustaballer Jul 3, 2023
9de083b
test if tesseract is cached
Mustaballer Jul 3, 2023
3e1439a
try cache brew package
Mustaballer Jul 3, 2023
6209ba7
try cache brew again
Mustaballer Jul 3, 2023
6e7bfa8
Remove failing tesseract cache
Mustaballer Jul 3, 2023
1a8240a
Merge branch 'main' into formatting-changes
Mustaballer Jul 3, 2023
e0d5ead
Merge branch 'main' into formatting-changes
Mustaballer Jul 4, 2023
aa6419e
Address lint errors from recent merge
Mustaballer Jul 4, 2023
843a22a
replace test command
Mustaballer Jul 4, 2023
d88767f
address comments on annotations and ran black
Mustaballer Jul 5, 2023
7a3dc30
change todo
0dm Jul 5, 2023
71c1c30
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jul 6, 2023
9059d48
Merge branch 'main' into formatting-changes
Mustaballer Jul 6, 2023
a5faf67
Merge branch 'formatting-changes' of https://github.com/Mustaballer/p…
Mustaballer Jul 6, 2023
ff35c33
Shorten word line max length to 88 for comments
Mustaballer Jul 6, 2023
64b5139
try executing script
Mustaballer Jul 7, 2023
6311741
keep windows runner as todo
Mustaballer Jul 10, 2023
7381715
comment poetry shell in install_opendapt.sh
Mustaballer Jul 10, 2023
413d7bf
add error flag in mac install script to avoid poetry shell in github …
Mustaballer Jul 10, 2023
0c99d6a
try to see if this will pass
Mustaballer Jul 10, 2023
a652676
update main.yml
Mustaballer Jul 10, 2023
87188ec
Address incorrect function annotations in record.py
Mustaballer Jul 11, 2023
1601717
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jul 11, 2023
6159a69
Address annotation errors in _windows.py
Mustaballer Jul 12, 2023
ea5e2a6
Addressed more general annotations
Mustaballer Jul 13, 2023
80a53e0
Address incomplete annotations in util.py
Mustaballer Jul 13, 2023
0000bbd
run isort and other precommit hooks with custom black config on all f…
Mustaballer Jul 14, 2023
27ed9e4
Update openadapt/crud.py
abrichr Jul 14, 2023
082f1ae
replaced more 'Any' type annotations
Mustaballer Jul 15, 2023
e696def
Merge branch 'formatting-changes' of https://github.com/Mustaballer/p…
Mustaballer Jul 15, 2023
d92a296
Merge branch 'main' of https://github.com/MLDSAI/OpenAdapt into forma…
Mustaballer Jul 17, 2023
b76801d
resolve lint errors from recent merge
Mustaballer Jul 17, 2023
b2c7c0f
Merge branch 'main' into formatting-changes
Mustaballer Jul 18, 2023
7a8313a
ran black
Mustaballer Jul 18, 2023
4d079dc
resolve circular imports, and address Any annotations
Mustaballer Jul 20, 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
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
exclude=alembic/versions,.venv
Mustaballer marked this conversation as resolved.
Show resolved Hide resolved
docstring-convention=google
max-line-length = 88
extend-ignore = ANN101
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ body:
label: To Reproduce
description: What Operating System did you use and steps would we take to reproduce the behaviour?
placeholder: "I use [macOS/Microsoft Windows].
Steps:
1. Go to '...'
2. Click on '....'
Steps:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....' "
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
blank_issues_enabled: true
blank_issues_enabled: true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/use_case.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ body:
attributes:
label: Workflow
description: How is the task accomplished? Please place each step on a new line.
placeholder: |
placeholder: |
1. Open Chrome
2. Navigate to Google Flights
3. Set the departure city
4. ...
validations:
required: true
required: true
51 changes: 33 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ on:

jobs:
run-ci:
runs-on: windows-latest
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash

strategy:
matrix:
# TODO: add windows matrix
os: [macos-latest]

steps:
- name: Checkout code
Expand All @@ -18,25 +26,32 @@ jobs:
with:
python-version: '3.10'

- name: Install dependencies
run: |
pip install wheel
pip install -r requirements.txt
pip install -e .
- name: Run tests using the shell script (macOS compatible).
if: matrix.os == 'macos-latest'
run: SKIP_POETRY_SHELL=1 sh install/install_openadapt.sh

- name: Check formatting with Black
run: |
black --check --exclude "(src|alembic)/" .
- name: Checkout code
uses: actions/checkout@v3

- name: Run headless tests
uses: coactions/setup-xvfb@v1
- name: Install poetry
uses: snok/install-poetry@v1
with:
run: python -m pytest
working-directory: ./ # Optional: Specify the working directory if needed
options: # Optional: Add any additional options or arguments for pytest
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: flake8 Lint
uses: py-actions/flake8@v2
- name: Cache deps
id: cache-deps
uses: actions/cache@v2
with:
plugins: "flake8-docstrings"
extra-args: "--docstring-convention=google --exclude=alembic/versions"
path: .venv
Mustaballer marked this conversation as resolved.
Show resolved Hide resolved
key: pydeps-${{ hashFiles('**/poetry.lock') }}

- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- name: Check formatting with Black
run: poetry run black --check .

- name: Run Flake8
run: poetry run flake8
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to contribute

We would love to implement your contributions to this project! We simply ask that you observe the following guidelines.
We would love to implement your contributions to this project! We simply ask that you observe the following guidelines.

## Code Style

Expand Down Expand Up @@ -30,11 +30,11 @@ In order to effectively communicate any bugs or request new features, please sel
## Testing
[GitHub Actions](https://github.com/MLDSAI/OpenAdapt/actions/new) are automatically run on each pull request to ensure consistent behavior and style. The Actions are composed of PyTest, [black](https://github.com/psf/black) and [flake8](https://flake8.pycqa.org/en/latest/user/index.html).

You can run these tests on your own computer by downloading the dependencies using `poetry` (see [here](https://github.com/OpenAdaptAI/OpenAdapt/blob/main/README.md#install)) and then running `pytest` in the root directory.
You can run these tests on your own computer by downloading the dependencies using `poetry` (see [here](https://github.com/OpenAdaptAI/OpenAdapt/blob/main/README.md#install)) and then running `pytest` in the root directory.

## Pull Request Format

To speed up the review process, please use the provided pull request template and create a draft pull request to get initial feedback.
To speed up the review process, please use the provided pull request template and create a draft pull request to get initial feedback.

The pull request template includes areas to explain the changes, and a checklist with boxes for code style, testing, and documentation.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ alembic revision --autogenerate -m "<msg>"

### Pre-commit Hooks

To ensure code quality and consistency, OpenAdapt uses pre-commit hooks. These hooks
To ensure code quality and consistency, OpenAdapt uses pre-commit hooks. These hooks
will be executed automatically before each commit to perform various checks and
validations on your codebase.

Expand All @@ -269,7 +269,7 @@ The following pre-commit hooks are used in OpenAdapt:
To set up the pre-commit hooks, follow these steps:

1. Navigate to the root directory of your OpenAdapt repository.

2. Run the following command to install the hooks:

```
Expand Down
2 changes: 1 addition & 1 deletion alembic/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Generic single-database configuration.
Generic single-database configuration.
43 changes: 21 additions & 22 deletions alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
"""Alembic Environment Configuration.

This module provides the environment configuration for Alembic.
"""

from logging.config import fileConfig

from sqlalchemy import engine_from_config
from sqlalchemy import pool
from sqlalchemy import engine_from_config, pool

from alembic import context
from openadapt.config import DB_URL
from openadapt.db import Base

# this is the Alembic Config object, which provides
# This is the Alembic Config object, which provides
# access to the values within the .ini file in use.
alembic_config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
if alembic_config .config_file_name is not None:
fileConfig(alembic_config .config_file_name)
if alembic_config.config_file_name is not None:
fileConfig(alembic_config.config_file_name)

# add your model's MetaData object here
# Add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
from openadapt.config import DB_URL
from openadapt.models import *
from openadapt.db import Base

target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def get_url() -> str:
print(f"{DB_URL=}")
"""Get the database URL.

Returns:
str: The database URL.
"""
print(f"DB_URL={DB_URL}")
return DB_URL


Expand All @@ -40,14 +42,12 @@ def run_migrations_offline() -> None:

This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
here as well. By skipping the Engine creation,
we don't even need a DBAPI to be available.

Calls to context.execute() here emit the given string to the
script output.

"""
# url = config.get_main_option("sqlalchemy.url")
url = get_url()
context.configure(
url=url,
Expand All @@ -64,11 +64,10 @@ def run_migrations_offline() -> None:
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.

In this scenario we need to create an Engine
In this scenario, we need to create an Engine
and associate a connection with the context.

"""
configuration = alembic_config .get_section(alembic_config .config_ini_section)
configuration = alembic_config.get_section(alembic_config.config_ini_section)
configuration["sqlalchemy.url"] = get_url()
connectable = engine_from_config(
configuration=configuration,
Expand Down
17 changes: 9 additions & 8 deletions install/install_openadapt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Cleanup() {

# Run a command and ensure it did not fail
RunAndCheck() {

if $1 ; then
echo "Success: $2"
else
Expand Down Expand Up @@ -97,12 +96,12 @@ if ! CheckCMDExists "brew"; then

# Check the type of chip
cpu=$(sysctl machdep.cpu.brand_string)
if [[ $cpu == *"Apple"* ]]; then
# Add brew to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
if [[ $cpu == *"Apple"* ]]; then
# Add brew to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi

brewExists=$(CheckCMDExists "brew")
if ! CheckCMDExists "brew"; then
echo "Failed to download brew"
Expand Down Expand Up @@ -130,5 +129,7 @@ RunAndCheck "pip3.10 install poetry" "Install Poetry"
RunAndCheck "poetry install" "Install Python dependencies"
RunAndCheck "poetry run alembic upgrade head" "Update database"
RunAndCheck "poetry run pytest" "Run tests"
RunAndCheck "poetry shell" "Activate virtual environment"
if [ -z "$SKIP_POETRY_SHELL" ]; then
RunAndCheck "poetry shell" "Activate virtual environment"
fi
echo OpenAdapt installed successfully!
4 changes: 4 additions & 0 deletions openadapt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""OpenAdapt package.

This package contains modules for the OpenAdapt project.
"""
__version__ = "0.5.1"
9 changes: 9 additions & 0 deletions openadapt/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
"""openadapt.app package.

This package contains modules for the OpenAdapt application.

Example usage:
from openadapt.app import run_app

run_app()
"""
from openadapt.app.main import run_app

if __name__ == "__main__":
Expand Down
13 changes: 11 additions & 2 deletions openadapt/app/build.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
"""openadapt.app.build module.

This module provides functionality for building the OpenAdapt application.

Example usage:
python build.py
"""

from pathlib import Path
import os
import subprocess
from pathlib import Path

import nicegui

Expand All @@ -19,7 +27,8 @@

subprocess.call(spec)

# add import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5) to line 2 of OpenAdapt.spec
# add import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)
# to line 2 of OpenAdapt.spec
with open("OpenAdapt.spec", "r+") as f:
lines = f.readlines()
lines[1] = "import sys ; sys.setrecursionlimit(sys.getrecursionlimit() * 5)\n"
Expand Down
Loading