def delete_runs(self, **opts): if not self._deleted_runs_dir and not opts.get("permanent"): raise remotelib.OperationNotSupported( "remote '%s' does not support non permanent deletes\n" "Use the '--permanent' with this command and try again." % self.name ) args = click_util.Args(archive=self._runs_dir, remote=None, **opts) self._sync_runs_meta() if args.permanent: preview = cmd_impl_support.format_warn( "WARNING: You are about to permanently delete " "the following runs on %s:" % self.name ) confirm = "Permanently delete these runs?" else: preview = "You are about to delete the following runs on %s:" % self.name confirm = "Delete these runs?" no_runs_help = "Nothing to delete." def delete_f(selected): self._delete_runs(selected, args.permanent) self._sync_runs_meta(force=True) try: runs_impl.runs_op( args, None, preview, confirm, no_runs_help, delete_f, confirm_default=not args.permanent, ) except SystemExit as e: raise self._fix_system_exit_msg_for_remote(e, ["runs rm", "runs delete"])
def purge_runs(self, **opts): if not self._deleted_runs_dir: raise remotelib.OperationNotSupported() self._sync_runs_meta() args = click_util.Args(archive=self._deleted_runs_dir, remote=None, **opts) preview = ( "WARNING: You are about to permanently delete " "the following runs on %s:" % self.name ) confirm = "Permanently delete these runs?" no_runs_help = "Nothing to purge." def purge_f(selected): self._purge_runs(selected) self._sync_runs_meta(force=True) try: runs_impl.runs_op( args, None, preview, confirm, no_runs_help, purge_f, confirm_default=False, ) except SystemExit as e: self._fix_system_exit_msg_for_remote(e, ["runs purge"])
def restore_runs(self, **opts): if not self._deleted_runs_dir: raise remotelib.OperationNotSupported() self._sync_runs_meta() args = click_util.Args(archive=self._deleted_runs_dir, remote=None, **opts) preview = "You are about to restore the following runs on %s:" % self.name confirm = "Restore these runs?" no_runs_help = "Nothing to restore." def restore_f(selected): self._restore_runs(selected) self._sync_runs_meta(force=True) try: runs_impl.runs_op( args, None, preview, confirm, no_runs_help, restore_f, confirm_default=True, ) except SystemExit as e: self._fix_system_exit_msg_for_remote(e, ["runs restore"])
def list_runs(self, **opts): deleted = opts.pop("deleted", False) if deleted and not self._deleted_runs_dir: raise remotelib.OperationNotSupported( "remote '%s' does not support '--delete' option" % self.name ) self._sync_runs_meta() runs_dir = self._deleted_runs_dir if deleted else self._runs_dir if not os.path.exists(runs_dir): return assert not opts.get("archive"), opts assert not opts.get("remote"), opts args = click_util.Args( deleted=False, archive=runs_dir, remote=None, json=False, **opts ) try: runs_impl.list_runs(args) except SystemExit as e: raise self._fix_system_exit_msg_for_remote(e, ["runs list", "runs"])
def stop(self): raise remotelib.OperationNotSupported( "stop is not supported for ssh remotes")
def reinit(self): if not self.init: raise remotelib.OperationNotSupported( "init is not defined for this remote") self._ssh_cmd(self.init)
def stop_runs(self, **opts): raise remotelib.OperationNotSupported()
def check(self, **opts): raise remotelib.OperationNotSupported()
def watch_run(self, **opts): raise remotelib.OperationNotSupported()
def run_op(self, opspec, flags, restart, no_wait, **opts): raise remotelib.OperationNotSupported()
def reinit(self): raise remotelib.OperationNotSupported( "reinit is not supported for ssh remotes")