mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-03 21:18:11 +08:00
Move jsonification to engine level (#511)
This commit is contained in:
@@ -3,6 +3,9 @@ from enum import Enum
|
||||
|
||||
DEFAULT_TOP_N = 10
|
||||
|
||||
# response mimetypes
|
||||
JSON_MIMETYPE = "application/json"
|
||||
|
||||
|
||||
class AugmentedEnum(Enum):
|
||||
def __hash__(self):
|
||||
@@ -27,4 +30,6 @@ class DiffExpMode(AugmentedEnum):
|
||||
VAR_FILTER = "varFilter"
|
||||
|
||||
|
||||
JSON_NaN_to_num_warning_msg = "JSON encoding failure - suggest trying --nan-to-num command line option"
|
||||
JSON_NaN_to_num_warning_msg = (
|
||||
"JSON encoding failure - suggest trying --nan-to-num command line option"
|
||||
)
|
||||
|
||||
@@ -16,6 +16,15 @@ class InteractiveError(Exception):
|
||||
self.message = message
|
||||
|
||||
|
||||
class JSONEncodingValueError(Exception):
|
||||
"""
|
||||
Raised when file loaded into scanpy is misformatted
|
||||
"""
|
||||
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
|
||||
class MimeTypeError(Exception):
|
||||
"""
|
||||
Raised when incompatible MIME type selected
|
||||
|
||||
@@ -54,3 +54,7 @@ def whole_number(value):
|
||||
if value < 0:
|
||||
raise ArgumentTypeError(f"{value} is not >= 0")
|
||||
return value
|
||||
|
||||
|
||||
def jsonify_scanpy(data):
|
||||
return json.dumps(data, cls=Float32JSONEncoder, allow_nan=False)
|
||||
|
||||
Reference in New Issue
Block a user