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
--auto-close-interval ODS_EXD_API_AUTO_CLOSE_INTERVAL 0 Interval in seconds for auto-close scheduler (0 disables)
--auto-close-idle ODS_EXD_API_AUTO_CLOSE_IDLE 900 Idle timeout in seconds before files are auto-closed
--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.5.0.tar.gz (73.3 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.5.0-py3-none-any.whl (45.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ods_exd_api_box-1.5.0.tar.gz
  • Upload date:
  • Size: 73.3 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.5.0.tar.gz
Algorithm Hash digest
SHA256 9cf0f9d063d80b3b802986d516ec9a37d727b4099c130124d300e685b3776eee
MD5 4a2ebab8c922e43509103358f52a55d1
BLAKE2b-256 4069ac763d6f2e7076edd328806978fb620a19c3222ab8c67a2357fa28abb100

See more details on using hashes here.

Provenance

The following attestation bundles were made for ods_exd_api_box-1.5.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.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ods_exd_api_box-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 67c88fd6335db4c4a164410ecc1dcc803a923216266ab3e32da041b84e29b04f
MD5 a3f11c481eda26a42d813dcd0245e8c9
BLAKE2b-256 6055ea1d414b0c76225b835f50678a867e75b8d52104cbc6ad5f80ab2f941da8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ods_exd_api_box-1.5.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