From 29e1f50e524d6b349132abc80a0c91370018c9e4 Mon Sep 17 00:00:00 2001 From: Kenza EL HOUSSAINI Date: Thu, 16 Dec 2021 13:06:31 +0100 Subject: [PATCH] 'initialcommit' --- .github/workflows/pythonpackage.yml | 75 +++++++++++++++++++++++++++++ .gitignore | 8 +++ MANIFEST.in | 1 + Makefile | 55 +++++++++++++++++++++ README.md | 74 ++++++++++++++++++++++++++++ USA_Arrests/__init__.py | 8 +++ USA_Arrests/data/.keep | 0 notebooks/.keep | 0 requirements.txt | 29 +++++++++++ scripts/USA_Arrests-run | 2 + setup.py | 17 +++++++ tests/__init__.py | 0 12 files changed, 269 insertions(+) create mode 100644 .github/workflows/pythonpackage.yml create mode 100644 .gitignore create mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 README.md create mode 100644 USA_Arrests/__init__.py create mode 100644 USA_Arrests/data/.keep create mode 100644 notebooks/.keep create mode 100644 requirements.txt create mode 100644 scripts/USA_Arrests-run create mode 100644 setup.py create mode 100644 tests/__init__.py diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..a4b56a4 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,75 @@ + +# 🤖 usage +# +# this file contains the conf for GitHub Continuous Integration +# and Continuous Deployment to Heroku +# +# in order to activate the tests in GitHub CI: +# - uncomment the content of the CI paragraph (lines 41-55) +# - create some tests in the tests/ directory +# +# in order to activate CD to Heroku: +# - activate the tests in GitHub CI +# - uncomment the content of the CD paragraph (lines 57-75) + +name: Python package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + # 🤖 CI paragraph + # + # uncomment the content of this paragraph to activate the tests in GitHub CI + # - remove the 2 trailing characters "# ", do not change the spaces + # (the `name` keys should be at the same level as the `uses` key) + # (the `strategy` key should be at the same level as the `steps` key) + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Say hello + run: | + echo "Hello, World!" + # - name: Set up Python ${{ matrix.python-version }} + # uses: actions/setup-python@v1 + # with: + # python-version: ${{ matrix.python-version }} + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install -r requirements.txt + # - name: Install package and test + # run: | + # make install test clean + + # strategy: + # matrix: + # python-version: [3.8] + + # # 🤖 CD paragraph + # # + # # uncomment the following lines to activate CD to Heroku + # # - remove the 2 trailing characters "# ", do not change the spaces + # # (there should be 2 spaces before the `deploy_heroku` key) + # # - keep in mind you also need to configure Heroku HEROKU_API_KEY and HEROKU_EMAIL in GitHub secrets + # # - and replace REPLACE_WITH_YOUR_HEROKU_APP_NAME in this file with the name of your Heroku app + + # deploy_heroku: + # needs: build + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v2 + # - uses: akhileshns/heroku-deploy@v3.0.4 # This is the action + # with: + # heroku_api_key: ${{secrets.HEROKU_API_KEY}} + # heroku_app_name: "REPLACE_WITH_YOUR_HEROKU_APP_NAME" # Must be unique in Heroku + # heroku_email: ${{secrets.HEROKU_EMAIL}} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..022840a --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.egg-info +.coverage +.ipynb_checkpoints +.DS_Store +raw_data/ +*.csv +**/__pycache__/ +.env diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f9bd145 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include requirements.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..42f6950 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +# ---------------------------------- +# INSTALL & TEST +# ---------------------------------- +install_requirements: + @pip install -r requirements.txt + +check_code: + @flake8 scripts/* USA_Arrests/*.py + +black: + @black scripts/* USA_Arrests/*.py + +test: + @coverage run -m pytest tests/*.py + @coverage report -m --omit="${VIRTUAL_ENV}/lib/python*" + +ftest: + @Write me + +clean: + @rm -f */version.txt + @rm -f .coverage + @rm -fr */__pycache__ */*.pyc __pycache__ + @rm -fr build dist + @rm -fr USA_Arrests-*.dist-info + @rm -fr USA_Arrests.egg-info + +install: + @pip install . -U + +all: clean install test black check_code + +count_lines: + @find ./ -name '*.py' -exec wc -l {} \; | sort -n| awk \ + '{printf "%4s %s\n", $$1, $$2}{s+=$$0}END{print s}' + @echo '' + @find ./scripts -name '*-*' -exec wc -l {} \; | sort -n| awk \ + '{printf "%4s %s\n", $$1, $$2}{s+=$$0}END{print s}' + @echo '' + @find ./tests -name '*.py' -exec wc -l {} \; | sort -n| awk \ + '{printf "%4s %s\n", $$1, $$2}{s+=$$0}END{print s}' + @echo '' + +# ---------------------------------- +# UPLOAD PACKAGE TO PYPI +# ---------------------------------- +PYPI_USERNAME= +build: + @python setup.py sdist bdist_wheel + +pypi_test: + @twine upload -r testpypi dist/* -u $(PYPI_USERNAME) + +pypi: + @twine upload dist/* -u $(PYPI_USERNAME) diff --git a/README.md b/README.md new file mode 100644 index 0000000..43d9366 --- /dev/null +++ b/README.md @@ -0,0 +1,74 @@ +# Data analysis +- Document here the project: USA_Arrests +- Description: Project Description +- Data Source: +- Type of analysis: + +Please document the project the better you can. + +# Startup the project + +The initial setup. + +Create virtualenv and install the project: +```bash +sudo apt-get install virtualenv python-pip python-dev +deactivate; virtualenv ~/venv ; source ~/venv/bin/activate ;\ + pip install pip -U; pip install -r requirements.txt +``` + +Unittest test: +```bash +make clean install test +``` + +Check for USA_Arrests in gitlab.com/{group}. +If your project is not set please add it: + +- Create a new project on `gitlab.com/{group}/USA_Arrests` +- Then populate it: + +```bash +## e.g. if group is "{group}" and project_name is "USA_Arrests" +git remote add origin git@github.com:{group}/USA_Arrests.git +git push -u origin master +git push -u origin --tags +``` + +Functionnal test with a script: + +```bash +cd +mkdir tmp +cd tmp +USA_Arrests-run +``` + +# Install + +Go to `https://github.com/{group}/USA_Arrests` to see the project, manage issues, +setup you ssh public key, ... + +Create a python3 virtualenv and activate it: + +```bash +sudo apt-get install virtualenv python-pip python-dev +deactivate; virtualenv -ppython3 ~/venv ; source ~/venv/bin/activate +``` + +Clone the project and install it: + +```bash +git clone git@github.com:{group}/USA_Arrests.git +cd USA_Arrests +pip install -r requirements.txt +make clean install test # install and test +``` +Functionnal test with a script: + +```bash +cd +mkdir tmp +cd tmp +USA_Arrests-run +``` diff --git a/USA_Arrests/__init__.py b/USA_Arrests/__init__.py new file mode 100644 index 0000000..f6c9cc1 --- /dev/null +++ b/USA_Arrests/__init__.py @@ -0,0 +1,8 @@ +from os.path import isfile +from os.path import dirname + +version_file = '{}/version.txt'.format(dirname(__file__)) + +if isfile(version_file): + with open(version_file) as version_file: + __version__ = version_file.read().strip() diff --git a/USA_Arrests/data/.keep b/USA_Arrests/data/.keep new file mode 100644 index 0000000..e69de29 diff --git a/notebooks/.keep b/notebooks/.keep new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0651175 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,29 @@ +# packaging +pip>=9 +setuptools>=26 +twine +wheel>=0.29 + +# data science +numpy +pandas +scikit-learn + +# tests/linter +black +coverage +flake8 +pytest +yapf + +# API +gcsfs +google-cloud-storage +mlflow +s3fs + +# utilities +six>=1.14 +joblib +memoized-property +termcolor diff --git a/scripts/USA_Arrests-run b/scripts/USA_Arrests-run new file mode 100644 index 0000000..faa18be --- /dev/null +++ b/scripts/USA_Arrests-run @@ -0,0 +1,2 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..fc34246 --- /dev/null +++ b/setup.py @@ -0,0 +1,17 @@ +from setuptools import find_packages +from setuptools import setup + +with open('requirements.txt') as f: + content = f.readlines() +requirements = [x.strip() for x in content if 'git+' not in x] + +setup(name='USA_Arrests', + version="1.0", + description="Project Description", + packages=find_packages(), + install_requires=requirements, + test_suite='tests', + # include_package_data: to install data from MANIFEST.in + include_package_data=True, + scripts=['scripts/USA_Arrests-run'], + zip_safe=False) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29