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: 1 addition & 3 deletions src/transformers/models/graphormer/collating_graphormer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def convert_to_single_emb(x, offset: int = 512):


def preprocess_item(item, keep_features=True):
requires_backends(preprocess_item, ["Cython"])
Comment thread
clefourrier marked this conversation as resolved.
if not is_cython_available():
raise ImportError("Graphormer preprocessing needs Cython (pyximport)")
requires_backends(preprocess_item, ["cython"])

if keep_features and "edge_attr" in item.keys(): # edge_attr
edge_attr = np.asarray(item["edge_attr"], dtype=np.int64)
Expand Down
6 changes: 6 additions & 0 deletions src/transformers/utils/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ def is_cython_available():
decord`. Please note that you may need to restart your runtime after installation.
"""

CYTHON_IMPORT_ERROR = """
{0} requires the Cython library but it was not found in your environment. You can install it with pip: `pip install
Cython`. Please note that you may need to restart your runtime after installation.
"""

BACKENDS_MAPPING = OrderedDict(
[
("bs4", (is_bs4_available, BS4_IMPORT_ERROR)),
Expand Down Expand Up @@ -1023,6 +1028,7 @@ def is_cython_available():
("accelerate", (is_accelerate_available, ACCELERATE_IMPORT_ERROR)),
("oneccl_bind_pt", (is_ccl_available, CCL_IMPORT_ERROR)),
("decord", (is_decord_available, DECORD_IMPORT_ERROR)),
("cython", (is_cython_available, CYTHON_IMPORT_ERROR)),
]
)

Expand Down