offline mode for firewalled envs (#10407)

* offline mode start

* add specific values

* fix fallback

* add test

* better values check and range

* test that actually works

* document the offline mode

* Apply suggestions from code review

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>

* more strict check

* cleaner test

* pt-only test

* style

Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
Stas Bekman
2021-03-05 17:27:48 -08:00
committed by GitHub
parent 90ecc29656
commit 88a951e3cc
7 changed files with 111 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ from .file_utils import (
cached_path,
hf_bucket_url,
is_flax_available,
is_offline_mode,
is_remote_url,
is_tf_available,
is_tokenizers_available,
@@ -1597,6 +1598,10 @@ class PreTrainedTokenizerBase(SpecialTokensMixin):
revision = kwargs.pop("revision", None)
subfolder = kwargs.pop("subfolder", None)
if is_offline_mode() and not local_files_only:
logger.info("Offline mode: forcing local_files_only=True")
local_files_only = True
s3_models = list(cls.max_model_input_sizes.keys())
pretrained_model_name_or_path = str(pretrained_model_name_or_path)
vocab_files = {}