Skip to content

develop

Attributes

KIARA_DEV_SETTINGS = KiaraDevSettings() module-attribute

Classes

DetailLevel

Bases: Enum

Source code in src/kiara/utils/develop/__init__.py
82
83
84
85
class DetailLevel(Enum):
    NONE = "none"
    MINIMAL = "minimal"
    FULL = "full"

Attributes

NONE = 'none' class-attribute instance-attribute
MINIMAL = 'minimal' class-attribute instance-attribute
FULL = 'full' class-attribute instance-attribute

PreRunMsgDetails

Bases: BaseModel

Source code in src/kiara/utils/develop/__init__.py
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
class PreRunMsgDetails(BaseModel):
    model_config = ConfigDict(
        extra="forbid", validate_assignment=True, use_enum_values=True
    )

    pipeline_steps: bool = Field(
        description="Whether to also display information for modules that are run as part of a pipeline.",
        default=False,
    )
    module_info: DetailLevel = Field(
        description="Whether to display details about the module to be run.",
        default=DetailLevel.MINIMAL,
    )
    internal_modules: bool = Field(
        description="Whether to also print details about runs of internal modules.",
        default=False,
    )
    inputs_info: DetailLevel = Field(
        description="Whether to display details about the run inputs.",
        default=DetailLevel.MINIMAL,
    )

Attributes

model_config = ConfigDict(extra='forbid', validate_assignment=True, use_enum_values=True) class-attribute instance-attribute
pipeline_steps: bool = Field(description='Whether to also display information for modules that are run as part of a pipeline.', default=False) class-attribute instance-attribute
module_info: DetailLevel = Field(description='Whether to display details about the module to be run.', default=DetailLevel.MINIMAL) class-attribute instance-attribute
internal_modules: bool = Field(description='Whether to also print details about runs of internal modules.', default=False) class-attribute instance-attribute
inputs_info: DetailLevel = Field(description='Whether to display details about the run inputs.', default=DetailLevel.MINIMAL) class-attribute instance-attribute

PostRunMsgDetails

Bases: BaseModel

Source code in src/kiara/utils/develop/__init__.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
class PostRunMsgDetails(BaseModel):
    model_config = ConfigDict(
        extra="forbid", validate_assignment=True, use_enum_values=True
    )

    pipeline_steps: bool = Field(
        description="Whether to also display information for modules that are run as part of a pipeline",
        default=False,
    )
    module_info: DetailLevel = Field(
        description="Whether to display details about the module that was run.",
        default=DetailLevel.NONE,
    )
    internal_modules: bool = Field(
        description="Whether to also print details about runs of internal module.",
        default=False,
    )
    inputs_info: DetailLevel = Field(
        description="Whether to display details about the run inputs.",
        default=DetailLevel.NONE,
    )
    outputs_info: DetailLevel = Field(
        description="Whether to display details about the run outputs.",
        default=DetailLevel.MINIMAL,
    )

Attributes

model_config = ConfigDict(extra='forbid', validate_assignment=True, use_enum_values=True) class-attribute instance-attribute
pipeline_steps: bool = Field(description='Whether to also display information for modules that are run as part of a pipeline', default=False) class-attribute instance-attribute
module_info: DetailLevel = Field(description='Whether to display details about the module that was run.', default=DetailLevel.NONE) class-attribute instance-attribute
internal_modules: bool = Field(description='Whether to also print details about runs of internal module.', default=False) class-attribute instance-attribute
inputs_info: DetailLevel = Field(description='Whether to display details about the run inputs.', default=DetailLevel.NONE) class-attribute instance-attribute
outputs_info: DetailLevel = Field(description='Whether to display details about the run outputs.', default=DetailLevel.MINIMAL) class-attribute instance-attribute

KiaraDevLogSettings

Bases: BaseModel

Source code in src/kiara/utils/develop/__init__.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
class KiaraDevLogSettings(BaseModel):
    PROFILES: ClassVar[Dict[str, Any]] = {
        "full": {
            "log_pre_run": True,
            "pre_run": {
                "pipeline_steps": True,
                "module_info": "full",
                "inputs_info": "full",
            },
            "log_post_run": True,
            "post_run": {
                "pipeline_steps": True,
                "module_info": "minimal",
                "inputs_info": "minimal",
                "outputs_info": "full",
            },
        },
        "internal": {
            "pre_run": {"internal_modules": True},
            "post_run": {"internal_modules": True},
        },
    }
    model_config = ConfigDict(
        extra="forbid", validate_assignment=True, use_enum_values=True
    )

    exc: DetailLevel = Field(
        description="How detailed to print exceptions", default=DetailLevel.MINIMAL
    )
    log_pre_run: bool = Field(
        description="Print details about a module and its inputs before running it.",
        default=True,
    )
    pre_run: PreRunMsgDetails = Field(
        description="Fine-grained settings about what to display in the pre-run message.",
        default_factory=PreRunMsgDetails,
    )
    log_post_run: bool = Field(
        description="Print details about the results of a module run.", default=True
    )
    post_run: PostRunMsgDetails = Field(
        description="Fine-grained settings aobut what to display in the post-run message.",
        default_factory=PostRunMsgDetails,
    )

Attributes

PROFILES: Dict[str, Any] = {'full': {'log_pre_run': True, 'pre_run': {'pipeline_steps': True, 'module_info': 'full', 'inputs_info': 'full'}, 'log_post_run': True, 'post_run': {'pipeline_steps': True, 'module_info': 'minimal', 'inputs_info': 'minimal', 'outputs_info': 'full'}}, 'internal': {'pre_run': {'internal_modules': True}, 'post_run': {'internal_modules': True}}} class-attribute
model_config = ConfigDict(extra='forbid', validate_assignment=True, use_enum_values=True) class-attribute instance-attribute
exc: DetailLevel = Field(description='How detailed to print exceptions', default=DetailLevel.MINIMAL) class-attribute instance-attribute
log_pre_run: bool = Field(description='Print details about a module and its inputs before running it.', default=True) class-attribute instance-attribute
pre_run: PreRunMsgDetails = Field(description='Fine-grained settings about what to display in the pre-run message.', default_factory=PreRunMsgDetails) class-attribute instance-attribute
log_post_run: bool = Field(description='Print details about the results of a module run.', default=True) class-attribute instance-attribute
post_run: PostRunMsgDetails = Field(description='Fine-grained settings aobut what to display in the post-run message.', default_factory=PostRunMsgDetails) class-attribute instance-attribute

KiaraDevSettings

Bases: BaseSettings

Source code in src/kiara/utils/develop/__init__.py
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
class KiaraDevSettings(BaseSettings):
    # TODO[pydantic]: We couldn't refactor this class, please create the `model_config` manually.
    # Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information.

    model_config = SettingsConfigDict(
        extra="forbid",
        validate_assignment=True,
        use_enum_values=True,
        env_prefix="dev_",
        env_nested_delimiter="__",
    )

    # class Config:
    #
    #     extra = Extra.forbid
    #     validate_assignment = True
    #     env_prefix = "dev_"
    #     use_enum_values = True
    #     env_nested_delimiter = "__"
    #
    #     @classmethod
    #     def customise_sources(
    #         cls,
    #         init_settings,
    #         env_settings,
    #         file_secret_settings,
    #     ):
    #         return (
    #             init_settings,
    #             # profile_settings_source,
    #             dev_config_file_settings_source,
    #             env_settings,
    #         )

    @classmethod
    def settings_customise_sources(
        cls,
        settings_cls: Type[BaseSettings],
        init_settings: PydanticBaseSettingsSource,
        env_settings: PydanticBaseSettingsSource,
        dotenv_settings: PydanticBaseSettingsSource,
        file_secret_settings: PydanticBaseSettingsSource,
    ) -> Tuple[PydanticBaseSettingsSource, ...]:
        return (
            init_settings,
            env_settings,
        )

    log: KiaraDevLogSettings = Field(
        description="Settings about what messages to print in 'develop' mode, and what details to include.",
        default_factory=KiaraDevLogSettings,
    )
    job_cache: bool = Field(
        description="Whether to always disable the job cache (ignores the runtime_job_cache setting in the kiara configuration).",
        default=True,
    )

    def create_renderable(self, **render_config: Any):
        from kiara.utils.output import create_recursive_table_from_model_object

        return create_recursive_table_from_model_object(
            self, render_config=render_config
        )

Attributes

model_config = SettingsConfigDict(extra='forbid', validate_assignment=True, use_enum_values=True, env_prefix='dev_', env_nested_delimiter='__') class-attribute instance-attribute
log: KiaraDevLogSettings = Field(description="Settings about what messages to print in 'develop' mode, and what details to include.", default_factory=KiaraDevLogSettings) class-attribute instance-attribute
job_cache: bool = Field(description='Whether to always disable the job cache (ignores the runtime_job_cache setting in the kiara configuration).', default=True) class-attribute instance-attribute

Functions

settings_customise_sources(settings_cls: Type[BaseSettings], init_settings: PydanticBaseSettingsSource, env_settings: PydanticBaseSettingsSource, dotenv_settings: PydanticBaseSettingsSource, file_secret_settings: PydanticBaseSettingsSource) -> Tuple[PydanticBaseSettingsSource, ...] classmethod
Source code in src/kiara/utils/develop/__init__.py
218
219
220
221
222
223
224
225
226
227
228
229
230
@classmethod
def settings_customise_sources(
    cls,
    settings_cls: Type[BaseSettings],
    init_settings: PydanticBaseSettingsSource,
    env_settings: PydanticBaseSettingsSource,
    dotenv_settings: PydanticBaseSettingsSource,
    file_secret_settings: PydanticBaseSettingsSource,
) -> Tuple[PydanticBaseSettingsSource, ...]:
    return (
        init_settings,
        env_settings,
    )
create_renderable(**render_config: Any)
Source code in src/kiara/utils/develop/__init__.py
241
242
243
244
245
246
def create_renderable(self, **render_config: Any):
    from kiara.utils.output import create_recursive_table_from_model_object

    return create_recursive_table_from_model_object(
        self, render_config=render_config
    )

Functions

log_dev_message(msg: RenderableType, title: Union[str, None] = None)

Source code in src/kiara/utils/develop/__init__.py
17
18
19
20
21
22
23
24
25
26
27
def log_dev_message(msg: RenderableType, title: Union[str, None] = None):
    if not is_develop():
        return

    if not title:
        title = "Develop-mode message"
    panel = Panel(Group("", msg), title=f"[yellow]{title}[/yellow]", title_align="left")

    from kiara.utils.cli import terminal_print

    terminal_print(panel)