Skip to content

Commit

Permalink
Merge branch 'main' into willnilges/integration-2-2
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges authored Sep 1, 2023
2 parents 81ed703 + b4f2e2f commit 4c648ec
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
extend-ignore = E203
7 changes: 6 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- name: "Upgrade pip"
run: "pip install --upgrade pip"
- name: "Install package"
run: pip install ".[dev]"
- name: "Run lint checks"
run: invoke lint
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM python:3.11-bullseye

WORKDIR /opt/meshdb
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY pyproject.toml .
RUN mkdir meshdb
RUN pip install .

# FIXME: This probably isn't the file structure we want.
COPY . .
Expand Down
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ python3 -m venv .venv
source .venv/bin/activate
```

Next, install the project dependencies
Next, install the project dependencies, including dev dependencies
```sh
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip install -e ".[dev]"
```

Finally, run `pytest`:
Expand Down Expand Up @@ -73,3 +72,23 @@ Then, in a separate window, or in your IDE, you can run the meshdb server
Finally, open another window, and run the tests.

`PYTHONPATH=. pytest .`


## Invoke.py Commands

For convenience, this package uses [invoke](https://www.pyinvoke.org/) to wrap common
tasks into one-line commands. For example:

```sh
invoke format
```

Will automatically apply `black` formatting and `isort` import sorting in a single command.

You can also quickly peform all the relevant lint checks locally using
```sh
invoke lint
```

See `tasks.py` for a complete list of the tasks available.

4 changes: 1 addition & 3 deletions meshdb/models/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class building(Base):

id: Mapped[int] = mapped_column(primary_key=True)
bin: Mapped[int] = mapped_column()
building_status: Mapped[BuildingStatusEnum] = mapped_column(
SQLAlchemyEnum(BuildingStatusEnum), nullable=False
)
building_status: Mapped[BuildingStatusEnum] = mapped_column(SQLAlchemyEnum(BuildingStatusEnum), nullable=False)
street_address: Mapped[str] = mapped_column(TEXT)
city: Mapped[str] = mapped_column(String)
state: Mapped[str] = mapped_column(String)
Expand Down
4 changes: 1 addition & 3 deletions meshdb/models/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class install(Base):

id: Mapped[int] = mapped_column(primary_key=True)
install_number: Mapped[int] = mapped_column()
install_status: Mapped[InstallStatusEnum] = mapped_column(
SQLAlchemyEnum(InstallStatusEnum), nullable=False
)
install_status: Mapped[InstallStatusEnum] = mapped_column(SQLAlchemyEnum(InstallStatusEnum), nullable=False)
building_id: Mapped[int] = mapped_column(ForeignKey("buildings.id"))
member_id: Mapped[int] = mapped_column(ForeignKey("members.id"))
4 changes: 1 addition & 3 deletions meshdb/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class request(Base):
__tablename__ = "requests"

id: Mapped[int] = mapped_column(primary_key=True)
request_status: Mapped[RequestStatusEnum] = mapped_column(
SQLAlchemyEnum(RequestStatusEnum), nullable=False
)
request_status: Mapped[RequestStatusEnum] = mapped_column(SQLAlchemyEnum(RequestStatusEnum), nullable=False)
ticket_id: Mapped[int] = mapped_column()
member_id: Mapped[int] = mapped_column(ForeignKey("members.id"), nullable=True)
building_id: Mapped[int] = mapped_column(ForeignKey("buildings.id"), nullable=True)
Expand Down
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[project]
name = "nycmesh-meshdb"
version = "0.1"
dependencies = [
"Flask==2.3.2",
"gunicorn==21.2.*",
"SQLAlchemy==2.0.20",
"SQLAlchemy_Utils==0.41.1",
"psycopg2-binary==2.9.*",
"python-dotenv==1.0.*",
"stringcase==1.2.*"
]


[project.optional-dependencies]
dev = [
"invoke == 2.2.*",
"pytest == 7.4.*",
"flake8 == 6.1.*",
"black == 23.7.*",
"isort == 5.12.*",
"mypy == 1.5.*"
]


[build-system]
requires = [ "setuptools >= 61", "wheel", "mypy" ]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = [ "meshdb" ]


[tool.mypy]
check_untyped_defs = true
show_error_codes = true
pretty = true
ignore_missing_imports = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
warn_unused_configs = true


[tool.black]
line-length = 120
include = '\.pyi?$'


[tool.isort]
profile = "black"
line_length = 120
known_first_party = [ "meshdb" ]

1 change: 0 additions & 1 deletion requirements-dev.txt

This file was deleted.

7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

20 changes: 20 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from invoke import task


@task
def format(context):
context.run("black .")
# context.run("isort .")


@task
def lint(context):
context.run("black . --check")
# context.run("isort . --check")
# context.run("flake8 meshdb tests unit_tests")
# context.run("mypy meshdb")


@task
def unit_test(context):
context.run("pytest unit_tests/")

0 comments on commit 4c648ec

Please sign in to comment.