From 4f0299446ed528248f50cd9d5e3191f4a779adf8 Mon Sep 17 00:00:00 2001 From: Sam Grayson Date: Fri, 19 Jan 2024 16:09:34 -0600 Subject: [PATCH 1/3] Make sciunit vcs checkin more robust --- sciunit2/version_control.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sciunit2/version_control.py b/sciunit2/version_control.py index 91a3ab7..dc0eb75 100644 --- a/sciunit2/version_control.py +++ b/sciunit2/version_control.py @@ -24,6 +24,9 @@ def __init__(self, location): # adds a new execution to the de-duplication engine def checkin(self, rev, pkgdir, spinner): parent, name = os.path.split(os.path.abspath(pkgdir)) + # Let filesystem settle before trying to tar it up + # This avoids "file changed as we read it" + os.sync() # creates a tar file from dir 'name' in 'parent' dir, # writes it to stdout, then commits it to # de-duplication engine using 'vv' under the 'rev' eid @@ -40,7 +43,8 @@ def checkin(self, rev, pkgdir, spinner): _, err = p.communicate() if p.returncode == 0: self.cleanup(pkgdir) - return int(err) + last_line = err.split("\n")[-1] + return int(last_line) else: raise CommandError('execution %r already exists' % rev if self.__found(rev) else err) From f1e23cf76b0691a2a62df3b0410e3f8820207173 Mon Sep 17 00:00:00 2001 From: Sam Grayson Date: Fri, 19 Jan 2024 16:16:44 -0600 Subject: [PATCH 2/3] Bytes -> str --- sciunit2/version_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sciunit2/version_control.py b/sciunit2/version_control.py index dc0eb75..7d3a6b2 100644 --- a/sciunit2/version_control.py +++ b/sciunit2/version_control.py @@ -43,7 +43,7 @@ def checkin(self, rev, pkgdir, spinner): _, err = p.communicate() if p.returncode == 0: self.cleanup(pkgdir) - last_line = err.split("\n")[-1] + last_line = err.split(b"\n")[-1] return int(last_line) else: raise CommandError('execution %r already exists' % rev From 35cef52c12cd402ed49d4a82d8bd15f9c704b982 Mon Sep 17 00:00:00 2001 From: Sam Grayson Date: Fri, 19 Jan 2024 16:19:43 -0600 Subject: [PATCH 3/3] Strip string before splitting --- sciunit2/version_control.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sciunit2/version_control.py b/sciunit2/version_control.py index 7d3a6b2..0f8d187 100644 --- a/sciunit2/version_control.py +++ b/sciunit2/version_control.py @@ -43,7 +43,7 @@ def checkin(self, rev, pkgdir, spinner): _, err = p.communicate() if p.returncode == 0: self.cleanup(pkgdir) - last_line = err.split(b"\n")[-1] + last_line = err.strip().split(b"\n")[-1] return int(last_line) else: raise CommandError('execution %r already exists' % rev