コード例 #1
0
    def copy_study(
        self,
        src_uuid: str,
        dest_study_name: str,
        group_ids: List[str],
        params: RequestParameters,
    ) -> str:
        src_study = self._get_study(src_uuid)
        self._assert_permission(params.user, src_study,
                                StudyPermissionType.READ)

        if not isinstance(src_study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {src_uuid} with type {src_study.type} not recognized")

        dest_study = deepcopy(src_study)
        dest_study.id = str(uuid4())
        dest_study.name = dest_study_name
        dest_study.workspace = DEFAULT_WORKSPACE_NAME
        dest_study.path = str(self.study_service.get_default_workspace_path() /
                              dest_study.id)

        study = self.study_service.copy_study(src_study, dest_study)
        self._save_study(study, params.user, group_ids)
        self.event_bus.push(
            Event(EventType.STUDY_CREATED, study.to_json_summary()))
        return str(study.id)
コード例 #2
0
    def get_study_information(self, uuid: str,
                              params: RequestParameters) -> JSON:
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.READ)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        return self.study_service.get_study_information(study)
コード例 #3
0
    def get_matrix(self, route: str, params: RequestParameters) -> bytes:
        uuid, path = StorageServiceUtils.extract_info_from_url(route)
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.READ)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        return self.exporter_service.get_matrix(study, path)
コード例 #4
0
    def get(self, route: str, depth: int, params: RequestParameters) -> JSON:
        uuid, url = StorageServiceUtils.extract_info_from_url(route)
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.READ)

        if isinstance(study, RawStudy):
            return self.study_service.get(study, url, depth)

        raise StudyTypeUnsupported(
            f"Study {uuid} with type {study.type} not recognized")
コード例 #5
0
    def import_output(self, uuid: str, stream: IO[bytes],
                      params: RequestParameters) -> JSON:
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.RUN)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        res = self.importer_service.import_output(study, stream)
        return res
コード例 #6
0
    def delete_output(self, uuid: str, output_name: str,
                      params: RequestParameters) -> None:
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.WRITE)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        self.study_service.delete_output(study, output_name)
        self.event_bus.push(
            Event(EventType.STUDY_EDITED, study.to_json_summary()))
コード例 #7
0
    def edit_study(self, route: str, new: JSON,
                   params: RequestParameters) -> JSON:
        uuid, url = StorageServiceUtils.extract_info_from_url(route)
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.WRITE)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        updated = self.study_service.edit_study(study, url, new)
        self.event_bus.push(
            Event(EventType.STUDY_EDITED, study.to_json_summary()))
        return updated
コード例 #8
0
    def upload_matrix(self, path: str, data: bytes,
                      params: RequestParameters) -> None:
        uuid, matrix_path = StorageServiceUtils.extract_info_from_url(path)
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.WRITE)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        self.importer_service.upload_matrix(study, matrix_path, data)

        self.event_bus.push(
            Event(EventType.STUDY_EDITED, study.to_json_summary()))
コード例 #9
0
    def export_study(
        self,
        uuid: str,
        params: RequestParameters,
        outputs: bool = True,
    ) -> BytesIO:
        study = self._get_study(uuid)
        self._assert_permission(params.user, study, StudyPermissionType.READ)
        if not isinstance(study, RawStudy):
            raise StudyTypeUnsupported(
                f"Study {uuid} with type {study.type} not recognized")

        return self.exporter_service.export_study(study, outputs)