This is an automated email from the ASF dual-hosted git repository. piotr pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/iggy.git
The following commit(s) were added to refs/heads/master by this push: new 2371cb05 chore(python): rename Python SDK from iggy_py to apache-iggy (#2050) 2371cb05 is described below commit 2371cb05c0542671106673d1e7864a85a9e64ce0 Author: Albin Skott <cstr...@users.noreply.github.com> AuthorDate: Tue Jul 29 16:38:08 2025 +0200 chore(python): rename Python SDK from iggy_py to apache-iggy (#2050) --- DEPENDENCIES.md | 10 +++---- foreign/python/Cargo.toml | 4 +-- foreign/python/README.md | 4 +-- foreign/python/{iggy_py.pyi => apache_iggy.pyi} | 0 foreign/python/pyproject.toml | 2 +- foreign/python/python_examples/consumer.py | 2 +- foreign/python/python_examples/producer.py | 2 +- foreign/python/scripts/test.sh | 8 +++--- foreign/python/src/bin/stub_gen.rs | 4 +-- foreign/python/src/client.rs | 2 +- foreign/python/src/consumer.rs | 35 +++++++++++------------ foreign/python/src/identifier.rs | 10 +++---- foreign/python/src/lib.rs | 2 +- foreign/python/tests/conftest.py | 37 ++++++++++++------------- foreign/python/tests/test_iggy_sdk.py | 4 +-- 15 files changed, 63 insertions(+), 63 deletions(-) diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index cf830ad0..eaac67f5 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -56,8 +56,8 @@ atomic-waker: 1.1.2, "Apache-2.0 OR MIT", attohttpc: 0.28.5, "MPL-2.0", autocfg: 1.5.0, "Apache-2.0 OR MIT", aws-creds: 0.38.0, "MIT", -aws-lc-rs: 1.13.3, "ISC AND (Apache-2.0 OR ISC)", -aws-lc-sys: 0.30.0, "ISC AND (Apache-2.0 OR ISC) AND OpenSSL", +aws-lc-rs: 1.13.3, "(Apache-2.0 OR ISC) AND ISC", +aws-lc-sys: 0.30.0, "(Apache-2.0 OR ISC) AND ISC AND OpenSSL", aws-region: 0.26.0, "MIT", axum: 0.7.9, "MIT", axum: 0.8.4, "MIT", @@ -426,8 +426,8 @@ lru-slab: 0.1.2, "Apache-2.0 OR MIT OR Zlib", macro_rules_attribute: 0.1.3, "MIT", macro_rules_attribute-proc_macro: 0.1.3, "MIT", matchers: 0.1.0, "MIT", -matchit: 0.7.3, "MIT AND BSD-3-Clause", -matchit: 0.8.4, "MIT AND BSD-3-Clause", +matchit: 0.7.3, "BSD-3-Clause AND MIT", +matchit: 0.8.4, "BSD-3-Clause AND MIT", maybe-async: 0.2.10, "MIT", md-5: 0.10.6, "Apache-2.0 OR MIT", md5: 0.7.0, "Apache-2.0 OR MIT", @@ -759,7 +759,7 @@ ulid: 1.2.1, "MIT", uncased: 0.9.10, "Apache-2.0 OR MIT", unicase: 2.8.1, "Apache-2.0 OR MIT", unicode-bidi: 0.3.18, "Apache-2.0 OR MIT", -unicode-ident: 1.0.18, "(MIT OR Apache-2.0) AND Unicode-3.0", +unicode-ident: 1.0.18, "(Apache-2.0 OR MIT) AND Unicode-3.0", unicode-linebreak: 0.1.5, "Apache-2.0", unicode-normalization: 0.1.24, "Apache-2.0 OR MIT", unicode-properties: 0.1.3, "Apache-2.0 OR MIT", diff --git a/foreign/python/Cargo.toml b/foreign/python/Cargo.toml index 427cea89..9206337d 100644 --- a/foreign/python/Cargo.toml +++ b/foreign/python/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "iggy-py" +name = "apache-iggy" version = "0.5.0" edition = "2021" authors = ["Dario Lencina Talarico <darioalessandrolenc...@gmail.com>", "Albin Skott <al...@mattsson.io>"] @@ -19,7 +19,7 @@ pyo3-stub-gen = "0.11.1" tokio = "1.40.0" [lib] -name = "iggy_py" +name = "apache_iggy" crate-type = ["cdylib", "rlib"] [[bin]] diff --git a/foreign/python/README.md b/foreign/python/README.md index 5fea83b4..d5b5b81d 100644 --- a/foreign/python/README.md +++ b/foreign/python/README.md @@ -1,4 +1,4 @@ -# iggy_py +# apache-iggy [](https://discord.gg/C5Sux5NcRa) @@ -9,7 +9,7 @@ Apache Iggy is the persistent message streaming platform written in Rust, suppor ### Basic Installation ```bash -pip install iggy-py +pip install apache-iggy ``` ### Development Installation diff --git a/foreign/python/iggy_py.pyi b/foreign/python/apache_iggy.pyi similarity index 100% rename from foreign/python/iggy_py.pyi rename to foreign/python/apache_iggy.pyi diff --git a/foreign/python/pyproject.toml b/foreign/python/pyproject.toml index 213bf3ce..02730e13 100644 --- a/foreign/python/pyproject.toml +++ b/foreign/python/pyproject.toml @@ -3,7 +3,7 @@ requires = ["maturin>=1.2,<2.0"] build-backend = "maturin" [project] -name = "iggy_py" +name = "apache-iggy" requires-python = ">=3.7" version = "0.5.0" description = "Apache Iggy is the persistent message streaming platform written in Rust, supporting QUIC, TCP and HTTP transport protocols, capable of processing millions of messages per second." diff --git a/foreign/python/python_examples/consumer.py b/foreign/python/python_examples/consumer.py index b1a260f2..3e4af311 100644 --- a/foreign/python/python_examples/consumer.py +++ b/foreign/python/python_examples/consumer.py @@ -19,7 +19,7 @@ import asyncio from loguru import logger # Assuming there's a Python module for iggy with similar functionalities. -from iggy_py import IggyClient, ReceiveMessage, PollingStrategy +from apache_iggy import IggyClient, ReceiveMessage, PollingStrategy STREAM_NAME = "sample-stream" TOPIC_NAME = "sample-topic" diff --git a/foreign/python/python_examples/producer.py b/foreign/python/python_examples/producer.py index acbcbd0d..05b77b04 100644 --- a/foreign/python/python_examples/producer.py +++ b/foreign/python/python_examples/producer.py @@ -19,7 +19,7 @@ import asyncio from loguru import logger # Assuming we have a Python module for iggy with similar functionality as the Rust one. -from iggy_py import IggyClient, SendMessage as Message, StreamDetails, TopicDetails +from apache_iggy import IggyClient, SendMessage as Message, StreamDetails, TopicDetails STREAM_NAME = "sample-stream" TOPIC_NAME = "sample-topic" diff --git a/foreign/python/scripts/test.sh b/foreign/python/scripts/test.sh index d931bfac..85042473 100755 --- a/foreign/python/scripts/test.sh +++ b/foreign/python/scripts/test.sh @@ -45,7 +45,7 @@ echo "📍 Resolved ${IGGY_SERVER_HOST} to ${SERVER_IP}" python3 -c " import asyncio import sys -from iggy_py import IggyClient +from apache_iggy import IggyClient async def test_connection(): try: @@ -89,12 +89,12 @@ fi # Run examples if tests pass if [ $TEST_EXIT_CODE -eq 0 ] && [ "${RUN_EXAMPLES:-false}" = "true" ]; then echo "🚀 Running example scripts..." - + # Note: Examples might run indefinitely, so we'll just test they start correctly timeout 10 python3 examples/producer.py & PRODUCER_PID=$! sleep 5 - + if kill -0 $PRODUCER_PID 2>/dev/null; then echo "✅ Producer example started successfully" kill $PRODUCER_PID @@ -104,4 +104,4 @@ if [ $TEST_EXIT_CODE -eq 0 ] && [ "${RUN_EXAMPLES:-false}" = "true" ]; then fi echo "📊 Test results saved to test-results/" -exit $TEST_EXIT_CODE \ No newline at end of file +exit $TEST_EXIT_CODE diff --git a/foreign/python/src/bin/stub_gen.rs b/foreign/python/src/bin/stub_gen.rs index 64a31ba8..e9db7605 100644 --- a/foreign/python/src/bin/stub_gen.rs +++ b/foreign/python/src/bin/stub_gen.rs @@ -45,7 +45,7 @@ const LICENSE: &str = "# Licensed to the Apache Software Foundation (ASF) under fn main() -> Result<()> { // `stub_info` is a function defined by `define_stub_info_gatherer!` macro. - let stub = iggy_py::client::stub_info()?; + let stub = apache_iggy::client::stub_info()?; stub.generate()?; let path = Path::new(file!()) .parent() @@ -54,7 +54,7 @@ fn main() -> Result<()> { .unwrap() .parent() .unwrap() - .join("iggy_py.pyi"); + .join("apache_iggy.pyi"); let mut f = File::open(&path)?; let mut content = LICENSE.as_bytes().to_owned(); f.read_to_end(&mut content)?; diff --git a/foreign/python/src/client.rs b/foreign/python/src/client.rs index 0b444307..ca6735a5 100644 --- a/foreign/python/src/client.rs +++ b/foreign/python/src/client.rs @@ -316,7 +316,7 @@ impl IggyClient { init_retry_interval=None, allow_replay=false, ))] - fn consumer_group<'a>( + fn consumer_group( &self, name: &str, stream: &str, diff --git a/foreign/python/src/consumer.rs b/foreign/python/src/consumer.rs index 0844a549..15677bd2 100644 --- a/foreign/python/src/consumer.rs +++ b/foreign/python/src/consumer.rs @@ -53,36 +53,36 @@ pub struct IggyConsumer { #[pymethods] impl IggyConsumer { /// Get the last consumed offset or `None` if no offset has been consumed yet. - fn get_last_consumed_offset<'a>(&self, partition_id: u32) -> Option<u64> { + fn get_last_consumed_offset(&self, partition_id: u32) -> Option<u64> { self.inner .blocking_lock() .get_last_consumed_offset(partition_id) } /// Get the last stored offset or `None` if no offset has been stored yet. - fn get_last_stored_offset<'a>(&self, partition_id: u32) -> Option<u64> { + fn get_last_stored_offset(&self, partition_id: u32) -> Option<u64> { self.inner .blocking_lock() .get_last_stored_offset(partition_id) } /// Gets the name of the consumer group. - fn name<'a>(&self) -> String { + fn name(&self) -> String { self.inner.blocking_lock().name().to_string() } /// Gets the current partition id or `0` if no messages have been polled yet. - fn partition_id<'a>(&self) -> u32 { + fn partition_id(&self) -> u32 { self.inner.blocking_lock().partition_id() } /// Gets the name of the stream this consumer group is configured for. - fn stream<'a>(&self) -> PyIdentifier { + fn stream(&self) -> PyIdentifier { self.inner.blocking_lock().stream().into() } /// Gets the name of the topic this consumer group is configured for. - fn topic<'a>(&self) -> PyIdentifier { + fn topic(&self) -> PyIdentifier { self.inner.blocking_lock().topic().into() } @@ -141,7 +141,7 @@ impl IggyConsumer { let inner = self.inner.clone(); let callback: Py<PyMessageCallback> = callback.unbind(); let shutdown_event: Option<Py<PyAsyncioEvent>> = - shutdown_event.and_then(|e| Some(e.unbind())); + shutdown_event.map(|e| e.unbind()); future_into_py(py, async { let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel::<()>(); @@ -199,7 +199,7 @@ impl IggyConsumer { consume_result = handle_consume.await; } - let _ = consume_result + consume_result .unwrap() .map_err(|e| PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(format!("{e:?}")))?; Ok(()) @@ -330,9 +330,9 @@ pub enum AutoCommit { After(AutoCommitAfter), } -impl Into<RustAutoCommit> for &AutoCommit { - fn into(self) -> RustAutoCommit { - match self { +impl From<&AutoCommit> for RustAutoCommit { + fn from(val: &AutoCommit) -> RustAutoCommit { + match val { AutoCommit::Disabled() => RustAutoCommit::Disabled, AutoCommit::Interval(delta) => { let duration = py_delta_to_iggy_duration(delta); @@ -367,9 +367,9 @@ pub enum AutoCommitWhen { ConsumingEveryNthMessage(u32), } -impl Into<RustAutoCommitWhen> for &AutoCommitWhen { - fn into(self) -> RustAutoCommitWhen { - match self { +impl From<&AutoCommitWhen> for RustAutoCommitWhen { + fn from(val: &AutoCommitWhen) -> RustAutoCommitWhen { + match val { AutoCommitWhen::PollingMessages() => RustAutoCommitWhen::PollingMessages, AutoCommitWhen::ConsumingAllMessages() => RustAutoCommitWhen::ConsumingAllMessages, AutoCommitWhen::ConsumingEachMessage() => RustAutoCommitWhen::ConsumingEachMessage, @@ -384,6 +384,7 @@ impl Into<RustAutoCommitWhen> for &AutoCommitWhen { #[derive(Debug, PartialEq, Copy, Clone)] #[gen_stub_pyclass_complex_enum] #[pyclass] +#[allow(clippy::enum_variant_names)] pub enum AutoCommitAfter { /// The offset is stored on the server after all the messages are consumed. ConsumingAllMessages(), @@ -393,9 +394,9 @@ pub enum AutoCommitAfter { ConsumingEveryNthMessage(u32), } -impl Into<RustAutoCommitAfter> for &AutoCommitAfter { - fn into(self) -> RustAutoCommitAfter { - match self { +impl From<&AutoCommitAfter> for RustAutoCommitAfter { + fn from(val: &AutoCommitAfter) -> RustAutoCommitAfter { + match val { AutoCommitAfter::ConsumingAllMessages() => RustAutoCommitAfter::ConsumingAllMessages, AutoCommitAfter::ConsumingEachMessage() => RustAutoCommitAfter::ConsumingEachMessage, AutoCommitAfter::ConsumingEveryNthMessage(n) => { diff --git a/foreign/python/src/identifier.rs b/foreign/python/src/identifier.rs index f1a6e854..402fe89b 100644 --- a/foreign/python/src/identifier.rs +++ b/foreign/python/src/identifier.rs @@ -40,11 +40,11 @@ impl From<PyIdentifier> for Identifier { } } -impl Into<PyIdentifier> for &Identifier { - fn into(self) -> PyIdentifier { - match self.kind { - IdKind::String => PyIdentifier::String(self.get_string_value().unwrap()), - IdKind::Numeric => PyIdentifier::Int(self.get_u32_value().unwrap()), +impl From<&Identifier> for PyIdentifier { + fn from(val: &Identifier) -> PyIdentifier { + match val.kind { + IdKind::String => PyIdentifier::String(val.get_string_value().unwrap()), + IdKind::Numeric => PyIdentifier::Int(val.get_u32_value().unwrap()), } } } diff --git a/foreign/python/src/lib.rs b/foreign/python/src/lib.rs index 804d012e..efc12cab 100644 --- a/foreign/python/src/lib.rs +++ b/foreign/python/src/lib.rs @@ -34,7 +34,7 @@ use topic::TopicDetails; /// A Python module implemented in Rust. #[pymodule] -fn iggy_py(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { +fn apache_iggy(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::<SendMessage>()?; m.add_class::<ReceiveMessage>()?; m.add_class::<IggyClient>()?; diff --git a/foreign/python/tests/conftest.py b/foreign/python/tests/conftest.py index f28a09fa..21e904e8 100644 --- a/foreign/python/tests/conftest.py +++ b/foreign/python/tests/conftest.py @@ -26,23 +26,22 @@ import asyncio import os import socket import time -from typing import Generator, Optional import pytest -from iggy_py import IggyClient +from apache_iggy import IggyClient def get_server_config() -> tuple[str, int]: """ Get server configuration from environment variables or defaults. - + Returns: tuple: (host, port) for the Iggy server """ host = os.environ.get("IGGY_SERVER_HOST", "127.0.0.1") port = int(os.environ.get("IGGY_SERVER_TCP_PORT", "8090")) - + # Convert hostname to IP address for the Rust client if host not in ("127.0.0.1", "localhost"): try: @@ -54,25 +53,25 @@ def get_server_config() -> tuple[str, int]: pass elif host == "localhost": host = "127.0.0.1" - + return host, port def wait_for_server(host: str, port: int, timeout: int = 60, interval: int = 2) -> None: """ Wait for the server to become available. - + Args: host: Server hostname or IP port: Server port timeout: Maximum time to wait in seconds interval: Time between connection attempts in seconds - + Raises: TimeoutError: If server doesn't become available within timeout """ start_time = time.time() - + while True: try: with socket.create_connection((host, port), timeout=interval): @@ -89,17 +88,17 @@ def wait_for_server(host: str, port: int, timeout: int = 60, interval: int = 2) async def wait_for_ping(client: IggyClient, timeout: int = 30, interval: int = 2) -> None: """ Wait for the server to respond to ping requests. - + Args: client: Iggy client instance timeout: Maximum time to wait in seconds interval: Time between ping attempts in seconds - + Raises: TimeoutError: If server doesn't respond to ping within timeout """ start_time = time.time() - + while True: try: await client.ping() @@ -117,32 +116,32 @@ async def wait_for_ping(client: IggyClient, timeout: int = 30, interval: int = 2 async def iggy_client() -> IggyClient: """ Create and configure an Iggy client for testing. - + This fixture: 1. Gets server configuration from environment 2. Waits for server to be available 3. Creates and connects the client 4. Authenticates with default credentials 5. Verifies connectivity with ping - + Returns: IggyClient: Authenticated client ready for testing """ host, port = get_server_config() - + # Wait for server to be ready wait_for_server(host, port) - + # Create and connect client client = IggyClient(f"{host}:{port}") await client.connect() - + # Wait for server to be fully ready await wait_for_ping(client) - + # Authenticate await client.login_user("iggy", "iggy") - + return client @@ -158,7 +157,7 @@ def configure_asyncio(): def pytest_configure(config): """Configure pytest with custom markers.""" config.addinivalue_line( - "markers", + "markers", "integration: marks tests as integration tests (may be slow)" ) config.addinivalue_line( diff --git a/foreign/python/tests/test_iggy_sdk.py b/foreign/python/tests/test_iggy_sdk.py index 25f6ad57..39f1a425 100644 --- a/foreign/python/tests/test_iggy_sdk.py +++ b/foreign/python/tests/test_iggy_sdk.py @@ -28,8 +28,8 @@ import uuid import pytest -from iggy_py import IggyClient, PollingStrategy, AutoCommit -from iggy_py import SendMessage as Message +from apache_iggy import IggyClient, PollingStrategy, AutoCommit +from apache_iggy import SendMessage as Message class TestConnectivity: