Skip to content

Commit f21aa04

Browse files
Allow external storage as file to store at root.
1 parent 4cc72af commit f21aa04

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

datajoint/external.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,17 @@ def s3(self):
7474

7575
def _make_external_filepath(self, relative_filepath):
7676
"""resolve the complete external path based on the relative path"""
77-
posix_path = PurePosixPath(PureWindowsPath(self.spec['location']))
78-
location_path = Path(
79-
*posix_path.parts[1:]) if any(
80-
case in posix_path.parts[0] for case in (
81-
'\\', ':')) else Path(posix_path)
82-
return PurePosixPath(location_path, relative_filepath)
77+
if self.spec['protocol'] == 's3':
78+
posix_path = PurePosixPath(PureWindowsPath(self.spec['location']))
79+
location_path = Path(
80+
*posix_path.parts[1:]) if any(
81+
case in posix_path.parts[0] for case in (
82+
'\\', ':')) else Path(posix_path)
83+
return PurePosixPath(location_path, relative_filepath)
84+
elif self.spec['protocol'] == 'file':
85+
return PurePosixPath(Path(self.spec['location']), relative_filepath)
86+
else:
87+
assert False
8388

8489
def _make_uuid_path(self, uuid, suffix=''):
8590
"""create external path based on the uuid hash"""

tests/test_blob_migrate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from . import S3_CONN_INFO
88
from . import CONN_INFO
99
from datajoint.migrate import _migrate_dj011_blob
10+
dj.config['enable_python_native_blobs'] = True
1011

1112

1213
class TestBlobMigrate:

0 commit comments

Comments
 (0)