Skip to main content

gRPC interface to lara_django_data

Project description

LARA Django Data - gRPC API

This directory contains the gRPC interface for the lara-django-data application, providing a high-performance API for managing data, experiments, evaluations, and machine learning workflows in the LARA database.

Overview

The gRPC API provides remote procedure call access to the LARA Django Data 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-data-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_data_grpc/
        ├── lara_django_data_data_model.py   # Data model definitions
        ├── lara_django_data_interfaces.py   # High-level interface
        └── v1/
            └── *_pb2.py         # Generated protocol buffer code

## Installation

### Using uv (Recommended)

Install the `lara-django-data-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-data-grpc

Or from the local directory:

cd api/grpc
pip install .

Dependencies

  • Runtime: grpcio>=1.73.0
  • Development:
    • grpcio-tools>=1.73.0
    • pytest>=8,<9
    • pytest-cov>=6,<7
    • pytest-asyncio

Code Generation

Protocol buffer definitions are located in ../proto/lara_django_data_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/ and includes tests for all major entities:

Using uv

# From the api/grpc directory
uv run pytest api/tests/

# With coverage
uv run pytest api/tests/ --cov

Using pytest directly

# From the api/grpc directory
pytest api/tests/

# With coverage
pytest api/tests/ --cov

Test Files

  • test_lara_django_data_Evaluation_grpc.py - Evaluation tests

Usage Examples

Python Client

import grpc
from lara_django_data_grpc import data_pb2, data_pb2_grpc

# Create a channel to the gRPC server
channel = grpc.insecure_channel('localhost:50051')

# Create a stub (client)
stub = data_pb2_grpc.DataServiceStub(channel)

# Make a request
response = stub.GetData(data_pb2.GetDataRequest(id=1))
print(response)

# 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

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:

  1. Edit .proto files in ../proto/lara_django_data_grpc/
  2. Run buf generate to regenerate code
  3. Update tests as needed
  4. Run the test suite to ensure compatibility

License

See the LICENSE file in the project root.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lara_django_data_grpc-0.2.94.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lara_django_data_grpc-0.2.94-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file lara_django_data_grpc-0.2.94.tar.gz.

File metadata

  • Download URL: lara_django_data_grpc-0.2.94.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for lara_django_data_grpc-0.2.94.tar.gz
Algorithm Hash digest
SHA256 85dea593be624b366e09f140995a7498bc01601272bc0eaac0b0c100501a667d
MD5 ea3ead313bd11a2f789fe0d39b8c1ec2
BLAKE2b-256 0253ef1be1aa87d36298bb36450572a93ec29572f5ddd0dd26a8134d90a728d1

See more details on using hashes here.

File details

Details for the file lara_django_data_grpc-0.2.94-py3-none-any.whl.

File metadata

File hashes

Hashes for lara_django_data_grpc-0.2.94-py3-none-any.whl
Algorithm Hash digest
SHA256 5c45ae3a8ece3d14c72ab76b45d66a96ba38d2175668e2b123f711bfe5d423b3
MD5 66f8b8c9a664833c3f04dcb675cfbb53
BLAKE2b-256 b89ec460dd246d7e8ac6e2ba3549b6d4305a454580485a5e381f093e5a078cb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page