Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertLucey committed Dec 28, 2021
0 parents commit 111232e
Show file tree
Hide file tree
Showing 16 changed files with 855 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Upload Python Package

on:
push:
branches:
- master
create:
tags:
- 'v*'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get install make
python -m pip install --upgrade pip
python -m pip install virtualenv
- name: Test
run: make test

release:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
sudo apt-get install make
python -m pip install --upgrade pip
python -m pip install virtualenv
- name: Build package
run: make build_dist
- name: Publish package
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
__pycache__/

.coverage*
coverage.xml
htmlcov/

*.py[cod]

# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

.env_python*

*egg-info*

.eggs/
dist/
RPMS/
BUILD/
BUILDROOT/
SRPMS/
SOURCES/
cache/

.env
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PYTHON=python3

# TODO: might be nice to have a non threading setting
TEST_CONTEXT=export TEST_ENV=True &&

ENV_DIR=.env_$(PYTHON)
IN_ENV=. $(ENV_DIR)/bin/activate &&

env: $(ENV_DIR)

setup:
$(PYTHON) -m pip install --upgrade pip
$(PYTHON) -m pip install virtualenv
$(PYTHON) -m virtualenv -p $(PYTHON) $(ENV_DIR)
$(IN_ENV) $(PYTHON) -m pip install --upgrade -r requirements.txt
$(IN_ENV) $(PYTHON) -m pip install --editable .

test_requirements:
$(IN_ENV) $(PYTHON) -m pip install --upgrade -r test_requirements.txt

upload_pip: test build_dist
twine upload --repository road_collisions_uk dist/*

build_dist: setup
rm -fr dist/
$(IN_ENV) python setup.py sdist bdist_wheel

build: setup

quick_build:
$(IN_ENV) $(PYTHON) -m pip install --editable .

test: build test_requirements quick_test

quick_test:
$(IN_ENV) $(PYTHON) -m unittest

load:
$(IN_ENV) load_road_collisions_uk
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Road Collisions Ireland
=======================

| Region | years |
| ---------------- | ----------- |
| United Kingdom | 2016 - 2021 |

There is UK data from the 70s to present but it's very big. I'll work on making it so it is small enough for pypi when I have the time

# Quickstart

To enter a debugger with access to all collision data run `make load_road_collisions_uk` and you will have access to the variable `collisions` which contains everything
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
road-collisions-base
30 changes: 30 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from setuptools import (
find_packages,
setup
)

INSTALL_REQUIRES = (
'road-collisions-base'
)

setup(
name='road_collisions_uk',
version='0.0.1',
python_requires='>=3.6',
description='Road collision data for the UK',
author='Robert Lucey',
url='https://github.com/RobertLucey/road-collisions-uk',
packages=find_packages('src'),
package_dir={'': 'src'},
install_requires=INSTALL_REQUIRES,
package_data={
'road_collisions_uk': [
'resources/uk/uk.csv.tgz'
]
},
entry_points={
'console_scripts': [
'load_road_collisions_uk = road_collisions_uk.bin.load:main',
]
}
)
Empty file added src/__init__.py
Empty file.
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions src/road_collisions_uk/bin/load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from road_collisions_base import logger

from road_collisions_uk.models.collision import Collisions


def main():
collisions = Collisions.load_all(region='uk')

logger.info('Loaded %s collisions', (len(collisions)))
logger.info('Do something with the data in the variable \'collisions\'...')

import pdb; pdb.set_trace()

pass


if __name__ == '__main__':
main()
Empty file.
Loading

0 comments on commit 111232e

Please sign in to comment.