mirror of
https://github.com/bellingcat/geoclustering.git
synced 2026-06-12 05:28:29 +03:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6e3671a16 | ||
|
|
f287cb8d02 | ||
|
|
6f83246478 | ||
|
|
b02139c50f | ||
|
|
0c789c3335 | ||
|
|
55cdec2fc8 | ||
|
|
aa228bcde2 | ||
|
|
fa4983aea6 | ||
|
|
2596b3d87c | ||
|
|
c91b0cd94d | ||
|
|
e6f56d6c62 | ||
|
|
4c46ff44a8 | ||
|
|
2e63491f72 | ||
|
|
03e132ff03 | ||
|
|
3b47f2343d | ||
|
|
6eb9007ece |
54
.github/actions/setup-venv/action.yml
vendored
Normal file
54
.github/actions/setup-venv/action.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: Python virtualenv
|
||||||
|
description: Set up a Python virtual environment with caching
|
||||||
|
inputs:
|
||||||
|
python-version:
|
||||||
|
description: The Python version to use
|
||||||
|
required: true
|
||||||
|
cache-prefix:
|
||||||
|
description: Update this to invalidate the cache
|
||||||
|
required: true
|
||||||
|
default: v0
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ inputs.python-version }}
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
# Install prerequisites.
|
||||||
|
pip install --upgrade pip setuptools wheel virtualenv
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
# Get the exact Python version to use in the cache key.
|
||||||
|
echo "PYTHON_VERSION=$(python --version)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
id: virtualenv-cache
|
||||||
|
with:
|
||||||
|
path: .venv
|
||||||
|
key: ${{ inputs.cache-prefix }}-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
|
||||||
|
|
||||||
|
- if: steps.virtualenv-cache.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Set up virtual environment without cache hit.
|
||||||
|
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install -e .[dev]
|
||||||
|
|
||||||
|
- if: steps.virtualenv-cache.outputs.cache-hit == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Set up virtual environment from cache hit.
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip install --no-deps -e .[dev]
|
||||||
|
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
# Show environment info.
|
||||||
|
. .venv/bin/activate
|
||||||
|
echo "✓ Installed $(python --version) virtual environment to $(which python)"
|
||||||
10
.github/workflows/lint.yml
vendored
10
.github/workflows/lint.yml
vendored
@@ -1,10 +0,0 @@
|
|||||||
name: Lint
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
black:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: psf/black@stable
|
|
||||||
113
.github/workflows/main.yml
vendored
Normal file
113
.github/workflows/main.yml
vendored
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
name: Main
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
# on: [push]
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Change this to invalidate existing cache.
|
||||||
|
CACHE_PREFIX: v0
|
||||||
|
PYTHONPATH: ./
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
checks:
|
||||||
|
name: Python ${{ matrix.python }} - ${{ matrix.task.name }}
|
||||||
|
runs-on: [ubuntu-latest]
|
||||||
|
timeout-minutes: 15
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- python: "3.10"
|
||||||
|
task:
|
||||||
|
name: "Build"
|
||||||
|
run: |
|
||||||
|
python setup.py check
|
||||||
|
python setup.py bdist_wheel sdist
|
||||||
|
|
||||||
|
- python: "3.10"
|
||||||
|
task:
|
||||||
|
name: "Style"
|
||||||
|
run: |
|
||||||
|
black --check .
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Python environment
|
||||||
|
uses: ./.github/actions/setup-venv
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
cache-prefix: ${{ env.CACHE_PREFIX }}
|
||||||
|
|
||||||
|
- name: ${{ matrix.task.name }}
|
||||||
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
|
${{ matrix.task.run }}
|
||||||
|
|
||||||
|
- name: Upload package distribution files
|
||||||
|
if: matrix.task.name == 'Build'
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: package
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Clean up
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
|
pip uninstall -y geoclustering
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [checks]
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install requirements
|
||||||
|
run: |
|
||||||
|
pip install --upgrade pip setuptools wheel "twine>=1.11.0"
|
||||||
|
|
||||||
|
- name: Prepare environment
|
||||||
|
run: |
|
||||||
|
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
|
||||||
|
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Download package distribution files
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: package
|
||||||
|
path: dist
|
||||||
|
|
||||||
|
- name: Publish package to PyPI
|
||||||
|
run: |
|
||||||
|
twine upload -u '${{ secrets.PYPI_USERNAME }}' -p '${{ secrets.PYPI_PASSWORD }}' dist/*
|
||||||
|
|
||||||
|
- name: Publish GitHub release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
# body_path: ${{ github.workspace }}-RELEASE_NOTES.md
|
||||||
|
prerelease: ${{ contains(env.TAG, 'rc') }}
|
||||||
|
files: |
|
||||||
|
dist/*
|
||||||
19
Pipfile
Normal file
19
Pipfile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
click = "*"
|
||||||
|
geojson = "*"
|
||||||
|
keplergl = "*"
|
||||||
|
numpy = "*"
|
||||||
|
pandas = "*"
|
||||||
|
scikit-learn = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
black = "*"
|
||||||
|
wheel = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.9"
|
||||||
1124
Pipfile.lock
generated
Normal file
1124
Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
# geocluster
|
# geoclustering
|
||||||
|
|
||||||
> 📍 command-line tool for clustering geolocations.
|
> 📍 command-line tool for clustering geolocations.
|
||||||
|
|
||||||
@@ -18,8 +18,8 @@ A cluster is created when a certain number of points (=> `--size`) each are with
|
|||||||
Clone the repository:
|
Clone the repository:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/fspoettel/geocluster
|
git clone https://github.com/bellingcat/geoclustering
|
||||||
cd geocluster
|
cd geoclustering
|
||||||
```
|
```
|
||||||
|
|
||||||
Install keplergl build dependencies:
|
Install keplergl build dependencies:
|
||||||
@@ -37,7 +37,7 @@ pip install .
|
|||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: geocluster [OPTIONS] FILENAME
|
Usage: geoclustering [OPTIONS] FILENAME
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d, --distance FLOAT (in km) Max. distance between two points in
|
-d, --distance FLOAT (in km) Max. distance between two points in
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import click
|
import click
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
import geocluster.clustering as clustering
|
import geoclustering.clustering as clustering
|
||||||
import geocluster.encoding as encoding
|
import geoclustering.encoding as encoding
|
||||||
import geocluster.io as io
|
import geoclustering.io as io
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@@ -68,7 +68,7 @@ def write_visualization(dirname, filename, data):
|
|||||||
map.add_data(data=data, name="clusters")
|
map.add_data(data=data, name="clusters")
|
||||||
|
|
||||||
# config configures a default color scheme for our clusters layer.
|
# config configures a default color scheme for our clusters layer.
|
||||||
config_file = resource_filename("geocluster", "kepler_config.json")
|
config_file = resource_filename("geoclustering", "kepler_config.json")
|
||||||
with open(config_file) as f:
|
with open(config_file) as f:
|
||||||
map.config = json.loads(f.read())
|
map.config = json.loads(f.read())
|
||||||
|
|
||||||
11
geoclustering/version.py
Normal file
11
geoclustering/version.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
_MAJOR = "0"
|
||||||
|
_MINOR = "1"
|
||||||
|
# On main and in a nightly release the patch should be one ahead of the last
|
||||||
|
# released build.
|
||||||
|
_PATCH = "2"
|
||||||
|
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
||||||
|
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
||||||
|
_SUFFIX = ""
|
||||||
|
|
||||||
|
VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
|
||||||
|
VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX)
|
||||||
18
scripts/release.sh
Normal file
18
scripts/release.sh
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TAG=$(python -c 'from geoclustering.version import VERSION; print("v" + VERSION)')
|
||||||
|
|
||||||
|
read -p "Creating new release for $TAG. Do you want to continue? [Y/n] " prompt
|
||||||
|
|
||||||
|
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
|
||||||
|
git add -A
|
||||||
|
git commit -m "Bump version to $TAG for release" || true && git push
|
||||||
|
echo "Creating new git tag $TAG"
|
||||||
|
git tag "$TAG" -m "$TAG"
|
||||||
|
git push --tags
|
||||||
|
else
|
||||||
|
echo "Cancelled"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
28
setup.py
28
setup.py
@@ -1,12 +1,30 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
# version.py defines the VERSION and VERSION_SHORT variables.
|
||||||
|
# We use exec here so we don't import cached_path whilst setting up.
|
||||||
|
VERSION = {} # type: ignore
|
||||||
|
with open("geoclustering/version.py", "r") as version_file:
|
||||||
|
exec(version_file.read(), VERSION)
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="geocluster",
|
name="geoclustering",
|
||||||
version="0.1",
|
version=VERSION["VERSION"],
|
||||||
description="",
|
description="📍 command-line tool for clustering geolocations.",
|
||||||
|
long_description=open("README.md").read(),
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
classifiers=[
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Intended Audience :: Science/Research",
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
],
|
||||||
author="Bellingcat",
|
author="Bellingcat",
|
||||||
packages=["geocluster"],
|
author_email="tech@bellingcat.com",
|
||||||
entry_points={"console_scripts": ["geocluster = geocluster.__main__:main"]},
|
license="MIT",
|
||||||
|
packages=["geoclustering"],
|
||||||
|
package_data={"geoclustering": ["kepler_config.json"]}
|
||||||
|
keywords=["cluster", "gis", "pattern-analysis"],
|
||||||
|
entry_points={"console_scripts": ["geoclustering = geoclustering.__main__:main"]},
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"click",
|
"click",
|
||||||
"geojson",
|
"geojson",
|
||||||
|
|||||||
Reference in New Issue
Block a user