Skip to content

Commit

Permalink
'initialcommit'
Browse files Browse the repository at this point in the history
  • Loading branch information
kelhoussaini committed Dec 16, 2021
0 parents commit 29e1f50
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected] # 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}}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.egg-info
.coverage
.ipynb_checkpoints
.DS_Store
raw_data/
*.csv
**/__pycache__/
.env
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include requirements.txt
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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=<AUTHOR>
build:
@python setup.py sdist bdist_wheel

pypi_test:
@twine upload -r testpypi dist/* -u $(PYPI_USERNAME)

pypi:
@twine upload dist/* -u $(PYPI_USERNAME)
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]:{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 [email protected]:{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
```
8 changes: 8 additions & 0 deletions USA_Arrests/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
Empty file added USA_Arrests/data/.keep
Empty file.
Empty file added notebooks/.keep
Empty file.
29 changes: 29 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions scripts/USA_Arrests-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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)
Empty file added tests/__init__.py
Empty file.

0 comments on commit 29e1f50

Please sign in to comment.