Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Lint

on: [pull_request]
on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: psf/black@stable
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pip install ruff
- run: ruff check .
- run: ruff format --check .
19 changes: 9 additions & 10 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ on:

jobs:
deploy:
name: upload release to PyPI
runs-on: ubuntu-latest
name: upload release to PyPI
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
run: |
python setup.py sdist bdist_wheel
- name: Install build dependencies
run: python -m pip install --upgrade pip build
- name: Build package
run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
18 changes: 8 additions & 10 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,26 @@ on:
branches: [dev]
pull_request:
branches: [master, dev]
workflow_dispatch:

jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.9", "3.13"]
os: [ubuntu-latest]
python-version: ["3.10", "3.14"]
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install test dependencies
run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi

- name: Install package
run: python -m pip install .
- name: Install package with test dependencies
run: python -m pip install ".[test]"

- name: Run pytest tests
run: pytest tests -x -vv
run: pytest tests
9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

15 changes: 11 additions & 4 deletions geofetch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
"""Package-level data"""
"""Package-level data."""

from importlib.metadata import PackageNotFoundError, version

import coloredlogs
import logmuse

from geofetch._version import __version__
from geofetch.finder import Finder
from geofetch.geofetch import Geofetcher

__author__ = ["Oleksandr Khoroshevskyi", "Vince Reuter", "Nathan Sheffield"]
__all__ = ["Finder", "Geofetcher", "__version__"]
__author__: list[str] = ["Oleksandr Khoroshevskyi", "Vince Reuter", "Nathan Sheffield"]

try:
__version__: str = version("geofetch")
except PackageNotFoundError:
__version__ = "unknown"

__all__: list[str] = ["Finder", "Geofetcher", "__version__"]

_LOGGER = logmuse.init_logger("geofetch")
coloredlogs.install(
Expand Down
1 change: 0 additions & 1 deletion geofetch/_version.py

This file was deleted.

61 changes: 35 additions & 26 deletions geofetch/cli.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import argparse
import os
from importlib.metadata import PackageNotFoundError, version

import logmuse
from ubiquerg import VersionInHelpParser

from geofetch._version import __version__


def _safe_echo(var):
"""Returns an environment variable if it exists, or an empty string if not"""
def _safe_echo(var: str) -> str:
"""Return an environment variable if it exists, or an empty string if not."""
return os.getenv(var, "")


def _parse_cmdl(cmdl):
"""
parser
"""
def _get_version() -> str:
"""Return the package version, or 'unknown' if not installed."""
try:
return version("geofetch")
except PackageNotFoundError:
return "unknown"


def _parse_cmdl(cmdl: list[str]) -> argparse.Namespace:
"""Parse command-line arguments for geofetch."""
parser = VersionInHelpParser(
description="Automatic GEO and SRA data downloader",
usage="""geofetch [<args>]
Expand All @@ -27,7 +32,7 @@ def _parse_cmdl(cmdl):
geofetch -i GSE67303 --processed --geo-folder <folder> -m <folder>

""",
version=__version__,
version=_get_version(),
)

processed_group = parser.add_argument_group("processed")
Expand All @@ -54,7 +59,7 @@ def _parse_cmdl(cmdl):
default=_safe_echo("SRAMETA"),
help="Specify a parent folder location to store metadata. "
"The project name will be added as a subfolder "
"[Default: $SRAMETA:" + _safe_echo("SRAMETA") + "]",
"(Default: $SRAMETA:" + _safe_echo("SRAMETA") + ")",
)

parser.add_argument(
Expand Down Expand Up @@ -87,7 +92,7 @@ def _parse_cmdl(cmdl):
default=None,
help="Optional: Specify one or more filepaths to SAMPLES pipeline interface yaml files. "
"These will be added to the project config file to make it immediately "
"compatible with looper. [Default: null]",
"compatible with looper. (Default: null)",
)

# Optional
Expand All @@ -96,7 +101,7 @@ def _parse_cmdl(cmdl):
default=None,
help="Optional: Specify one or more filepaths to PROJECT pipeline interface yaml files. "
"These will be added to the project config file to make it immediately "
"compatible with looper. [Default: null]",
"compatible with looper. (Default: null)",
)
# Optional
parser.add_argument(
Expand All @@ -111,7 +116,7 @@ def _parse_cmdl(cmdl):
"--skip",
default=0,
type=int,
help="Skip some accessions. [Default: no skip].",
help="Skip some accessions. (Default: no skip).",
)

parser.add_argument(
Expand All @@ -132,15 +137,15 @@ def _parse_cmdl(cmdl):
type=int,
default=50,
help="Optional: Limit of the number of the constant sample characters "
"that should not be in project yaml. [Default: 50]",
"that should not be in project yaml. (Default: 50)",
)

parser.add_argument(
"--const-limit-discard",
type=int,
default=1000,
help="Optional: Limit of the number of the constant sample characters "
"that should not be discarded [Default: 250]",
"that should not be discarded (Default: 250)",
)

parser.add_argument(
Expand All @@ -149,7 +154,7 @@ def _parse_cmdl(cmdl):
default=500,
help="Optional: Limit of the number of sample characters."
"Any attribute with more than X characters will truncate to the first X,"
" where X is a number of characters [Default: 500]",
" where X is a number of characters (Default: 500)",
)

parser.add_argument(
Expand All @@ -163,7 +168,7 @@ def _parse_cmdl(cmdl):
type=str,
default="1GB",
help="""Optional: Max size of soft file.
[Default: 1GB].
(Default: 1GB).
Supported input formats : 12B, 12KB, 12MB, 12GB. """,
)

Expand All @@ -178,7 +183,7 @@ def _parse_cmdl(cmdl):
"--processed",
default=False,
action="store_true",
help="Download processed data [Default: download raw data].",
help="Download processed data (Default: download raw data).",
)

processed_group.add_argument(
Expand All @@ -190,13 +195,13 @@ def _parse_cmdl(cmdl):
" to retrieve processed data, which may be attached to the"
" collective series entity, or to individual samples. "
"Allowable values are: samples, series or both (all). "
"Ignored unless 'processed' flag is set. [Default: samples]",
"Ignored unless 'processed' flag is set. (Default: samples)",
)

processed_group.add_argument(
"--filter",
default=None,
help="Optional: Filter regex for processed filenames [Default: None]."
help="Optional: Filter regex for processed filenames (Default: None)."
"Ignored unless 'processed' flag is set.",
)

Expand All @@ -205,7 +210,7 @@ def _parse_cmdl(cmdl):
dest="filter_size",
default=None,
help="""Optional: Filter size for processed files
that are stored as sample repository [Default: None].
that are stored as sample repository (Default: None).
Works only for sample data.
Supported input formats : 12B, 12KB, 12MB, 12GB.
Ignored unless 'processed' flag is set.""",
Expand All @@ -217,7 +222,7 @@ def _parse_cmdl(cmdl):
default=_safe_echo("GEODATA"),
help="Optional: Specify a location to store processed GEO files."
" Ignored unless 'processed' flag is set."
"[Default: $GEODATA:" + _safe_echo("GEODATA") + "]",
"(Default: $GEODATA:" + _safe_echo("GEODATA") + ")",
)

raw_group.add_argument(
Expand All @@ -238,7 +243,9 @@ def _parse_cmdl(cmdl):
default=_safe_echo("SRABAM"),
help="""Optional: Specify folder of bam files. Geofetch will not
download sra files when corresponding bam files already exist.
[Default: $SRABAM:""" + _safe_echo("SRABAM") + "]",
(Default: $SRABAM:"""
+ _safe_echo("SRABAM")
+ ")",
)

raw_group.add_argument(
Expand All @@ -248,7 +255,9 @@ def _parse_cmdl(cmdl):
default=_safe_echo("SRAFQ"),
help="""Optional: Specify folder of fastq files. Geofetch will not
download sra files when corresponding fastq files already exist.
[Default: $SRAFQ:""" + _safe_echo("SRAFQ") + "]",
(Default: $SRAFQ:"""
+ _safe_echo("SRAFQ")
+ ")",
)

# Deprecated; these are for bam conversion which now happens in sra_convert
Expand All @@ -260,7 +269,7 @@ def _parse_cmdl(cmdl):
default=_safe_echo("SRARAW"),
help=argparse.SUPPRESS,
# help="Optional: Specify a location to store sra files "
# "[Default: $SRARAW:" + safe_echo("SRARAW") + "]"
# "(Default: $SRARAW:" + safe_echo("SRARAW") + ")"
)
raw_group.add_argument(
"--bam-conversion",
Expand All @@ -274,7 +283,7 @@ def _parse_cmdl(cmdl):
dest="picard_path",
default=_safe_echo("PICARD"),
# help="Specify a path to the picard jar, if you want to convert "
# "fastq to bam [Default: $PICARD:" + safe_echo("PICARD") + "]",
# "fastq to bam (Default: $PICARD:" + safe_echo("PICARD") + ")",
help=argparse.SUPPRESS,
)

Expand Down
Loading