Metadata-Version: 2.4
Name: biohub-data-cli
Version: 0.4.0
Summary: Biohub data CLI
License: MIT License
        
        Copyright (c) 2025 Chan Zuckerberg Initiative
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/chanzuckerberg/biohub-data-cli
Project-URL: Repository, https://github.com/chanzuckerberg/biohub-data-cli
Project-URL: Issues, https://github.com/chanzuckerberg/biohub-data-cli/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0.0
Requires-Dist: boto3>=1.34.0
Requires-Dist: botocore>=1.34.0
Requires-Dist: requests>=2.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: rich>=13.0.0
Dynamic: license-file

# data-cli

[![CI](https://github.com/chanzuckerberg/biohub-data-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/chanzuckerberg/biohub-data-cli/actions/workflows/ci.yml)
[![Coverage](https://github.com/chanzuckerberg/biohub-data-cli/raw/badges/coverage.svg)](https://github.com/chanzuckerberg/biohub-data-cli/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/biohub-data-cli.svg)](https://pypi.org/project/biohub-data-cli/)
[![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fchanzuckerberg%2Fbiohub-data-cli%2Fmain%2Fpyproject.toml)](https://github.com/chanzuckerberg/biohub-data-cli/blob/main/pyproject.toml)

Command-line tool for downloading datasets published by CZ Biohub. Resolves a collection ID to its constituent datasets and downloads files from S3 and HTTP, with progress bars, size estimates, and dry-run accounting.

## Installation

To install the OPS data CLI, run:

```bash
pip install biohub-data-cli
```

## Quick start

See what a collection contains without downloading:

```bash
ops-data download collection <collection-id> --dry-run
```

Download a collection to the current directory:

```bash
ops-data download collection <collection-id>
```

Download multiple collections to a specific directory, skipping the prompt:

```bash
ops-data download collection <id-a> <id-b> -o ./data -y
```

Files land under `<outdir>/<collection-slug>/<dataset-slug>/`.

## Commands

### `ops-data download collection IDS...`

Download one or more collections by ID.

| Option | Description |
|--------|-------------|
| `-o, --outdir PATH` | Output directory. Defaults to `.`. |
| `-y, --yes` | Skip the size-estimate confirmation prompt. |
| `--dry-run` | Print per-dataset size statistics without downloading. Mutually exclusive with `-y`. |

**Dry run** resolves every S3 URI (listing prefixes, heading objects) to report exact byte totals per dataset. HTTP URLs are not sized during dry run and surface as a warning in the summary.

**Confirmation prompt** shows the aggregate size estimate before any bytes move. Pass `-y` to skip it in scripts.

**Failures** are collected and reported at the end. The process exits non-zero if any download failed, but other downloads continue — one bad URL won't abort the run.

## Development

This project uses [`uv`](https://docs.astral.sh/uv/) for dependency management.

Install dependencies (including dev extras):

```bash
uv sync
```

Run tests:

```bash
uv run pytest
```

Run tests with coverage report:

```bash
uv run pytest --cov=biohub_data_cli --cov-report=term-missing
```

Run the CLI from a checkout:

```bash
uv run ops-data --help
```

### Integration tests

Tests marked `integration` hit real S3 buckets / HTTP servers and are deselected by default. Run them explicitly:

```bash
uv run pytest -m integration
```

## Code of Conduct

This project adheres to the Contributor Covenant [code of conduct](https://github.com/chanzuckerberg/.github/blob/master/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [opensource@chanzuckerberg.com](mailto:opensource@chanzuckerberg.com).

## Reporting Security Issues

If you believe you have found a security issue, please responsibly disclose by contacting us at [security@chanzuckerberg.com](mailto:security@chanzuckerberg.com).
