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 Python CI #35

Merged
merged 1 commit into from
Feb 28, 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
74 changes: 74 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Test Python

on:
push:
branches:
- main
pull_request:

jobs:
lint-test:
name: Lint and Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: python
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Cargo fmt
run: cargo fmt --all -- --check

- name: "clippy --all"
run: cargo clippy --all --all-features --tests -- -D warnings

- name: "cargo check"
run: cargo check --all --all-features

- name: "cargo test"
run: |
cargo test --all
cargo test --all --all-features

pytest:
name: Pytest
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- uses: Swatinem/rust-cache@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install a specific version of uv
uses: astral-sh/setup-uv@v3
with:
enable-cache: true
version: "0.5.x"

- name: uv sync
working-directory: python
run: uv sync --no-install-package geoindex-rs

- name: maturin venv Build
working-directory: python
run: uv run --no-project maturin develop

# - name: Run pytest
# working-directory: python
# run: uv run --no-project pytest
1 change: 0 additions & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pyo3-async-runtimes = "0.23"
pyo3-bytes = "0.1.2"
pyo3-object_store = { git = "https://github.com/developmentseed/obstore", rev = "28ba07a621c1c104f084fb47ae7f8d08b1eae3ea" }
thiserror = "1"
tiff = "0.9.1"

# We opt-in to using rustls as the TLS provider for reqwest, which is the HTTP
# library used by object_store.
Expand Down
10 changes: 5 additions & 5 deletions python/python/async_tiff/_ifd.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ class ImageFileDirectory:
@property
def predictor(self) -> Predictor | None: ...
@property
def tile_width(self) -> int: ...
def tile_width(self) -> int | None: ...
@property
def tile_height(self) -> int: ...
def tile_height(self) -> int | None: ...
@property
def tile_offsets(self) -> list[int]: ...
def tile_offsets(self) -> list[int] | None: ...
@property
def tile_byte_counts(self) -> list[int]: ...
def tile_byte_counts(self) -> list[int] | None: ...
@property
def extra_samples(self) -> bytes | None: ...
def extra_samples(self) -> list[int] | None: ...
@property
def sample_format(self) -> list[SampleFormat]: ...
@property
Expand Down
3 changes: 2 additions & 1 deletion python/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use async_tiff::decoder::{Decoder, DecoderRegistry};
use async_tiff::error::AiocogeoError;
use async_tiff::tiff::tags::PhotometricInterpretation;
use bytes::Bytes;
use pyo3::exceptions::PyTypeError;
use pyo3::intern;
Expand Down Expand Up @@ -53,7 +54,7 @@ impl Decoder for PyDecoder {
fn decode_tile(
&self,
buffer: bytes::Bytes,
_photometric_interpretation: tiff::tags::PhotometricInterpretation,
_photometric_interpretation: PhotometricInterpretation,
_jpeg_tables: Option<&[u8]>,
) -> async_tiff::error::Result<bytes::Bytes> {
let decoded_buffer = Python::with_gil(|py| self.call(py, buffer))
Expand Down
8 changes: 4 additions & 4 deletions python/src/enums.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use pyo3::intern;
use pyo3::prelude::*;
use pyo3::types::{PyString, PyTuple};
use tiff::tags::{
use async_tiff::tiff::tags::{
CompressionMethod, PhotometricInterpretation, PlanarConfiguration, Predictor, ResolutionUnit,
SampleFormat,
};
use pyo3::intern;
use pyo3::prelude::*;
use pyo3::types::{PyString, PyTuple};

pub(crate) struct PyCompressionMethod(CompressionMethod);

Expand Down
14 changes: 7 additions & 7 deletions python/src/ifd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl PyImageFileDirectory {
}

#[getter]
pub fn strip_offsets(&self) -> Option<&[u32]> {
pub fn strip_offsets(&self) -> Option<&[u64]> {
self.0.strip_offsets()
}

Expand All @@ -80,7 +80,7 @@ impl PyImageFileDirectory {
}

#[getter]
pub fn strip_byte_counts(&self) -> Option<&[u32]> {
pub fn strip_byte_counts(&self) -> Option<&[u64]> {
self.0.strip_byte_counts()
}

Expand Down Expand Up @@ -162,25 +162,25 @@ impl PyImageFileDirectory {
}

#[getter]
pub fn tile_width(&self) -> u32 {
pub fn tile_width(&self) -> Option<u32> {
self.0.tile_width()
}
#[getter]
pub fn tile_height(&self) -> u32 {
pub fn tile_height(&self) -> Option<u32> {
self.0.tile_height()
}

#[getter]
pub fn tile_offsets(&self) -> &[u32] {
pub fn tile_offsets(&self) -> Option<&[u64]> {
self.0.tile_offsets()
}
#[getter]
pub fn tile_byte_counts(&self) -> &[u32] {
pub fn tile_byte_counts(&self) -> Option<&[u64]> {
self.0.tile_byte_counts()
}

#[getter]
pub fn extra_samples(&self) -> Option<&[u8]> {
pub fn extra_samples(&self) -> Option<&[u16]> {
self.0.extra_samples()
}

Expand Down
Loading