def samples(self, pk: int) -> Response: """get samples from a Dataset --- get: description: >- get samples from a Dataset parameters: - in: path schema: type: integer name: pk - in: query schema: type: boolean name: force responses: 200: description: Dataset samples content: application/json: schema: type: object properties: result: $ref: '#/components/schemas/ChartDataResponseResult' 401: $ref: '#/components/responses/401' 403: $ref: '#/components/responses/403' 404: $ref: '#/components/responses/404' 422: $ref: '#/components/responses/422' 500: $ref: '#/components/responses/500' """ try: force = parse_boolean_string(request.args.get("force")) rv = SamplesDatasetCommand(g.user, pk, force).run() response_data = simplejson.dumps( {"result": rv}, default=json_int_dttm_ser, ignore_nan=True, ) resp = make_response(response_data, 200) resp.headers["Content-Type"] = "application/json; charset=utf-8" return resp except DatasetNotFoundError: return self.response_404() except DatasetForbiddenError: return self.response_403() except DatasetSamplesFailedError as ex: logger.error( "Error get dataset samples %s: %s", self.__class__.__name__, str(ex), exc_info=True, ) return self.response_422(message=str(ex))
# Enable experimental feature to search for other dashboards "OMNIBAR": False, "DASHBOARD_RBAC": False, "ENABLE_EXPLORE_DRAG_AND_DROP": False, # Enabling ALERTS_ATTACH_REPORTS, the system sends email and slack message # with screenshot and link # Disables ALERTS_ATTACH_REPORTS, the system DOES NOT generate screenshot # for report with type 'alert' and sends email and slack message with only link; # for report with type 'report' still send with email and slack message with # screenshot and link "ALERTS_ATTACH_REPORTS": True, } # Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars. DEFAULT_FEATURE_FLAGS.update({ k[len("SUPERSET_FEATURE_"):]: parse_boolean_string(v) for k, v in os.environ.items() if re.search(r"^SUPERSET_FEATURE_\w+", k) }) # This is merely a default. FEATURE_FLAGS: Dict[str, bool] = {} # A function that receives a dict of all feature flags # (DEFAULT_FEATURE_FLAGS merged with FEATURE_FLAGS) # can alter it, and returns a similar dict. Note the dict of feature # flags passed to the function is a deepcopy of the dict in the config, # and can therefore be mutated without side-effect # # GET_FEATURE_FLAGS_FUNC can be used to implement progressive rollouts, # role-based features, or a full on A/B testing framework. #
def put(self, pk: int) -> Response: """Changes a Dataset --- put: description: >- Changes a Dataset parameters: - in: path schema: type: integer name: pk - in: query schema: type: boolean name: override_columns requestBody: description: Dataset schema required: true content: application/json: schema: $ref: '#/components/schemas/{{self.__class__.__name__}}.put' responses: 200: description: Dataset changed content: application/json: schema: type: object properties: id: type: number result: $ref: '#/components/schemas/{{self.__class__.__name__}}.put' 400: $ref: '#/components/responses/400' 401: $ref: '#/components/responses/401' 403: $ref: '#/components/responses/403' 404: $ref: '#/components/responses/404' 422: $ref: '#/components/responses/422' 500: $ref: '#/components/responses/500' """ override_columns = (parse_boolean_string( request.args["override_columns"]) if "override_columns" in request.args else False) if not request.is_json: return self.response_400(message="Request is not JSON") try: item = self.edit_model_schema.load(request.json) # This validates custom Schema with custom validations except ValidationError as error: return self.response_400(message=error.messages) try: changed_model = UpdateDatasetCommand(g.user, pk, item, override_columns).run() if override_columns: RefreshDatasetCommand(g.user, pk).run() response = self.response(200, id=changed_model.id, result=item) except DatasetNotFoundError: response = self.response_404() except DatasetForbiddenError: response = self.response_403() except DatasetInvalidError as ex: response = self.response_422(message=ex.normalized_messages()) except DatasetUpdateFailedError as ex: logger.error( "Error updating model %s: %s", self.__class__.__name__, str(ex), exc_info=True, ) response = self.response_422(message=str(ex)) return response