concoction


Nameconcoction JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/soapun/concoction
SummaryLibrary to inject configurations
upload_time2024-06-29 17:57:32
maintainerNone
docs_urlNone
authorsoapun
requires_python<4,>=3.8
licenseMIT
keywords python config configuration settings injection injector configuration-management
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Concoction

Concoction is a simple configuration injection library that allows you to easily inject configuration values into your
Python applications. It supports both `pydantic` and `dataclasses` for defining configuration models. Unlike traditional
configuration management tools, Concoction does not parse or layer configurations; it only works with a dictionary
object as an input.

## Inspiration

Concoction is inspired by the `@ConfigurationProperties` and `@Value` annotations from Spring Boot. These annotations
allow for easy injection of configuration properties into Java applications, and Concoction aims to provide a similar
experience for Python developers.

## Key Features

- **Flexibility with Plain Dictionaries**: Simple and flexible configuration management using plain dictionaries.
- **Injecting Whole Configuration Blocks**: Inject entire configuration blocks for modular and decoupled settings.
- **Injecting Individual Fields**: Granular control with the ability to inject specific configuration fields.

## Installation

To install Concoction, run the following command:

```bash
pip install concoction
```

## Usage

Here is an example of `config.yaml` file:

```yaml
app:
  service:
    host: 0.0.0.0
    port: 8000
```

and injecting `service` section into our config

```python
import yaml  # pip install pyyaml
from pydantic import BaseModel
from concoction import Configuration, set_global_config


# define config with injection

@Configuration("app.service")
class ServiceConfig(BaseModel):
    host: str
    port: int


# Load configuration from a YAML file
with open("config.yaml") as f:
    config = yaml.safe_load(f)

set_global_config(config)

# Create an instance of the configuration model
app_config = ServiceConfig()
```

or field-wise

```python
from concoction.values.pydantic import Value


class ServiceConfig(BaseModel):
    host: str = Value("app.service.host")
    port: int = Value("app.service.port")
```

## Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/soapun/concoction",
    "name": "concoction",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.8",
    "maintainer_email": null,
    "keywords": "python, config, configuration, settings, injection, injector, configuration-management",
    "author": "soapun",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a0/07/f973f69b98e0c5b228508bc880b94e6d888e3e1d5fc4d81a2758982a9eec/concoction-0.1.1.tar.gz",
    "platform": null,
    "description": "# Concoction\n\nConcoction is a simple configuration injection library that allows you to easily inject configuration values into your\nPython applications. It supports both `pydantic` and `dataclasses` for defining configuration models. Unlike traditional\nconfiguration management tools, Concoction does not parse or layer configurations; it only works with a dictionary\nobject as an input.\n\n## Inspiration\n\nConcoction is inspired by the `@ConfigurationProperties` and `@Value` annotations from Spring Boot. These annotations\nallow for easy injection of configuration properties into Java applications, and Concoction aims to provide a similar\nexperience for Python developers.\n\n## Key Features\n\n- **Flexibility with Plain Dictionaries**: Simple and flexible configuration management using plain dictionaries.\n- **Injecting Whole Configuration Blocks**: Inject entire configuration blocks for modular and decoupled settings.\n- **Injecting Individual Fields**: Granular control with the ability to inject specific configuration fields.\n\n## Installation\n\nTo install Concoction, run the following command:\n\n```bash\npip install concoction\n```\n\n## Usage\n\nHere is an example of `config.yaml` file:\n\n```yaml\napp:\n  service:\n    host: 0.0.0.0\n    port: 8000\n```\n\nand injecting `service` section into our config\n\n```python\nimport yaml  # pip install pyyaml\nfrom pydantic import BaseModel\nfrom concoction import Configuration, set_global_config\n\n\n# define config with injection\n\n@Configuration(\"app.service\")\nclass ServiceConfig(BaseModel):\n    host: str\n    port: int\n\n\n# Load configuration from a YAML file\nwith open(\"config.yaml\") as f:\n    config = yaml.safe_load(f)\n\nset_global_config(config)\n\n# Create an instance of the configuration model\napp_config = ServiceConfig()\n```\n\nor field-wise\n\n```python\nfrom concoction.values.pydantic import Value\n\n\nclass ServiceConfig(BaseModel):\n    host: str = Value(\"app.service.host\")\n    port: int = Value(\"app.service.port\")\n```\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Library to inject configurations",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/soapun/concoction",
        "Repository": "https://github.com/soapun/concoction"
    },
    "split_keywords": [
        "python",
        " config",
        " configuration",
        " settings",
        " injection",
        " injector",
        " configuration-management"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "388d5930e5acef8f5e2d310c8d1a99b2bc411f6246dff024e4cdef202a47d8ff",
                "md5": "dae6539188d2bda0904fee158f9439db",
                "sha256": "9846842aff6c04d3dd1764d8bf56c81895d00bb456e6d2af8756d5b5a6f4a089"
            },
            "downloads": -1,
            "filename": "concoction-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dae6539188d2bda0904fee158f9439db",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.8",
            "size": 4651,
            "upload_time": "2024-06-29T17:57:31",
            "upload_time_iso_8601": "2024-06-29T17:57:31.285809Z",
            "url": "https://files.pythonhosted.org/packages/38/8d/5930e5acef8f5e2d310c8d1a99b2bc411f6246dff024e4cdef202a47d8ff/concoction-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a007f973f69b98e0c5b228508bc880b94e6d888e3e1d5fc4d81a2758982a9eec",
                "md5": "2d4d6d66db6291be4553d910ae465617",
                "sha256": "6748b686972018fec9a8f677fc7c54c26aef8b1186b73c976ad833ab86dee4fc"
            },
            "downloads": -1,
            "filename": "concoction-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2d4d6d66db6291be4553d910ae465617",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.8",
            "size": 3447,
            "upload_time": "2024-06-29T17:57:32",
            "upload_time_iso_8601": "2024-06-29T17:57:32.686352Z",
            "url": "https://files.pythonhosted.org/packages/a0/07/f973f69b98e0c5b228508bc880b94e6d888e3e1d5fc4d81a2758982a9eec/concoction-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-29 17:57:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "soapun",
    "github_project": "concoction",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "concoction"
}
        
Elapsed time: 0.28280s