diff --git a/.github/workflows/run-pytest-windows.yml b/.github/workflows/run-pytest-windows.yml new file mode 100644 index 0000000..54b4c99 --- /dev/null +++ b/.github/workflows/run-pytest-windows.yml @@ -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 diff --git a/.github/workflows/run-pytest.yml b/.github/workflows/run-pytest.yml index 6184da9..489f0f6 100644 --- a/.github/workflows/run-pytest.yml +++ b/.github/workflows/run-pytest.yml @@ -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: diff --git a/geofetch/geofetch.py b/geofetch/geofetch.py index 932fd74..0f904e3 100755 --- a/geofetch/geofetch.py +++ b/geofetch/geofetch.py @@ -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 @@ -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) @@ -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))) diff --git a/geofetch/utils.py b/geofetch/utils.py index 850a77e..70570da 100644 --- a/geofetch/utils.py +++ b/geofetch/utils.py @@ -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