Base Artifact

All BentoML artifacts are inherited from the BentoServiceArtifact base class:

class bentoml.service.artifacts.BentoServiceArtifact(*args, **kwargs)

BentoServiceArtifact is the base abstraction for describing the trained model serialization and deserialization process.

In a BentoService#artifacts returns an ArtifactCollection instance:

class bentoml.service.artifacts.ArtifactCollection

A dict of artifact instances ( -> artifact_instance)

Common Artifacts


class bentoml.service.artifacts.common.PickleArtifact(*args, **kwargs)

Abstraction for saving/loading python objects with pickle serialization

  • name (str) – Name for the artifact

  • pickle_module (module|str) – The python module will be used for pickle and unpickle artifact, default pickle module in BentoML’s fork of cloudpickle, which is identical to the Apache Spark fork

  • pickle_extension (str) – The extension format for pickled file.


class bentoml.service.artifacts.common.JSONArtifact(*args, **kwargs)

Abstraction for saving/loading objects to/from JSON files.

  • name (str) – Name of the artifact

  • encoding (str, optional) – The encoding will be used for saving/loading text. Defaults to “utf8”

  • json_module (module|object, optional) – Namespace/object implementing loads() and dumps() methods for serializing/deserializing to/from JSON string. Defaults to stdlib’s json module.


class bentoml.service.artifacts.common.TextFileArtifact(*args, **kwargs)

Abstraction for saving/loading string to/from text files

  • name (str) – Name of the artifact

  • file_extension (str, optional) – The file extension used for the saved text file. Defaults to “.txt”

  • encoding (str) – The encoding will be used for saving/loading text. Defaults to “utf8”