From 6c2b96cbf697adb72fe81f2eb9391441e84fea40 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:03:43 +0200 Subject: [PATCH 1/8] feat: setup project --- .gitignore | 1 + .python-version | 1 + oc4ids_datastore_pipeline/__init__.py | 0 oc4ids_datastore_pipeline/pipeline.py | 2 ++ pyproject.toml | 16 ++++++++++++++++ 5 files changed, 20 insertions(+) create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 oc4ids_datastore_pipeline/__init__.py create mode 100644 oc4ids_datastore_pipeline/pipeline.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1d17dae --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/oc4ids_datastore_pipeline/__init__.py b/oc4ids_datastore_pipeline/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/oc4ids_datastore_pipeline/pipeline.py b/oc4ids_datastore_pipeline/pipeline.py new file mode 100644 index 0000000..72d762d --- /dev/null +++ b/oc4ids_datastore_pipeline/pipeline.py @@ -0,0 +1,2 @@ +def run() -> None: + print("Hello World!") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..dd3bebb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,16 @@ +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] +name = "oc4ids-datastore-pipeline" +description = "OC4IDS Datastore Pipeline" +version = "1.0.0" +readme = "README.md" +dependencies = [] + +[project.optional-dependencies] +dev = [] + +[project.scripts] +oc4ids-datastore-pipeline = "oc4ids_datastore_pipeline.pipeline:run" From 2b8397d8fd149a8ad965f9e5148a717bc4049dee Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:08:08 +0200 Subject: [PATCH 2/8] feat: add logging --- .gitignore | 1 + oc4ids_datastore_pipeline/__init__.py | 10 ++++++++++ oc4ids_datastore_pipeline/pipeline.py | 8 +++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1d17dae..033df5f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .venv +__pycache__ diff --git a/oc4ids_datastore_pipeline/__init__.py b/oc4ids_datastore_pipeline/__init__.py index e69de29..f330511 100644 --- a/oc4ids_datastore_pipeline/__init__.py +++ b/oc4ids_datastore_pipeline/__init__.py @@ -0,0 +1,10 @@ +import logging +import time + + +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s:%(levelname)s:%(name)s:%(message)s", + datefmt="%Y-%m-%dT%H:%M:%S", +) +logging.Formatter.converter = time.gmtime diff --git a/oc4ids_datastore_pipeline/pipeline.py b/oc4ids_datastore_pipeline/pipeline.py index 72d762d..b54c394 100644 --- a/oc4ids_datastore_pipeline/pipeline.py +++ b/oc4ids_datastore_pipeline/pipeline.py @@ -1,2 +1,8 @@ +import logging + + +logger = logging.getLogger(__name__) + + def run() -> None: - print("Hello World!") + logger.info("Hello World!") From 2708978bdd3f3fc455e5c99e8e9cad3d03a4cf6e Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:12:19 +0200 Subject: [PATCH 3/8] style: add linting and type-checking --- README.md | 11 +++++++- oc4ids_datastore_pipeline/__init__.py | 1 - oc4ids_datastore_pipeline/pipeline.py | 1 - pyproject.toml | 17 +++++++++++- requirements_dev.txt | 38 +++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 requirements_dev.txt diff --git a/README.md b/README.md index cf82e6b..8d9fe46 100644 --- a/README.md +++ b/README.md @@ -1 +1,10 @@ -# oc4ids-datastore-pipeline \ No newline at end of file +# OC4IDS Datastore Pipeline + +## Run linting + +``` +black oc4ids_datastore_pipeline/ +isort oc4ids_datastore_pipeline/ +flake8 oc4ids_datastore_pipeline/ +mypy oc4ids_datastore_pipeline/ +``` diff --git a/oc4ids_datastore_pipeline/__init__.py b/oc4ids_datastore_pipeline/__init__.py index f330511..c3be62a 100644 --- a/oc4ids_datastore_pipeline/__init__.py +++ b/oc4ids_datastore_pipeline/__init__.py @@ -1,7 +1,6 @@ import logging import time - logging.basicConfig( level=logging.INFO, format="%(asctime)s:%(levelname)s:%(name)s:%(message)s", diff --git a/oc4ids_datastore_pipeline/pipeline.py b/oc4ids_datastore_pipeline/pipeline.py index b54c394..56081a4 100644 --- a/oc4ids_datastore_pipeline/pipeline.py +++ b/oc4ids_datastore_pipeline/pipeline.py @@ -1,6 +1,5 @@ import logging - logger = logging.getLogger(__name__) diff --git a/pyproject.toml b/pyproject.toml index dd3bebb..7313347 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,22 @@ readme = "README.md" dependencies = [] [project.optional-dependencies] -dev = [] +dev = [ + "black", + "isort", + "flake8", + "Flake8-pyproject", + "mypy", +] [project.scripts] oc4ids-datastore-pipeline = "oc4ids_datastore_pipeline.pipeline:run" + +[tool.isort] +profile = "black" + +[tool.flake8] +max-line-length = 88 + +[tool.mypy] +strict = true diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..561fb72 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,38 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile --extra=dev --output-file=requirements_dev.txt pyproject.toml +# +black==25.1.0 + # via oc4ids-datastore-pipeline (pyproject.toml) +click==8.1.8 + # via black +flake8==7.1.1 + # via + # flake8-pyproject + # oc4ids-datastore-pipeline (pyproject.toml) +flake8-pyproject==1.2.3 + # via oc4ids-datastore-pipeline (pyproject.toml) +isort==6.0.0 + # via oc4ids-datastore-pipeline (pyproject.toml) +mccabe==0.7.0 + # via flake8 +mypy==1.14.1 + # via oc4ids-datastore-pipeline (pyproject.toml) +mypy-extensions==1.0.0 + # via + # black + # mypy +packaging==24.2 + # via black +pathspec==0.12.1 + # via black +platformdirs==4.3.6 + # via black +pycodestyle==2.12.1 + # via flake8 +pyflakes==3.2.0 + # via flake8 +typing-extensions==4.12.2 + # via mypy From 31f9d648c3cb0e4306a64c553325897219748370 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:15:34 +0200 Subject: [PATCH 4/8] test: add pytest boilerplate --- pyproject.toml | 1 + requirements_dev.txt | 10 +++++++++- tests/test_pipeline.py | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tests/test_pipeline.py diff --git a/pyproject.toml b/pyproject.toml index 7313347..a4a59d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ dev = [ "flake8", "Flake8-pyproject", "mypy", + "pytest", ] [project.scripts] diff --git a/requirements_dev.txt b/requirements_dev.txt index 561fb72..b1ce205 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -14,6 +14,8 @@ flake8==7.1.1 # oc4ids-datastore-pipeline (pyproject.toml) flake8-pyproject==1.2.3 # via oc4ids-datastore-pipeline (pyproject.toml) +iniconfig==2.0.0 + # via pytest isort==6.0.0 # via oc4ids-datastore-pipeline (pyproject.toml) mccabe==0.7.0 @@ -25,14 +27,20 @@ mypy-extensions==1.0.0 # black # mypy packaging==24.2 - # via black + # via + # black + # pytest pathspec==0.12.1 # via black platformdirs==4.3.6 # via black +pluggy==1.5.0 + # via pytest pycodestyle==2.12.1 # via flake8 pyflakes==3.2.0 # via flake8 +pytest==8.3.4 + # via oc4ids-datastore-pipeline (pyproject.toml) typing-extensions==4.12.2 # via mypy diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py new file mode 100644 index 0000000..af8ff9f --- /dev/null +++ b/tests/test_pipeline.py @@ -0,0 +1,2 @@ +def test_hello_world() -> None: + pass From 27d2c039181bd0f05acd2c2418d700c0483981e1 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 15:21:17 +0200 Subject: [PATCH 5/8] ci: add lint and test checks --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..b4a8868 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: CI +on: [push] + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install dev requirements + run: pip install -r requirements_dev.txt + - name: Check black + run: black --check oc4ids_datastore_pipeline/ + - name: Check isort + run: isort --check-only oc4ids_datastore_pipeline/ + - name: Check flake8 + run: flake8 oc4ids_datastore_pipeline/ + - name: Check mypy + run: mypy oc4ids_datastore_pipeline/ + - name: Run tests + run: pytest From c44b4ba828d5b563da6bf5e4e0211222106bda45 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Wed, 29 Jan 2025 16:25:08 +0200 Subject: [PATCH 6/8] docs: add running instructions to readme --- README.md | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d9fe46..a4f1bf6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,29 @@ # OC4IDS Datastore Pipeline -## Run linting +A Python application to validate and store published OC4IDS datasets. + +## Local Development + +### Prerequisites + +- Python 3.12 + +### Install Python requirements + +``` +python -m venv .venv +source .venv/bin/activate +pip install -r requirements_dev.txt +``` + +### Run app + +``` +pip install -e . +oc4ids-datastore-pipeline +``` + +### Run linting and type checking ``` black oc4ids_datastore_pipeline/ @@ -8,3 +31,9 @@ isort oc4ids_datastore_pipeline/ flake8 oc4ids_datastore_pipeline/ mypy oc4ids_datastore_pipeline/ ``` + +### Run tests + +``` +pytest +``` From 4319e126bb49898af867cb8c9eaaec4b3da7dd43 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:39:49 +0200 Subject: [PATCH 7/8] build: update version number --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a4a59d0..603c4ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi" [project] name = "oc4ids-datastore-pipeline" description = "OC4IDS Datastore Pipeline" -version = "1.0.0" +version = "0.1.0" readme = "README.md" dependencies = [] From 2b6b9ba5f7d345f706802b4e6f31125bd0d46307 Mon Sep 17 00:00:00 2001 From: Tilly Woodfield <22456167+tillywoodfield@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:41:36 +0200 Subject: [PATCH 8/8] ci: run linters on test directory --- .github/workflows/ci.yml | 8 ++++---- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4a8868..6beb13e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,12 +12,12 @@ jobs: - name: Install dev requirements run: pip install -r requirements_dev.txt - name: Check black - run: black --check oc4ids_datastore_pipeline/ + run: black --check oc4ids_datastore_pipeline/ tests/ - name: Check isort - run: isort --check-only oc4ids_datastore_pipeline/ + run: isort --check-only oc4ids_datastore_pipeline/ tests/ - name: Check flake8 - run: flake8 oc4ids_datastore_pipeline/ + run: flake8 oc4ids_datastore_pipeline/ tests/ - name: Check mypy - run: mypy oc4ids_datastore_pipeline/ + run: mypy oc4ids_datastore_pipeline/ tests/ - name: Run tests run: pytest diff --git a/README.md b/README.md index a4f1bf6..3fac6a2 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ oc4ids-datastore-pipeline ### Run linting and type checking ``` -black oc4ids_datastore_pipeline/ -isort oc4ids_datastore_pipeline/ -flake8 oc4ids_datastore_pipeline/ -mypy oc4ids_datastore_pipeline/ +black oc4ids_datastore_pipeline/ tests/ +isort oc4ids_datastore_pipeline/ tests/ +flake8 oc4ids_datastore_pipeline/ tests/ +mypy oc4ids_datastore_pipeline/ tests/ ``` ### Run tests