An application framework for Python.
Project description
⚠️ Note: This framework is still in the alpha release stage. Expect potential changes and improvements in future releases.
py-application-framework
An application framework for Python.
Features:
- Builder Pattern: The framework incorporates the builder pattern to facilitate the assembly of a Host that accommodates multiple Applications. This approach ensures a structured and efficient setup process.
- Dependency Injection: Support for dependency injection using a dependency container.
Compatibility
The library is compatible with the following Python versions:
- 3.7, 3.8, 3.9, 3.10, 3.11, 3.12
Installation
$ pip install py-application-framework
Quick Start
Here's a quick example to get you started:
# examples/single_app/main.py
import os
from application_framework.application.builder import ApplicationBuilder
from application_framework.config.builder import ConfigBuilder
from application_framework.host.builder import HostBuilder
from application_framework.monitoring.restart_policy import RestartPolicy
from examples.single_app.config import AppConfig, Config
from examples.single_app.src.application import Application
from examples.single_app.src.greet_action import GreetAction
def main():
config = (
ConfigBuilder()
.set_environment_profile(env=os.getenv("APP_ENV", "development"))
.add_yaml_file(path="config.common.yaml")
.add_profiled_file(template="config.{profile}.yaml")
.add_prefixed_env_vars(prefix="CFG_", section_separator=".")
.set_type_conversion('host.port', int)
.set_type_conversion('app.port', int)
.bind(Config)
.build()
)
application = (
ApplicationBuilder()
.set_config(config.app)
.set_root_directory(".")
.set_name("MyApp")
.run_in_separate_process()
.add_route(protocol="http", path="/app/?.*", port=config.app.port)
.set_application_class(Application)
.set_restart_policy(RestartPolicy.ExponentialBackoff)
.register_instance(AppConfig, config.app)
.register_transient(GreetAction)
.build()
)
host = (
HostBuilder()
.set_config(config.host)
.add_application(application)
.set_listening_port(config.host.port)
.build()
)
host.run()
if __name__ == "__main__":
main()
Documentation
For more advanced usage and examples, please visit our readthedocs page.
License
py-application-framework
is released under the GPL 3 license. See LICENSE for more details.
Source Code
You can find the source code for py-application-framework
on GitHub.
Release Notes
1.0.0-alpha.4 (2024-06-17)
- Internals Documentation: Added comprehensive documentation detailing the internal architecture of the framework, including basic concepts, the executor model, and the use of processes, threads, and coroutines.
1.0.0-alpha.3 (2024-06-08)
- New ApplicationBuilder Class: Introduced the ApplicationBuilder class for a more streamlined and structured application setup.
- Dependency Injection Support: Now using a dependency container for improved dependency injection throughout the application.
- Bug Fix: Fixed an issue with the default initialization of dataclass fields in Python 3.11 and above.
1.0.0-alpha.2 (2024-06-07)
- New ConfigBuilder Class: Introduced the ConfigBuilder class to handle application configuration flexibly and extensibly, supporting multiple sources such as YAML, JSON, INI, and environment variables, with type conversion and binding capabilities.
- Basic Documentation: Provided an initial set of documentation to give users an introduction to the library.
- License: Released under the GPL 3 license.
- Initial Alpha Release: Marked the initial alpha release of the framework.
This README reflects the current state of the project and will be updated with new features and improvements in future releases. Stay tuned for updates!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for py-application-framework-1.0.0a4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76e6d26e50c9495f68c1acfcc5218cc68fe8fb2dd9a2f6edb806ff58e9b60919 |
|
MD5 | dcc546d9ff9af59d6fcd46fb0d4cc5ca |
|
BLAKE2b-256 | 8361f618223b087c6b5d0de4bbf2cdacd40f121cdf7b05d4ccce7a021603e94d |
Hashes for py_application_framework-1.0.0a4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57f141e2fcec10296756eb8cc3b41d49aa0bef29d9826e8b74ea1558395957d3 |
|
MD5 | c1d5942d19ec1f8fae8a6c96230fc0aa |
|
BLAKE2b-256 | 377fd60e73ebf1cb6e054d36e2f78273a28c80fa59c436588a1565ea620cd31b |