Upload register.py with huggingface_hub
Browse files- register.py +10 -5
register.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import copy
|
2 |
import importlib
|
3 |
import inspect
|
4 |
import os
|
@@ -31,12 +30,14 @@ def _unregister_catalog(catalog: LocalCatalog):
|
|
31 |
|
32 |
def register_local_catalog(catalog_path: str):
|
33 |
assert os.path.exists(catalog_path), f"Catalog path {catalog_path} does not exist."
|
34 |
-
assert os.path.isdir(
|
|
|
|
|
35 |
_register_catalog(LocalCatalog(location=catalog_path))
|
36 |
|
37 |
|
38 |
def _catalogs_list():
|
39 |
-
return list(
|
40 |
|
41 |
|
42 |
def _register_all_catalogs():
|
@@ -59,12 +60,16 @@ def _register_all_artifacts():
|
|
59 |
file_name = os.path.basename(__file__)
|
60 |
|
61 |
for file in os.listdir(dir):
|
62 |
-
if
|
|
|
|
|
|
|
|
|
63 |
module_name = file.replace(".py", "")
|
64 |
|
65 |
module = importlib.import_module("." + module_name, __package__)
|
66 |
|
67 |
-
for
|
68 |
# Make sure the object is a class
|
69 |
if inspect.isclass(obj):
|
70 |
# Make sure the class is a subclass of Artifact (but not Artifact itself)
|
|
|
|
|
1 |
import importlib
|
2 |
import inspect
|
3 |
import os
|
|
|
30 |
|
31 |
def register_local_catalog(catalog_path: str):
|
32 |
assert os.path.exists(catalog_path), f"Catalog path {catalog_path} does not exist."
|
33 |
+
assert os.path.isdir(
|
34 |
+
catalog_path
|
35 |
+
), f"Catalog path {catalog_path} is not a directory."
|
36 |
_register_catalog(LocalCatalog(location=catalog_path))
|
37 |
|
38 |
|
39 |
def _catalogs_list():
|
40 |
+
return list(Artifactories())
|
41 |
|
42 |
|
43 |
def _register_all_catalogs():
|
|
|
60 |
file_name = os.path.basename(__file__)
|
61 |
|
62 |
for file in os.listdir(dir):
|
63 |
+
if (
|
64 |
+
file.endswith(".py")
|
65 |
+
and file not in non_registered_files
|
66 |
+
and file != file_name
|
67 |
+
):
|
68 |
module_name = file.replace(".py", "")
|
69 |
|
70 |
module = importlib.import_module("." + module_name, __package__)
|
71 |
|
72 |
+
for _name, obj in inspect.getmembers(module):
|
73 |
# Make sure the object is a class
|
74 |
if inspect.isclass(obj):
|
75 |
# Make sure the class is a subclass of Artifact (but not Artifact itself)
|