Base Artifact¶
All BentoML artifacts are inherited from the BentoServiceArtifact base class:
-
class
bentoml.service.artifacts.
BentoServiceArtifact
(name: str)¶ 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.name -> artifact_instance)
Common Artifacts¶
PickleArtifact
-
class
bentoml.service.artifacts.common.
PickleArtifact
(name, pickle_module=<module 'bentoml.utils.cloudpickle' from '/home/docs/checkouts/readthedocs.org/user_builds/bentoml/checkouts/latest/bentoml/utils/cloudpickle.py'>, pickle_extension='.pkl')¶ Abstraction for saving/loading python objects with pickle serialization
- Parameters
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.
JSONArtifact
-
class
bentoml.service.artifacts.common.
JSONArtifact
(name, file_extension='.json', encoding='utf-8', json_module=None)¶ Abstraction for saving/loading objects to/from JSON files.
- Parameters
name (str) – Name of the artifact
file_extension (
str
, optional) – The file extension used for the saved text file. Defaults to “.txt”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.
TextFileArtifact
-
class
bentoml.service.artifacts.common.
TextFileArtifact
(name, file_extension='.txt', encoding='utf-8')¶ Abstraction for saving/loading string to/from text files
- Parameters
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”