Skip to content

Commit 58b983c

Browse files
Merge pull request #151 from pepkit/modernize3
Release 0.12.11
2 parents 5b4a7ea + b0aaa5b commit 58b983c

18 files changed

+846
-687
lines changed

.github/workflows/black.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
name: Lint
22

3-
on: [pull_request]
3+
on: [push, pull_request]
44

55
jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v4
10-
- uses: actions/setup-python@v5
11-
- uses: psf/black@stable
9+
- uses: actions/checkout@v6
10+
- uses: actions/setup-python@v6
11+
with:
12+
python-version: "3.12"
13+
- run: pip install ruff
14+
- run: ruff check .
15+
- run: ruff format --check .

.github/workflows/python-publish.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@ on:
66

77
jobs:
88
deploy:
9-
name: upload release to PyPI
109
runs-on: ubuntu-latest
10+
name: upload release to PyPI
1111
permissions:
12+
contents: read
1213
id-token: write
14+
1315
steps:
14-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
1517
- name: Set up Python
16-
uses: actions/setup-python@v5
18+
uses: actions/setup-python@v6
1719
with:
1820
python-version: '3.x'
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install setuptools wheel twine
23-
- name: Build and publish
24-
run: |
25-
python setup.py sdist bdist_wheel
21+
- name: Install build dependencies
22+
run: python -m pip install --upgrade pip build
23+
- name: Build package
24+
run: python -m build
2625
- name: Publish package distributions to PyPI
2726
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run-pytest.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@ on:
55
branches: [dev]
66
pull_request:
77
branches: [master, dev]
8+
workflow_dispatch:
89

910
jobs:
1011
pytest:
1112
runs-on: ${{ matrix.os }}
1213
strategy:
1314
matrix:
14-
python-version: ["3.9", "3.13"]
15-
os: [ubuntu-latest]
15+
python-version: ["3.10", "3.14"]
16+
os: [ubuntu-latest, macos-latest]
1617

1718
steps:
18-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v6
1920

2021
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v5
22+
uses: actions/setup-python@v6
2223
with:
2324
python-version: ${{ matrix.python-version }}
2425

25-
- name: Install test dependencies
26-
run: if [ -f requirements/requirements-test.txt ]; then pip install -r requirements/requirements-test.txt; fi
27-
28-
- name: Install package
29-
run: python -m pip install .
26+
- name: Install package with test dependencies
27+
run: python -m pip install ".[test]"
3028

3129
- name: Run pytest tests
32-
run: pytest tests -x -vv
30+
run: pytest tests

MANIFEST.in

Lines changed: 0 additions & 9 deletions
This file was deleted.

geofetch/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
"""Package-level data"""
1+
"""Package-level data."""
2+
3+
from importlib.metadata import PackageNotFoundError, version
24

35
import coloredlogs
46
import logmuse
57

6-
from geofetch._version import __version__
78
from geofetch.finder import Finder
89
from geofetch.geofetch import Geofetcher
910

10-
__author__ = ["Oleksandr Khoroshevskyi", "Vince Reuter", "Nathan Sheffield"]
11-
__all__ = ["Finder", "Geofetcher", "__version__"]
11+
__author__: list[str] = ["Oleksandr Khoroshevskyi", "Vince Reuter", "Nathan Sheffield"]
12+
13+
try:
14+
__version__: str = version("geofetch")
15+
except PackageNotFoundError:
16+
__version__ = "unknown"
17+
18+
__all__: list[str] = ["Finder", "Geofetcher", "__version__"]
1219

1320
_LOGGER = logmuse.init_logger("geofetch")
1421
coloredlogs.install(

geofetch/_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

geofetch/cli.py

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import argparse
22
import os
3+
from importlib.metadata import PackageNotFoundError, version
34

45
import logmuse
56
from ubiquerg import VersionInHelpParser
67

7-
from geofetch._version import __version__
88

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

1413

15-
def _parse_cmdl(cmdl):
16-
"""
17-
parser
18-
"""
14+
def _get_version() -> str:
15+
"""Return the package version, or 'unknown' if not installed."""
16+
try:
17+
return version("geofetch")
18+
except PackageNotFoundError:
19+
return "unknown"
20+
21+
22+
def _parse_cmdl(cmdl: list[str]) -> argparse.Namespace:
23+
"""Parse command-line arguments for geofetch."""
1924
parser = VersionInHelpParser(
2025
description="Automatic GEO and SRA data downloader",
2126
usage="""geofetch [<args>]
@@ -27,7 +32,7 @@ def _parse_cmdl(cmdl):
2732
geofetch -i GSE67303 --processed --geo-folder <folder> -m <folder>
2833
2934
""",
30-
version=__version__,
35+
version=_get_version(),
3136
)
3237

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

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

9398
# Optional
@@ -96,7 +101,7 @@ def _parse_cmdl(cmdl):
96101
default=None,
97102
help="Optional: Specify one or more filepaths to PROJECT pipeline interface yaml files. "
98103
"These will be added to the project config file to make it immediately "
99-
"compatible with looper. [Default: null]",
104+
"compatible with looper. (Default: null)",
100105
)
101106
# Optional
102107
parser.add_argument(
@@ -111,7 +116,7 @@ def _parse_cmdl(cmdl):
111116
"--skip",
112117
default=0,
113118
type=int,
114-
help="Skip some accessions. [Default: no skip].",
119+
help="Skip some accessions. (Default: no skip).",
115120
)
116121

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

138143
parser.add_argument(
139144
"--const-limit-discard",
140145
type=int,
141146
default=1000,
142147
help="Optional: Limit of the number of the constant sample characters "
143-
"that should not be discarded [Default: 250]",
148+
"that should not be discarded (Default: 250)",
144149
)
145150

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

155160
parser.add_argument(
@@ -163,7 +168,7 @@ def _parse_cmdl(cmdl):
163168
type=str,
164169
default="1GB",
165170
help="""Optional: Max size of soft file.
166-
[Default: 1GB].
171+
(Default: 1GB).
167172
Supported input formats : 12B, 12KB, 12MB, 12GB. """,
168173
)
169174

@@ -178,7 +183,7 @@ def _parse_cmdl(cmdl):
178183
"--processed",
179184
default=False,
180185
action="store_true",
181-
help="Download processed data [Default: download raw data].",
186+
help="Download processed data (Default: download raw data).",
182187
)
183188

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

196201
processed_group.add_argument(
197202
"--filter",
198203
default=None,
199-
help="Optional: Filter regex for processed filenames [Default: None]."
204+
help="Optional: Filter regex for processed filenames (Default: None)."
200205
"Ignored unless 'processed' flag is set.",
201206
)
202207

@@ -205,7 +210,7 @@ def _parse_cmdl(cmdl):
205210
dest="filter_size",
206211
default=None,
207212
help="""Optional: Filter size for processed files
208-
that are stored as sample repository [Default: None].
213+
that are stored as sample repository (Default: None).
209214
Works only for sample data.
210215
Supported input formats : 12B, 12KB, 12MB, 12GB.
211216
Ignored unless 'processed' flag is set.""",
@@ -217,7 +222,7 @@ def _parse_cmdl(cmdl):
217222
default=_safe_echo("GEODATA"),
218223
help="Optional: Specify a location to store processed GEO files."
219224
" Ignored unless 'processed' flag is set."
220-
"[Default: $GEODATA:" + _safe_echo("GEODATA") + "]",
225+
"(Default: $GEODATA:" + _safe_echo("GEODATA") + ")",
221226
)
222227

223228
raw_group.add_argument(
@@ -238,7 +243,9 @@ def _parse_cmdl(cmdl):
238243
default=_safe_echo("SRABAM"),
239244
help="""Optional: Specify folder of bam files. Geofetch will not
240245
download sra files when corresponding bam files already exist.
241-
[Default: $SRABAM:""" + _safe_echo("SRABAM") + "]",
246+
(Default: $SRABAM:"""
247+
+ _safe_echo("SRABAM")
248+
+ ")",
242249
)
243250

244251
raw_group.add_argument(
@@ -248,7 +255,9 @@ def _parse_cmdl(cmdl):
248255
default=_safe_echo("SRAFQ"),
249256
help="""Optional: Specify folder of fastq files. Geofetch will not
250257
download sra files when corresponding fastq files already exist.
251-
[Default: $SRAFQ:""" + _safe_echo("SRAFQ") + "]",
258+
(Default: $SRAFQ:"""
259+
+ _safe_echo("SRAFQ")
260+
+ ")",
252261
)
253262

254263
# Deprecated; these are for bam conversion which now happens in sra_convert
@@ -260,7 +269,7 @@ def _parse_cmdl(cmdl):
260269
default=_safe_echo("SRARAW"),
261270
help=argparse.SUPPRESS,
262271
# help="Optional: Specify a location to store sra files "
263-
# "[Default: $SRARAW:" + safe_echo("SRARAW") + "]"
272+
# "(Default: $SRARAW:" + safe_echo("SRARAW") + ")"
264273
)
265274
raw_group.add_argument(
266275
"--bam-conversion",
@@ -274,7 +283,7 @@ def _parse_cmdl(cmdl):
274283
dest="picard_path",
275284
default=_safe_echo("PICARD"),
276285
# help="Specify a path to the picard jar, if you want to convert "
277-
# "fastq to bam [Default: $PICARD:" + safe_echo("PICARD") + "]",
286+
# "fastq to bam (Default: $PICARD:" + safe_echo("PICARD") + ")",
278287
help=argparse.SUPPRESS,
279288
)
280289

0 commit comments

Comments
 (0)