+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.9", "3.14"]
python-version: ["3.10", "3.14"]
runner: ["ubuntu-latest"]

steps:
- name: Check conditions
id: conditions
run: echo "run-tests=${{ github.ref == 'refs/heads/main' || (matrix.runner == 'ubuntu-20.04' && matrix.python-version == '3.9') }}" >> "$GITHUB_OUTPUT"
run: echo "run-tests=${{ github.ref == 'refs/heads/main' || (matrix.runner == 'ubuntu-20.04' && matrix.python-version == '3.10') }}" >> "$GITHUB_OUTPUT"

outputs:
python-version: ${{ matrix.python-version }}
Expand Down
7 changes: 3 additions & 4 deletions nf_core/commands_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import sys
from pathlib import Path
from typing import Optional, Union

import rich

Expand Down Expand Up @@ -282,9 +281,9 @@ def pipelines_list(ctx, keywords, sort, json, show_archived):
# nf-core pipelines rocrate
def pipelines_rocrate(
ctx,
pipeline_dir: Union[str, Path],
json_path: Optional[Union[str, Path]],
zip_path: Optional[Union[str, Path]],
pipeline_dir: str | Path,
json_path: str | Path | None,
zip_path: str | Path | None,
pipeline_version: str,
) -> None:
from nf_core.pipelines.rocrate import ROCrate
Expand Down
3 changes: 1 addition & 2 deletions nf_core/commands_test_datasets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import Optional

import click
import rich
Expand Down Expand Up @@ -30,7 +29,7 @@ def test_datasets_list_remote(ctx: click.Context, branch: str, generate_nf_path:


def test_datasets_search(
ctx: click.Context, branch: str, generate_nf_path: bool, generate_dl_url: bool, query: Optional[str]
ctx: click.Context, branch: str, generate_nf_path: bool, generate_dl_url: bool, query: str | None
) -> None:
"""
Search all files on a given branch in the remote nf-core/testdatasets repository on github
Expand Down
17 changes: 8 additions & 9 deletions nf_core/components/components_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import shutil
from pathlib import Path
from typing import Optional, Union

import nf_core.utils
from nf_core.modules.modules_json import ModulesJson
Expand All @@ -22,9 +21,9 @@ class ComponentCommand:
def __init__(
self,
component_type: str,
directory: Union[str, Path] = ".",
remote_url: Optional[str] = None,
branch: Optional[str] = None,
directory: str | Path = ".",
remote_url: str | None = None,
branch: str | None = None,
no_pull: bool = False,
hide_progress: bool = False,
no_prompts: bool = False,
Expand All @@ -37,7 +36,7 @@ def __init__(
self.modules_repo = ModulesRepo(remote_url, branch, no_pull, hide_progress)
self.hide_progress: bool = hide_progress
self.no_prompts: bool = no_prompts
self.repo_type: Optional[str] = None
self.repo_type: str | None = None
self.org: str = ""
self._configure_repo_and_paths()

Expand Down Expand Up @@ -114,7 +113,7 @@ def has_modules_file(self) -> None:
log.info("Creating missing 'module.json' file.")
ModulesJson(self.directory).create()

def clear_component_dir(self, component_name: str, component_dir: Union[str, Path]) -> bool:
def clear_component_dir(self, component_name: str, component_dir: str | Path) -> bool:
"""
Removes all files in the module/subworkflow directory

Expand Down Expand Up @@ -161,7 +160,7 @@ def components_from_repo(self, install_dir: str) -> list[str]:
]

def install_component_files(
self, component_name: str, component_version: str, modules_repo: ModulesRepo, install_dir: Union[str, Path]
self, component_name: str, component_version: str, modules_repo: ModulesRepo, install_dir: str | Path
) -> bool:
"""
Installs a module/subworkflow into the given directory
Expand Down Expand Up @@ -263,7 +262,7 @@ def check_patch_paths(self, patch_path: Path, module_name: str) -> None:
][module_name]["patch"] = str(patch_path.relative_to(self.directory.resolve()))
modules_json.dump()

def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[str, Union[int, str]]]]:
def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[str, int | str]]]:
"""
Checks for include statements in the main.nf file of the pipeline and a list of line numbers where the component is included
Args:
Expand All @@ -272,7 +271,7 @@ def check_if_in_include_stmts(self, component_path: str) -> dict[str, list[dict[
Returns:
(list): A list of dictionaries, with the workflow file and the line number where the component is included
"""
include_stmts: dict[str, list[dict[str, Union[int, str]]]] = {}
include_stmts: dict[str, list[dict[str, int | str]]] = {}
if self.repo_type == "pipeline":
workflow_files = Path(self.directory, "workflows").glob("*.nf")
for workflow_file in workflow_files:
Expand Down
7 changes: 3 additions & 4 deletions nf_core/components/components_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging
import os
from pathlib import Path
from typing import Union

from rich import box
from rich.console import Console, Group, RenderableType
Expand Down Expand Up @@ -308,7 +307,7 @@ def print_diff(
)

@staticmethod
def per_file_patch(patch_fn: Union[str, Path]) -> dict[str, list[str]]:
def per_file_patch(patch_fn: str | Path) -> dict[str, list[str]]:
"""
Splits a patch file for several files into one patch per file.

Expand Down Expand Up @@ -466,8 +465,8 @@ def try_apply_single_patch(file_lines, patch, reverse=False):
def try_apply_patch(
component_type: str,
component: str,
repo_path: Union[str, Path],
patch_path: Union[str, Path],
repo_path: str | Path,
patch_path: str | Path,
component_dir: Path,
reverse: bool = False,
) -> dict[str, list[str]]:
Expand Down
9 changes: 4 additions & 5 deletions nf_core/components/components_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os
import re
from pathlib import Path
from typing import Optional

import questionary
from rich import print
Expand Down Expand Up @@ -65,15 +64,15 @@ class ComponentsTest(ComponentCommand): # type: ignore[misc]
def __init__(
self,
component_type: str,
component_name: Optional[str] = None,
component_name: str | None = None,
directory: str = ".",
no_prompts: bool = False,
remote_url: Optional[str] = None,
branch: Optional[str] = None,
remote_url: str | None = None,
branch: str | None = None,
verbose: bool = False,
update: bool = False,
once: bool = False,
profile: Optional[str] = None,
profile: str | None = None,
):
super().__init__(component_type, directory, remote_url, branch, no_prompts=no_prompts)
self.component_name = component_name
Expand Down
11 changes: 5 additions & 6 deletions nf_core/components/components_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import re
from pathlib import Path
from typing import Optional, Union

import questionary
import requests
Expand All @@ -22,7 +21,7 @@
yaml.indent(mapping=2, sequence=2, offset=0)


def get_repo_info(directory: Path, use_prompt: Optional[bool] = True) -> tuple[Path, Optional[str], str]:
def get_repo_info(directory: Path, use_prompt: bool | None = True) -> tuple[Path, str | None, str]:
"""
Determine whether this is a pipeline repository or a clone of
nf-core/modules
Expand Down Expand Up @@ -95,7 +94,7 @@ def prompt_component_version_sha(
component_name: str,
component_type: str,
modules_repo: "ModulesRepo",
installed_sha: Optional[str] = None,
installed_sha: str | None = None,
) -> str:
"""
Creates an interactive questionary prompt for selecting the module/subworkflow version
Expand Down Expand Up @@ -146,7 +145,7 @@ def prompt_component_version_sha(


def get_components_to_install(
subworkflow_dir: Union[str, Path],
subworkflow_dir: str | Path,
) -> tuple[list[dict[str, str]], list[dict[str, str]]]:
"""
Parse the subworkflow main.nf file to retrieve all imported modules and subworkflows.
Expand Down Expand Up @@ -198,7 +197,7 @@ def get_components_to_install(
return list(modules.values()), list(subworkflows.values())


def get_biotools_response(tool_name: str) -> Optional[dict]:
def get_biotools_response(tool_name: str) -> dict | None:
"""
Try to get bio.tools information for 'tool'
"""
Expand Down Expand Up @@ -237,7 +236,7 @@ def get_biotools_id(data: dict, tool_name: str) -> str:

def get_channel_info_from_biotools(
data: dict, tool_name: str
) -> Optional[tuple[DictWithStrAndTuple, DictWithStrAndTuple]]:
) -> tuple[DictWithStrAndTuple, DictWithStrAndTuple] | None:
"""
Try to find input and output channels and the respective EDAM ontology terms

Expand Down
19 changes: 9 additions & 10 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import shutil
import subprocess
from pathlib import Path
from typing import Optional, Union

import jinja2
import questionary
Expand Down Expand Up @@ -41,12 +40,12 @@ def __init__(
component_type: str,
directory: Path = Path("."),
component: str = "",
author: Optional[str] = None,
process_label: Optional[str] = None,
has_meta: Optional[str] = None,
author: str | None = None,
process_label: str | None = None,
has_meta: str | None = None,
force: bool = False,
conda_name: Optional[str] = None,
conda_version: Optional[str] = None,
conda_name: str | None = None,
conda_version: str | None = None,
empty_template: bool = False,
migrate_pytest: bool = False, # TODO: Deprecate this flag in the future
):
Expand Down Expand Up @@ -293,7 +292,7 @@ def _get_module_structure_components(self):
default=True,
)

def _render_template(self) -> Optional[bool]:
def _render_template(self) -> bool | None:
"""
Create new module/subworkflow files with Jinja2.
"""
Expand Down Expand Up @@ -560,7 +559,7 @@ def generate_meta_yml_file(self) -> None:
)

if hasattr(self, "inputs"):
inputs_array: list[Union[dict, list[dict]]] = []
inputs_array: list[dict | list[dict]] = []
for i, (input_name, ontologies) in enumerate(self.inputs.items()):
channel_entry: dict[str, dict] = {
input_name: {
Expand Down Expand Up @@ -609,9 +608,9 @@ def generate_meta_yml_file(self) -> None:
meta_yml["input"][0]["bam"]["ontologies"][2].yaml_add_eol_comment("SAM", "edam")

if hasattr(self, "outputs"):
outputs_dict: dict[str, Union[list, dict]] = {}
outputs_dict: dict[str, list | dict] = {}
for i, (output_name, ontologies) in enumerate(self.outputs.items()):
channel_contents: list[Union[list[dict], dict]] = []
channel_contents: list[list[dict] | dict] = []
if self.has_meta:
channel_contents.append(
[
Expand Down
23 changes: 11 additions & 12 deletions nf_core/components/info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
from pathlib import Path
from typing import Optional, Union

import questionary
import yaml
Expand Down Expand Up @@ -59,18 +58,18 @@ class ComponentInfo(ComponentCommand):
def __init__(
self,
component_type: str,
pipeline_dir: Union[str, Path],
pipeline_dir: str | Path,
component_name: str,
remote_url: Optional[str] = None,
branch: Optional[str] = None,
remote_url: str | None = None,
branch: str | None = None,
no_pull: bool = False,
):
super().__init__(component_type, pipeline_dir, remote_url, branch, no_pull)
self.meta: Optional[dict] = None
self.local_path: Optional[Path] = None
self.remote_location: Optional[str] = None
self.meta: dict | None = None
self.local_path: Path | None = None
self.remote_location: str | None = None
self.local: bool = False
self.modules_json: Optional[ModulesJson] = None
self.modules_json: ModulesJson | None = None

if self.repo_type == "pipeline":
# Check modules directory structure
Expand All @@ -90,7 +89,7 @@ def _configure_repo_and_paths(self, nf_dir_req=False) -> None:
"""
return super()._configure_repo_and_paths(nf_dir_req)

def init_mod_name(self, component: Optional[str]) -> str:
def init_mod_name(self, component: str | None) -> str:
"""
Makes sure that we have a module/subworkflow name before proceeding.

Expand Down Expand Up @@ -170,11 +169,11 @@ def get_component_info(self):

return self.generate_component_info_help()

def get_local_yaml(self) -> Optional[dict]:
def get_local_yaml(self) -> dict | None:
"""Attempt to get the meta.yml file from a locally installed module/subworkflow.

Returns:
Optional[dict]: Parsed meta.yml if found, None otherwise
dict | None: Parsed meta.yml if found, None otherwise
"""

if self.repo_type == "pipeline":
Expand Down Expand Up @@ -213,7 +212,7 @@ def get_local_yaml(self) -> Optional[dict]:

return {}

def get_remote_yaml(self) -> Optional[dict]:
def get_remote_yaml(self) -> dict | None:
"""Attempt to get the meta.yml file from a remote repo.

Returns:
Expand Down
15 changes: 7 additions & 8 deletions nf_core/components/install.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
from pathlib import Path
from typing import Optional, Union

import questionary
from rich import print
Expand Down Expand Up @@ -30,15 +29,15 @@
class ComponentInstall(ComponentCommand):
def __init__(
self,
pipeline_dir: Union[str, Path],
pipeline_dir: str | Path,
component_type: str,
force: bool = False,
prompt: bool = False,
sha: Optional[str] = None,
remote_url: Optional[str] = None,
branch: Optional[str] = None,
sha: str | None = None,
remote_url: str | None = None,
branch: str | None = None,
no_pull: bool = False,
installed_by: Optional[list[str]] = None,
installed_by: list[str] | None = None,
):
super().__init__(component_type, pipeline_dir, remote_url, branch, no_pull)
self.current_remote = ModulesRepo(remote_url, branch)
Expand All @@ -52,7 +51,7 @@ def __init__(
else:
self.installed_by = [self.component_type]

def install(self, component: Union[str, dict[str, str]], silent: bool = False) -> bool:
def install(self, component: str | dict[str, str], silent: bool = False) -> bool:
if isinstance(component, dict):
# Override modules_repo when the component to install is a dependency from a subworkflow.
remote_url = component.get("git_remote", self.current_remote.remote_url)
Expand Down Expand Up @@ -211,7 +210,7 @@ def install_included_components(self, subworkflow_dir):
self.installed_by = original_installed

def collect_and_verify_name(
self, component: Optional[str], modules_repo: "nf_core.modules.modules_repo.ModulesRepo"
self, component: str | None, modules_repo: "nf_core.modules.modules_repo.ModulesRepo"
) -> str:
"""
Collect component name.
Expand Down
Loading
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载