Skip to content

Conversation

@thorwhalen
Copy link
Member

No description provided.

This commit implements the core functionality of uf (UI Fast), a minimal-
boilerplate system for creating web UIs from Python functions.

Key additions:
- uf/base.py: Core mk_rjsf_app() function and UfApp class
- uf/specs.py: FunctionSpecStore for managing function specifications
- uf/templates.py: HTML template generation with React + RJSF
- uf/routes.py: API routes for function listing and spec retrieval
- uf/__init__.py: Main package exports
- pyproject.toml: Added dependencies (qh, ju, i2, dol, meshed)
- README.md: Comprehensive documentation and usage examples
- examples/: Basic and advanced usage examples

Features:
- One-line app creation from functions
- Automatic RJSF form generation from function signatures
- Type-aware form fields based on type hints
- Framework-agnostic (Bottle/FastAPI)
- Zero configuration required with sensible defaults
- Progressive enhancement for customization

The implementation follows the development plan's Phase 1, providing a
complete MVP that bridges functions → HTTP services (qh) → Web UI (ju.rjsf).
This commit completes the full development plan, implementing Milestones
2, 3, and 4 with comprehensive features for production-ready use.

**Milestone 2: Configuration (COMPLETED)**

New modules:
- uf/rjsf_config.py: RJSF customization layer
  * RjsfFieldConfig: Dataclass for field configuration
  * RjsfConfigBuilder: Fluent interface for building configs
  * Predefined field configs (email, textarea, date, etc.)
  * ConditionalFieldConfig for conditional display

- uf/trans.py: Input transformation registry
  * InputTransformRegistry: Custom type transformations
  * Global registry with common types pre-registered
  * Support for datetime, date, Path, UUID, Decimal
  * Integration with qh's input/output transformation

**Milestone 3: Enhancement (COMPLETED)**

New modules:
- uf/organization.py: Function grouping and organization
  * FunctionGroup: Dataclass for organizing functions
  * FunctionOrganizer: Build and manage groups
  * mk_grouped_app: Create apps with grouped navigation
  * Auto-grouping utilities (by prefix, module, tag)

- uf/decorators.py: UI metadata decorators
  * @ui_config: Complete UI configuration
  * @group: Simple grouping decorator
  * @hidden: Hide functions from UI
  * @field_config: Configure specific fields
  * @with_example: Attach example data
  * @deprecated, @requires_auth, @rate_limit: Additional metadata
  * Helper functions: get_ui_config, get_group, etc.

**Milestone 4: Advanced (COMPLETED)**

New modules:
- uf/field_interactions.py: Field dependencies
  * FieldDependency: Define field relationships
  * DependencyAction: Enum for dependency actions
  * DependencyBuilder: Fluent interface for dependencies
  * @with_dependencies: Decorator for field dependencies
  * Support for conditional show/hide/enable/disable

- uf/testing.py: Testing utilities
  * UfTestClient: Test client for uf apps
  * UfAppTester: Context manager for testing
  * test_ui_function: Test individual functions
  * FormDataBuilder: Build test form data
  * Schema assertion helpers

**Tests:**
- tests/test_specs.py: FunctionSpecStore tests
- tests/test_decorators.py: Decorator tests
- tests/test_testing.py: Testing utilities tests

**Examples:**
- examples/full_featured_example.py: Comprehensive showcase
  * Demonstrates all decorators and features
  * Function grouping with icons and ordering
  * Field configurations and dependencies
  * Custom CSS styling
  * Complete enterprise admin panel example

**Documentation:**
- Updated README.md with complete feature documentation
  * Table of contents for easy navigation
  * Detailed sections for all features
  * Code examples for every feature
  * API reference for all classes and functions
  * Development roadmap showing all milestones complete

- Updated uf/__init__.py with all new exports
  * Organized imports by category
  * Complete __all__ list for public API
  * Docstring updates

**Key Features Delivered:**

✓ UI decorators for rich metadata (@ui_config, @group, etc.)
✓ Field configuration system (predefined and custom)
✓ Function grouping and organization
✓ Custom type transformations
✓ Field dependencies and conditional display
✓ Comprehensive testing utilities
✓ Production-ready examples
✓ Complete documentation

All milestones from the development plan are now complete, providing
a full-featured, production-ready package for creating web UIs from
Python functions with minimal boilerplate.
This commit adds four major enhancement modules that dramatically expand
uf's capabilities for production use:

**1. Result Rendering System (uf/renderers.py)**
- Smart rendering of function results based on type
- ResultRenderer base class for custom renderers
- Built-in renderers:
  * JsonRenderer: Format JSON output
  * TableRenderer: Render list[dict] as tables
  * DataFrameRenderer: pandas DataFrame support
  * ChartRenderer: Auto-detect chart data
  * ImageRenderer: Display images (PNG, JPEG, GIF)
  * MarkdownRenderer: Render markdown strings
  * HtmlRenderer: Display HTML (with sanitization)
- ResultRendererRegistry for managing renderers
- @result_renderer decorator to specify renderer type
- Global registry for convenience

**2. Async Function Support (uf/async_support.py)**
- Seamless async/await support
- is_async_function(): Detect async functions
- async_to_sync(): Convert async to sync wrapper
- make_sync_compatible(): Batch convert functions
- AsyncFunctionWrapper: Dual sync/async interface
- batch_async_calls(): Concurrent execution
- @timeout_async decorator: Add timeouts
- @retry_async decorator: Retry logic
- AsyncContext: Proper event loop management
- Framework detection (FastAPI vs Bottle)

**3. Pydantic Integration (uf/pydantic_support.py)**
- Full Pydantic v1 and v2 compatibility
- is_pydantic_model(): Type detection
- pydantic_model_to_json_schema(): Schema conversion
- function_uses_pydantic(): Signature analysis
- create_pydantic_spec(): Auto-generate RJSF from Pydantic
- wrap_pydantic_function(): Automatic dict ↔ model conversion
- pydantic_to_dict() and dict_to_pydantic(): Converters
- extract_field_validators(): Pull validators from models
- pydantic_error_to_user_friendly(): Format validation errors
- PydanticRegistry: Global model registry

**4. Call History & Presets (uf/history.py)**
- Track all function calls for reuse
- FunctionCall: Record of single call with result/timestamp
- CallHistory: Manage call history per function
  * Configurable max size per function
  * get_recent(): Retrieve recent calls
  * get_successful_calls(): Filter successes
  * Persistence via to_dict()/from_dict()
- Preset: Named parameter sets
- PresetManager: Save and load parameter presets
  * save(): Create named presets
  * get(): Retrieve preset by name
  * list_presets(): All presets for function
- HistoryManager: Unified interface
  * Combines history + presets
  * save_to_file() / load_from_file()
  * Global instance for convenience
- @enable_history decorator: Auto-track calls

**Updated Exports:**
- uf/__init__.py: Added 38 new exports
- All new modules properly integrated
- Backward compatible with existing code

**Key Benefits:**
✓ Async functions now work seamlessly
✓ Pydantic users get automatic form generation
✓ Results display beautifully (tables, charts, etc.)
✓ Users can save and reuse parameter sets
✓ Call history for debugging and iteration

These enhancements make uf significantly more powerful while maintaining
the zero-config philosophy - all features work automatically but can be
customized when needed.
@thorwhalen thorwhalen merged commit dbb57c6 into master Nov 18, 2025
2 of 8 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.

3 participants