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

update pre-commit hooks and rename top-level directory #57

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
api:
- carbonplan_offsets_db/**/*
- offsets_db_api/**/*
- migrations/**/*
- Procfile
- environment.yml
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ dmypy.json
# mac
.DS_Store

carbonplan_offsets_db/_version.py
offsets_db_api/_version.py
.vscode/
*.sqlite
*.csv
Expand Down
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
autoupdate_schedule: monthly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,24 +13,18 @@ repos:
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.272'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.3'
hooks:
- id: ruff
args: ['--fix']

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
hooks:
- id: blackdoc
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.9-for-vscode
rev: v3.0.3
hooks:
- id: prettier
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: gunicorn -w 2 -t 300 -k uvicorn.workers.UvicornWorker carbonplan_offsets_db.main:app --config gunicorn_config.py
web: gunicorn -w 2 -t 300 -k uvicorn.workers.UvicornWorker offsets_db_api.main:app --config gunicorn_config.py
4 changes: 2 additions & 2 deletions migrations/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from sqlalchemy import engine_from_config, pool
from sqlmodel import SQLModel

from carbonplan_offsets_db.models import ( # (be sure to import all models you need migrated)
from offsets_db_api.models import ( # (be sure to import all models you need migrated)
Credit,
File,
Project,
)
from carbonplan_offsets_db.settings import get_settings
from offsets_db_api.settings import get_settings

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down
2 changes: 1 addition & 1 deletion notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ After that, update the `migrations/env.py` file to point to the correct database
```python
import os
from sqlmodel import SQLModel
from carbonplan_offsets_db.models import Project
from offsets_db_api.models import Project


# https://stackoverflow.com/questions/37890284/ini-file-load-environment-variable
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
It also contains information about the offset credits that have been issued for each project.
The raw data are retrieved from the following registries:

- [art-trees](https://www.artredd.org/trees/)
- [art-trees](https://art.apx.com/)
- [climate action reserve](https://thereserve2.apx.com)
- [american carbon registry](https://acr2.apx.com/)
- [verra](https://registry.verra.org/)
Expand All @@ -34,9 +34,9 @@


metadata = dict(
title='CarbonPlan Offsets Database',
title='CarbonPlan Offsets-DB API',
description=description,
contact=dict(name='CarbonPlan', url='https://github.com/carbonplan/offsets-db/issues'),
contact=dict(name='CarbonPlan', url='https://github.com/carbonplan/offsets-db-api/issues'),
license_info=dict(name='MIT License', url='https://spdx.org/licenses/MIT.html'),
version=version,
)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


def get_logger() -> logging.Logger:
logger = logging.getLogger('offsets-db')
logger = logging.getLogger('offsets-db-api')

if not logger.handlers:
handler = logging.StreamHandler(stream=sys.stdout)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -282,18 +282,17 @@ def get_projects_by_listing_date(
protocol: list[str] | None = Query(None, description='Protocol name'),
category: list[str] | None = Query(None, description='Category name'),
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
listed_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
listed_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
issued_min: int | None = Query(None, description='Minimum number of issued credits'),
issued_max: int | None = Query(None, description='Maximum number of issued credits'),
retired_min: int | None = Query(None, description='Minimum number of retired credits'),
retired_max: int | None = Query(None, description='Maximum number of retired credits'),
search: str
| None = Query(
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down Expand Up @@ -455,14 +454,13 @@ def get_credits_by_transaction_date(
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
transaction_type: list[str] | None = Query(None, description='Transaction type'),
vintage: list[int] | None = Query(None, description='Vintage'),
transaction_date_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
transaction_date_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
search: str
| None = Query(
transaction_date_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
transaction_date_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down Expand Up @@ -533,12 +531,12 @@ def get_credits_by_project_id(
project_id: str,
transaction_type: list[str] | None = Query(None, description='Transaction type'),
vintage: list[int] | None = Query(None, description='Vintage'),
transaction_date_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
transaction_date_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
transaction_date_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
transaction_date_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
freq: typing.Literal['D', 'W', 'M', 'Y'] = Query(None, description='Frequency of bins'),
current_page: int = Query(1, description='Page number', ge=1),
per_page: int = Query(100, description='Items per page', le=200, ge=1),
Expand Down Expand Up @@ -595,24 +593,23 @@ def get_projects_by_credit_totals(
protocol: list[str] | None = Query(None, description='Protocol name'),
category: list[str] | None = Query(None, description='Category name'),
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
listed_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
started_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
started_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
listed_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
started_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
started_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
issued_min: int | None = Query(None, description='Minimum number of issued credits'),
issued_max: int | None = Query(None, description='Maximum number of issued credits'),
retired_min: int | None = Query(None, description='Minimum number of retired credits'),
retired_max: int | None = Query(None, description='Maximum number of retired credits'),
search: str
| None = Query(
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down Expand Up @@ -688,18 +685,17 @@ def get_projects_by_category(
protocol: list[str] | None = Query(None, description='Protocol name'),
category: list[str] | None = Query(None, description='Category name'),
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
listed_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
listed_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
issued_min: int | None = Query(None, description='Minimum number of issued credits'),
issued_max: int | None = Query(None, description='Maximum number of issued credits'),
retired_min: int | None = Query(None, description='Minimum number of retired credits'),
retired_max: int | None = Query(None, description='Maximum number of retired credits'),
search: str
| None = Query(
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down Expand Up @@ -761,18 +757,17 @@ def get_credits_by_category(
protocol: list[str] | None = Query(None, description='Protocol name'),
category: list[str] | None = Query(None, description='Category name'),
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
listed_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
listed_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
issued_min: int | None = Query(None, description='Minimum number of issued credits'),
issued_max: int | None = Query(None, description='Maximum number of issued credits'),
retired_min: int | None = Query(None, description='Minimum number of retired credits'),
retired_max: int | None = Query(None, description='Maximum number of retired credits'),
search: str
| None = Query(
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ def get_clips(
project_id: list[str] | None = Query(None, description='Project ID'),
tags: list[str] | None = Query(None, description='Tags'),
article_type: list[str] | None = Query(None, description='Article type'),
published_at_from: datetime.date
| datetime.datetime
| None = Query(None, description='Published at from'),
published_at_to: datetime.date
| datetime.datetime
| None = Query(None, description='Published at to'),
search: str
| None = Query(
published_at_from: datetime.date | datetime.datetime | None = Query(
None, description='Published at from'
),
published_at_to: datetime.date | datetime.datetime | None = Query(
None, description='Published at to'
),
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `title` fields only.',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ def get_credits(
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
transaction_type: list[str] | None = Query(None, description='Transaction type'),
vintage: list[int] | None = Query(None, description='Vintage'),
transaction_date_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
transaction_date_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
search: str
| None = Query(
transaction_date_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
transaction_date_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ def get_projects(
protocol: list[str] | None = Query(None, description='Protocol name'),
category: list[str] | None = Query(None, description='Category name'),
is_compliance: bool | None = Query(None, description='Whether project is an ARB project'),
listed_at_from: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_to: datetime.date
| datetime.datetime
| None = Query(default=None, description='Format: YYYY-MM-DD'),
listed_at_from: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
listed_at_to: datetime.date | datetime.datetime | None = Query(
default=None, description='Format: YYYY-MM-DD'
),
issued_min: int | None = Query(None, description='Minimum number of issued credits'),
issued_max: int | None = Query(None, description='Maximum number of issued credits'),
retired_min: int | None = Query(None, description='Minimum number of retired credits'),
retired_max: int | None = Query(None, description='Maximum number of retired credits'),
search: str
| None = Query(
search: str | None = Query(
None,
description='Case insensitive search string. Currently searches on `project_id` and `name` fields only.',
),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading