diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index fbaf30b02b2a..1762aea0e578 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -29,7 +29,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** examples/** graphgym/** diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b2f7ff6987e4..89242a95c032 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -29,7 +29,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** docs/** examples/** diff --git a/.github/workflows/testing_latest.yml b/.github/workflows/testing_latest.yml index 391fcd31ea5f..027eaa79e062 100644 --- a/.github/workflows/testing_latest.yml +++ b/.github/workflows/testing_latest.yml @@ -41,7 +41,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** docs/** examples/** diff --git a/.github/workflows/testing_minimal.yml b/.github/workflows/testing_minimal.yml index d61e5e09b56a..5a0fd7323ab1 100644 --- a/.github/workflows/testing_minimal.yml +++ b/.github/workflows/testing_minimal.yml @@ -29,7 +29,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** docs/** examples/** diff --git a/.github/workflows/testing_nightly.yml b/.github/workflows/testing_nightly.yml index 0a93926fa1e5..1ae649fdbcac 100644 --- a/.github/workflows/testing_nightly.yml +++ b/.github/workflows/testing_nightly.yml @@ -29,7 +29,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** docs/** examples/** diff --git a/.github/workflows/testing_prev.yml b/.github/workflows/testing_prev.yml index 2b092ba8beae..191f2c8d708e 100644 --- a/.github/workflows/testing_prev.yml +++ b/.github/workflows/testing_prev.yml @@ -41,7 +41,6 @@ jobs: with: files: | benchmark/** - conda/** docker/** docs/** examples/** diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 44baf571238d..0261a4a12159 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,13 +19,6 @@ repos: name: Remove trailing whitespaces - id: check-toml name: Check toml - - id: check-yaml - name: Check yaml - exclude: | - (?x)^( - conda/pytorch-geometric/meta.yaml| - conda/pyg/meta.yaml - )$ - repo: https://github.com/adrienverge/yamllint.git rev: v1.37.1 diff --git a/torch_geometric/data/dataset.py b/torch_geometric/data/dataset.py index 0ab74df0521e..6a3d5e889987 100644 --- a/torch_geometric/data/dataset.py +++ b/torch_geometric/data/dataset.py @@ -1,4 +1,5 @@ import copy +import os import os.path as osp import re import sys @@ -258,7 +259,7 @@ def _process(self): if not self.force_reload and files_exist(self.processed_paths): return - if self.log and 'pytest' not in sys.modules: + if self.log and 'PYTEST_CURRENT_TEST' not in os.environ: print('Processing...', file=sys.stderr) fs.makedirs(self.processed_dir, exist_ok=True) @@ -269,7 +270,7 @@ def _process(self): path = osp.join(self.processed_dir, 'pre_filter.pt') fs.torch_save(_repr(self.pre_filter), path) - if self.log and 'pytest' not in sys.modules: + if self.log and 'PYTEST_CURRENT_TEST' not in os.environ: print('Done!', file=sys.stderr) def __len__(self) -> int: diff --git a/torch_geometric/data/download.py b/torch_geometric/data/download.py index 6f656f6412d4..faceba188282 100644 --- a/torch_geometric/data/download.py +++ b/torch_geometric/data/download.py @@ -34,11 +34,11 @@ def download_url( path = osp.join(folder, filename) if fs.exists(path): # pragma: no cover - if log and 'pytest' not in sys.modules: + if log and 'PYTEST_CURRENT_TEST' not in os.environ: print(f'Using existing file {filename}', file=sys.stderr) return path - if log and 'pytest' not in sys.modules: + if log and 'PYTEST_CURRENT_TEST' not in os.environ: print(f'Downloading {url}', file=sys.stderr) os.makedirs(folder, exist_ok=True) diff --git a/torch_geometric/data/extract.py b/torch_geometric/data/extract.py index 7e3bb9df288e..b179234ae162 100644 --- a/torch_geometric/data/extract.py +++ b/torch_geometric/data/extract.py @@ -1,5 +1,6 @@ import bz2 import gzip +import os import os.path as osp import sys import tarfile @@ -7,7 +8,7 @@ def maybe_log(path: str, log: bool = True) -> None: - if log and 'pytest' not in sys.modules: + if log and 'PYTEST_CURRENT_TEST' not in os.environ: print(f'Extracting {path}', file=sys.stderr) diff --git a/torch_geometric/io/fs.py b/torch_geometric/io/fs.py index ee41ac8ec620..c88a04ad5a9a 100644 --- a/torch_geometric/io/fs.py +++ b/torch_geometric/io/fs.py @@ -1,4 +1,5 @@ import io +import os import os.path as osp import pickle import re @@ -117,7 +118,7 @@ def cp( # Cache result if the protocol is not local: cache_dir: Optional[str] = None if not islocal(path1): - if log and 'pytest' not in sys.modules: + if log and 'PYTEST_CURRENT_TEST' not in os.environ: print(f'Downloading {path1}', file=sys.stderr) if extract and use_cache: # Cache seems to confuse the gcs filesystem. diff --git a/torch_geometric/nn/conv/fa_conv.py b/torch_geometric/nn/conv/fa_conv.py index 8fd2f17917e1..8672de393cbd 100644 --- a/torch_geometric/nn/conv/fa_conv.py +++ b/torch_geometric/nn/conv/fa_conv.py @@ -163,10 +163,13 @@ def forward( # noqa: F811 edge_index (torch.Tensor or SparseTensor): The edge indices. edge_weight (torch.Tensor, optional): The edge weights. (default: :obj:`None`) - return_attention_weights (bool, optional): If set to :obj:`True`, - will additionally return the tuple - :obj:`(edge_index, attention_weights)`, holding the computed - attention weights for each edge. (default: :obj:`None`) + return_attention_weights (bool, optional): + Will additionally return the tuple + :obj:`(edge_index, attention_weights)` whenever it is set to + a value, regardless of its actual value + (might be `True` or `False`), holding the computed attention + weights for each edge. + (default: :obj:`None`) """ if self.normalize: if isinstance(edge_index, Tensor): diff --git a/torch_geometric/nn/conv/gat_conv.py b/torch_geometric/nn/conv/gat_conv.py index 720dfb09811c..c78e106ec495 100644 --- a/torch_geometric/nn/conv/gat_conv.py +++ b/torch_geometric/nn/conv/gat_conv.py @@ -273,10 +273,13 @@ def forward( # noqa: F811 (default: :obj:`None`) size ((int, int), optional): The shape of the adjacency matrix. (default: :obj:`None`) - return_attention_weights (bool, optional): If set to :obj:`True`, - will additionally return the tuple - :obj:`(edge_index, attention_weights)`, holding the computed - attention weights for each edge. (default: :obj:`None`) + return_attention_weights (bool, optional): + Will additionally return the tuple + :obj:`(edge_index, attention_weights)` whenever it is set to + a value, regardless of its actual value + (might be `True` or `False`), holding the computed attention + weights for each edge. + (default: :obj:`None`) """ # NOTE: attention weights will be returned whenever # `return_attention_weights` is set to a value, regardless of its diff --git a/torch_geometric/nn/conv/gatv2_conv.py b/torch_geometric/nn/conv/gatv2_conv.py index f3b2f4937e52..43a898c17d54 100644 --- a/torch_geometric/nn/conv/gatv2_conv.py +++ b/torch_geometric/nn/conv/gatv2_conv.py @@ -266,10 +266,13 @@ def forward( # noqa: F811 edge_index (torch.Tensor or SparseTensor): The edge indices. edge_attr (torch.Tensor, optional): The edge features. (default: :obj:`None`) - return_attention_weights (bool, optional): If set to :obj:`True`, - will additionally return the tuple - :obj:`(edge_index, attention_weights)`, holding the computed - attention weights for each edge. (default: :obj:`None`) + return_attention_weights (bool, optional): + Will additionally return the tuple + :obj:`(edge_index, attention_weights)` whenever it is set to + a value, regardless of its actual value + (might be `True` or `False`), holding the computed attention + weights for each edge. + (default: :obj:`None`) """ H, C = self.heads, self.out_channels diff --git a/torch_geometric/nn/conv/rgat_conv.py b/torch_geometric/nn/conv/rgat_conv.py index 4c3a9937db5b..97b03d4e42a6 100644 --- a/torch_geometric/nn/conv/rgat_conv.py +++ b/torch_geometric/nn/conv/rgat_conv.py @@ -340,10 +340,13 @@ def forward( (default: :obj:`None`) size ((int, int), optional): The shape of the adjacency matrix. (default: :obj:`None`) - return_attention_weights (bool, optional): If set to :obj:`True`, - will additionally return the tuple - :obj:`(edge_index, attention_weights)`, holding the computed - attention weights for each edge. (default: :obj:`None`) + return_attention_weights (bool, optional): + Will additionally return the tuple + :obj:`(edge_index, attention_weights)` whenever it is set to + a value, regardless of its actual value + (might be `True` or `False`), holding the computed attention + weights for each edge. + (default: :obj:`None`) """ # propagate_type: (x: Tensor, edge_type: OptTensor, # edge_attr: OptTensor) diff --git a/torch_geometric/nn/conv/transformer_conv.py b/torch_geometric/nn/conv/transformer_conv.py index b3467774992f..1cf9936a3429 100644 --- a/torch_geometric/nn/conv/transformer_conv.py +++ b/torch_geometric/nn/conv/transformer_conv.py @@ -212,10 +212,13 @@ def forward( # noqa: F811 edge_index (torch.Tensor or SparseTensor): The edge indices. edge_attr (torch.Tensor, optional): The edge features. (default: :obj:`None`) - return_attention_weights (bool, optional): If set to :obj:`True`, - will additionally return the tuple - :obj:`(edge_index, attention_weights)`, holding the computed - attention weights for each edge. (default: :obj:`None`) + return_attention_weights (bool, optional): + Will additionally return the tuple + :obj:`(edge_index, attention_weights)` whenever it is set to + a value, regardless of its actual value + (might be `True` or `False`), holding the computed attention + weights for each edge. + (default: :obj:`None`) """ H, C = self.heads, self.out_channels diff --git a/torch_geometric/nn/dense/linear.py b/torch_geometric/nn/dense/linear.py index 28d3f99e2fb7..9b609314db5e 100644 --- a/torch_geometric/nn/dense/linear.py +++ b/torch_geometric/nn/dense/linear.py @@ -1,5 +1,5 @@ import math -import sys +import os import time from typing import Any, Dict, Optional, Tuple, Union @@ -262,7 +262,7 @@ def _update_timing_cache( key: int, ) -> None: - MEASURE_ITER = 1 if 'pytest' in sys.modules else 3 + MEASURE_ITER = 1 if 'PYTEST_CURRENT_TEST' not in os.environ else 3 if torch.cuda.is_available(): torch.cuda.synchronize() diff --git a/torch_geometric/typing.py b/torch_geometric/typing.py index b8be379ec777..36ada2a83235 100644 --- a/torch_geometric/typing.py +++ b/torch_geometric/typing.py @@ -1,6 +1,5 @@ import inspect import os -import sys import typing import warnings from typing import Any, Dict, List, Optional, Set, Tuple, TypeAlias, Union @@ -43,7 +42,8 @@ WITH_PYG_LIB = True WITH_GMM = WITH_PT20 and hasattr(pyg_lib.ops, 'grouped_matmul') WITH_SEGMM = hasattr(pyg_lib.ops, 'segment_matmul') - if WITH_SEGMM and 'pytest' in sys.modules and torch.cuda.is_available(): + if WITH_SEGMM and torch.cuda.is_available( + ) and 'PYTEST_CURRENT_TEST' not in os.environ: # NOTE `segment_matmul` is currently bugged on older NVIDIA cards which # let our GPU tests on CI crash. Try if this error is present on the # current GPU and disable `WITH_SEGMM`/`WITH_GMM` if necessary.