Exemplo n.º 1
0
 def log_lines(
     self,
     app_handle: AppHandle,
     role_name: str,
     k: int = 0,
     regex: Optional[str] = None,
     since: Optional[datetime] = None,
     until: Optional[datetime] = None,
     should_tail: bool = False,
 ) -> Iterable:
     scheduler_backend, _, app_id = parse_app_handle(app_handle)
     tsm_event = self._generate_tsm_event(
         "log_lines",
         scheduler_backend,
         app_id,
     )
     try:
         log_iter = self._log_lines(app_handle, role_name, k, regex, since,
                                    until, should_tail)
         record(tsm_event)
         return log_iter
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 2
0
 def list(self) -> Dict[AppHandle, Application]:
     tsm_event = self._generate_tsm_event("list", "")
     try:
         res = self._list()
         record(tsm_event)
         return res
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 3
0
 def wait(self, app_handle: AppHandle) -> Optional[AppStatus]:
     scheduler_backend, _, app_id = parse_app_handle(app_handle)
     tsm_event = self._generate_tsm_event("wait", scheduler_backend, app_id)
     try:
         record(tsm_event)
         return self._wait(app_handle)
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 4
0
 def status(self, app_handle: AppHandle) -> Optional[AppStatus]:
     # allow status checks of apps from other sessions
     scheduler_backend, _, app_id = parse_app_handle(app_handle)
     tsm_event = self._generate_tsm_event("status", scheduler_backend,
                                          app_id)
     try:
         app_status = self._status(app_handle)
         record(tsm_event)
         return app_status
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 5
0
 def stop(self, app_handle: AppHandle) -> None:
     scheduler_backend, _, app_id = parse_app_handle(app_handle)
     tsm_event = self._generate_tsm_event(
         "stop",
         scheduler_backend,
         app_id,
     )
     try:
         self._stop(app_handle)
         record(tsm_event)
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 6
0
    def describe(self, app_handle: AppHandle) -> Optional[Application]:
        scheduler_backend, _, app_id = parse_app_handle(app_handle)

        tsm_event = self._generate_tsm_event(
            "describe",
            scheduler_backend,
            app_id,
        )
        try:
            res = self._describe(app_handle)
            record(tsm_event)
            return res
        except Exception:
            tsm_event.raw_exception = traceback.format_exc()
            record(tsm_event)
            raise
Exemplo n.º 7
0
 def status(self,
            app_handle: AppHandle,
            external: bool = True) -> Optional[AppStatus]:
     # TODO(wilsonhong): ``external`` is a short term soluation. For long term we should
     # fill this value automatically instead of exposing this to user.
     # allow status checks of apps from other sessions
     scheduler_backend, _, app_id = parse_app_handle(app_handle)
     tsm_event = self._generate_tsm_event(
         "status",
         scheduler_backend,
         app_id,
         source=SourceType.EXTERNAL if external else SourceType.INTERNAL,
     )
     try:
         app_status = self._status(app_handle)
         record(tsm_event)
         return app_status
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise
Exemplo n.º 8
0
 def schedule(self, dryrun_info: AppDryRunInfo) -> AppHandle:
     scheduler_backend = dryrun_info._scheduler
     runcfg = json.dumps(
         dryrun_info._cfg.cfgs) if dryrun_info._cfg else None
     tsm_event = self._generate_tsm_event(
         "schedule",
         scheduler_backend,
         runcfg=runcfg,
     )
     try:
         app_handle = self._schedule(dryrun_info)
         _, _, app_id = parse_app_handle(app_handle)
         tsm_event.app_id = app_id
         # TODO(avivanou): t81936552 each action corresponds to a method call
         # as a result instead of repeatedly log events in each method, we
         # can log them implicitly via footsteps lib
         record(tsm_event)
         return app_handle
     except Exception:
         tsm_event.raw_exception = traceback.format_exc()
         record(tsm_event)
         raise