Skip to main content

Helper package to build ASAM ODS EXD API grpc plugins.

Project description

ASAM ODS EXD-API for NI TDMS Files

Python 3.12+ License: MIT Code style: black Type checking: mypy

ASAM ODS EXD-API Architecture

sequenceDiagram

actor CLIENT as Client
participant PDTT as 🛠️Importer
participant PODS as 🗃️ASAM ODS server
participant PLUGIN as 📊EXD-API plugin
participant FILE as 🗂️File Storage

autonumber

opt Import phase
  FILE ->>+ PDTT: New file shows up
  PDTT ->>+ PLUGIN : Get Structure
  PLUGIN -> FILE: Extract content information
  PLUGIN ->> PLUGIN: Create Structure
  PLUGIN ->>- PDTT: Return Structure
  PDTT ->> PODS: Import ODS structure
  Note right of PDTT: Create hierarchy<br/>AoTest,AoMeasurement,...
  PDTT ->>- PODS: Add External Data info
  Note right of PDTT: Attach AoFile ... for external data<br/>AoFile,AoSubmatrix,AoLocalColumn,...
end

Note over CLIENT, FILE: Now we can work with the imported files

loop Runtime phase
  CLIENT ->> PODS: Establish ODS session
  CLIENT ->> PODS: Work with meta data imported from structure
  CLIENT ->> PODS: Access external channel in preview
  PODS ->> PLUGIN: GetValues
  PLUGIN ->> FILE: Get Channel values
  PLUGIN ->> PODS: Return values of channels
  PODS ->> CLIENT: Return values needed for plot
end

Configuration & Usage

Server Options

python external_data_file.py --help

Key configuration options:

Option Env Variable Default Description
--port ODS_EXD_API_PORT 50051 Port to run gRPC server on
--verbose ODS_EXD_API_VERBOSE False Enable debug logging
--bind-address ODS_EXD_API_BIND_ADDRESS [::] Address to bind gRPC server to
--max-workers ODS_EXD_API_MAX_WORKERS 2 × CPU count Maximum number of worker threads
--max-concurrent-streams ODS_EXD_API_MAX_CONCURRENT_STREAMS None Maximum concurrent gRPC streams
--max-send-message-length ODS_EXD_API_MAX_SEND_MESSAGE_LENGTH 512 Max send message length (MB)
--max-receive-message-length ODS_EXD_API_MAX_RECEIVE_MESSAGE_LENGTH 32 Max receive message length (MB)
--use-tls ODS_EXD_API_USE_TLS False Enable TLS/SSL
--tls-cert-file ODS_EXD_API_TLS_CERT_FILE None Path to server certificate (PEM)
--tls-key-file ODS_EXD_API_TLS_KEY_FILE None Path to server private key (PEM)
--tls-client-ca-file ODS_EXD_API_TLS_CLIENT_CA_FILE None CA bundle for client verification
--require-client-cert ODS_EXD_API_REQUIRE_CLIENT_CERT False Require valid client certificate
--health-check-enabled ODS_EXD_API_HEALTH_CHECK_ENABLED False Enable health check service
--health-check-bind-address ODS_EXD_API_HEALTH_CHECK_BIND_ADDRESS [::] Health check service bind address
--health-check-port ODS_EXD_API_HEALTH_CHECK_PORT 50052 Health check service port
--env-prefix - ODS_EXD_API_ Environment variable prefix for multi-instance deployments

Configuration Priority

Values are resolved in this order (highest to lowest priority):

  1. Command line arguments
  2. Environment variables
  3. Default values

TLS Configuration

Basic TLS:

python external_data_file.py \
  --use-tls \
  --tls-cert-file /path/to/server.crt \
  --tls-key-file /path/to/server.key

Mutual TLS (mTLS):

python external_data_file.py \
  --use-tls \
  --tls-cert-file /path/to/server.crt \
  --tls-key-file /path/to/server.key \
  --tls-client-ca-file /path/to/client-ca.crt \
  --require-client-cert

Docker with TLS:

docker run \
  -v /path/to/certs:/certs \
  -p 50051:50051 \
  ghcr.io/totonga/asam-ods-exd-api-nptdms:latest \
  --use-tls \
  --tls-cert-file /certs/server.crt \
  --tls-key-file /certs/server.key

Development

Setup Development Environment

# Install with development dependencies
pip install -e ".[dev]"

Type Checking

mypy .

Running Tests

python -m unittest discover -s tests

Running Docker Integration Tests

python -m unittest tests.test_docker_integration -v

Code Style

The project uses:

  • Black for code formatting
  • isort for import sorting
  • Pylint for linting
  • Mypy for static type checking

Updating Protocol Buffers

The protobuf files are generated from the ASAM ODS standard specifications:

# Download latest proto files
curl -o ods.proto https://raw.githubusercontent.com/asam-ev/ASAM-ODS-Interfaces/main/ods.proto
curl -o ods_external_data.proto https://raw.githubusercontent.com/asam-ev/ASAM-ODS-Interfaces/main/ods_external_data.proto

# Generate Python stubs
mkdir -p ods_exd_api_box/proto
python3 -m grpc_tools.protoc \
  -I. \
  --python_out=ods_exd_api_box/proto/. \
  --pyi_out=ods_exd_api_box/proto/. \
  --grpc_python_out=ods_exd_api_box/proto/. \
  ods.proto ods_external_data.proto

Performance Considerations

  • File Caching - Opened files are cached to minimize I/O operations
  • Reference Counting - Automatic resource cleanup with reference counting
  • Thread Pool - Configurable worker threads for parallel request handling
  • Message Size Limits - Configurable max send/receive message sizes

Troubleshooting

Connection Refused

Ensure the server is running and listening on the correct port:

netstat -tlnp | grep 50051

TLS Certificate Errors

Verify certificate paths and permissions:

openssl x509 -in /path/to/cert.crt -text -noout

Type Checking Failures

Ensure all dependencies are installed with type stubs:

pip install -e ".[dev]"
mypy .

Contributing

Contributions are welcome! Please:

  1. Use dev container or set up local dev environment
  2. Ensure type checking passes: `mypy .
  3. Run tests: python -m unittest discover -s tests
  4. Follow code style (Black, isort)
  5. Add tests for new features

License

MIT License - see LICENSE file for details.

References

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

ods_exd_api_box-1.4.0.tar.gz (69.2 kB view details)

Uploaded Source

Built Distribution

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

ods_exd_api_box-1.4.0-py3-none-any.whl (43.9 kB view details)

Uploaded Python 3

File details

Details for the file ods_exd_api_box-1.4.0.tar.gz.

File metadata

  • Download URL: ods_exd_api_box-1.4.0.tar.gz
  • Upload date:
  • Size: 69.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ods_exd_api_box-1.4.0.tar.gz
Algorithm Hash digest
SHA256 1278bdece449fcf738e0ea1ad5770875e6dd0c138e5aceb68cc9f817a2507b1f
MD5 379e297640bb62b44f8ba264e722ed2b
BLAKE2b-256 68e4fb6ae1e5edbd180d9abaef186e06f6d02760614592431292c61e6366b46b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ods_exd_api_box-1.4.0.tar.gz:

Publisher: build.yml on totonga/ods-exd-api-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ods_exd_api_box-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ods_exd_api_box-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e10ebfdf79a886946fd2409143cdb4a82a0c56d1b35c2a945dd0a41f2a93c4ff
MD5 7d9ad4b5cbef45c8d0c779b60c7ba6d7
BLAKE2b-256 9177c7a84acebb675f3031afdcbefb2a22173fd9bca1ea1926ede7105862c483

See more details on using hashes here.

Provenance

The following attestation bundles were made for ods_exd_api_box-1.4.0-py3-none-any.whl:

Publisher: build.yml on totonga/ods-exd-api-box

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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