diff --git a/sciunit2/command/checkout.py b/sciunit2/command/checkout.py index 31269d6..5176dcd 100644 --- a/sciunit2/command/checkout.py +++ b/sciunit2/command/checkout.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from sciunit2.command import AbstractCommand -from sciunit2.command.context import CheckoutContext +from sciunit2.command.context import CheckoutContext_Parallel from sciunit2.exceptions import CommandLineError from sciunit2.util import quoted_format import sciunit2.core @@ -22,7 +22,7 @@ def run(self, args): optlist, args = getopt(args, '') if len(args) != 1: raise CommandLineError - with CheckoutContext(args[0]) as (pkgdir, _): + with CheckoutContext_Parallel(args[0]) as (pkgdir, _): return pkgdir def note(self, project_dir): diff --git a/sciunit2/command/context.py b/sciunit2/command/context.py index 5e16891..22eb65f 100644 --- a/sciunit2/command/context.py +++ b/sciunit2/command/context.py @@ -18,6 +18,18 @@ def CheckoutContext(rev): repo.checkout(rev) yield pkgdir, orig +# returns the pkgdir and original command used +# to execute execution 'rev' +@contextmanager +def CheckoutContext_Parallel(rev): + emgr, repo = sciunit2.workspace.current() + with emgr.exclusive(): + orig = emgr.get(rev).cmd + pkgdir = os.path.join(repo.location,rev,'cde-package') + repo.cleanup(pkgdir) + repo.checkout_Parallel(rev) + yield pkgdir, orig + @contextmanager def CheckoutContext_Diff(rev): diff --git a/sciunit2/command/repeat.py b/sciunit2/command/repeat.py index f79e04c..fdd69bb 100644 --- a/sciunit2/command/repeat.py +++ b/sciunit2/command/repeat.py @@ -1,7 +1,7 @@ from __future__ import absolute_import from sciunit2.command import AbstractCommand -from sciunit2.command.context import CheckoutContext +from sciunit2.command.context import CheckoutContext_Parallel from sciunit2.exceptions import CommandLineError import sciunit2.core @@ -21,5 +21,5 @@ def run(self, args): optlist, args = getopt(args, '') if not args: raise CommandLineError - with CheckoutContext(args[0]) as (pkgdir, orig): + with CheckoutContext_Parallel(args[0]) as (pkgdir, orig): sys.exit(sciunit2.core.repeat(pkgdir, orig, args[1:])) diff --git a/sciunit2/version_control.py b/sciunit2/version_control.py index 91a3ab7..a88c8b7 100644 --- a/sciunit2/version_control.py +++ b/sciunit2/version_control.py @@ -56,6 +56,21 @@ def checkout(self, rev): raise CommandError('execution %r not found' % rev if not self.__found(rev) else err) + # brings out the execution identified by 'rev' + # from the de-duplication engine + def checkout_Parallel(self, rev): + rev_repo = os.path.join(self.location, rev) + self._mkdir_p(rev_repo) + self.cleanup(os.path.join(rev_repo, 'cde-package')) + cmd = quoted_format('{0} checkout {1} - | tar xf - -C {2}', + sciunit2.libexec.vv.which, rev, rev_repo) + p = subprocess.Popen(cmd, shell=True, cwd=self.location, stderr=PIPE) + _, err = p.communicate() + print("hi in checkout parallel"+cmd) + if p.wait() != 0: + raise CommandError('execution %r not found' % rev + if not self.__found(rev) else err) + def checkout_Diff(self, rev): cmd = quoted_format('{0} checkout {1} - | tar xf -', sciunit2.libexec.vv.which, rev)