Skip to content

Commit 0909ca7

Browse files
committed
remove limit of listing from config
1 parent 36d90a6 commit 0909ca7

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ c.DrivesConfig.access_key_id = "<Drives Access Key ID / IAM Access Key ID>"
4040
c.DrivesConfig.secret_access_key = "<Drives Secret Access Key / IAM Secret>"
4141
c.DrivesConfig.session_token = "<Drives Session Token / IAM Session Token (optional)>"
4242
c.DrivesConfig.provider = "<Drives provider e.g.: s3, gcs>"
43-
c.DrivesConfig.max_files_listed = "<Integer repersenting maximum number of files that can be shown in a listing, given any path (optional)>"
4443
```
4544

4645
### Custom credentials file path
@@ -63,7 +62,6 @@ export JP_DRIVES_ACCESS_KEY_ID="<Drives Access Key ID>"
6362
export JP_DRIVES_SECRET_ACCESS_KEY="<Drives Secret Access Key>"
6463
export JP_DRIVES_SESSION_TOKEN="<Drives Session Token (optional)>"
6564
export JP_DRIVES_CUSTOM_CREDENTIALS_PATH="<Path to local file which contains credentials (optional)>"
66-
export JP_DRIVES_MAX_FILES_LISTED="<Integer repersenting maximum number of files that can be shown in a listing, given any path (optional)>"
6765
```
6866

6967
## Uninstall

jupyter_drives/base.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,6 @@ class DrivesConfig(Configurable):
5959
help="Custom path of file where credentials are located. Extension automatically checks jupyter_notebook_config.py or directly in ~/.aws/credentials for AWS CLI users."
6060
)
6161

62-
max_files_listed = Int(
63-
None,
64-
config = True,
65-
allow_none = True,
66-
help="The maximum number of files that will show inside the drive browser, given any path."
67-
)
68-
6962
@default("api_base_url")
7063
def set_default_api_base_url(self):
7164
# for AWS S3 drives
@@ -87,14 +80,7 @@ def __init__(self, **kwargs):
8780
super().__init__(**kwargs)
8881
self._load_credentials()
8982

90-
def _load_credentials(self):
91-
# check if max_files_shown is not set in jupyter_notebook_config.py
92-
if self.max_files_listed is None:
93-
if "JP_DRIVES_MAX_FILES_LISTED" in os.environ:
94-
self.max_files_listed = os.environ["JP_DRIVES_MAX_FILES_LISTED"]
95-
else:
96-
self.max_files_listed = 1000
97-
83+
def _load_credentials(self):
9884
# check if credentials were already set in jupyter_notebook_config.py
9985
if self.access_key_id is not None and self.secret_access_key is not None:
10086
return
@@ -103,7 +89,7 @@ def _load_credentials(self):
10389
if self.custom_credentials_path is None and "JP_DRIVES_CUSTOM_CREDENTIALS_PATH" in os.environ:
10490
self.custom_credentials_path = os.environ["JP_DRIVES_CUSTOM_CREDENTIALS_PATH"]
10591
if self.custom_credentials_path is not None:
106-
self.provider, self.access_key_id, self.secret_access_key, self.session_token, self.max_files_listed = self._extract_credentials_from_file(self.custom_credentials_path)
92+
self.provider, self.access_key_id, self.secret_access_key, self.session_token = self._extract_credentials_from_file(self.custom_credentials_path)
10793
return
10894

10995
# if not, try to load credentials from AWS CLI
@@ -126,7 +112,6 @@ def _extract_credentials_from_file(self, file_path):
126112
try:
127113
with open(file_path, 'r') as file:
128114
provider, access_key_id, secret_access_key, session_token = None, None, None, None
129-
max_files_listed = 1000
130115
lines = file.readlines()
131116
for line in lines:
132117
if line.startswith("drives_provider ="):
@@ -137,9 +122,7 @@ def _extract_credentials_from_file(self, file_path):
137122
secret_access_key = line.split("=")[1].strip()
138123
elif line.startswith("drives_session_token ="):
139124
session_token = line.split("=")[1].strip()
140-
elif line.startswith("drives_max_files_shwon ="):
141-
max_files_listed = line.split("=")[1].strip()
142-
return provider, access_key_id, secret_access_key, session_token, max_files_listed
125+
return provider, access_key_id, secret_access_key, session_token
143126
except Exception as e:
144127
print(f"Failed loading credentials from {file_path}: {e}")
145128
return

0 commit comments

Comments
 (0)