Skip to content

Commit

Permalink
Merge pull request #16 from transferwise/pre-commit-check
Browse files Browse the repository at this point in the history
Pre commit check cleanup
  • Loading branch information
AlxdrPolyakov authored Feb 5, 2024
2 parents d76e00d + 0fceaf3 commit 578b030
Show file tree
Hide file tree
Showing 54 changed files with 899 additions and 454 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @transferwise/customer-understanding-data-science
* @transferwise/customer-understanding-data-science
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
check:
runs-on: macos-latest
strategy:
matrix:
matrix:
python-version: ["3.9"]

steps:
Expand All @@ -28,4 +28,4 @@ jobs:
run: make venvdev

- name: Linting
run: make lint
run: make lint
18 changes: 18 additions & 0 deletions .github/workflows/pre-commit-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: pre-commit check

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
name: Pre-commit check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- uses: pre-commit/[email protected]
4 changes: 2 additions & 2 deletions .github/workflows/pypi-publication.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ jobs:

- name: Check distributable
run: twine check --strict dist/*.whl

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
password: ${{ secrets.PYPI_API_TOKEN }}
password: ${{ secrets.PYPI_API_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
with:
with:
auto-activate-base: false
channels: conda-forge, defaults
python-version: ${{ matrix.python-version }}
activate-environment: tw_exp
environment-file: envs/environment.yml


- name: Conda info
shell: bash -el {0}
Expand All @@ -49,4 +49,4 @@ jobs:
run: conda list

- name: Testing (without coverage)
run: pytest tests/
run: pytest tests/
1 change: 0 additions & 1 deletion .github/workflows/tests-poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ jobs:

- name: Run tests via pytest
run: poetry run pytest

52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# File introduces automated checks triggered on git events
# to enable run `pip install pre-commit && pre-commit install`
# Update this file:
# pre-commit autoupdate

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-case-conflict
- id: check-docstring-first
- id: check-added-large-files
- id: check-json
- id: check-yaml
- id: check-merge-conflict
- id: debug-statements
#- id: detect-aws-credentials
# args: [--allow-missing-credentials]
#- id: detect-private-key
#- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
args:
- --max-line-length=88

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort

# - repo: https://github.com/pycqa/pylint
# rev: v2.15.4
# hooks:
# - id: pylint
# args:
# - --disable=too-many-arguments

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.982
# hooks:
# - id: mypy
# additional_dependencies:
# - types-requests
# - types-protobuf
# - types-tqdm
# - types-python-dateutil
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ set-up-poetry-windows:
poetry config virtualenvs.in-project true ;\
pip install pyenv-win ;\
pyenv-win install --list | grep " 3\.[9]" ;\
poetry install
poetry install
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TW Experimentation: A library for automated A/B testing


**TW Experimentation** is a library to design experiments, check data, run statistical tests and make decisions
**TW Experimentation** is a library to design experiments, check data, run statistical tests and make decisions

<summary><strong><em>Table of Contents</em></strong></summary>

Expand Down Expand Up @@ -67,27 +67,27 @@ For running streamlit app please just open the terminal and run:
run_tw_experimentation_streamlit
```

2. You can install the package via the dependency manager poetry after cloning/git pull/download it as a zip from this repository.
2. You can install the package via the dependency manager poetry after cloning/git pull/download it as a zip from this repository.

To do so, clone the repository by running
```
git clone [email protected]:transferwise/tw-experimentation.git
```
from terminal.
To set up poetry, run
To set up poetry, run
```
make set-up-poetry-mac
```
for mac (or linux) and
```
make set-up-poetry-windows
```
for windows.
Then, run
for windows.
Then, run
```
make run-streamlit-poetry
```
from the root of the package folder.
```
from the root of the package folder.

3. **Alernative:** TW Experimentation requires the following libraries to work which you can find in the .yml file. To install requirements please make sure you have installed the package manager Anaconda and then run the following commands in the terminal:

Expand All @@ -112,8 +112,8 @@ conda install -c conda-forge jax

Make sure you have followed the installation instructions.

### Notebooks
You can use the jupyter notebooks `1_pre_experiment.ipynb` or `2_integrity_checks + evaluation.ipynb` for experiments design and evaluation.
### Notebooks
You can use the jupyter notebooks `1_pre_experiment.ipynb` or `2_integrity_checks + evaluation.ipynb` for experiments design and evaluation.
The tw experimentation package can be used for different things, for example for analyzing results:

```Python
Expand Down Expand Up @@ -148,7 +148,7 @@ run_tw_experimentation_streamlit

Or:

Open terminal and navigate to the repository.
Open terminal and navigate to the repository.
Then navigate to the folder `./tw_experimentation/streamlit`.

Now run the command `streamlit run Main.py` and the app should open in your browser.
Expand Down
2 changes: 1 addition & 1 deletion envs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ dependencies:
- snowflake_sqlalchemy
- cloudpickle
- jupyter
- streamlit-extras
- streamlit-extras
42 changes: 21 additions & 21 deletions envs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
numpy~=1.23.5
pandas<=1.5.3
pytest
scipy
scikit_learn
matplotlib
dcor
holidays
setuptools==65.5.1
ipykernel
boto3

#other
causaltune
cloudpickle
dcor
dill
fsspec
s3fs
mlflow
ipywidgets
holidays
ipykernel
ipympl
ipywidgets
jupyter
matplotlib
mlflow
networkx
sympy

#other
causaltune
statsmodels
numpy~=1.23.5
numpyro
pandas<=1.5.3
plotly
pytest
s3fs
scikit_learn
scipy
seaborn
setuptools==65.5.1
snowflake_sqlalchemy
SQLAlchemy
cloudpickle
jupyter
numpyro
statsmodels
streamlit
sympy
wise-pizza>=0.2.0
4 changes: 2 additions & 2 deletions tests/test_bayes_in_notebook.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pytest

import numpy as np
from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.bayes.bayes_test import BayesTest
from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.utils import ExperimentDataset


@pytest.fixture
Expand Down
3 changes: 1 addition & 2 deletions tests/test_bayestest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import pytest

from tw_experimentation.utils import ExperimentDataset

from tw_experimentation.bayes.bayes_test import BayesTest
from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.utils import ExperimentDataset


class TestBayesTesterEndToEnd(object):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_datasets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.utils import ExperimentDataset


@pytest.fixture(params=[True, False])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_experiment_design.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pytest

from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.setuper import ExpDesignAutoCalculate, Setuper
import numpy as np
from tw_experimentation.utils import ExperimentDataset


@pytest.fixture
Expand Down
6 changes: 2 additions & 4 deletions tests/test_frequentist_hypothesis_tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import pytest
from pandas import testing as tm

from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.data_generation import RevenueConversion

from tw_experimentation.statistical_tests import (
FrequentistTest,
compute_frequentist_results,
)

from pandas import testing as tm
from tw_experimentation.utils import ExperimentDataset


@pytest.fixture
Expand Down
16 changes: 5 additions & 11 deletions tests/test_frequentist_static.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import numpy as np
import pandas as pd
import pytest

import pandas as pd
import numpy as np
from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.data_generation import RevenueConversion

from tw_experimentation.statistical_tests import FrequentistTest, BaseTest

from tw_experimentation.widgetizer import (
FrequentistEvaluation,
)

from tw_experimentation.statistical_tests import cuped
from tw_experimentation.statistical_tests import BaseTest, FrequentistTest, cuped
from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.widgetizer import FrequentistEvaluation


@pytest.fixture
Expand Down
8 changes: 4 additions & 4 deletions tests/test_generate_output.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import os

import pytest
from plotly import graph_objects as go

from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.result_generator import (
generate_results,
save_output,
load_output,
save_output,
)
import os

from plotly import graph_objects as go


@pytest.fixture()
Expand Down
11 changes: 5 additions & 6 deletions tests/test_integrity_checks_in_notebook.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import pytest

import numpy as np
from tw_experimentation.utils import ExperimentDataset
from tw_experimentation.data_generation import RevenueConversion
import plotly.graph_objects as go
import pytest

from tw_experimentation.checker import (
Monitoring,
NormalityChecks,
SegmentMonitoring,
SequentialTest,
NormalityChecks,
)
import plotly.graph_objects as go
from tw_experimentation.data_generation import RevenueConversion
from tw_experimentation.utils import ExperimentDataset


@pytest.fixture(params=[True, False])
Expand Down
Loading

0 comments on commit 578b030

Please sign in to comment.