mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-18 18:38:11 +08:00
This splits the backend into two parts: the local backend for desktop cellxgene and the AWS backend for hosted cellxgene. The local backend is in local_server while the hosted remains in server. The general idea is to copy everything from server to local_server, pull unneeded stuff out of local_server, and keep server as-is for this PR. Not touching server means all the infra and deployment code will continue working just as it did before so we can make those changes incrementally.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""
|
|
Code to decode, for testing purposes, the flatbuffer encoded blobs.
|
|
|
|
This code will need to be updated if fbs/matrix.fbs changes. For more information, see fbs/matrix.fbs and
|
|
local_server/data_common/fbs/
|
|
"""
|
|
|
|
import local_server.data_common.fbs.NetEncoding.Matrix as Matrix
|
|
from local_server.data_common.fbs.matrix import deserialize_typed_array
|
|
|
|
|
|
def decode_matrix_FBS(buf):
|
|
"""
|
|
Given a FBS Matrix, return an decoded Python dict containing same info in native format.
|
|
NOTE / TODO: row_idx not currently implemented
|
|
"""
|
|
df = Matrix.Matrix.GetRootAsMatrix(buf, 0)
|
|
n_rows = df.NRows()
|
|
n_cols = df.NCols()
|
|
|
|
columns_length = df.ColumnsLength()
|
|
|
|
decoded_columns = []
|
|
for col_idx in range(0, columns_length):
|
|
col = df.Columns(col_idx)
|
|
tarr = (col.UType(), col.U())
|
|
decoded_columns.append(deserialize_typed_array(tarr))
|
|
|
|
cidx = deserialize_typed_array((df.ColIndexType(), df.ColIndex()))
|
|
|
|
return {"n_rows": n_rows, "n_cols": n_cols, "columns": decoded_columns, "col_idx": cidx, "row_idx": None}
|