Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ env:
- COMPOSE_HTTP_TIMEOUT="300"
- UID="2000"
- GID="2000"
- COVERALLS_SERVICE_NAME="travis-ci"
- COVERALLS_REPO_TOKEN="fd0BoXG46TPReEem0uMy7BJO5j0w1MQiY"
services:
- docker
main: &main
Expand Down Expand Up @@ -64,10 +66,3 @@ jobs:
env:
- PY_VER: "3.5"
- MYSQL_VER: "5.6"
- stage: Coverage
os: linux
language: shell
script:
- sudo pip install python-coveralls
- coveralls
>>>>>>> bff58baac8da58b43be95ba1c58174cb7721411f
5 changes: 4 additions & 1 deletion LNX-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ services:
- PYTHON_USER=dja
- JUPYTER_PASSWORD=datajoint
- DISPLAY
- COVERALLS_SERVICE_NAME
- COVERALLS_REPO_TOKEN
working_dir: /src
command: >
/bin/sh -c
"
pip install --user nose nose-cov .;
pip install --user nose nose-cov coveralls .;
pip freeze | grep datajoint;
nosetests -vsw tests --with-coverage --cover-package=datajoint;
coveralls;
# jupyter notebook;
"
# ports:
Expand Down
4 changes: 2 additions & 2 deletions datajoint/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def s3(self):

def _make_external_filepath(self, relative_filepath):
"""resolve the complete external path based on the relative path"""
return PurePosixPath(self.spec['location'], relative_filepath)
return PurePosixPath(Path(self.spec['location']), relative_filepath)

def _make_uuid_path(self, uuid, suffix=''):
"""create external path based on the uuid hash"""
Expand Down Expand Up @@ -211,7 +211,7 @@ def upload_filepath(self, local_filepath):
"""
local_filepath = Path(local_filepath)
try:
relative_filepath = str(local_filepath.relative_to(self.spec['stage']))
relative_filepath = str(local_filepath.relative_to(self.spec['stage']).as_posix())
except ValueError:
raise DataJointError('The path {path} is not in stage {stage}'.format(
path=local_filepath.parent, **self.spec)) from None
Expand Down
14 changes: 7 additions & 7 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def setup_package():

# Add old MySQL
source = Path(
os.path.dirname(os.path.realpath(__file__)),
Path(__file__).resolve().parent,
'external-legacy-data')
db_name = "djtest_blob_migrate"
db_file = "v0_11.sql"
Expand All @@ -127,7 +127,7 @@ def setup_package():

# Add old S3
source = Path(
os.path.dirname(os.path.realpath(__file__)),
Path(__file__).resolve().parent,
'external-legacy-data','s3')
bucket = "migrate-test"
region = "us-east-1"
Expand All @@ -141,7 +141,7 @@ def setup_package():
if os.path.isfile(str(path)) and ".sql" not in str(path):
minioClient.fput_object(
bucket, str(Path(
os.path.relpath(path,Path(source,bucket)))
os.path.relpath(str(path),str(Path(source,bucket))))
.as_posix()), str(path))
# Add S3
try:
Expand All @@ -152,9 +152,9 @@ def setup_package():
# Add old File Content
try:
shutil.copytree(
Path(os.path.dirname(os.path.realpath(__file__)),
'external-legacy-data','file','temp'),
Path(os.path.expanduser('~'),'temp'))
str(Path(Path(__file__).resolve().parent,
'external-legacy-data','file','temp')),
str(Path(os.path.expanduser('~'),'temp')))
except FileExistsError:
pass

Expand Down Expand Up @@ -191,4 +191,4 @@ def teardown_package():
minioClient.remove_bucket(bucket)

# Remove old File Content
shutil.rmtree(Path(os.path.expanduser('~'),'temp'))
shutil.rmtree(str(Path(os.path.expanduser('~'),'temp')))
30 changes: 30 additions & 0 deletions tests/test_filepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@
def setUp(self):
dj.config['stores'] = stores_config

def test_path_match(store="repo"):
""" test file path matches and empty file"""
ext = schema.external[store]
stage_path = dj.config['stores'][store]['stage']

# create a mock file
relpath = 'path/to/films'
managed_file = Path(stage_path, relpath, 'vid.mov')
managed_file.parent.mkdir(parents=True, exist_ok=True)
open(str(managed_file), 'a').close()

# put the file
uuid = ext.upload_filepath(managed_file)

#remove
managed_file.unlink()
assert_false(managed_file.exists())

#check filepath
assert_equal(
(ext & {'hash': uuid}).fetch1('filepath'),
str(managed_file.relative_to(stage_path).as_posix()))

# # Download the file and check its contents.
restored_path, checksum = ext.download_filepath(uuid)
assert_equal(restored_path, managed_file)
assert_equal(checksum, dj.hash.uuid_from_file(managed_file))

# cleanup
ext.delete(delete_external_files=True)

def test_filepath(store="repo"):
""" test file management """
Expand Down