gRPC interface to lara_django_base
Project description
LARA Django Base - gRPC API
This directory contains the gRPC interface for the lara-django-base application, providing a high-performance API for managing base entities like addresses, locations, countries, cities, tags, and other core data types in the LARA database.
Overview
The gRPC API provides remote procedure call access to the LARA Django Base service with support for multiple programming languages through protocol buffer definitions. It also contains a high-level Python interface for easy integration with Python applications.
Package: lara-django-base-grpc
Python Requirement: 3.13.*
Project Structure
api/grpc/
├── go/ # Go gRPC client code
├── connect-es/ # Connect-ES client code
├── connectrpc-es/ # ConnectRPC ES implementations
├── grpc-web/ # gRPC-Web client code
├── gen/ # Generated code from protobuf definitions
├── dist/ # Distribution packages
├── pyproject.toml # Python project configuration
└── python/ # Python API module root
└── lara_django_base_grpc/
├── lara_django_base_data_model.py # Data model definitions
├── lara_django_base_interfaces.py # High-level interface
└── v1/
└── *_pb2.py # Generated protocol buffer code
## Installation
### Using uv (Recommended)
Install the `lara-django-base-grpc` package with uv for faster dependency resolution:
```bash
cd api/grpc
uv pip install .
Or with development dependencies:
uv pip install -e ".[dev]"
For development, install with editable mode and all dependency groups:
cd api/grpc
uv sync --all-groups
Using pip
Alternatively, install with pip:
pip install lara-django-base-grpc
Or from the local directory:
cd api/grpc
pip install .
Dependencies
- Runtime:
grpcio>=1.73.0 - Development:
grpcio-tools>=1.73.0pytest>=8,<9pytest-cov>=6,<7pytest-asyncio
Code Generation
Protocol buffer definitions are located in ../proto/lara_django_base_grpc/. To regenerate gRPC code from protobuf definitions, e.g. in case you changed the .proto file, use the Buf CLI:
cd api
buf generate
This will generate code for multiple targets as configured in buf.gen.yaml:
- Python
- Go
- JavaScript/TypeScript (Connect-ES, ConnectRPC, gRPC-Web)
Running Tests
The test suite is located in api/tests_latest/ and includes tests for all major entities:
Using uv
# From the api/grpc directory
uv run pytest ../tests_latest/
# With coverage
uv run pytest ../tests_latest/ --cov
Using pytest directly
# From the api/grpc directory
pytest ../tests_latest/
# With coverage
pytest ../tests_latest/ --cov
Test Files
test_lara_django_base_Address_grpc.py- Address teststest_lara_django_base_City_grpc.py- City teststest_lara_django_base_Country_grpc.py- Country teststest_lara_django_base_CountrySubdivision_grpc.py- Country subdivision teststest_lara_django_base_Currency_grpc.py- Currency teststest_lara_django_base_DataType_grpc.py- Data type teststest_lara_django_base_ExternalResource_grpc.py- External resource teststest_lara_django_base_ExtraData_grpc.py- Extra data teststest_lara_django_base_GeoLocation_grpc.py- Geo location teststest_lara_django_base_ItemStatus_grpc.py- Item status teststest_lara_django_base_LARASyncServer_grpc.py- LARA sync server teststest_lara_django_base_Location_grpc.py- Location teststest_lara_django_base_MediaType_grpc.py- Media type teststest_lara_django_base_Namespace_grpc.py- Namespace teststest_lara_django_base_PhysicalStateMatter_grpc.py- Physical state matter teststest_lara_django_base_PhysicalUnit_grpc.py- Physical unit teststest_lara_django_base_RoomCategory_grpc.py- Room category teststest_lara_django_base_ScientificConstant_grpc.py- Scientific constant teststest_lara_django_base_SubdivisionType_grpc.py- Subdivision type teststest_lara_django_base_Tag_grpc.py- Tag tests
Usage Examples
Python Client
import grpc
from lara_django_base_grpc.v1 import lara_django_base_pb2, lara_django_base_pb2_grpc
# Create a channel to the gRPC server
channel = grpc.insecure_channel('localhost:50051')
# Create a stub (client) - example with Country
stub = lara_django_base_pb2_grpc.CountryControllerStub(channel)
# Make a request to list countries
response = stub.List(lara_django_base_pb2.CountryListRequest())
for country in response.results:
print(f"{country.name} ({country.iso_code})")
# Don't forget to close the channel when done
channel.close()
For more comprehensive examples, see the demo clients in ../../demo_clients/.
Development
Building
The project uses the uv_build backend for building:
# Using uv (recommended)
uv build
# Or using Python build module
python -m build
Working with uv
This project is configured for uv with the following features:
- Build Backend:
uv_build>=0.9.0,<=0.10.0 - Module Root:
python/(all Python gRPC code should be placed here) - Dependency Groups: Development dependencies are organized in groups
Common uv commands:
# Sync dependencies
uv sync
# Sync with development dependencies
uv sync --all-groups
# Add a new dependency
uv add package-name
# Add a development dependency
uv add --dev package-name
# Run a command in the uv environment
uv run python script.py
# Build the package
uv build
Module Root
The Python module root is configured at python/, meaning all Python gRPC code should be placed in that directory.
Documentation
- Project Documentation: https://larasuite.gitlab.io/lara-django-base/
- Source Code: https://gitlab.com/larasuite/lara-django-base
- Issue Tracker: https://gitlab.com/larasuite/lara-django-base/-/issues
- Protocol Buffer Definitions: ../proto/lara_django_base_grpc/
Protocol Buffer Linting
The project uses Buf for linting and breaking change detection. Configuration is in ../buf.yaml:
- Follows DEFAULT lint rules with specific exceptions
- Breaking change detection enabled
- Ignores certain Google type definitions
Contributing
Contributions are welcome! Please see the CONTRIBUTING.md file in the project root for guidelines.
When modifying protobuf definitions:
- Edit
.protofiles in../proto/lara_django_base_grpc/ - Run
buf generateto regenerate code - Update tests as needed
- Run the test suite to ensure compatibility
License
See the LICENSE file in the project root.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lara_django_base_grpc-0.2.113.tar.gz.
File metadata
- Download URL: lara_django_base_grpc-0.2.113.tar.gz
- Upload date:
- Size: 72.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f37dade42cef2669059a9eaaedb4cec10fb749abdc6afcf46fbf2ab7d7ab87b
|
|
| MD5 |
7ca200475bf6d61cacd13d7b59f13605
|
|
| BLAKE2b-256 |
53c3887a7c8d399875f8319aa04f77422b8543e2b67d9fdf610f0397ffc8580e
|
File details
Details for the file lara_django_base_grpc-0.2.113-py3-none-any.whl.
File metadata
- Download URL: lara_django_base_grpc-0.2.113-py3-none-any.whl
- Upload date:
- Size: 75.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23559249ff7960b86967e0d490b00f0dd8cee81240a77fdcb48732d60ca25efe
|
|
| MD5 |
1987b7f3ec2c12b7fc9d71723b78cda5
|
|
| BLAKE2b-256 |
28716332fc552b2cfea46dea8925a1dfdd4e50bb231281391181fae9b38425b0
|