Skip to content

Commit 8e7fb56

Browse files
author
Thomas Gilgenast
committed
rework github large file open to treat http extra as optional
1 parent 75a6f4e commit 8e7fb56

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

fsspec/implementations/github.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from ..spec import AbstractFileSystem
66
from ..utils import infer_storage_options
7-
from .http import HTTPFileSystem
87
from .memory import MemoryFile
98

109
# TODO: add GIST backend, would be very similar
@@ -64,7 +63,7 @@ def __init__(
6463

6564
self.root = sha
6665
self.ls("")
67-
self.http_fs = HTTPFileSystem(**kwargs)
66+
self.kwargs = kwargs
6867

6968
@property
7069
def kw(self):
@@ -247,7 +246,14 @@ def _open(
247246
# we land here if the content was not present in the first response
248247
# (regular file over 1MB or git-lfs tracked file)
249248
# in this case, we get let the HTTPFileSystem handle the download
250-
return self.http_fs.open(
249+
try:
250+
from .http import HTTPFileSystem
251+
except ImportError as e:
252+
raise ImportError(
253+
"Please install fsspec[http] to acccess github files >1 MB "
254+
"or git-lfs tracked files."
255+
) from e
256+
return HTTPFileSystem(**self.kwargs).open(
251257
content_json["download_url"],
252258
mode=mode,
253259
block_size=block_size,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ full = [
5656
fuse = ["fusepy"]
5757
gcs = ["gcsfs"]
5858
git = ["pygit2"]
59-
github = ["fsspec[http]", "requests"]
59+
github = ["requests"]
6060
gs = ["gcsfs"]
6161
gui = ["panel"]
6262
hdfs = ["pyarrow >= 1"]

0 commit comments

Comments
 (0)