Artifact Stores
Setting up the storage for your artifacts
This is an older version of the ZenML documentation. To check the latest version please visit https://docs.zenml.io
In ZenML, all the inputs and outputs which go through a step are treated as artifacts and as its name suggests, an ArtifactStore
is a place where these artifacts get stored.
Before reading this chapter, make sure that you are familiar with the concept of stacks, stack components and their flavors.
Base Abstraction
The artifact store establishes one of the main components in every ZenML stack. Now, let us take a deeper dive into the fundamentals behind its abstraction, namely the BaseArtifactStore
:
As it is the base class for a specific type of StackComponent, it inherits from the StackComponent class. This sets the
TYPE
variable to a StackComponentType. TheFLAVOR
class variable needs to be set in the specific subclass.As ZenML only supports filesystem-based artifact stores, it features an instance configuration parameter called
path
, which will indicate the root path of the artifact store. When creating an instance of any flavor of anArtifactStore
, users will have to define this parameter.Moreover, there is an empty class variable called
SUPPORTED_SCHEMES
that needs to be defined in every flavor implementation. It indicates the supported filepath schemes for the corresponding implementation. For instance, for the Azure artifact store, this set will be defined as{"abfs://", "az://"}
.Lastly, the base class features a set of
abstractmethod
s:open
,copyfile
,exists
,glob
,isdir
,listdir
,makedirs
,mkdir
,remove
,rename
,rmtree
,stat
,walk
. In the implementation of everyArtifactStore
flavor, it is required to define these methods with respect to the flavor at hand.
Putting all these considerations together, we end up with the following implementation:
This is a slimmed-down version of the base implementation which aims to highlight the abstraction layer. In order to see the full implementation and get the complete docstrings, please check the API docs.
The effect on the zenml.io.fileio
If you created an instance of an artifact store, added it to your stack and activated the stack, it will create a filesystem each time you run a ZenML pipeline and make it available to the zenml.io.fileio
module.
This means that when you utilize a method such as fileio.open(...)
with a filepath which starts with one of the SUPPORTED_SCHEMES
within your steps or materializers, it will be able to use the open(...)
method that you defined within your artifact store.
List of available artifact stores
Out of the box, ZenML comes with a LocalArtifactStore
implementation, which is a simple implementation for a local setup.
Moreover, additional artifact stores can be found in specific integration
modules, such as the GCPArtifactStore
in the gcp
integration and the AzureArtifactStore
in the azure
integration.
Flavor | Integration | |
---|---|---|
local |
| |
s3 | s3 | |
gcp | gcp | |
azure | azure |
If you would like to see the available flavors for artifact stores, you can use the command:
Build your own custom artifact store
If you want to create your own custom flavor for an artifact store, you can follow the following steps:
Create a class which inherits from the
BaseArtifactStore
.Define the
FLAVOR
class variable.Implement the
abstactmethod
s based on your desired filesystem.
Once you are done with the implementation, you can register it through the CLI as:
Last updated