Skip to content

Commit

Permalink
Merge pull request #7 from OCHA-DAP/HAPI-224/remove-hdx-python-databa…
Browse files Browse the repository at this point in the history
…se-dep

Hapi 224 remove hdx python database dep
  • Loading branch information
turnerm authored Oct 15, 2023
2 parents 433800a + a13d6c1 commit 5fefebf
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .config/pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ repos:
- id: pip-compile
name: pip-compile requirements.txt
files: pyproject.toml
args: [pyproject.toml, --resolver=backtracking, --upgrade, -q, -o, requirements.txt]
args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt]
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,9 @@ cython_debug/
.idea/

## Project
# DB
hapi.db
# Version file
src/hapi/pipelines/_version.py

# Project YAML file
src/hapi/pipelines/app/project_configuration.yaml
# Version file
src/hapi_schema/_version.py

#OS Files
# OS Files
*DS_Store
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.0]

### Changed

- Dependency on hdx-python-database is optional
- View definitions converted to parameter dicts

## [0.1.1]

### Fixed
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
]
requires-python = ">=3.8"
dependencies = [
'sqlalchemy',
'hdx-python-database'
]
dependencies = ['sqlalchemy']
dynamic = ["version"]

[project.readme]
Expand All @@ -44,6 +41,9 @@ content-type = "text/markdown"
[project.urls]
Homepage = "https://github.com/OCHA-DAP/hapi-schemas"

[project.optional-dependencies]
database = ["hdx-python-database>=1.2.8"]

#########
# Hatch #
#########
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --output-file=requirements.txt pyproject.toml
# pip-compile --all-extras --output-file=requirements.txt pyproject.toml
#
greenlet==3.0.0
# via sqlalchemy
hdx-python-database==1.2.8
# via hapi-schema (pyproject.toml)
sqlalchemy==2.0.21
sqlalchemy==2.0.22
# via
# hapi-schema (pyproject.toml)
# hdx-python-database
Expand Down
6 changes: 3 additions & 3 deletions src/hapi_schema/db_admin1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Admin1 table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
Boolean,
DateTime,
Expand All @@ -15,6 +13,8 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship

from hapi_schema.db_location import DBLocation
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBAdmin1(Base):
Expand All @@ -40,7 +40,7 @@ class DBAdmin1(Base):
location = relationship("DBLocation")


admin1_view = view(
view_params_admin1 = ViewParams(
name="admin1_view",
metadata=Base.metadata,
selectable=select(
Expand Down
6 changes: 3 additions & 3 deletions src/hapi_schema/db_admin2.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Admin2 table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
Boolean,
DateTime,
Expand All @@ -16,6 +14,8 @@

from hapi_schema.db_admin1 import DBAdmin1
from hapi_schema.db_location import DBLocation
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBAdmin2(Base):
Expand All @@ -41,7 +41,7 @@ class DBAdmin2(Base):
admin1 = relationship("DBAdmin1")


admin2_view = view(
view_params_admin2 = ViewParams(
name="admin2_view",
metadata=Base.metadata,
selectable=select(
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_age_range.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Age range table and view."""

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import Integer, String, select
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBAgeRange(Base):
__tablename__ = "age_range"
Expand All @@ -14,7 +15,7 @@ class DBAgeRange(Base):
age_max: Mapped[int] = mapped_column(Integer, nullable=True)


age_range_view = view(
view_params_age_range = ViewParams(
name="age_range_view",
metadata=Base.metadata,
selectable=select(*DBAgeRange.__table__.columns),
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_dataset.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Dataset table and view."""

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import Integer, String, select
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBDataset(Base):
__tablename__ = "dataset"
Expand All @@ -25,7 +26,7 @@ class DBDataset(Base):
)


dataset_view = view(
view_params_dataset = ViewParams(
name="dataset_view",
metadata=Base.metadata,
selectable=select(*DBDataset.__table__.columns),
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_gender.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Gender table and view."""

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import CHAR, String, select
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBGender(Base):
__tablename__ = "gender"
Expand All @@ -13,7 +14,7 @@ class DBGender(Base):
description: Mapped[str] = mapped_column(String(256), nullable=False)


gender_view = view(
view_params_gender = ViewParams(
name="gender_view",
metadata=Base.metadata,
selectable=select(*DBGender.__table__.columns),
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_location.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Location table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import DateTime, Integer, String, select, text
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBLocation(Base):
__tablename__ = "location"
Expand All @@ -21,7 +22,7 @@ class DBLocation(Base):
)


location_view = view(
view_params_location = ViewParams(
name="location_view",
metadata=Base.metadata,
selectable=select(*DBLocation.__table__.columns),
Expand Down
6 changes: 3 additions & 3 deletions src/hapi_schema/db_operational_presence.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""OperationalPresence table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
DateTime,
ForeignKey,
Expand All @@ -21,6 +19,8 @@
from hapi_schema.db_org_type import DBOrgType
from hapi_schema.db_resource import DBResource
from hapi_schema.db_sector import DBSector
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBOperationalPresence(Base):
Expand Down Expand Up @@ -54,7 +54,7 @@ class DBOperationalPresence(Base):
admin2 = relationship("DBAdmin2")


operational_presence_view = view(
view_params_operational_presence = ViewParams(
name="operational_presence_view",
metadata=Base.metadata,
selectable=select(
Expand Down
6 changes: 3 additions & 3 deletions src/hapi_schema/db_org.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Org table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
DateTime,
ForeignKey,
Expand All @@ -14,6 +12,8 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship

from hapi_schema.db_org_type import DBOrgType
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBOrg(Base):
Expand All @@ -36,7 +36,7 @@ class DBOrg(Base):
org_type = relationship("DBOrgType")


org_view = view(
view_params_org = ViewParams(
name="org_view",
metadata=Base.metadata,
selectable=select(
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_org_type.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""OrgType table and view."""

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import String, select
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBOrgType(Base):
__tablename__ = "org_type"
Expand All @@ -13,7 +14,7 @@ class DBOrgType(Base):
description: Mapped[str] = mapped_column(String(512), nullable=False)


org_type_view = view(
view_params_org_type = ViewParams(
name="org_type_view",
metadata=Base.metadata,
selectable=select(*DBOrgType.__table__.columns),
Expand Down
20 changes: 0 additions & 20 deletions src/hapi_schema/db_orgtype.py

This file was deleted.

6 changes: 3 additions & 3 deletions src/hapi_schema/db_population.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Population table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
DateTime,
ForeignKey,
Expand All @@ -20,6 +18,8 @@
from hapi_schema.db_gender import DBGender
from hapi_schema.db_location import DBLocation
from hapi_schema.db_resource import DBResource
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBPopulation(Base):
Expand Down Expand Up @@ -56,7 +56,7 @@ class DBPopulation(Base):
gender = relationship("DBGender")


population_view = view(
view_params_population = ViewParams(
name="population_view",
metadata=Base.metadata,
selectable=select(
Expand Down
6 changes: 3 additions & 3 deletions src/hapi_schema/db_resource.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Resource table and view."""

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import (
Boolean,
DateTime,
Expand All @@ -13,6 +11,8 @@
from sqlalchemy.orm import Mapped, mapped_column, relationship

from hapi_schema.db_dataset import DBDataset
from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBResource(Base):
Expand All @@ -37,7 +37,7 @@ class DBResource(Base):
dataset = relationship("DBDataset")


resource_view = view(
view_params_resource = ViewParams(
name="resource_view",
metadata=Base.metadata,
selectable=select(
Expand Down
7 changes: 4 additions & 3 deletions src/hapi_schema/db_sector.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Sector table and view."""
from datetime import datetime

from hdx.database.no_timezone import Base
from hdx.database.views import view
from sqlalchemy import DateTime, String, select, text
from sqlalchemy.orm import Mapped, mapped_column

from hapi_schema.utils.base import Base
from hapi_schema.utils.view_params import ViewParams


class DBSector(Base):
__tablename__ = "sector"
Expand All @@ -20,7 +21,7 @@ class DBSector(Base):
)


sector_view = view(
view_params_sector = ViewParams(
name="sector_view",
metadata=Base.metadata,
selectable=select(*DBSector.__table__.columns),
Expand Down
Empty file.
Loading

0 comments on commit 5fefebf

Please sign in to comment.