Skip to content

Commit

Permalink
windows fix (temporarily)
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Jan 15, 2024
1 parent d49c5d0 commit d41ebe1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/run-pytest-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Run pytests windows

on:
push:
branches: [dev]
pull_request:
branches: [master, dev]

jobs:
pytest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10"]
os: [windows-latest]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
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: Run pytest tests
run: pytest tests -x -vv
2 changes: 1 addition & 1 deletion .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
os: [ubuntu-latest]

steps:
Expand Down
22 changes: 15 additions & 7 deletions geofetch/geofetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,17 @@ def fetch_all(self, input: str, name: str = None) -> Union[NoReturn, peppy.Proje
# check to make sure prefetch is callable
if not self.just_metadata and not self.processed:
if not is_command_callable("prefetch"):
raise SystemExit(
"To download raw data You must first install the sratoolkit, with prefetch in your PATH."
" Installation instruction: http://geofetch.databio.org/en/latest/install/"
)
if os.name == "nt":
_LOGGER.warning(
"GEOfetch is not checking if prefetch is installed on Windows,"
" please make sure it is installed and in your PATH, otherwise "
"it will not be possible to download raw data."
)
else:
raise SystemExit(
"To download raw data You must first install the sratoolkit, with prefetch in your PATH."
" Installation instruction: http://geofetch.databio.org/en/latest/install/"
)

acc_GSE_list = parse_accessions(
input, self.metadata_expanded, self.just_metadata
Expand Down Expand Up @@ -1036,7 +1043,7 @@ def _write_processed_annotation(
)

if not just_object:
with open(file_annotation_path, "w") as m_file:
with open(file_annotation_path, "w", encoding="utf-8") as m_file:
dict_writer = csv.DictWriter(m_file, processed_metadata[0].keys())
dict_writer.writeheader()
dict_writer.writerows(processed_metadata)
Expand Down Expand Up @@ -1865,12 +1872,13 @@ def _get_SRA_meta(self, file_gse_content: list, gsm_metadata, file_sra=None):
else:
# open existing annotation
_LOGGER.info("Found SRA metadata, opening..")
with open(file_sra, "r") as m_file:
with open(file_sra, "r", encoding="UTF-8") as m_file:
reader = csv.reader(m_file)
file_list = []
srp_list = []
for k in reader:
file_list.append(k)
if k:
file_list.append(k)
for value_list in file_list[1:]:
srp_list.append(dict(zip(file_list[0], value_list)))

Expand Down
2 changes: 1 addition & 1 deletion geofetch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def fetch_metadata(
os.makedirs(dirpath)

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

return result_list
Expand Down

0 comments on commit d41ebe1

Please sign in to comment.