Upload register.py with huggingface_hub
Browse files- register.py +17 -0
register.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .artifact import Artifact
|
| 2 |
+
from . import blocks
|
| 3 |
+
|
| 4 |
+
import inspect
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def register_blocks():
|
| 8 |
+
# Iterate over every object in the blocks module
|
| 9 |
+
for name, obj in inspect.getmembers(blocks):
|
| 10 |
+
# Make sure the object is a class
|
| 11 |
+
if inspect.isclass(obj):
|
| 12 |
+
# Make sure the class is a subclass of Artifact (but not Artifact itself)
|
| 13 |
+
if issubclass(obj, Artifact) and obj is not Artifact:
|
| 14 |
+
Artifact.register_class(obj)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
register_blocks()
|