Upload register.py with huggingface_hub
Browse files12345678911 unmodified lines212223242526272 unmodified lines303132333435363738394041import importlibimport inspectimport osfrom .artifact import Artifact, Artifactoriesfrom .catalog import PATHS_SEP, GithubCatalog, LocalCatalogfrom .utils import SingletonUNITXT_ARTIFACTORIES_ENV_VAR = "UNITXT_ARTIFACTORIES"11 unmodified linesdef _register_catalog(catalog: LocalCatalog):Artifactories().register_atrifactory(catalog)def register_local_catalog(catalog_path: str):2 unmodified lines_register_catalog(LocalCatalog(location=catalog_path))def _register_all_catalogs():_register_catalog(GithubCatalog())_register_catalog(LocalCatalog())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))def _register_all_artifacts():1234567891011 unmodified lines22232425262728293031322 unmodified lines3536373839404142434445464748495051525354555657import copyimport importlibimport inspectimport osfrom .artifact import Artifact, Artifactoriesfrom .catalog import PATHS_SEP, EnvironmentLocalCatalog, GithubCatalog, LocalCatalogfrom .utils import SingletonUNITXT_ARTIFACTORIES_ENV_VAR = "UNITXT_ARTIFACTORIES"11 unmodified linesdef _register_catalog(catalog: LocalCatalog):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(EnvironmentLocalCatalog(location=path))def _register_all_artifacts():
register.py+19-3