Skip to content

feat: Add backend availability API for runtime backend detection#16

Merged
shaia merged 5 commits intomasterfrom
feature/backend-availability-api
Jan 1, 2026
Merged

feat: Add backend availability API for runtime backend detection#16
shaia merged 5 commits intomasterfrom
feature/backend-availability-api

Conversation

@shaia
Copy link
Copy Markdown
Owner

@shaia shaia commented Jan 1, 2026

Implements Phase 5 of the v0.1.6 migration plan:

  • Add BACKEND_SCALAR, BACKEND_SIMD, BACKEND_OMP, BACKEND_CUDA constants
  • Add backend_is_available() to check if a backend is available
  • Add backend_get_name() to get backend name string
  • Add list_solvers_by_backend() to get solvers for a specific backend
  • Add get_available_backends() to list all available backends
  • Update init.py with new exports and fix version to v0.1.6+
  • Add comprehensive test suite for backend availability API

Implements Phase 5 of the v0.1.6 migration plan:
- Add BACKEND_SCALAR, BACKEND_SIMD, BACKEND_OMP, BACKEND_CUDA constants
- Add backend_is_available() to check if a backend is available
- Add backend_get_name() to get backend name string
- Add list_solvers_by_backend() to get solvers for a specific backend
- Add get_available_backends() to list all available backends
- Update __init__.py with new exports and fix version to v0.1.6+
- Add comprehensive test suite for backend availability API
@shaia shaia requested a review from Copilot January 1, 2026 08:08
@shaia shaia self-assigned this Jan 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements Phase 5 of the v0.1.6 migration plan, adding a comprehensive backend availability API for runtime backend detection. This enables Python code to query which solver backends (scalar, SIMD, OpenMP, CUDA) are available at runtime, supporting the CFD library's new modular backend architecture in v0.1.6.

Key changes:

  • Added four backend type constants (BACKEND_SCALAR, BACKEND_SIMD, BACKEND_OMP, BACKEND_CUDA) mapped to the C library's ns_solver_backend_t enum
  • Implemented four new API functions: backend_is_available(), backend_get_name(), list_solvers_by_backend(), and get_available_backends()
  • Added comprehensive test suite with 17 tests covering constants, availability checking, name queries, and solver listing

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/test_backend_availability.py New comprehensive test suite with 17 tests validating backend constants, availability checks, name queries, and function exports
src/cfd_python.c Adds four Python wrapper functions (backend_is_available_py, backend_get_name_py, list_solvers_by_backend_py, get_available_backends_py) with proper error handling and memory management, plus module initialization for backend constants
cfd_python/init.py Updates module docstring to v0.1.6+, adds backend availability section to documentation, and exports new constants and functions in all
MIGRATION_PLAN.md Marks Phase 5 as completed, updates timeline estimates, and documents the implemented features with completion date

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to +52
Functions:

Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Functions:" header on this line appears to be incomplete or misplaced. It's followed by an empty line and then the "Solver backend availability (v0.1.6):" section starts. This creates a confusing documentation structure.

Either remove this line entirely (since "Boundary condition functions:" on line 66 provides the actual function listing), or restructure the documentation to make it clear what falls under this "Functions:" heading.

Suggested change
Functions:

Copilot uses AI. Check for mistakes.
shaia added 4 commits January 1, 2026 10:17
PyList_SET_ITEM is a macro not available in the limited/stable API.
Replace with PyList_SetItem function which is available in abi3.
The backend availability functions and constants were added to the C
extension but not exported through _loader.py, which is required for
the module namespace population.
- BACKEND_OMP returns "openmp" not "omp"
- Invalid backend returns "unknown" not None
Move BC functions under the Boundary conditions section and remove
the duplicate/empty Functions header.
@shaia shaia merged commit 8c33254 into master Jan 1, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants