From 0ff35a222cd8e615a8de60aea24a7c1b95b7b48c Mon Sep 17 00:00:00 2001 From: Novak <116580988+NovakApis@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:51:33 +0200 Subject: [PATCH 1/5] local pytest --- .github/workflows/my_pytest.yml | 50 ++++++++++++++++++++++++++++++++ nf_core/modules/modules_utils.py | 12 ++++---- 2 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/my_pytest.yml diff --git a/.github/workflows/my_pytest.yml b/.github/workflows/my_pytest.yml new file mode 100644 index 0000000000..176395ab0b --- /dev/null +++ b/.github/workflows/my_pytest.yml @@ -0,0 +1,50 @@ +name: Python tests +# This workflow is triggered on pushes and PRs to the repository. +# Only run if we changed a Python file +on: + push: + branches: + - feature/** + pull_request: + release: + types: [published] + +# Cancel if a newer run is started +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + pytest: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8"] + + steps: + - uses: actions/checkout@v3 + name: Check out source-code repository + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install python dependencies + run: | + python -m pip install --upgrade pip -r requirements-dev.txt + pip install -e . + + - name: Install Nextflow + uses: nf-core/setup-nextflow@v1 + with: + version: "latest-everything" + + - name: Test with pytest + run: python3 -m pytest tests/ --color=yes --cov-report=xml --cov-config=.github/.coveragerc --cov=nf_core + + - uses: codecov/codecov-action@v1 + name: Upload code coverage report + with: + if: success() + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/nf_core/modules/modules_utils.py b/nf_core/modules/modules_utils.py index 47826d3804..a7836394c4 100644 --- a/nf_core/modules/modules_utils.py +++ b/nf_core/modules/modules_utils.py @@ -2,6 +2,7 @@ import os import urllib from pathlib import Path +from typing import List, Optional, Tuple from .nfcore_module import NFCoreModule @@ -14,12 +15,13 @@ class ModuleException(Exception): pass -def repo_full_name_from_remote(remote_url): +def repo_full_name_from_remote(remote_url: str) -> str: """ Extracts the path from the remote URL See https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS for the possible URL patterns """ # Check whether we have a https or ssh url + path: str if remote_url.startswith("https"): path = urllib.parse.urlparse(remote_url) path = path.path @@ -38,7 +40,7 @@ def repo_full_name_from_remote(remote_url): return path -def get_installed_modules(dir, repo_type="modules"): +def get_installed_modules(dir: str, repo_type="modules") -> Tuple[List[str], List[str]]: """ Make a list of all modules installed in this repository @@ -52,9 +54,9 @@ def get_installed_modules(dir, repo_type="modules"): returns (local_modules, nfcore_modules) """ # initialize lists - local_modules = [] - nfcore_modules = [] - local_modules_dir = None + local_modules: List[str] = [] + nfcore_modules: List[str] = [] + local_modules_dir: Optional[str] = None nfcore_modules_dir = os.path.join(dir, "modules", "nf-core") # Get local modules From bf1ba308a014c5c3d4079592454458c0076f277c Mon Sep 17 00:00:00 2001 From: Novak <116580988+NovakApis@users.noreply.github.com> Date: Tue, 28 Mar 2023 14:16:17 +0200 Subject: [PATCH 2/5] deleted my_pytest.yml --- .github/workflows/my_pytest.yml | 50 --------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 .github/workflows/my_pytest.yml diff --git a/.github/workflows/my_pytest.yml b/.github/workflows/my_pytest.yml deleted file mode 100644 index 176395ab0b..0000000000 --- a/.github/workflows/my_pytest.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Python tests -# This workflow is triggered on pushes and PRs to the repository. -# Only run if we changed a Python file -on: - push: - branches: - - feature/** - pull_request: - release: - types: [published] - -# Cancel if a newer run is started -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - pytest: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8"] - - steps: - - uses: actions/checkout@v3 - name: Check out source-code repository - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - - name: Install python dependencies - run: | - python -m pip install --upgrade pip -r requirements-dev.txt - pip install -e . - - - name: Install Nextflow - uses: nf-core/setup-nextflow@v1 - with: - version: "latest-everything" - - - name: Test with pytest - run: python3 -m pytest tests/ --color=yes --cov-report=xml --cov-config=.github/.coveragerc --cov=nf_core - - - uses: codecov/codecov-action@v1 - name: Upload code coverage report - with: - if: success() - token: ${{ secrets.CODECOV_TOKEN }} From 6a38397eda8424675f002c245625a54fdc033f87 Mon Sep 17 00:00:00 2001 From: kedhammar Date: Wed, 18 Oct 2023 11:31:55 +0200 Subject: [PATCH 3/5] fix mypy error --- nf_core/modules/modules_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/modules_utils.py b/nf_core/modules/modules_utils.py index 83e17e81b6..10040e0559 100644 --- a/nf_core/modules/modules_utils.py +++ b/nf_core/modules/modules_utils.py @@ -21,7 +21,6 @@ def repo_full_name_from_remote(remote_url: str) -> str: See https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS for the possible URL patterns """ # Check whether we have a https or ssh url - path: str if remote_url.startswith("https"): path = urllib.parse.urlparse(remote_url) path = path.path @@ -84,7 +83,9 @@ def get_installed_modules(dir: str, repo_type="modules") -> Tuple[List[str], Lis nfcore_modules.append(m) # Make full (relative) file paths and create NFCoreComponent objects - local_modules = [os.path.join(local_modules_dir, m) for m in local_modules] + if local_modules_dir: + local_modules = [os.path.join(local_modules_dir, m) for m in local_modules] + nfcore_modules = [ NFCoreComponent( m, From 810f766b50d654bccdb9d7a87ce972453d2b4f05 Mon Sep 17 00:00:00 2001 From: kedhammar Date: Wed, 18 Oct 2023 11:39:32 +0200 Subject: [PATCH 4/5] Fix remaining error --- nf_core/modules/modules_utils.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nf_core/modules/modules_utils.py b/nf_core/modules/modules_utils.py index 10040e0559..9e72dd4d2e 100644 --- a/nf_core/modules/modules_utils.py +++ b/nf_core/modules/modules_utils.py @@ -1,6 +1,6 @@ import logging import os -import urllib +from urllib.parse import urlparse from pathlib import Path from typing import List, Optional, Tuple @@ -22,18 +22,16 @@ def repo_full_name_from_remote(remote_url: str) -> str: """ # Check whether we have a https or ssh url if remote_url.startswith("https"): - path = urllib.parse.urlparse(remote_url) - path = path.path + path = urlparse(remote_url).path # Remove the intial '/' path = path[1:] # Remove extension path = os.path.splitext(path)[0] else: # Remove the initial `git@`` - path = remote_url.split("@") - path = path[-1] if len(path) > 1 else path[0] - path = urllib.parse.urlparse(path) - path = path.path + split_path: list = remote_url.split("@") + path = split_path[-1] if len(split_path) > 1 else split_path[0] + path = urlparse(path).path # Remove extension path = os.path.splitext(path)[0] return path From 72b46715bd73a7d51a570f7b028160ec3373dcf8 Mon Sep 17 00:00:00 2001 From: kedhammar Date: Wed, 18 Oct 2023 11:41:52 +0200 Subject: [PATCH 5/5] isort --- nf_core/modules/modules_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/modules/modules_utils.py b/nf_core/modules/modules_utils.py index 9e72dd4d2e..504cb1095d 100644 --- a/nf_core/modules/modules_utils.py +++ b/nf_core/modules/modules_utils.py @@ -1,8 +1,8 @@ import logging import os -from urllib.parse import urlparse from pathlib import Path from typing import List, Optional, Tuple +from urllib.parse import urlparse from ..components.nfcore_component import NFCoreComponent