Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic package framework with CLI scripts #3

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: prefix-dev/[email protected]
with:
environments: dev
manifest-path: pyproject.toml
cache: false
locked: false
#cache-write:
# ${{ github.event_name == 'push' && github.ref_name == 'main' }}

- name: Run Pytest
run: |
pixi run test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ cython_debug/

# PyPI configuration file
.pypirc

# pixi environments
.pixi
*.egg-info
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing Guide

Contributions are welcome!

We recommend use [pixi](https://pixi.sh) for environment management. The "dev" environment installs additional packages such as `pytest` for developing new functions.

```bash
git clone https://github.com/uw-cryo/grid_pc.git
cd coincident
git checkout -b newfeature
pixi shell -e dev # type `exit` to deactivate
pixi run test
```
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# grid_pc

[![Actions Status][actions-badge]][actions-link]
[actions-badge]: https://github.com/uw-cryo/grid_pc/workflows/Tests/badge.svg
[actions-link]: https://github.com/uw-cryo/grid_pc/actions

Tools to generate gridded products from LiDAR (airborne and satellite) point clouds

**Warning!** This package brand new, so don't expect it to work yet!

## Quickstart

We recommend using [pixi](https://pixi.sh/latest/) to install a locked software environment for executing code in this repository. Once installed, you can run scripts from a terminal:

```bash
git clone https://github.com/uw-cryo/grid_pc.git
cd grid_pc
pixi shell
pdal_pipeline notebooks/processing_extent.geojson notebooks/SRS_CRS.wkt notebooks/UTM_13N_WGS84_G2139_3D.wkt /tmp/dem
```

## Installation

By default, pixi only manages dependencies *required* to run scripts in this respository, such as [PDAL](https://pdal.io). However, you might also want to install optional libraries into the same environment such as [GDAL](https://github.com/OSGeo/gdal) command line tools:

```
pixi add gdal
```

Or [Ames Stereo pipeline](https://stereopipeline.readthedocs.io/en/latest/installation.html#conda-intro):
```
pixi project channel add nasa-ames-stereo-pipeline
pixi project channel add usgs-astrogeology
pixi add stereo-pipeline
```

### Using pip

If you already have an environment you can install just the code in this library with pip:

```
pip install git+https://github.com/uw-cryo/grid_pc.git@main --no-deps
```
4,667 changes: 4,667 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[project]
name = "grid_pc"
version="0.1.0"
authors = [
{ name = "Scott Henderson", email = "[email protected]" },
{ name = "David Shean", email = "[email protected]" },
{ name = "Shashank Bhushan", email = "[email protected]" },
{ name = "Karthik Venkataramani", email = "[email protected]" },
]
description = "Centralized airborne lidar processing workflows to generate standard products"
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.9"
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
]

dependencies = [
#Not recommended, install via conda-forge instead
#"PDAL>=3.4.5,<4",
"rasterio>=1.4.3,<2",
"scipy>=1.15.1,<2",
"geopandas>=1.0.1,<2",
"typer>=0.15.1,<0.16",
"requests>=2.32.3,<3"
]

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling"]

[project.optional-dependencies]
dev = [
"ipykernel>=6.29.5,<7",
"pytest >=6",
]

[project.scripts]
pdal_pipeline = "grid_pc.cli:app"

[tool.pixi.project]
channels = ["conda-forge"]
platforms = ["osx-arm64", "linux-64"]

[tool.pixi.environments]
dev = { features = ["dev"], solve-group = "default" }

[tool.pixi.feature.dev.tasks]
test = "pytest"

[tool.pixi.dependencies]
rasterio = "*"
python-pdal = ">=3.4.5,<4"
scipy = "*"
geopandas = "*"
typer = "*"
requests = "*"

[tool.pixi.pypi-dependencies]
grid_pc = { path = ".", editable = false }

[tool.pixi.feature.dev.dependencies]
gdal = ">=3.10.1,<4"
pytest = "*"

[tool.pixi.feature.dev.pypi-dependencies]
grid_pc = { path = ".", editable = true }
6 changes: 6 additions & 0 deletions src/grid_pc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from grid_pc import filter_percentile
from importlib.metadata import version as _version

__version__ = _version("grid_pc")

__all__ = ["filter_percentile"]
3 changes: 3 additions & 0 deletions src/grid_pc/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
if __name__ == "__main__":
from grid_pc.cli import app
app()
15 changes: 15 additions & 0 deletions src/grid_pc/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
A CLI following https://packaging.python.org/en/latest/guides/creating-command-line-tools/
"""

import typer

from .pdal_pipeline import create_dsm


app = typer.Typer()
app.command()(create_dsm)


if __name__ == "__main__":
app()
Loading
Loading