Skip to content

Commit 6fd3684

Browse files
committed
iterate on public bucket functionality
1 parent 6b635c0 commit 6fd3684

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

jupyter_drives/manager.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self, config: traitlets.config.Config) -> None:
5252
self._content_managers = {}
5353
self._max_files_listed = 1025
5454
self._drives = None
55+
self._external_drives = []
5556

5657
# instate fsspec file system
5758
self._file_system = fsspec.filesystem(self._config.provider, asynchronous=True)
@@ -178,7 +179,7 @@ async def list_drives(self):
178179
"""
179180
data = []
180181
if self._config.access_key_id and self._config.secret_access_key:
181-
if self._drives is None:
182+
if self._drives is None and len(self._external_drives) == 0:
182183
raise tornado.web.HTTPError(
183184
status_code= httpx.codes.NOT_IMPLEMENTED,
184185
reason="Listing drives not supported for given provider.",
@@ -187,17 +188,7 @@ async def list_drives(self):
187188
results = []
188189
for drive in self._drives:
189190
try:
190-
if hasattr(drive, 'is_public'):
191-
results.append({
192-
"name": drive.url,
193-
"region": self._config.region_name,
194-
"creationDate": datetime.datetime.now(),
195-
"mounted": False if result.name not in self._content_managers else True,
196-
"provider": self._config.provider
197-
})
198-
else:
199-
results += drive.list_containers()
200-
191+
results += drive.list_containers()
201192
except Exception as e:
202193
raise tornado.web.HTTPError(
203194
status_code=httpx.codes.BAD_REQUEST,
@@ -214,6 +205,23 @@ async def list_drives(self):
214205
"provider": self._config.provider
215206
}
216207
)
208+
209+
if len(self._external_drives) != 0:
210+
for drive in self._external_drives:
211+
try:
212+
data.append({
213+
"name": drive['url'],
214+
"region": self._config.region_name,
215+
"creationDate": datetime.now().isoformat(timespec='milliseconds').replace('+00:00', 'Z'),
216+
"mounted": False if result.name not in self._content_managers else True,
217+
"provider": self._config.provider
218+
})
219+
except Exception as e:
220+
raise tornado.web.HTTPError(
221+
status_code=httpx.codes.BAD_REQUEST,
222+
reason=f"The following error occured when listing drives: {e}",
223+
)
224+
217225
else:
218226
raise tornado.web.HTTPError(
219227
status_code= httpx.codes.BAD_REQUEST,
@@ -645,9 +653,7 @@ async def add_public_drive(self, drive_url):
645653
"is_public": True,
646654
"url": drive_url
647655
};
648-
print('ADDED PUBLIC DRIVE: ', drive)
649-
self._drives.append(drive);
650-
print(self._drives)
656+
self._external_drives.append(drive);
651657
except Exception as e:
652658
raise tornado.web.HTTPError(
653659
status_code= httpx.codes.BAD_REQUEST,

src/plugins/driveBrowserPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ namespace Private {
440440
]
441441
}).then(result => {
442442
if (result.value) {
443-
drive.addPublicDrive(result.value[0]);
443+
drive.addPublicDrive(result.value);
444444
}
445445
});
446446
},

0 commit comments

Comments
 (0)