-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add datasets full offline mode with HF_DATASETS_OFFLINE (#1976)
* add HF_DATASETS_OFFLINE env var * fail network calls instantly if offline is true * update offline simulation for test env * update tests with new offline mode * minor * docs * Update test_file_utils.py
- Loading branch information
Showing
8 changed files
with
124 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
import pytest | ||
import requests | ||
|
||
from .utils import RequestWouldHangIndefinitelyError, offline | ||
from datasets.utils.file_utils import http_head | ||
|
||
from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline | ||
|
||
|
||
def test_offline_with_timeout(): | ||
with offline(connection_times_out=True): | ||
with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT): | ||
with pytest.raises(RequestWouldHangIndefinitelyError): | ||
requests.request("GET", "https://huggingface.co") | ||
with pytest.raises(requests.exceptions.ConnectTimeout): | ||
requests.request("GET", "https://huggingface.co", timeout=1.0) | ||
|
||
|
||
def test_offline_with_connection_error(): | ||
with offline(connection_times_out=False): | ||
with offline(OfflineSimulationMode.CONNECTION_FAILS): | ||
with pytest.raises(requests.exceptions.ConnectionError): | ||
requests.request("GET", "https://huggingface.co") | ||
|
||
|
||
def test_offline_with_datasets_offline_mode_enabled(): | ||
with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1): | ||
with pytest.raises(ConnectionError): | ||
http_head("https://huggingface.co") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96acc04
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show benchmarks
PyArrow==0.17.1
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json
Show updated benchmarks!
Benchmark: benchmark_array_xd.json
Benchmark: benchmark_indices_mapping.json
Benchmark: benchmark_iterating.json
Benchmark: benchmark_map_filter.json