From 7e946b96485cf2f4ce46045d196e22797e417767 Mon Sep 17 00:00:00 2001 From: eugeneyan Date: Sat, 20 Jun 2020 20:19:52 -0700 Subject: [PATCH 1/5] Deliberately introduce a bug --- src/data_prep/categorical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data_prep/categorical.py b/src/data_prep/categorical.py index 8e259ef..3de77f8 100644 --- a/src/data_prep/categorical.py +++ b/src/data_prep/categorical.py @@ -46,7 +46,7 @@ def extract_title(df: pd.DataFrame, col: str, replace_dict: dict = None, """ df[title_col] = df[col].str.extract(r' ([A-Za-z]+)\.', expand=False) - if replace_dict: + if replace_dict == True: df[title_col] = np.where(df[title_col].isin(replace_dict.keys()), df[title_col].map(replace_dict), df[title_col]) From dde5dfae9ef9033160776e5228d4595fa56305d7 Mon Sep 17 00:00:00 2001 From: eugeneyan Date: Sat, 20 Jun 2020 20:22:06 -0700 Subject: [PATCH 2/5] Fix bug that was introduced --- src/data_prep/categorical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data_prep/categorical.py b/src/data_prep/categorical.py index 3de77f8..8e259ef 100644 --- a/src/data_prep/categorical.py +++ b/src/data_prep/categorical.py @@ -46,7 +46,7 @@ def extract_title(df: pd.DataFrame, col: str, replace_dict: dict = None, """ df[title_col] = df[col].str.extract(r' ([A-Za-z]+)\.', expand=False) - if replace_dict == True: + if replace_dict: df[title_col] = np.where(df[title_col].isin(replace_dict.keys()), df[title_col].map(replace_dict), df[title_col]) From 02b28b53587852d362332e6ae111f6e304e1d763 Mon Sep 17 00:00:00 2001 From: Segun Adelowo Date: Sat, 27 Jun 2020 21:47:37 +0100 Subject: [PATCH 3/5] docs: Add text space --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 444ee1b..028ca6a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ make setup -B make check ``` -Make a pull request to this repo to see the checks in action 😎 +Make a pull request to this repo to see the checks in action 😎 Here's a [sample pull request](https://github.com/eugeneyan/python-collab-template/pull/1) which initially failed ❌ the checks, and then passed ✅. From 9117dc74b89ca12feecea75258d6931e73e3f92d Mon Sep 17 00:00:00 2001 From: eugeneyan Date: Thu, 1 Oct 2020 10:58:30 -0700 Subject: [PATCH 4/5] Add todo --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 444ee1b..15b7d6c 100644 --- a/README.md +++ b/README.md @@ -175,3 +175,6 @@ jobs: ``` ### 👉 View the [article](https://eugeneyan.com/writing/setting-up-python-project-for-automation-and-collaboration/) for the walkthrough. + +### Todo +- [ ] Update requirements.txt to use `poetry` From 38bd194374bbca80a2e7378190fcc616590a81d6 Mon Sep 17 00:00:00 2001 From: eugeneyan Date: Sat, 2 Jul 2022 09:38:19 -0700 Subject: [PATCH 5/5] Add support for running checks in Docker --- .github/workflows/tests.yml | 4 ++-- .gitignore | 1 + Dockerfile | 20 ++++++++++++++++++++ Makefile | 18 ++++++++++++++++-- 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b3e25c2..f68c9ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,6 +10,6 @@ jobs: with: python-version: 3.8 architecture: x64 - - run: make setup - - run: make check + - run: make setup-venv + - run: make checks - run: bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8812897..767e168 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea/ +.vscode/ .venv/ _build/ notebooks/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dbea447 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +ARG BASE_IMAGE=python:3.8 + +FROM ${BASE_IMAGE} as base + +LABEL maintainer='eugeneyan ' + +# Use the opt directory as our dev directory +WORKDIR /opt + +ENV PYTHONUNBUFFERED TRUE + +COPY requirements.dev . +COPY requirements.prod . + +# Install python dependencies +RUN pip install --upgrade pip \ + && pip install --no-cache-dir wheel \ + && pip install --no-cache-dir -r requirements.dev \ + && pip install --no-cache-dir -r requirements.prod \ + && pip list \ No newline at end of file diff --git a/Makefile b/Makefile index 2807060..0d808ef 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,14 @@ -setup: +.PHONY: setup-venv setup clean-pyc clean-test test mypy lint docs check + +setup-venv: python -m venv .venv && . .venv/bin/activate pip install --upgrade pip pip install -r requirements.dev pip install -r requirements.prod +setup: + DOCKER_BUILDKIT=1 docker build -t dev -f Dockerfile . + clean-pyc: find . -name '*.pyc' -exec rm -f {} + find . -name '*.pyo' -exec rm -f {} + @@ -13,8 +18,11 @@ clean-pyc: clean-test: rm -f .coverage rm -f .coverage.* + find . -name '.pytest_cache' -exec rm -fr {} + clean: clean-pyc clean-test + find . -name '.my_cache' -exec rm -fr {} + + rm -rf logs/ test: clean . .venv/bin/activate && py.test tests --cov=src --cov-report=term-missing --cov-fail-under 95 @@ -30,4 +38,10 @@ docs: FORCE cd docs; . .venv/bin/activate && sphinx-build -b html ./source ./build FORCE: -check: test lint mypy \ No newline at end of file +checks: test lint mypy clean + +run-checks: + docker run --rm -it --name run-checks -v $(shell pwd):/opt -t dev make checks + +bash: + docker run --rm -it --name run-checks -v $(shell pwd):/opt -t dev bash \ No newline at end of file