Skip to content

omnipy.config

Shared configuration base types and display helpers.

MODULE DESCRIPTION
data

Configuration models for data display, UI, and HTTP behavior.

engine

Configuration models for selecting and tuning job runner engines.

job

Configuration models for persisted task and flow outputs.

root_log

Configuration for Omnipy root logger outputs and formatting.

CLASS DESCRIPTION
ConfigBase

Base class for Omnipy configuration models.

ConfigBase

Bases: DataPublisher


              flowchart BT
              omnipy.config.ConfigBase[ConfigBase]
              omnipy.util.publisher.DataPublisher[DataPublisher]

                              omnipy.util.publisher.DataPublisher --> omnipy.config.ConfigBase
                                omnipy.util.pydantic.BaseModel --> omnipy.util.publisher.DataPublisher
                



              click omnipy.config.ConfigBase href "" "omnipy.config.ConfigBase"
              click omnipy.util.publisher.DataPublisher href "" "omnipy.util.publisher.DataPublisher"
            

Base class for Omnipy configuration models.

METHOD DESCRIPTION
as_model

Return a JSON model representation of the current configuration.

default_repr_to_terminal_str
Source code in src/omnipy/config/__init__.py
class ConfigBase(DataPublisher):
    """Base class for Omnipy configuration models."""
    def as_model(self) -> 'JsonDictModel':
        """Return a JSON model representation of the current configuration.

        Allows the configuration object to be serialized, displayed, and
        inspected using the same rendering pipeline as any other Omnipy
        model.  The returned ``ConfigModel`` subclass also customizes the
        default display panel to use JSON5 syntax.

        Returns:
            JsonDictModel: A JSON model view of this configuration instance.
        """
        from omnipy.components.json.models import JsonDictModel

        class ConfigModel(JsonDictModel):
            @override
            def _default_panel(self, **kwargs) -> 'DraftPanel':
                kwargs_copy = kwargs.copy()
                kwargs_copy['syntax'] = SyntaxLanguageSpec.JSON5
                return self._full(**kwargs_copy)

        return ConfigModel(self)  # pyright: ignore [reportReturnType]

    def default_repr_to_terminal_str(
        self,
        ui_type: TerminalOutputUserInterfaceType.Literals,
    ) -> str:
        return self.as_model().default_repr_to_terminal_str(ui_type)

    def _repr_pretty_(self, p: 'RepresentationPrinter', cycle: bool) -> None:
        self.as_model()._repr_pretty_(p, cycle)

    def _ipython_display_(self) -> None:
        self.as_model()._ipython_display_()

    def __str__(self):
        return repr(self)

as_model

as_model() -> JsonDictModel

Return a JSON model representation of the current configuration.

Allows the configuration object to be serialized, displayed, and inspected using the same rendering pipeline as any other Omnipy model. The returned ConfigModel subclass also customizes the default display panel to use JSON5 syntax.

RETURNS DESCRIPTION
JsonDictModel

A JSON model view of this configuration instance.

TYPE: JsonDictModel

Source code in src/omnipy/config/__init__.py
def as_model(self) -> 'JsonDictModel':
    """Return a JSON model representation of the current configuration.

    Allows the configuration object to be serialized, displayed, and
    inspected using the same rendering pipeline as any other Omnipy
    model.  The returned ``ConfigModel`` subclass also customizes the
    default display panel to use JSON5 syntax.

    Returns:
        JsonDictModel: A JSON model view of this configuration instance.
    """
    from omnipy.components.json.models import JsonDictModel

    class ConfigModel(JsonDictModel):
        @override
        def _default_panel(self, **kwargs) -> 'DraftPanel':
            kwargs_copy = kwargs.copy()
            kwargs_copy['syntax'] = SyntaxLanguageSpec.JSON5
            return self._full(**kwargs_copy)

    return ConfigModel(self)  # pyright: ignore [reportReturnType]

default_repr_to_terminal_str

default_repr_to_terminal_str(ui_type: TerminalOutputUserInterfaceType.Literals) -> str
Source code in src/omnipy/config/__init__.py
def default_repr_to_terminal_str(
    self,
    ui_type: TerminalOutputUserInterfaceType.Literals,
) -> str:
    return self.as_model().default_repr_to_terminal_str(ui_type)