[ARVADOS] updated: 1.3.0-971-g64eadab02
Git user
git at public.curoverse.com
Fri Jun 7 16:28:47 UTC 2019
Summary of changes:
sdk/python/arvados/commands/put.py | 33 ++++++++++++++++++++++++++-------
sdk/python/tests/test_arv_put.py | 33 +++++++++++++++++++++++++--------
2 files changed, 51 insertions(+), 15 deletions(-)
via 64eadab02f0ffd58b3b6c66c463b91abe07ecc07 (commit)
via 82748dedc1cf53895da24fba2801ab4cf6c52d80 (commit)
from 56e6ffd4a9b53f5341c542c566b87466ecf37547 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 64eadab02f0ffd58b3b6c66c463b91abe07ecc07
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Fri Jun 7 13:27:22 2019 -0300
14930: Adds expiration notice in local time at the end of the run.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 219db5da8..4b04ad229 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -1002,6 +1002,9 @@ class ArvPutUploadJob(object):
def collection_name(self):
return self._my_collection().api_response()['name'] if self._my_collection().api_response() else None
+ def collection_trash_at(self):
+ return self._my_collection().get_trash_at()
+
def manifest_locator(self):
return self._my_collection().manifest_locator()
@@ -1310,10 +1313,18 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr,
output = ','.join(writer.data_locators())
else:
try:
+ expiration_notice = ""
+ if writer.collection_trash_at() is not None:
+ # Get the local timezone-naive version, and log it with timezone information.
+ local_trash_at = writer.collection_trash_at().replace(tzinfo=None) - datetime.timedelta(seconds=time.timezone)
+ expiration_notice = ". It will expire on {} {}.".format(
+ local_trash_at.strftime("%Y-%m-%d %H:%M:%S"), time.strftime("%z"))
if args.update_collection:
- logger.info(u"Collection updated: '{}'".format(writer.collection_name()))
+ logger.info(u"Collection updated: '{}'{}".format(
+ writer.collection_name(), expiration_notice))
else:
- logger.info(u"Collection saved as '{}'".format(writer.collection_name()))
+ logger.info(u"Collection saved as '{}'{}".format(
+ writer.collection_name(), expiration_notice))
if args.portable_data_hash:
output = writer.portable_data_hash()
else:
commit 82748dedc1cf53895da24fba2801ab4cf6c52d80
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Fri Jun 7 12:00:15 2019 -0300
14930: Assumes end-of-day datetime when --trash-at YYYY-MM-DD only.
Also:
* Refuses day-less dates on --trash-at
* Enhances readability on utc offset usage
* Adds tests
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index defd3c3fd..219db5da8 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -1120,6 +1120,14 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr,
# Trash arguments validation
trash_at = None
if args.trash_at is not None:
+ # ciso8601 considers YYYYMM as invalid but YYYY-MM as valid, so here we
+ # make sure the user provides a complete YYYY-MM-DD date.
+ if not re.match(r'^\d{4}(?P<dash>-?)\d{2}?(?P=dash)\d{2}', args.trash_at):
+ logger.error("--trash-at argument format invalid, use --help to see examples.")
+ sys.exit(1)
+ # Check if no time information was provided. In that case, assume end-of-day.
+ if re.match(r'^\d{4}(?P<dash>-?)\d{2}?(?P=dash)\d{2}$', args.trash_at):
+ args.trash_at += 'T23:59:59'
try:
trash_at = ciso8601.parse_datetime(args.trash_at)
except:
@@ -1128,19 +1136,19 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr,
else:
if trash_at.tzinfo is not None:
# Timezone aware datetime provided.
- utcoffset = trash_at.utcoffset()
+ utcoffset = -trash_at.utcoffset()
else:
# Timezone naive datetime provided. Assume is local.
- utcoffset = datetime.timedelta(hours=-time.timezone/3600)
+ utcoffset = datetime.timedelta(seconds=time.timezone)
# Convert to UTC timezone naive datetime.
- trash_at = trash_at.replace(tzinfo=None) - utcoffset
+ trash_at = trash_at.replace(tzinfo=None) + utcoffset
if trash_at <= datetime.datetime.utcnow():
- logger.error("--trash-at argument should be set in the future")
+ logger.error("--trash-at argument must be set in the future")
sys.exit(1)
if args.trash_after is not None:
if args.trash_after < 1:
- logger.error("--trash-after argument should be >= 1")
+ logger.error("--trash-after argument must be >= 1")
sys.exit(1)
trash_at = datetime.timedelta(seconds=(args.trash_after * 24 * 60 * 60))
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 42ab24235..d27ac9be0 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -1185,7 +1185,7 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
self.assertNotEqual(None, col['uuid'])
c = arv_put.api_client.collections().get(uuid=col['uuid']).execute()
self.assertEqual(
- ciso8601.parse_datetime(trash_at).replace(tzinfo=None)+datetime.timedelta(hours=3),
+ ciso8601.parse_datetime(trash_at).replace(tzinfo=None) + datetime.timedelta(hours=3),
ciso8601.parse_datetime(c['trash_at']).replace(tzinfo=None))
def test_put_collection_with_timezone_naive_expiring_datetime(self):
@@ -1199,17 +1199,34 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
self.assertNotEqual(None, col['uuid'])
c = arv_put.api_client.collections().get(uuid=col['uuid']).execute()
self.assertEqual(
- ciso8601.parse_datetime(trash_at) - datetime.timedelta(hours=-time.timezone/3600),
+ ciso8601.parse_datetime(trash_at) + datetime.timedelta(seconds=time.timezone),
ciso8601.parse_datetime(c['trash_at']).replace(tzinfo=None))
- def test_put_collection_with_invalid_absolute_expiring_datetime(self):
+ def test_put_collection_with_timezone_expiring_date_only(self):
tmpdir = self.make_tmpdir()
+ trash_at = '2140-01-01'
+ end_of_day = datetime.timedelta(hours=23, minutes=59, seconds=59)
with open(os.path.join(tmpdir, 'file1'), 'w') as f:
f.write('Relaxing in basins at the end of inlets terminates the endless tests from the box')
- with self.assertRaises(AssertionError):
- self.run_and_find_collection(
- "",
- ['--no-progress', '--trash-at', 'tomorrow at noon', tmpdir])
+ col = self.run_and_find_collection(
+ "",
+ ['--no-progress', '--trash-at', trash_at, tmpdir])
+ self.assertNotEqual(None, col['uuid'])
+ c = arv_put.api_client.collections().get(uuid=col['uuid']).execute()
+ self.assertEqual(
+ ciso8601.parse_datetime(trash_at) + end_of_day + datetime.timedelta(seconds=time.timezone),
+ ciso8601.parse_datetime(c['trash_at']).replace(tzinfo=None))
+
+ def test_put_collection_with_invalid_absolute_expiring_datetimes(self):
+ cases = ['2100', '210010','2100-10', '2100-Oct']
+ tmpdir = self.make_tmpdir()
+ with open(os.path.join(tmpdir, 'file1'), 'w') as f:
+ f.write('Relaxing in basins at the end of inlets terminates the endless tests from the box')
+ for test_datetime in cases:
+ with self.assertRaises(AssertionError):
+ self.run_and_find_collection(
+ "",
+ ['--no-progress', '--trash-at', test_datetime, tmpdir])
def test_put_collection_with_relative_expiring_datetime(self):
expire_after = 7
@@ -1228,7 +1245,7 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
self.assertTrue(dt_after > trash_at)
def test_put_collection_with_invalid_relative_expiring_datetime(self):
- expire_after = 0 # Should be >= 1
+ expire_after = 0 # Must be >= 1
tmpdir = self.make_tmpdir()
with open(os.path.join(tmpdir, 'file1'), 'w') as f:
f.write('Relaxing in basins at the end of inlets terminates the endless tests from the box')
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list