Upload register.py with huggingface_hub
Browse files12345667891011 unmodified lines2223242425262728293031322 unmodified lines353637383940414243444546474849505152533854555657import copyimport importlibimport inspectimport os
from .artifact import Artifact, Artifactoriesfrom .catalog import PATHS_SEP, GithubCatalog, LocalCatalogfrom .catalog import PATHS_SEP, EnvironmentLocalCatalog, GithubCatalog, LocalCatalogfrom .utils import Singleton
UNITXT_ARTIFACTORIES_ENV_VAR = "UNITXT_ARTIFACTORIES"11 unmodified lines
def _register_catalog(catalog: LocalCatalog): Artifactories().register_atrifactory(catalog) Artifactories().register(catalog)
def _unregister_catalog(catalog: LocalCatalog): Artifactories().unregister(catalog)
def register_local_catalog(catalog_path: str):2 unmodified lines _register_catalog(LocalCatalog(location=catalog_path))
def _catalogs_list(): return list(a for a in Artifactories())
def _register_all_catalogs(): _register_catalog(GithubCatalog()) _register_catalog(LocalCatalog()) _reset_env_local_catalogs()
def _reset_env_local_catalogs(): for catalog in _catalogs_list(): if isinstance(catalog, EnvironmentLocalCatalog): _unregister_catalog(catalog) if UNITXT_ARTIFACTORIES_ENV_VAR in os.environ: for path in os.environ[UNITXT_ARTIFACTORIES_ENV_VAR].split(PATHS_SEP): _register_catalog(LocalCatalog(location=path)) _register_catalog(EnvironmentLocalCatalog(location=path))
def _register_all_artifacts():register.py+19-3