Skip to content

Metadata

Metadata module.

update(**kwargs)

Update metadata in the current pipeline or step execution.

Parameters:

Name Type Description Default
**kwargs Any

Metadata.

{}

Returns:

Name Type Description
bool bool

True if metadata was updated, False otherwise.

Example
import devpipe as dp

@dp.step
def my_step():
    dp.metadata.update(pages=35)
    ...

@dp.pipeline
def my_pipeline():
    dp.metadata.update(author="John Doe")
    ...

Warning

Nothing will happen if the update function is not called from a pipeline or step.

Warning

Make sure that all the metadata values are JSON serializable.

Source code in devpipe/core/metadata.py
def update(**kwargs: Any) -> bool:
    """Update metadata in the current pipeline or step execution.

    Args:
        **kwargs (Any): Metadata.

    Returns:
        bool: True if metadata was updated, False otherwise.

    Example:
        ```python
        import devpipe as dp

        @dp.step
        def my_step():
            dp.metadata.update(pages=35)
            ...

        @dp.pipeline
        def my_pipeline():
            dp.metadata.update(author="John Doe")
            ...
        ```
    !!! warning
        Nothing will happen if the update function is not called from a
        pipeline or step.

    !!! warning
        Make sure that all the metadata values are JSON serializable.
    """
    execution = SExec._from_context() or PExec._from_context()
    if not execution:
        logger.warning(
            "Metadata update not called from a pipeline or step. "
            "Metadata will not be updated."
        )
        return False
    execution.meta.update(kwargs)
    logger.debug(f"Metadata updated for {repr(execution)}.")
    return True