Skip to content

Commit

Permalink
renamed download_by_prefix to download
Browse files Browse the repository at this point in the history
  • Loading branch information
ymahlich committed Dec 10, 2024
1 parent 7c7342c commit 8ab2d77
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion coderdata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .download.downloader import download_data_by_prefix
from .download.downloader import download
from .load.loader import DatasetLoader, join_datasets
from .split.splitter import train_test_validate
from .dataset.dataset import (
Expand Down
4 changes: 2 additions & 2 deletions coderdata/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
from .download.downloader import download_data_by_prefix
from .download.downloader import download

def main():
parser = argparse.ArgumentParser(prog='coderdata')
Expand All @@ -9,7 +9,7 @@ def main():
parser_download = subparsers.add_parser('download', help='Download datasets')
parser_download.add_argument('--prefix', type=str, default=None,
help='Prefix of the dataset to download (e.g., "hcmi"), "all", or leave empty for all files.')
parser_download.set_defaults(func=download_data_by_prefix)
parser_download.set_defaults(func=download)

args = parser.parse_args()
if hasattr(args, 'func'):
Expand Down
2 changes: 1 addition & 1 deletion coderdata/download/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .downloader import download_data_by_prefix
from .downloader import download

9 changes: 8 additions & 1 deletion coderdata/download/downloader.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# coderdata/download/downloader.py

from pathlib import Path
from os import PathLike
import os
import requests

def download_data_by_prefix(dataset_prefix=None):
def download(
name: str=None,
local_path: PathLike=Path.cwd(),
exist_ok: bool=False
):
"""
Download the most recent version of files from a Figshare dataset, filtered by a specific prefix or all files.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_download_and_load_beataml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tests/test_download_beataml.py

from coderdata.download.downloader import download_data_by_prefix
from coderdata.download.downloader import download
from coderdata.load.loader import DatasetLoader
import os
import glob
Expand All @@ -9,7 +9,7 @@
def test_download_data_beataml():

#BeatAML
download_data_by_prefix('beataml')
download('beataml')

beataml_drugs = glob.glob('beataml_drugs*')
assert len(beataml_drugs) > 0, "File beataml_drugs does not exist."
Expand Down
4 changes: 2 additions & 2 deletions tests/test_download_and_load_cell_line.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tests/test_download_depmap.py

from coderdata.download.downloader import download_data_by_prefix
from coderdata.download.downloader import download
from coderdata.load.loader import DatasetLoader
import os
import glob
Expand All @@ -9,7 +9,7 @@
def test_download_data_depmap():

#depmap
download_data_by_prefix('depmap')
download('depmap')

depmap_samples = glob.glob('depmap_samples*')
assert len(depmap_samples) > 0, "File depmap_samples does not exist."
Expand Down
4 changes: 2 additions & 2 deletions tests/test_download_and_load_cptac.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# tests/test_download_cptac.py

from coderdata.download.downloader import download_data_by_prefix
from coderdata.download.downloader import download
from coderdata.load.loader import DatasetLoader
import os
import glob
Expand All @@ -10,7 +10,7 @@
def test_download_data_cptac():

#CPTAC
download_data_by_prefix('cptac')
download('cptac')

cptac_copy_number = glob.glob('cptac_copy_number*')
assert len(cptac_copy_number) > 0, "File cptac_copy_number does not exist."
Expand Down
4 changes: 2 additions & 2 deletions tests/test_download_and_load_hcmi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tests/test_download_hcmi.py

from coderdata.download.downloader import download_data_by_prefix
from coderdata.download.downloader import download
from coderdata.load.loader import DatasetLoader
import os
import glob
Expand All @@ -9,7 +9,7 @@
def test_download_data_hcmi():

#HCMI
download_data_by_prefix('hcmi')
download('hcmi')

hcmi_mutations = glob.glob('hcmi_mutations*')
assert len(hcmi_mutations) > 0, "File hcmi_mutations does not exist."
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reload_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pandas as pd
import os
from coderdata.load.loader import DatasetLoader
from coderdata.download import download_data_by_prefix
from coderdata.download import download


def test_reload_all_datasets():
download_data_by_prefix("hcmi")
download("hcmi")
loader = DatasetLoader("hcmi")

# Ensure the datasets are initially empty
Expand Down
4 changes: 2 additions & 2 deletions tests/test_reload_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pandas as pd
import os
from coderdata.load.loader import DatasetLoader
from coderdata.download import download_data_by_prefix
from coderdata.download import download


def test_reload_specific_dataset():
download_data_by_prefix("hcmi")
download("hcmi")
loader = DatasetLoader("hcmi")

# Ensure the dataset is initially empty
Expand Down

0 comments on commit 8ab2d77

Please sign in to comment.