Skip to content

Commit

Permalink
initial commit tw-experimentation
Browse files Browse the repository at this point in the history
  • Loading branch information
julianteichgraber committed Jan 10, 2024
1 parent 7a3d281 commit 7a586b2
Show file tree
Hide file tree
Showing 80 changed files with 32,268 additions and 128 deletions.
9 changes: 9 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[flake8]
ignore = D100,D104,E203, W503
exclude =
.git
__pycache__
docs
build
dist
venv
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @transferwise/customer-understanding-data-science
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Linter

on:
push:
branches: [main]
pull_request:
branches: [main]

workflow_dispatch:

jobs:
check:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- name: Checking out repo
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: make venvdev

- name: Linting
run: make lint
52 changes: 52 additions & 0 deletions .github/workflows/tests-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Conda

on:
push:
branches: [main]
pull_request:
branches: [main]

workflow_dispatch:

jobs:
create-env:
name: tests-pytest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["macos-latest"]
python-version: ["3.9"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checking out repo
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Set up conda
uses: conda-incubator/setup-miniconda@v2
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}
run: conda info
- name: Conda list
shell: pwsh
run: conda list

- name: Testing (without coverage)
run: pytest tests/
43 changes: 43 additions & 0 deletions .github/workflows/tests-poetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Tests (pytest, with poetry)

on:
push:
branches: [main]
pull_request:
branches: [main]

workflow_dispatch:

jobs:
run-tests:
name: tests-pytest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.9"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checking out repo
uses: actions/checkout@v2

- name: set up python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: python -m pip install --upgrade pip poetry

- name: Setup virtual environment
run: poetry install

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

157 changes: 31 additions & 126 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,129 +1,34 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
notebooks/catboost_info/
notebooks/catboost_info/
*.swp
**/.ipynb_checkpoints/
**/.DS_Store
.vscode
dist/
**/.pkl
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
**/__pycache__/

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml

# Sensitive or high-churn files:
.idea/
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

*.tsv
*.pyc
.ipynb_checkpoints
*/.ipynb_checkpoints/*__pycache__/

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
72 changes: 72 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package_name = tw_experimentation
coverage_target = 70
max_line_length = 88

venv_name = venv
venv_activate_path := ./$(venv_name)/bin/activate
cov_args := --cov $(package_name) --cov-fail-under=$(coverage_target) --cov-report=term-missing
not_slow = -m "not slow"

.PHONY: clean venv update lint test slowtest cov slowcov

clean:
rm -rf ./$(venv_name)

venv:
python3 -m venv $(venv_name) ;\
. $(venv_activate_path) ;\
pip install --upgrade pip setuptools wheel ;\
pip install --upgrade -r envs/requirements-dev.txt ;\
pip install --upgrade -r envs/requirements.txt


venvdev:
python3 -m venv $(venv_name) ;\
. $(venv_activate_path) ;\
pip install --upgrade pip setuptools wheel ;\
pip install --upgrade -r envs/requirements-dev.txt ;\

update:
. $(venv_activate_path) ;\
pip install --upgrade -r envs/requirements-dev.txt ;\
pip install --upgrade -r envs/requirements.txt

lint:
. $(venv_activate_path) ;\
flake8 --max-line-length=$(max_line_length)

test:
. $(venv_activate_path) ;\
py.test $(not_slow) --disable-warnings

slowtest:
. $(venv_activate_path) ;\
py.test

cov:
. $(venv_activate_path) ;\
py.test $(cov_args) $(not_slow)

slowcov:
. $(venv_activate_path) ;\
py.test $(cov_args)

streamlit-run:
streamlit run tw_experimentation/streamlit/Main.py

run-streamlit-poetry:
poetry run streamlit run tw_experimentation/streamlit/Main.py

set-up-poetry-mac:
pip install poetry ;\
poetry config virtualenvs.in-project true ;\
brew install pyenv ;\
pyenv install --list | grep " 3\.[9]" ;\
poetry install

set-up-poetry-windows:
pip install poetry ;\
poetry config virtualenvs.in-project true ;\
pip install pyenv-win ;\
pyenv-win install --list | grep " 3\.[9]" ;\
poetry install
Loading

0 comments on commit 7a586b2

Please sign in to comment.