Skip to main content

Engrate SDK for plugin developers

Project description

Engrate SDK

A utility SDK providing common services for logging, configuration, and HTTP clients to connect the Engrate Platform.

Features

  • Simple and consistent logging interface
  • Flexible configuration management
  • HTTP client utilities for seamless API integration
  • TypeScript support

Installation

Add the dependency to your project configuration (i.e. UV):

"engrate-sdk ~= 0.0.16"

Then update your local environment

uv pip install .

Usage

from engrate_sdk import Logger, Config, HttpClient

# Logging
logger = Logger()
logger.info('Engrate SDK initialized')

# Configuration
config = Config()
config.load_from_env()

# HTTP Client
client = HttpClient(base_url=config.get('API_URL'))
response = client.get('/status')

Registry

The library contains a regystry.py module which provides access to our internal plugin registry. Every plugin has to call to the register_plugin() method at some point in the plugin bootstrap process (if using ```FastAPI``this is usually recommended to use a lifespan function).

@asynccontextmanager
async def lifespan(fast_app: FastAPI):
    """Startup and shutdown logic using lifespan events."""
    try:
        print("Validating environment variables...")
        env.validate()
        if env.should_register():
            logger.info("Registering plugin...")
            plugin = PluginRegistry(registrar_url=env.get_registrar_url())
            await plugin.register_plugin()
        yield
    finally:
        logger.info("Shutting down application...")

This method will look for a plugin_manifest.yamlfile at root level of the project (it's also possible to provide an url when initializing the PluginRegistryobject) This file must exist and contain the following format (WIP: this might change in the near future):

name: "power-tariffs"
author: "Energy development solutions"
description: "Test plugin to use Engrate SDK"
product_category: "market_intelligence"
extensions:
 markets:
   - "*"
   - "nl"
   - "de"
   - "se"
plugin_metadata:
 display_name: "Demo Plugin"
 service_name: "demo-plugin"
 url_prefix: "demo-plugin"
 fav_icon: ""
 image: ""
 port: "3111"
 api_version: "v1"
 flavors:
   - "external-api"
 traits:
   - "storage"

Mock registrar

For testing purposes, the library includes a mock registrarthat mimics the behaviour for the actual registrar in the core services. This is a simple FastApi server that will implement the required endpoints for puglins lifecycle.

Documentation

[TODO]

License

[TBD]

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

engrate_sdk-0.0.23.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

engrate_sdk-0.0.23-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file engrate_sdk-0.0.23.tar.gz.

File metadata

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

File hashes

Hashes for engrate_sdk-0.0.23.tar.gz
Algorithm Hash digest
SHA256 e102d2a4c46b1a53751c3c674da5dbec38568cca750aedbbca83c6c398ca79b4
MD5 2cf7d9d7f18413b20ef92e6f0aecfd8f
BLAKE2b-256 31af1ee7fa7de4003d40218bad2b6cdbf0b4a779ec34864f89433b72bdcb2dc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for engrate_sdk-0.0.23.tar.gz:

Publisher: release.yaml on engrate/engrate-sdk

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

File details

Details for the file engrate_sdk-0.0.23-py3-none-any.whl.

File metadata

  • Download URL: engrate_sdk-0.0.23-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for engrate_sdk-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 6f762f114ab2d370a3fd3badcd597395bd78b0c9483bcef73ec096c1650c6d5d
MD5 a1e3a9e2f49b9709a74a94b21e6d1526
BLAKE2b-256 afcaaccf373303df52456600ebf9efb2a83d55a1472ff55f435f7973987f1b6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for engrate_sdk-0.0.23-py3-none-any.whl:

Publisher: release.yaml on engrate/engrate-sdk

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