Creating plugins¶
It is possible to create plugins to the dtool
command line tool. There are
two different types of plugins: command line tools and backend storage brokers.
The former allows a developer to add custom extensions to the dtool
command. The latter allows a developer to create an interface for talking to a
new type of storage. One could for example create a storage broker to interface
with Amazon S3 object storage.
Extending the dtool
command line tool¶
Information on how to extend the dtool
command line tool is available in
the README file of dtool-cli.
Concrete examples making use of this plugin system are:
Creating an interface to a new type of storage¶
Below are the steps required to create a storage broker for allowing dtool
to interact with a new backend. A concrete example making use of this plugin
system is dtool-irods.
Examine the code in
dtoolcore.storagebroker.DiskStorageBroker
.Create a Python class for your storage, e.g.
MyStorageBroker
Add a
MyStorageBroker.key`
attribute to the class, this key is used to lookup an appropriate storage broker when interacting with a datasetAdd a
dtoolcore.FileHasher
instance that matches the hashing algorithm used by your storage to yourMyStorageBroker.hasher
attributeAdd implementations for all the public functions in
dtoolcore.storagebroker.DiskStorageBroker
class toMyStorageBroker
Expose the
MyStorageBroker
class as adtool.storage_broker
entrypoint, e.g. add a section along the lines of the below to thesetup.py
file:entry_points={ "dtool.storage_brokers": [ "MyStorageBroker=my_dtool_storage_plugin:MyStorageBroker", ], },