Upload register.py with huggingface_hub
Browse files- register.py +19 -3
register.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
|
|
| 1 |
import importlib
|
| 2 |
import inspect
|
| 3 |
import os
|
| 4 |
|
| 5 |
from .artifact import Artifact, Artifactories
|
| 6 |
-
from .catalog import PATHS_SEP, GithubCatalog, LocalCatalog
|
| 7 |
from .utils import Singleton
|
| 8 |
|
| 9 |
UNITXT_ARTIFACTORIES_ENV_VAR = "UNITXT_ARTIFACTORIES"
|
|
@@ -21,7 +22,11 @@ non_registered_files = [
|
|
| 21 |
|
| 22 |
|
| 23 |
def _register_catalog(catalog: LocalCatalog):
|
| 24 |
-
Artifactories().
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
|
| 27 |
def register_local_catalog(catalog_path: str):
|
|
@@ -30,12 +35,23 @@ def register_local_catalog(catalog_path: str):
|
|
| 30 |
_register_catalog(LocalCatalog(location=catalog_path))
|
| 31 |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
def _register_all_catalogs():
|
| 34 |
_register_catalog(GithubCatalog())
|
| 35 |
_register_catalog(LocalCatalog())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
if UNITXT_ARTIFACTORIES_ENV_VAR in os.environ:
|
| 37 |
for path in os.environ[UNITXT_ARTIFACTORIES_ENV_VAR].split(PATHS_SEP):
|
| 38 |
-
_register_catalog(
|
| 39 |
|
| 40 |
|
| 41 |
def _register_all_artifacts():
|
|
|
|
| 1 |
+
import copy
|
| 2 |
import importlib
|
| 3 |
import inspect
|
| 4 |
import os
|
| 5 |
|
| 6 |
from .artifact import Artifact, Artifactories
|
| 7 |
+
from .catalog import PATHS_SEP, EnvironmentLocalCatalog, GithubCatalog, LocalCatalog
|
| 8 |
from .utils import Singleton
|
| 9 |
|
| 10 |
UNITXT_ARTIFACTORIES_ENV_VAR = "UNITXT_ARTIFACTORIES"
|
|
|
|
| 22 |
|
| 23 |
|
| 24 |
def _register_catalog(catalog: LocalCatalog):
|
| 25 |
+
Artifactories().register(catalog)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _unregister_catalog(catalog: LocalCatalog):
|
| 29 |
+
Artifactories().unregister(catalog)
|
| 30 |
|
| 31 |
|
| 32 |
def register_local_catalog(catalog_path: str):
|
|
|
|
| 35 |
_register_catalog(LocalCatalog(location=catalog_path))
|
| 36 |
|
| 37 |
|
| 38 |
+
def _catalogs_list():
|
| 39 |
+
return list(a for a in Artifactories())
|
| 40 |
+
|
| 41 |
+
|
| 42 |
def _register_all_catalogs():
|
| 43 |
_register_catalog(GithubCatalog())
|
| 44 |
_register_catalog(LocalCatalog())
|
| 45 |
+
_reset_env_local_catalogs()
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def _reset_env_local_catalogs():
|
| 49 |
+
for catalog in _catalogs_list():
|
| 50 |
+
if isinstance(catalog, EnvironmentLocalCatalog):
|
| 51 |
+
_unregister_catalog(catalog)
|
| 52 |
if UNITXT_ARTIFACTORIES_ENV_VAR in os.environ:
|
| 53 |
for path in os.environ[UNITXT_ARTIFACTORIES_ENV_VAR].split(PATHS_SEP):
|
| 54 |
+
_register_catalog(EnvironmentLocalCatalog(location=path))
|
| 55 |
|
| 56 |
|
| 57 |
def _register_all_artifacts():
|