Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Oct 12, 2023
1 parent e7c7b40 commit 23892a2
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: python3 -m pip instlall ".[test]"
run: python3 -m pip install ".[test]"

- name: Run tests
run: python3 -m pytest tests/
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# WagsTails

Data acquisition tools for Wagnerds
Data acquisition tools for Wagnerds.

## Installation

Install from PyPI:

```shell
python3 -m pip install wagstails
```

## Usage

Data source classes provide a `get_latest()` method that acquires the most recent available data file and returns a pathlib.Path object with its location:

```pycon
>>> from wagstails.mondo import MondoData
>>> m = MondoData()
>>> m.get_latest(force_refresh=True)
Downloading mondo.owl: 100%|█████████████████| 171M/171M [00:28<00:00, 6.23MB/s]
PosixPath('/Users/genomicmedlab/.local/share/wagstails/mondo/mondo_v2023-09-12.owl')
```

## Configuration

All data is stored within source-specific subdirectories of a designated WagsTails data directory. By default, this location is `~/.local/share/wagstails/`, but it can be configured by passing a Path directly to a data class on initialization, via the `$WAGSTAILS` environment variable, or via [XDG data environment variables](https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html).
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dev = ["pre-commit", "black", "ruff"]

[project.urls]
Homepage = "https://github.com/GenomicMedLab/WagsTails/"
# Documentation = ""
Changelog = "https://github.com/GenomicMedLab/WagsTails/releases"
Source = "https://github.com/GenomicMedLab/WagsTails/"
"Bug Tracker" = "https://github.com/GenomicMedLab/WagsTails/issues"
Expand Down
4 changes: 4 additions & 0 deletions src/wagstails/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
"""Data acquisition tools for Wagnerds."""
from .chembl import ChemblData
from .mondo import MondoData

__all__ = ["MondoData", "ChemblData"]
8 changes: 7 additions & 1 deletion src/wagstails/base_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ def __init__(self, data_dir: Optional[Path] = None, silent: bool = True) -> None
data_dir = self._get_data_base() / self._src_name
data_dir.mkdir(exist_ok=True)
self._data_dir = data_dir
self._tqdm_params = {"unit": "B", "ncols": 80, "disable": silent}
self._tqdm_params = {
"unit": "B",
"ncols": 80,
"disable": silent,
"unit_divisor": 1024,
"unit_scale": True,
}

@abc.abstractmethod
def get_latest(self, from_local: bool = False, force_refresh: bool = False) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion src/wagstails/chembl.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ChemblData(DataSource):
"""Provide access to ChEMBL database."""

def __init__(self, data_dir: Optional[Path] = None, silent: bool = True) -> None:
def __init__(self, data_dir: Optional[Path] = None, silent: bool = False) -> None:
"""Set common class parameters.
:param data_dir: direct location to store data files in. If not provided, tries
Expand Down
2 changes: 1 addition & 1 deletion src/wagstails/mondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class MondoData(GitHubDataSource):
"""Provide access to Mondo disease ontology data."""

def __init__(self, data_dir: Optional[Path] = None, silent: bool = True) -> None:
def __init__(self, data_dir: Optional[Path] = None, silent: bool = False) -> None:
"""Set common class parameters.
:param data_dir: direct location to store data files in. If not provided, tries
Expand Down
2 changes: 1 addition & 1 deletion tests/test_chembl.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def chembl_data_dir(base_data_dir: Path):
@pytest.fixture(scope="function")
def chembl(chembl_data_dir: Path):
"""Provide ChemblData fixture"""
return ChemblData(chembl_data_dir)
return ChemblData(chembl_data_dir, silent=True)


@pytest.fixture(scope="module")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mondo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def mondo_data_dir(base_data_dir: Path):
@pytest.fixture(scope="function")
def mondo(mondo_data_dir: Path):
"""Provide MondoData fixture"""
return MondoData(mondo_data_dir)
return MondoData(mondo_data_dir, silent=True)


@pytest.fixture(scope="module")
Expand Down

0 comments on commit 23892a2

Please sign in to comment.