Fix Mappy Python Bindings Compilation Issues #14

Open
opened 2026-05-01 17:48:34 +02:00 by kade · 0 comments
Owner

Mappy Python Bindings Compilation Fix

Current Status

  • mappy-python fails to compile due to Rust ownership issues
  • forgejo-client search falls back to memory-only caching
  • Ansible deployment configurations ready
  • PostgreSQL integration functional
  • All forgejo-client tests pass (32/32)

Issues Identified

  1. Rust Ownership Errors: 70+ compilation errors in mappy-python/src/lib.rs
  2. Arc Move Issues: Methods consuming Arc require proper cloning
  3. Type Mismatches: String references vs owned strings
  4. Method Call Issues: Methods require Arc-wrapped receivers

Root Cause

The mappy-core API methods take Arc<Self> by value (consuming), but the Python bindings try to call them on shared references, causing ownership violations.

Required Fixes

1. Fix Arc Ownership Issues

// Before (fails)
maplet.insert(key, value).await

// After (works)
Arc::clone(maplet).insert(key, value).await

2. Fix String Type Issues

// Before (fails)
maplet.query(&key).await

// After (works)
Arc::clone(maplet).query(key.clone()).await

3. Fix Engine Method Calls

// Before (fails)
self.inner.get(key).await

// After (works)
Arc::clone(&self.inner).get(key).await

Specific Methods to Fix

Maplet Methods

  • insert() - Arc cloning required
  • query() - Arc cloning + string ownership
  • delete() - Arc cloning + value ownership
  • contains() - Arc cloning
  • len() - Arc cloning
  • is_empty() - Arc cloning
  • load_factor() - Arc cloning
  • find_slot_for_key() - Arc cloning

Engine Methods

  • get() - Arc cloning
  • exists() - Arc cloning
  • set() - Arc cloning
  • delete() - Arc cloning
  • expire() - Arc cloning
  • ttl() - Arc cloning
  • persist() - Arc cloning
  • stats() - Arc cloning
  • memory_usage() - Arc cloning
  • flush() - Arc cloning
  • close() - Arc cloning
  • find_slot_for_key() - Arc cloning

Impact

  • High Priority: Blocks forgejo-client search caching functionality
  • Scope: Only affects Python bindings, core mappy functionality works
  • Workaround: Memory-only caching currently functional

Files to Fix

  • services/mappy/mappy-python/src/lib.rs - Main Python bindings

Test Plan

  1. Apply systematic Arc cloning fixes
  2. Test compilation: cargo build --package mappy-python
  3. Verify Python import: from mappy_core import MappyCache
  4. Test forgejo-client with mappy caching enabled
  5. Deploy mappy service via ansible playbooks

Next Steps

  1. Fix Compilation: Apply ownership fixes systematically
  2. Test Integration: Verify forgejo-client search works
  3. Deploy Services: Use ansible playbooks for deployment
  4. Full Stack Test: End-to-end caching verification

Current Workaround

Forgejo-client search works with memory-only caching:

# Falls back gracefully when mappy-core not available
cache = ResultCache()  # Uses memory cache only
stats = cache.get_stats()
# {'mappy_available': False, 'postgres_available': False, ...}

Labels

bug, high-priority, mappy, python-bindings, rust-ownership

# Mappy Python Bindings Compilation Fix ## Current Status - ❌ **mappy-python** fails to compile due to Rust ownership issues - ❌ **forgejo-client search** falls back to memory-only caching - ✅ **Ansible deployment** configurations ready - ✅ **PostgreSQL integration** functional - ✅ **All forgejo-client tests pass** (32/32) ## Issues Identified 1. **Rust Ownership Errors**: 70+ compilation errors in mappy-python/src/lib.rs 2. **Arc Move Issues**: Methods consuming Arc<Self> require proper cloning 3. **Type Mismatches**: String references vs owned strings 4. **Method Call Issues**: Methods require Arc-wrapped receivers ## Root Cause The mappy-core API methods take `Arc<Self>` by value (consuming), but the Python bindings try to call them on shared references, causing ownership violations. ## Required Fixes ### 1. Fix Arc Ownership Issues ```rust // Before (fails) maplet.insert(key, value).await // After (works) Arc::clone(maplet).insert(key, value).await ``` ### 2. Fix String Type Issues ```rust // Before (fails) maplet.query(&key).await // After (works) Arc::clone(maplet).query(key.clone()).await ``` ### 3. Fix Engine Method Calls ```rust // Before (fails) self.inner.get(key).await // After (works) Arc::clone(&self.inner).get(key).await ``` ## Specific Methods to Fix ### Maplet Methods - `insert()` - Arc cloning required - `query()` - Arc cloning + string ownership - `delete()` - Arc cloning + value ownership - `contains()` - Arc cloning - `len()` - Arc cloning - `is_empty()` - Arc cloning - `load_factor()` - Arc cloning - `find_slot_for_key()` - Arc cloning ### Engine Methods - `get()` - Arc cloning - `exists()` - Arc cloning - `set()` - Arc cloning - `delete()` - Arc cloning - `expire()` - Arc cloning - `ttl()` - Arc cloning - `persist()` - Arc cloning - `stats()` - Arc cloning - `memory_usage()` - Arc cloning - `flush()` - Arc cloning - `close()` - Arc cloning - `find_slot_for_key()` - Arc cloning ## Impact - **High Priority**: Blocks forgejo-client search caching functionality - **Scope**: Only affects Python bindings, core mappy functionality works - **Workaround**: Memory-only caching currently functional ## Files to Fix - `services/mappy/mappy-python/src/lib.rs` - Main Python bindings ## Test Plan 1. Apply systematic Arc cloning fixes 2. Test compilation: `cargo build --package mappy-python` 3. Verify Python import: `from mappy_core import MappyCache` 4. Test forgejo-client with mappy caching enabled 5. Deploy mappy service via ansible playbooks ## Next Steps 1. **Fix Compilation**: Apply ownership fixes systematically 2. **Test Integration**: Verify forgejo-client search works 3. **Deploy Services**: Use ansible playbooks for deployment 4. **Full Stack Test**: End-to-end caching verification ## Current Workaround Forgejo-client search works with memory-only caching: ```python # Falls back gracefully when mappy-core not available cache = ResultCache() # Uses memory cache only stats = cache.get_stats() # {'mappy_available': False, 'postgres_available': False, ...} ``` ## Labels bug, high-priority, mappy, python-bindings, rust-ownership
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kade/forgejo-client#14
No description provided.