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 class:- As ZenML only supports filesystem-based artifact stores, it features a configuration parameter called
path
, which will indicate the root path of the artifact store. When registering an artifact store, users will have to define this parameter. - Moreover, there is another variable in the config class called
SUPPORTED_SCHEMES
. This is a class variable that needs to be defined in every subclass of the base artifact store configuration. 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.
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.
Build your own custom artifact store
If you want to implement your own custom Artifact Store, you can follow the following steps:- Create a class which inherits from the BaseArtifactStore class and implement the abstract methods.
- Create a class which inherits from the BaseArtifactStoreConfig class and fill in the
SUPPORTED_SCHEMES
based on your file system. - Bring both of these classes together by inheriting from the BaseArtifactStoreFlavor class.
- The CustomArtifactStoreFlavor class is imported and utilized upon the creation of the custom flavor through the CLI.
- The CustomArtifactStoreConfig class is imported when someone tries to register/update a stack component with this custom flavor. Especially, during the registration process of the stack component, the config will be used to validate the values given by the user. As
Config
object are inherentlypydantic
objects, you can also add your own custom validators here. - The CustomArtifactStore only comes into play when the component is ultimately in use.
CustomArtifactStoreFlavor
and the CustomArtifactStoreConfig
are implemented in a different module/path than the actual CustomArtifactStore
).