workflow.tasks.pusher.task
Top-level push() dispatch function for the Michelangelo pusher.
push
def push(
config: PusherConfig,
artifacts: dict[str, Any],
*,
storage_backend: StorageBackend | None = None,
registry_client: ModelRegistryClient | None = None,
registry: PluginRegistry | None = None,
fail_fast: bool = True,
on_error: Callable[[str, str, Exception], None] | None = None
) -> list[PusherResult]
Push one or more artifacts using their configured plugins.
Iterates config.items in order, resolves each artifact from
artifacts by name, instantiates the matching plugin, and calls
execute(). Infrastructure dependencies (storage_backend,
registry_client) are injected into every plugin.
Arguments:
config- Top-level pusher configuration listing artifact/plugin pairs.artifacts- Mapping from artifact name to artifact value. Keys must matchPusherPluginConfig.namefor each item in config.storage_backend- Backend used for artifact uploads. Required — pass aLocalStorageBackend,MinioStorageBackend, or anyStorageBackendsubclass. RaisesConfigurationErrorwhenNone.registry_client- Registry client injected into plugins that require one (e.g.ModelPusherPlugin). PassNonefor plugins that don't need a registry, or when registry clients are specified directly onModelPluginConfig.registry_clients.registry- Plugin registry to resolve plugin names against. Defaults todefault_registrywhenNone.fail_fast- WhenTrue(default), the first plugin failure raisesPusherPluginErrorand subsequent items are not processed. WhenFalse, all items run and failures are recorded inPusherResult.error.on_error- Optional callback invoked on every plugin failure, regardless offail_fast. Signature:(artifact_name, plugin_name, exc). Exceptions raised by the callback are logged and suppressed.
Returns:
List of PusherResult,
one per config.items entry processed. In fail_fast=True mode
the list is shorter than config.items when a failure occurs.
Raises:
ArtifactNotFoundError- If a name inconfig.itemsis absent fromartifacts.ConfigurationError- If a plugin name is not registered, or the artifact type does not match the registered expected type.PusherPluginError- If a plugin'sexecute()raises andfail_fast=True.
Example:
import tempfile
from michelangelo.lib.artifact_manager.storage_backend import LocalStorageBackend
from michelangelo.lib.model_manager.registry.client import (
InMemoryRegistryClient,
)
from michelangelo.workflow.schema.pusher import (
ModelPluginConfig, PusherConfig, PusherPluginConfig,
)
from michelangelo.workflow.tasks.pusher import push
from michelangelo.workflow.variables.types import AssembledModel, ModelArtifact
result = push(
config=PusherConfig(items=[
PusherPluginConfig(
name="clf",
model_plugin=ModelPluginConfig(model_name="my-classifier"),
),
]),
artifacts={
# path must point at an existing packaged model (file or directory)
"clf": AssembledModel(raw_model=ModelArtifact(path="/tmp/raw"))
},
storage_backend=LocalStorageBackend(tempfile.mkdtemp()),
registry_client=InMemoryRegistryClient(),
)
assert result[0].success