offline mode for firewalled envs (part 2) (#10569)

* more readable test

* add all the missing places

* one more nltk

* better exception check

* revert
This commit is contained in:
Stas Bekman
2021-03-08 08:52:20 -08:00
committed by GitHub
parent 5469369480
commit 6f84531e61
5 changed files with 42 additions and 6 deletions

View File

@@ -28,7 +28,7 @@ from flax.traverse_util import flatten_dict, unflatten_dict
from jax.random import PRNGKey
from .configuration_utils import PretrainedConfig
from .file_utils import FLAX_WEIGHTS_NAME, WEIGHTS_NAME, cached_path, hf_bucket_url, is_remote_url
from .file_utils import FLAX_WEIGHTS_NAME, WEIGHTS_NAME, cached_path, hf_bucket_url, is_offline_mode, is_remote_url
from .utils import logging
@@ -229,6 +229,10 @@ class FlaxPreTrainedModel(ABC):
use_auth_token = kwargs.pop("use_auth_token", None)
revision = kwargs.pop("revision", None)
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
# Load config if we don't provide a configuration
if not isinstance(config, PretrainedConfig):
config_path = config if config is not None else pretrained_model_name_or_path