Skip to content

Commit

Permalink
Refactor python part to publish on pypi + automate pypi publication
Browse files Browse the repository at this point in the history
  • Loading branch information
leavauchier committed Jun 25, 2024
1 parent f16e2ab commit 961ae62
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 14 deletions.
41 changes: 38 additions & 3 deletions .github/workflows/cicd_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,48 @@ on:
- "v*.*.*"

jobs:
build:
release-github:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release
- name: Release on github
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
make_latest: true
make_latest: true

deploy-pypi:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/pdal-ign-macro/
permissions:
contents: read
packages: write
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- name: Checkout branch
uses: actions/checkout@v4

# See https://github.com/marketplace/actions/setup-micromamba
- name: setup-micromamba
uses: mamba-org/[email protected]
with:
environment-file: environment.yml
environment-name: pdal_ign_plugin # activate the environment
cache-environment: true
cache-downloads: true
generate-run-shell: true

- name: Build pip package
shell: micromamba-shell {0}
run: |
rm -rf tmp
rm -rf pdal_ign_macro.egg-info
rm -rf dist
python -m build
- name: pypi-publish
uses: pypa/[email protected]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ xcode
.vscode
build
install
dist

# all pycache directories
__pycache__
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ ENV PROJ_LIB=/opt/conda/envs/pdal_ign_plugin/share/proj/
ENV PDAL_DRIVER_PATH=/pdal_ign_plugin/install/lib

# Install python macro module
COPY macro /pdal_ign_plugin/macro
COPY pdal_ign_macro /pdal_ign_plugin/pdal_ign_macro
COPY pyproject.toml /pdal_ign_plugin/pyproject.toml
WORKDIR /pdal_ign_plugin
RUN pip install .

# Add example scripts + test data (to be able to test inside the docker image)
COPY scripts /pdal_ign_plugin/scripts
COPY test /pdal_ign_plugin/test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ docker image.
### Syntax to use it in a python script

```python
from macro import macro
from pdal_ign_macro import macro

marco.my_macro(...)
```
Expand Down
2 changes: 2 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ dependencies:
- isort # import sorting
- flake8 # code analysis
- pytest
- build
- twine
# --------- pip & pip libraries --------- #
- pip
- pip:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pdal

from macro import macro
from pdal_ign_macro import macro

"""
This tool applies a pdal pipeline to select points for DSM and DTM calculation
Expand Down Expand Up @@ -42,7 +42,9 @@ def parse_args():
return parser.parse_args()


def main(input_las, output_las, dsm_dimension, dtm_dimension, output_dsm, output_dtm):
def mark_points_to_use_for_digital_models_with_new_dimension(
input_las, output_las, dsm_dimension, dtm_dimension, output_dsm, output_dtm
):
pipeline = pdal.Pipeline() | pdal.Reader.las(input_las)

# 0 - ajout de dimensions temporaires et de sortie
Expand Down Expand Up @@ -192,4 +194,4 @@ def main(input_las, output_las, dsm_dimension, dtm_dimension, output_dsm, output

if __name__ == "__main__":
args = parse_args()
main(**vars(args))
mark_points_to_use_for_digital_models_with_new_dimension(**vars(args))
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pdal

from macro import macro
from pdal_ign_macro import macro

"""
This tool shows how to use functions of macro in a pdal pipeline
Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
[project]
name = "pdal_ign_macro"
dynamic = ["version"]
readme = "README.md"
description = "Macros and pipelines for Pdal based on the https://github.com/IGNF/pdal-ign-plugin plugin"
dependencies = []
authors = [
{ name = "Antoine Lavenant", email = "[email protected]" },
{ name = "Léa Vauchier", email = "[email protected]" },
]

[tool.setuptools.dynamic]
version = { attr = "macro.version.__version__" }
version = { attr = "pdal_ign_macro.version.__version__" }

[tool.setuptools]
packages = ["macro"]
packages = ["pdal_ign_macro"]

[tool.black]
line-length = 99
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
import numpy as np
import pdal

from scripts.mark_points_to_use_for_digital_models_with_new_dimension import main
from pdal_ign_macro.mark_points_to_use_for_digital_models_with_new_dimension import (
mark_points_to_use_for_digital_models_with_new_dimension,
)


def test_main():
ini_las = "test/data/4_6.las"
dsm_dimension = "dsm_marker"
dtm_dimension = "dtm_marker"
with tempfile.NamedTemporaryFile(suffix="_mark_points_output.las") as las_output:
main(ini_las, las_output.name, dsm_dimension, dtm_dimension, "", "")
mark_points_to_use_for_digital_models_with_new_dimension(
ini_las, las_output.name, dsm_dimension, dtm_dimension, "", ""
)
pipeline = pdal.Pipeline()
pipeline |= pdal.Reader.las(las_output.name)
assert dsm_dimension in pipeline.quickinfo["readers.las"]["dimensions"].split(", ")
Expand Down

0 comments on commit 961ae62

Please sign in to comment.