Skip to content

Commit 4bab58b

Browse files
committed
update backend to add support for external drives
1 parent 916d80a commit 4bab58b

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

jupyter_drives/handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ async def post(self, drive: str = "", path: str = ""):
101101
body = self.get_json_body()
102102
if 'location' in body:
103103
result = await self._manager.new_drive(drive, **body)
104-
if 'public' in body:
105-
result = await self._manager.add_public_drive(drive)
104+
if 'is_public' in body:
105+
result = await self._manager.add_external_drive(drive, **body)
106106
else:
107107
result = await self._manager.new_file(drive, path, **body)
108108
self.finish(result)

jupyter_drives/manager.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,11 @@ async def mount_drive(self, drive_name, provider):
311311
"""
312312
try:
313313
if provider == 's3':
314-
region = await self._get_drive_location(drive_name)
314+
if drive_name in self._external_drives and self._external_drives[drive_name]["is_public"] is False:
315+
print('FOUND DRIVE IN EXTERNAL TO MOUNT: ', self._external_drives[drive_name]["location"])
316+
region = self._external_drives[drive_name]["location"]
317+
else:
318+
region = await self._get_drive_location(drive_name)
315319
self._initialize_content_manager(drive_name, provider, region)
316320
except Exception as e:
317321
raise tornado.web.HTTPError(
@@ -712,18 +716,21 @@ async def new_drive(self, new_drive_name, location='us-east-1'):
712716

713717
return
714718

715-
async def add_public_drive(self, drive_name):
719+
async def add_external_drive(self, drive_name, is_public, region='us-east-1'):
716720
"""Mount a drive.
717721
718722
Args:
719723
drive_name: name of public bucket to mount
720724
"""
721725
try:
722726
drive = {
723-
"is_public": True,
724-
"url": drive_name
727+
"is_public": is_public,
728+
"url": drive_name,
729+
"location": region
725730
};
731+
print('ADDED DRIVE: ', drive)
726732
self._external_drives[drive_name] = drive;
733+
print('NEW EXTERNAL DRIVEs: ', self._external_drives)
727734
except Exception as e:
728735
raise tornado.web.HTTPError(
729736
status_code= httpx.codes.BAD_REQUEST,

0 commit comments

Comments
 (0)