def set_workspace_resource_persistence(self, base_dir: str, res_name: str, persistent: bool) -> dict: base_dir = self._resolve_workspace_dir(base_dir) with cwd(base_dir): workspace = self.workspace_manager.set_workspace_resource_persistence( base_dir, res_name, persistent) return self._serialize_workspace(workspace)
def print_workspace_resource(self, base_dir: str, res_name_or_expr: str = None, monitor: Monitor = Monitor.NONE) -> None: with cwd(base_dir): self.workspace_manager.print_workspace_resource( base_dir, res_name_or_expr=res_name_or_expr, monitor=monitor)
def extract_pixel_values(self, base_dir: str, source: str, point: Tuple[float, float], indexers: dict) -> Dict[str, Any]: with cwd(base_dir): from cate.ops.subset import extract_point ds = self.workspace_manager.get_workspace(base_dir).resource_cache.get(source) if ds is None: return {} return extract_point(ds, point, indexers)
def get(self, base_dir, res_name): workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace = workspace_manager.delete_workspace_resource( base_dir, res_name) self.write_status_ok(content=workspace.to_json_dict()) except Exception as e: self.write_status_error(exception=e)
def get(self, base_dir, res_name): new_res_name = self.get_query_argument('new_res_name') workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace = workspace_manager.rename_workspace_resource( base_dir, res_name, new_res_name) self.write_status_ok(content=workspace.to_json_dict()) except Exception as e: self.write_status_error(exception=e)
def run_op_in_workspace(self, base_dir: str, op_name: str, op_args: OpKwArgs, monitor: Monitor = Monitor.NONE) -> Optional[Any]: with cwd(base_dir): return self.workspace_manager.run_op_in_workspace(base_dir, op_name, op_args, monitor=monitor)
def get(self, base_dir): res_name_or_expr = self.get_query_argument('res_name_or_expr', default=None) workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace = workspace_manager.print_workspace_resource( base_dir, res_name_or_expr) self.write_status_ok(content=workspace.to_json_dict()) except Exception as e: self.write_status_error(exception=e)
def get(self, base_dir, res_name): file_path = self.get_query_argument('file_path') format_name = self.get_query_argument('format_name', default=None) workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace = workspace_manager.write_workspace_resource( base_dir, res_name, file_path, format_name=format_name) self.write_status_ok(content=workspace.to_json_dict()) except Exception as e: self.write_status_error(exception=e)
def post(self, base_dir): op_name = self.get_body_argument('op_name') op_args = self.get_body_argument('op_args', default=None) op_args = json.loads(op_args) if op_args else None workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace = workspace_manager.run_op_in_workspace( base_dir, op_name, op_args=op_args, monitor=_new_monitor()) self.write_status_ok(content=workspace.to_json_dict()) except Exception as e: self.write_status_error(exception=e)
def set_workspace_resource(self, base_dir: str, op_name: str, op_args: OpKwArgs, res_name: Optional[str], overwrite: bool, monitor: Monitor) -> list: with cwd(base_dir): workspace, res_name = self.workspace_manager.set_workspace_resource( base_dir, op_name, op_args, res_name=res_name, overwrite=overwrite, monitor=monitor) return [workspace.to_json_dict(), res_name]
def get(self, base_dir, res_name): var_name = self.get_query_argument('var_name', default=None) file_path = self.get_query_argument('file_path', default=None) workspace_manager = self.application.workspace_manager try: with cwd(base_dir): workspace_manager.plot_workspace_resource(base_dir, res_name, var_name=var_name, file_path=file_path) self.write_status_ok() except Exception as e: self.write_status_error(exception=e)
def write_workspace_resource(self, base_dir: str, res_name: str, file_path: str, format_name: str = None, monitor: Monitor = Monitor.NONE) -> None: with cwd(base_dir): self.workspace_manager.write_workspace_resource( base_dir, res_name, file_path, format_name=format_name, monitor=monitor)
def set_workspace_resource(self, base_dir: str, op_name: str, op_args: OpKwArgs, res_name: Optional[str], overwrite: bool, monitor: Monitor) -> list: base_dir = self._resolve_workspace_dir(base_dir) with cwd(base_dir): workspace, res_name = self.workspace_manager.set_workspace_resource( base_dir, op_name, op_args, res_name=res_name, overwrite=overwrite, monitor=monitor) return [self._serialize_workspace(workspace), res_name]
def run_op_in_workspace(self, base_dir: str, op_name: str, op_args: OpKwArgs, monitor: Monitor = Monitor.NONE) -> dict: with cwd(base_dir): workspace = self.workspace_manager.run_op_in_workspace(base_dir, op_name, op_args, monitor=monitor) return workspace.to_json_dict()
def set_workspace_resource_persistence(self, base_dir: str, res_name: str, persistent: bool) -> dict: with cwd(base_dir): workspace = self.workspace_manager.set_workspace_resource_persistence(base_dir, res_name, persistent) return workspace.to_json_dict()
def open_workspace(self, base_dir: str, monitor: Monitor) -> dict: base_dir = self._resolve_workspace_dir(base_dir) with cwd(base_dir): workspace = self.workspace_manager.open_workspace(base_dir, monitor=monitor) return self._serialize_workspace(workspace)