Skip to content

Commit 2a27f69

Browse files
committed
refactor: remove repeated image_exists method from JSONReader
1 parent 82665bf commit 2a27f69

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

graphgen/models/reader/json_reader.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import json
2-
import os
3-
from typing import Any, Dict, List, Union
2+
from typing import List, Union
43

54
import ray
65
import ray.data
76

87
from graphgen.bases.base_reader import BaseReader
9-
from graphgen.utils import logger
108

119

1210
class JSONReader(BaseReader):
@@ -44,27 +42,6 @@ def read(self, input_path: Union[str, List[str]]) -> ray.data.Dataset:
4442
ds = ds.filter(self._should_keep_item)
4543
return ds
4644

47-
@staticmethod
48-
def _image_exists(path_or_url: str, timeout: int = 3) -> bool:
49-
"""
50-
Check if an image exists at the given local path or URL.
51-
:param path_or_url: Local file path or remote URL of the image.
52-
:param timeout: Timeout for remote URL requests in seconds.
53-
:return: True if the image exists, False otherwise.
54-
"""
55-
if not path_or_url:
56-
return False
57-
if not path_or_url.startswith(("http://", "https://", "ftp://")):
58-
path = path_or_url.replace("file://", "", 1)
59-
path = os.path.abspath(path)
60-
return os.path.isfile(path)
61-
try:
62-
import requests
63-
resp = requests.head(path_or_url, allow_redirects=True, timeout=timeout)
64-
return resp.status_code == 200
65-
except Exception:
66-
return False
67-
6845
@staticmethod
6946
def _unify_schema(data):
7047
"""

0 commit comments

Comments
 (0)