Skip to content

Commit

Permalink
define the default SSL context (#1574)
Browse files Browse the repository at this point in the history
Signed-off-by: chensuyue <suyue.chen@intel.com>
  • Loading branch information
chensuyue authored Jan 25, 2024
1 parent 31743fe commit b08725a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover
md5 (str): the md5 string.
"""
import urllib
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
root = os.path.expanduser(root)
if not filename:
filename = os.path.basename(url)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@
import tempfile
import urllib.request
import zipfile
import ssl
ssl._create_default_https_context = ssl._create_unverified_context

TASKS = ["CoLA", "SST", "MRPC", "QQP", "STS", "MNLI", "QNLI", "RTE", "WNLI", "diagnostic"]
TASK2PATH = {"CoLA":'https://dl.fbaipublicfiles.com/glue/data/CoLA.zip',
"SST":'https://dl.fbaipublicfiles.com/glue/data/SST-2.zip',
"QQP":'https://dl.fbaipublicfiles.com/glue/data/STS-B.zip',
"STS":'https://dl.fbaipublicfiles.com/glue/data/QQP-clean.zip',
"MNLI":'https://dl.fbaipublicfiles.com/glue/data/MNLI.zip',
"QNLI":'https://dl.fbaipublicfiles.com/glue/data/QNLIv2.zip',
"RTE":'https://dl.fbaipublicfiles.com/glue/data/RTE.zip',
"WNLI":'https://dl.fbaipublicfiles.com/glue/data/WNLI.zip',
"MRPC":"https://raw.githubusercontent.com/MegEngine/Models/master/official/nlp/bert/glue_data/MRPC/dev_ids.tsv",
"diagnostic":'https://dl.fbaipublicfiles.com/glue/data/AX.tsv'}
TASK2PATH = {"CoLA": 'https://dl.fbaipublicfiles.com/glue/data/CoLA.zip',
"SST": 'https://dl.fbaipublicfiles.com/glue/data/SST-2.zip',
"QQP": 'https://dl.fbaipublicfiles.com/glue/data/STS-B.zip',
"STS": 'https://dl.fbaipublicfiles.com/glue/data/QQP-clean.zip',
"MNLI": 'https://dl.fbaipublicfiles.com/glue/data/MNLI.zip',
"QNLI": 'https://dl.fbaipublicfiles.com/glue/data/QNLIv2.zip',
"RTE": 'https://dl.fbaipublicfiles.com/glue/data/RTE.zip',
"WNLI": 'https://dl.fbaipublicfiles.com/glue/data/WNLI.zip',
"MRPC": "https://raw.githubusercontent.com/MegEngine/Models/master/official/nlp/bert/glue_data/MRPC/dev_ids.tsv",
"diagnostic": 'https://dl.fbaipublicfiles.com/glue/data/AX.tsv'}

MRPC_TRAIN = 'https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_train.txt'
MRPC_TEST = 'https://dl.fbaipublicfiles.com/senteval/senteval_data/msr_paraphrase_test.txt'
Expand Down
3 changes: 3 additions & 0 deletions neural_compressor/data/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover
filename (str): the file name for saving.
md5 (str): the md5 string.
"""
import ssl
import urllib

ssl._create_default_https_context = ssl._create_unverified_context

root = os.path.expanduser(root)
if not filename:
filename = os.path.basename(url)
Expand Down
3 changes: 3 additions & 0 deletions neural_compressor/experimental/data/datasets/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,11 @@ def download_url(url, root, filename=None, md5=None): # pragma: no cover
filename (str): the file name for saving.
md5 (str): the md5 string.
"""
import ssl
import urllib

ssl._create_default_https_context = ssl._create_unverified_context

root = os.path.expanduser(root)
if not filename:
filename = os.path.basename(url)
Expand Down
3 changes: 3 additions & 0 deletions test/data/test_exp_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,11 @@ def testRandomResizedCrop(self):

def testSquadV1(self):
import json
import ssl
import urllib

ssl._create_default_https_context = ssl._create_unverified_context

vocab_url = (
"https://raw.githubusercontent.com/microsoft/SDNet/master/bert_vocab_files/bert-large-uncased-vocab.txt"
)
Expand Down
3 changes: 3 additions & 0 deletions test/data/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,11 @@ def testRandomResizedCrop(self):

def testSquadV1(self):
import json
import ssl
import urllib

ssl._create_default_https_context = ssl._create_unverified_context

vocab_url = (
"https://raw.githubusercontent.com/microsoft/SDNet/master/bert_vocab_files/bert-large-uncased-vocab.txt"
)
Expand Down

0 comments on commit b08725a

Please sign in to comment.