Skip to content

Commit

Permalink
Merge 5d32eef into e1e6cdf
Browse files Browse the repository at this point in the history
  • Loading branch information
aschroed committed Sep 28, 2022
2 parents e1e6cdf + 5d32eef commit b686b11
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ AllItems.xls
Custom_scripts/
Data_Files/MicroscopyCalibration/Files/
.pytest_cache/
.python-version
8 changes: 6 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@ Change Log
----------


3.0.1
=====

* Bug fix: Windows paths were not handled properly for File upload.

3.0.0
=======

`PR 159: Remove Python3.6 support <https://github.com/4dn-dcic/Submit4DN/pull/159>`_

* Drop support for Python3.6

* Add this CHANGELOG and test warning if it's not updated
* Add this CHANGELOG and test warning if it's not updated

* Update dependency to use dcicutils >=4.0

Expand Down Expand Up @@ -212,4 +217,3 @@ Change Log

0.2.2
=====

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Submit4DN"
version = "3.0.0"
version = "3.0.1"
description = "Utility package for submitting data to the 4DN Data Portal"
authors = ["4DN-DCIC Team <support@4dnucleome.org>"]
license = "MIT"
Expand Down
13 changes: 13 additions & 0 deletions tests/test_import_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import wranglertools.import_data as imp
import pytest
import pathlib as pp
# test data is in conftest.py


Expand Down Expand Up @@ -1556,3 +1557,15 @@ def test_get_collections(mock_profiles):
colls = imp.get_collections(mock_profiles)
for c in mock_profiles.keys():
assert c.lower() in colls


def test_get_just_filename_posix():
test_path = pp.PurePosixPath('Users', 'username', 'test_dir', 'test_file.fastq.gz')
filename = imp.get_just_filename(test_path)
assert filename == 'test_file.fastq.gz'


def test_get_just_filename_windows():
test_path = pp.PureWindowsPath('c:/', 'Users', 'username', 'test_dir', 'test_file.fastq.gz')
filename = imp.get_just_filename(test_path)
assert filename == 'test_file.fastq.gz'
22 changes: 16 additions & 6 deletions wranglertools/import_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def build_patch_json(fields, fields2types):


def get_just_filename(path):
return path.split('/')[-1]
return pp.Path(path).name


def check_extra_file_meta(ef_info, seen_formats, existing_formats):
Expand Down Expand Up @@ -1452,15 +1452,25 @@ def upload_file(creds, path): # pragma: no cover
print("Uploading file.")
start = time.time()
try:
subprocess.check_call(['aws', 's3', 'cp', '--only-show-errors', path, creds['upload_url']], env=env)
source = path
target = creds['upload_url']
print("Going to upload {} to {}.".format(source, target))
command = ['aws', 's3', 'cp']
command = command + ['--only-show-errors', source, target]
options = {}
if running_on_windows_native():
options = {"shell": True}
subprocess.check_call(command, env=env, **options)
except subprocess.CalledProcessError as e:
# The aws command returns a non-zero exit code on error.
print("Upload failed with exit code %d" % e.returncode)
sys.exit(e.returncode)
raise RuntimeError("Upload failed with exit code %d" % e.returncode)
else:
end = time.time()
duration = end - start
print("Uploaded in %.2f seconds" % duration)
show("Uploaded in %.2f seconds" % duration)


def running_on_windows_native():
return os.name == 'nt'


# the order to try to upload / update the items
Expand Down

0 comments on commit b686b11

Please sign in to comment.