ljw20180420 commited on
Commit
ec12cc6
·
verified ·
1 Parent(s): 0f706b8

Upload CRISPR_data.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. CRISPR_data.py +16 -3
CRISPR_data.py CHANGED
@@ -601,9 +601,22 @@ class CRISPRData(datasets.GeneratorBasedBuilder):
601
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
602
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
603
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
604
- hf_endpoint = os.environ.get("HF_ENDPOINT", "https://" + "huggingface.co")
605
- downloaded_files = dl_manager.download(f"{hf_endpoint}/datasets/ljw20180420/CRISPR_data/resolve/main/dataset.json.gz")
606
- # downloaded_files = dl_manager.download("https://github.com/ljw20180420/CRISPRdata/raw/refs/heads/main/dataset.json.gz")
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  # downloaded_files = dl_manager.download("./test.json.gz")
608
 
609
  ds = datasets.load_dataset('json', data_files=downloaded_files, features=datasets.Features({
 
601
  # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
602
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
603
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
604
+ proxy_url = os.environ.get("MY_HF_DATASETS_DOWNLOAD_MANAGER_PROXY")
605
+ if proxy_url:
606
+ from datasets.download.download_manager import DownloadManager, DownloadConfig
607
+ dl_manager_proxy = DownloadManager(
608
+ download_config=DownloadConfig(
609
+ proxies={
610
+ "http": proxy_url,
611
+ "https": proxy_url
612
+ }
613
+ )
614
+ )
615
+ downloaded_files = dl_manager_proxy.download("https://github.com/ljw20180420/CRISPRdata/raw/refs/heads/main/dataset.json.gz")
616
+ else:
617
+ downloaded_files = dl_manager.download("https://github.com/ljw20180420/CRISPRdata/raw/refs/heads/main/dataset.json.gz")
618
+ # hf_endpoint = os.environ.get("HF_ENDPOINT", "https://" + "huggingface.co")
619
+ # downloaded_files = dl_manager.download(f"{hf_endpoint}/datasets/ljw20180420/CRISPR_data/resolve/main/dataset.json.gz")
620
  # downloaded_files = dl_manager.download("./test.json.gz")
621
 
622
  ds = datasets.load_dataset('json', data_files=downloaded_files, features=datasets.Features({