Skip to content

Commit fac0ccd

Browse files
Merge pull request #132 from pepkit/dev
Release 0.12.6
2 parents d49c5d0 + b88522c commit fac0ccd

File tree

11 files changed

+76
-77
lines changed

11 files changed

+76
-77
lines changed
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This workflows will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
41
name: Upload Python Package
52

63
on:
@@ -9,9 +6,10 @@ on:
96

107
jobs:
118
deploy:
12-
9+
name: upload release to PyPI
1310
runs-on: ubuntu-latest
14-
11+
permissions:
12+
id-token: write
1513
steps:
1614
- uses: actions/checkout@v2
1715
- name: Set up Python
@@ -23,9 +21,7 @@ jobs:
2321
python -m pip install --upgrade pip
2422
pip install setuptools wheel twine
2523
- name: Build and publish
26-
env:
27-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
28-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2924
run: |
3025
python setup.py sdist bdist_wheel
31-
twine upload dist/*
26+
- name: Publish package distributions to PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run-codecov.yml

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

.github/workflows/run-pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ["3.8", "3.11"]
14+
python-version: ["3.8", "3.12"]
1515
os: [ubuntu-latest]
1616

1717
steps:

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ geofetch -i GSE95654 --just-metadata
5454
geofetch -i GSE95654 --processed --just-metadata
5555
```
5656

57+
58+
⁣**Note:** We ensure that GEOfetch is compatible with Unix, Linux, and Mac OS X.
59+
However, due to dependencies, some features of GEOfetch may not be available on Windows.
60+
5761
### Check out what exactly argument you want to use to download data:
5862

5963
![](./img/arguments_outputs.svg)

docs/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## [0.12.6] -- 2024-02-05
4+
- Updated support for Windows in Prefetch (Note: Some functionality may still be unavailable on Windows)
5+
36
## [0.12.5] -- 2023-11-29
47
- Fixed bug, where description was not populated in PEP
58

docs_jupyter/python-usage.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,13 @@
138138
}
139139
],
140140
"source": [
141-
"geof = Geofetcher(processed=True, data_source=\"all\", const_limit_project = 20, const_limit_discard = 500, attr_limit_truncate = 10000 )"
141+
"geof = Geofetcher(\n",
142+
" processed=True,\n",
143+
" data_source=\"all\",\n",
144+
" const_limit_project=20,\n",
145+
" const_limit_discard=500,\n",
146+
" attr_limit_truncate=10000,\n",
147+
")"
142148
]
143149
},
144150
{
@@ -418,7 +424,7 @@
418424
}
419425
],
420426
"source": [
421-
"len(projects['GSE95654_samples'].samples)"
427+
"len(projects[\"GSE95654_samples\"].samples)"
422428
]
423429
},
424430
{
@@ -684,7 +690,7 @@
684690
}
685691
],
686692
"source": [
687-
"projects['GSE95654_samples'].sample_table.iloc[:15 , :5]"
693+
"projects[\"GSE95654_samples\"].sample_table.iloc[:15, :5]"
688694
]
689695
}
690696
],

geofetch/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" Package-level data """
2+
23
import logmuse
34
import coloredlogs
45

geofetch/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.12.5"
1+
__version__ = "0.12.6"

geofetch/geofetch.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from rich.progress import track
1212
import re
1313
import logmuse
14-
from ubiquerg import expandpath, is_command_callable
14+
from ubiquerg import expandpath
1515
from typing import List, Union, Dict, Tuple, NoReturn
1616
import peppy
1717
import pandas as pd
@@ -59,6 +59,7 @@
5959
_filter_gsm,
6060
_unify_list_keys,
6161
gse_content_to_dict,
62+
is_prefetch_callable,
6263
)
6364

6465
_LOGGER = logging.getLogger(__name__)
@@ -371,10 +372,10 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
371372

372373
# check to make sure prefetch is callable
373374
if not self.just_metadata and not self.processed:
374-
if not is_command_callable("prefetch"):
375+
if not is_prefetch_callable():
375376
raise SystemExit(
376-
"To download raw data You must first install the sratoolkit, with prefetch in your PATH."
377-
" Installation instruction: http://geofetch.databio.org/en/latest/install/"
377+
"To download raw data, you must first install the sratoolkit, with prefetch in your PATH. "
378+
"Installation instruction: http://geofetch.databio.org/en/latest/install/"
378379
)
379380

380381
acc_GSE_list = parse_accessions(
@@ -546,9 +547,9 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
546547
name=self.project_name,
547548
meta_processed_samples=processed_metadata_samples,
548549
meta_processed_series=processed_metadata_series,
549-
gse_meta_dict=file_gse_content_dict
550-
if len(acc_GSE_list.keys()) == 1
551-
else None,
550+
gse_meta_dict=(
551+
file_gse_content_dict if len(acc_GSE_list.keys()) == 1 else None
552+
),
552553
)
553554
if self.just_object:
554555
return return_value
@@ -559,9 +560,9 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
559560
f"{self.project_name}_PEP",
560561
metadata_dict_combined,
561562
subannotation_dict_combined,
562-
gse_meta_dict=file_gse_content_dict
563-
if len(acc_GSE_list.keys()) == 1
564-
else None,
563+
gse_meta_dict=(
564+
file_gse_content_dict if len(acc_GSE_list.keys()) == 1 else None
565+
),
565566
)
566567
if self.just_object:
567568
return return_value
@@ -1036,7 +1037,7 @@ def _write_processed_annotation(
10361037
)
10371038

10381039
if not just_object:
1039-
with open(file_annotation_path, "w") as m_file:
1040+
with open(file_annotation_path, "w", encoding="utf-8") as m_file:
10401041
dict_writer = csv.DictWriter(m_file, processed_metadata[0].keys())
10411042
dict_writer.writeheader()
10421043
dict_writer.writerows(processed_metadata)
@@ -1789,15 +1790,22 @@ def _download_processed_file(self, file_url: str, data_folder: str) -> bool:
17891790
return True
17901791

17911792
except IOError as e:
1792-
_LOGGER.error(str(e))
1793-
# The server times out if we are hitting it too frequently,
1794-
# so we should sleep a bit to reduce frequency
1795-
sleeptime = (ntry + 1) ** 3
1796-
_LOGGER.info(f"Sleeping for {sleeptime} seconds")
1797-
time.sleep(sleeptime)
1798-
ntry += 1
1799-
if ntry > 4:
1800-
raise e
1793+
if os.name == "nt":
1794+
_LOGGER.error(f"{e}")
1795+
raise OSError(
1796+
"Windows may not have wget command. "
1797+
"Check if `wget` command is installed correctly."
1798+
)
1799+
else:
1800+
_LOGGER.error(str(e))
1801+
# The server times out if we are hitting it too frequently,
1802+
# so we should sleep a bit to reduce frequency
1803+
sleeptime = (ntry + 1) ** 3
1804+
_LOGGER.info(f"Sleeping for {sleeptime} seconds")
1805+
time.sleep(sleeptime)
1806+
ntry += 1
1807+
if ntry > 4:
1808+
raise e
18011809

18021810
def _get_SRA_meta(self, file_gse_content: list, gsm_metadata, file_sra=None):
18031811
"""
@@ -1865,12 +1873,13 @@ def _get_SRA_meta(self, file_gse_content: list, gsm_metadata, file_sra=None):
18651873
else:
18661874
# open existing annotation
18671875
_LOGGER.info("Found SRA metadata, opening..")
1868-
with open(file_sra, "r") as m_file:
1876+
with open(file_sra, "r", encoding="UTF-8") as m_file:
18691877
reader = csv.reader(m_file)
18701878
file_list = []
18711879
srp_list = []
18721880
for k in reader:
1873-
file_list.append(k)
1881+
if k:
1882+
file_list.append(k)
18741883
for value_list in file_list[1:]:
18751884
srp_list.append(dict(zip(file_list[0], value_list)))
18761885

geofetch/utils.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def fetch_metadata(
275275
os.makedirs(dirpath)
276276

277277
# save file:
278-
with open(outpath, "w") as f:
278+
with open(outpath, "w", encoding="utf-8") as f:
279279
f.write(result_text)
280280

281281
return result_list
@@ -757,3 +757,22 @@ def gse_content_to_dict(gse_content: List[str]) -> Dict[str, dict]:
757757
gse_dict[new_key] = new_value
758758

759759
return {"experiment_metadata": gse_dict}
760+
761+
762+
def is_prefetch_callable() -> bool:
763+
"""
764+
Test if the prefetch command can be run.
765+
766+
:return: True if it is available.
767+
"""
768+
try:
769+
# Option -V means display version and then quit.
770+
subprocess.run(
771+
["prefetch", "-V"],
772+
check=True,
773+
stdout=subprocess.PIPE,
774+
stderr=subprocess.PIPE,
775+
)
776+
return True
777+
except (subprocess.SubprocessError, OSError):
778+
return False

0 commit comments

Comments
 (0)