engrate-sdk


Nameengrate-sdk JSON
Version 0.0.21 PyPI version JSON
download
home_pageNone
SummaryEngrate SDK for plugin developers
upload_time2025-08-29 08:15:55
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT
keywords api-client energy engrate http-client logging mcp plugins sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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):

```code
"engrate-sdk ~= 0.0.16"
```
Then update your local environment
```bash
uv pip install .
```

## Usage

```python
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). 

```python
@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.yaml```file at root level of the project (it's also possible to provide an url when initializing the ```PluginRegistry```object) This file must exist and contain the following format ***(WIP: this might change in the near future)***:

 ```yaml
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 registrar```that 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]
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "engrate-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Carlos <carlos@engrate.io>, Joel <joel@engrate.io>, Rille <rille@engrate.io>",
    "keywords": "api-client, energy, engrate, http-client, logging, mcp, plugins, sdk",
    "author": null,
    "author_email": "Engrate Dev <dev@engrate.io>",
    "download_url": "https://files.pythonhosted.org/packages/1f/19/def9df56a2a78a2da9c26ace6deafd129ab693aa5040f8b6e3b4b6382f81/engrate_sdk-0.0.21.tar.gz",
    "platform": null,
    "description": "# Engrate SDK\n\nA utility SDK providing common services for logging, configuration, and HTTP clients to connect the Engrate Platform.\n\n## Features\n\n- Simple and consistent logging interface\n- Flexible configuration management\n- HTTP client utilities for seamless API integration\n- TypeScript support\n\n## Installation\n\nAdd the dependency to your project configuration (i.e. UV):\n\n```code\n\"engrate-sdk ~= 0.0.16\"\n```\nThen update your local environment\n```bash\nuv pip install .\n```\n\n## Usage\n\n```python\nfrom engrate_sdk import Logger, Config, HttpClient\n\n# Logging\nlogger = Logger()\nlogger.info('Engrate SDK initialized')\n\n# Configuration\nconfig = Config()\nconfig.load_from_env()\n\n# HTTP Client\nclient = HttpClient(base_url=config.get('API_URL'))\nresponse = client.get('/status')\n```\n\n## Registry\n\nThe library contains a ```regystry.py``` module which provides access to our internal plugin registry. Every plugin has to call to the ```register_plugin()``` method\nat some point in the plugin bootstrap process (if using ```FastAPI``this is usually recommended to use a lifespan function). \n\n```python\n@asynccontextmanager\nasync def lifespan(fast_app: FastAPI):\n    \"\"\"Startup and shutdown logic using lifespan events.\"\"\"\n    try:\n        print(\"Validating environment variables...\")\n        env.validate()\n        if env.should_register():\n            logger.info(\"Registering plugin...\")\n            plugin = PluginRegistry(registrar_url=env.get_registrar_url())\n            await plugin.register_plugin()\n        yield\n    finally:\n        logger.info(\"Shutting down application...\")\n```\nThis method will look for a ```plugin_manifest.yaml```file at root level of the project (it's also possible to provide an url when initializing the ```PluginRegistry```object) This file must exist and contain the following format ***(WIP: this might change in the near future)***:\n\n ```yaml\nname: \"power-tariffs\"\nauthor: \"Energy development solutions\"\ndescription: \"Test plugin to use Engrate SDK\"\nproduct_category: \"market_intelligence\"\nextensions:\n  markets:\n    - \"*\"\n    - \"nl\"\n    - \"de\"\n    - \"se\"\nplugin_metadata:\n  display_name: \"Demo Plugin\"\n  service_name: \"demo-plugin\"\n  url_prefix: \"demo-plugin\"\n  fav_icon: \"\"\n  image: \"\"\n  port: \"3111\"\n  api_version: \"v1\"\n  flavors:\n    - \"external-api\"\n  traits:\n    - \"storage\"\n\n ```\n\n### Mock registrar\nFor testing purposes, the library includes a ```mock registrar```that mimics the behaviour for the actual registrar in the core services. This is a simple ```FastApi``` server that will\nimplement the required endpoints for puglins lifecycle.\n\n## Documentation\n\n[TODO]\n\n## License\n\n[TBD]",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Engrate SDK for plugin developers",
    "version": "0.0.21",
    "project_urls": {
        "Homepage": "https://engrate.io",
        "Repository": "https://github.com/engrate/engrate-sdk"
    },
    "split_keywords": [
        "api-client",
        " energy",
        " engrate",
        " http-client",
        " logging",
        " mcp",
        " plugins",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f4edc938c5d7d36c552b38272bb649d31f5668fb1971b73c84b76d3cd0439fe5",
                "md5": "a9c9fca68c66ba045c93d64083713e2e",
                "sha256": "662425609b84c0278084762ac345fd0c28501f43e01947196885bfa25f8cb978"
            },
            "downloads": -1,
            "filename": "engrate_sdk-0.0.21-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a9c9fca68c66ba045c93d64083713e2e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14566,
            "upload_time": "2025-08-29T08:15:54",
            "upload_time_iso_8601": "2025-08-29T08:15:54.177441Z",
            "url": "https://files.pythonhosted.org/packages/f4/ed/c938c5d7d36c552b38272bb649d31f5668fb1971b73c84b76d3cd0439fe5/engrate_sdk-0.0.21-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1f19def9df56a2a78a2da9c26ace6deafd129ab693aa5040f8b6e3b4b6382f81",
                "md5": "b6b8d68b8299e48e57acc203f66d3a51",
                "sha256": "09bdf876c674a425e8458d3a7f87aca5c9de2dd4ccaee0629004204b61ddc18f"
            },
            "downloads": -1,
            "filename": "engrate_sdk-0.0.21.tar.gz",
            "has_sig": false,
            "md5_digest": "b6b8d68b8299e48e57acc203f66d3a51",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 12225,
            "upload_time": "2025-08-29T08:15:55",
            "upload_time_iso_8601": "2025-08-29T08:15:55.713054Z",
            "url": "https://files.pythonhosted.org/packages/1f/19/def9df56a2a78a2da9c26ace6deafd129ab693aa5040f8b6e3b4b6382f81/engrate_sdk-0.0.21.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-29 08:15:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "engrate",
    "github_project": "engrate-sdk",
    "github_not_found": true,
    "lcname": "engrate-sdk"
}
        
Elapsed time: 2.09636s