🤖 I have created a release *beep* *boop* --- ## [4.2.0](https://github.com/libretime/libretime/compare/4.1.0...4.2.0) (2024-06-22) ### Features * **legacy:** add current date macro to string block criteria ([#3013](https://github.com/libretime/libretime/issues/3013)) ([451652b](451652bc40)) * **legacy:** add filename block criteria ([#3015](https://github.com/libretime/libretime/issues/3015)) ([4642b6c](4642b6c08e)) ### Bug Fixes * pin pip version to <24.1 to allow installing pytz (celery) ([#3043](https://github.com/libretime/libretime/issues/3043)) ([646bc81](646bc81724)) * playlist allocates inaccurate time to smartblocks ([#3026](https://github.com/libretime/libretime/issues/3026)) ([2b43e51](2b43e51ed1)) ### Performance Improvements * optimize the api image health check ([#3038](https://github.com/libretime/libretime/issues/3038)) ([d99d6e1](d99d6e1a68)) * optimize the rabbitmq health check ([#3037](https://github.com/libretime/libretime/issues/3037)) ([9684214](9684214425)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Shared
The libretime_shared package contains reusable functions and classes for the LibreTime project.
Usage
This library assumes that:
- You will use
Clickto build a CLI for your app. - You will use
Pydanticto validate objects in your app.
Configuration
First define a schema for your configuration in order to validate it. A schema is a class that inherit from pydantic.BaseModel. Some existing schemas can be reused such as libretime_shared.config.RabbitMQ or libretime_shared.config.Database.
Load your configuration using a subclass of libretime_shared.config.BaseConfig.
from pydantic import BaseModel
from libretime_shared.config import RabbitMQConfig, BaseConfig
class AnalyzerConfig(BaseModel):
bpm_enabled: bool = False
bpm_track_max_length: int
class Config(BaseConfig):
rabbitmq: RabbitMQConfig
analyzer: AnalyzerConfig
config = Config("/etc/libretime/config.yml")
Don't instantiate a sub model if it has a required field, otherwise the
Configclass import will raise aValidationError.
CLI
Decorate your CLI commands with the shared decorators to add extra flags.
import click
from libretime_shared.cli import cli_logging_options, cli_config_options
from .app import App
@click.group()
def cli():
pass
@cli.command()
@cli_config_options()
@cli_logging_options()
def run(**kwargs):
app = App(**kwargs)
return app.run()