Skip to content

Commit

Permalink
remove Get genesets call (#498)
Browse files Browse the repository at this point in the history
* remove genesets
* removing initial fetch genesets call

Co-authored-by: ashin-czi <ashin@contractor.chanzuckerberg.com>
  • Loading branch information
Bento007 and ashin-czi authored Oct 24, 2022
1 parent fa59fa5 commit 31ce63c
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 107 deletions.
30 changes: 0 additions & 30 deletions client/src/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,6 @@ async function datasetMetadataFetchAndLoad(
portalUrl: links["collections-home-page"],
});
}
/**
*
* @param dispatch Function facilitating update of store.
* @param config Config object returned from config endpoint, notifies if genesets is enabled.
*/
async function genesetsFetchAndLoad(
dispatch: AppDispatch,
config: Config
): Promise<void> {
/* request genesets ONLY if the backend supports the feature */
const defaultResponse = {
genesets: [],
tid: 0,
};
if (config?.parameters?.annotations_genesets ?? false) {
fetchJson("genesets").then((response) => {
dispatch({
type: "geneset: initial load",
data: response ?? defaultResponse,
});
});
} else {
dispatch({
type: "geneset: initial load",
data: defaultResponse,
});
}
}

interface GeneInfoAPI {
ncbi_url: string;
Expand Down Expand Up @@ -194,8 +166,6 @@ const doInitialDataLoad = (): ((

datasetMetadataFetchAndLoad(dispatch, oldPrefix, config);

genesetsFetchAndLoad(dispatch, config);

const baseDataUrl = `${globals.API.prefix}${globals.API.version}`;
const annoMatrix = new AnnoMatrixLoader(baseDataUrl, schema.schema);
const obsCrossfilter = new AnnoMatrixObsCrossfilter(annoMatrix);
Expand Down
45 changes: 0 additions & 45 deletions client/src/reducers/genesets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,51 +53,6 @@ const GeneSets = (
action: AnyAction
): State => {
switch (action.type) {
/**
* Initial, load-time bootstrap.
* {
* type: "geneset: initial load"
* data: JSON response
* }
*/
case "geneset: initial load": {
const { data } = action;

if (
!data ||
typeof data.tid !== "number" ||
!Array.isArray(data.genesets)
)
throw new Error("missing or malformed JSON response");

const lastTid = data.tid;
const genesetsData = data.genesets;
const genesets = new Map();

for (const gsData of genesetsData) {
const genes = new Map();
for (const gene of gsData.genes) {
genes.set(gene.gene_symbol, {
geneSymbol: gene.gene_symbol,
geneDescription: gene?.gene_description ?? "",
});
}
const gs = {
genesetName: gsData.geneset_name,
genesetDescription: gsData?.geneset_description ?? "",
genes,
};
genesets.set(gsData.geneset_name, gs);
}

return {
...state,
initialized: true,
lastTid,
genesets,
};
}

/**
* Creates a new & empty geneset with the given name and description.
* {
Expand Down
8 changes: 0 additions & 8 deletions server/app/api/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ def get(self, data_adaptor):
return common_rest.layout_obs_get(request, data_adaptor)


class GenesetsAPI(S3URIResource):
@cache_control(immutable=True, max_age=ONE_YEAR)
@rest_get_s3uri_data_adaptor
def get(self, data_adaptor):
return common_rest.genesets_get(request, data_adaptor)


class SummarizeVarAPI(S3URIResource):
@rest_get_s3uri_data_adaptor
@cache_control(immutable=True, max_age=ONE_YEAR)
Expand Down Expand Up @@ -214,7 +207,6 @@ def add_resource(resource, url):
add_resource(AnnotationsVarAPI, "/annotations/var")
add_resource(DataVarAPI, "/data/var")
add_resource(GeneInfoAPI, "/geneinfo")
add_resource(GenesetsAPI, "/genesets")
add_resource(SummarizeVarAPI, "/summarize/var")
# Display routes
add_resource(ColorsAPI, "/colors")
Expand Down
12 changes: 0 additions & 12 deletions server/common/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,6 @@ def layout_obs_get(request, data_adaptor):
)


# TODO: I think this is no longer useful, but it is called. So just returning an effectively empty response for now
def genesets_get(request, data_adaptor):
preferred_mimetype = request.accept_mimetypes.best_match(["application/json", "text/csv"])
if preferred_mimetype not in ("application/json"):
return abort(HTTPStatus.NOT_ACCEPTABLE)

try:
return make_response(jsonify({"genesets": [], "tid": 0}), HTTPStatus.OK)
except (ValueError, KeyError) as e:
return abort_and_log(HTTPStatus.BAD_REQUEST, str(e))


def summarize_var_helper(request, data_adaptor, key, raw_query):
preferred_mimetype = request.accept_mimetypes.best_match(["application/octet-stream"])
if preferred_mimetype != "application/octet-stream":
Expand Down
2 changes: 1 addition & 1 deletion server/tests/e2e/test_api_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_cached_endpoints(self):
url_base = "/".join(
[self.api_url_base, "cellxgene", "s3_uri", quote(quote(body, safe=""), safe=""), "api/v0.3"]
)
endpoints = ["config", "schema", "colors", "genesets", "layout/obs", "annotations/obs", "annotations/var"]
endpoints = ["config", "schema", "colors", "layout/obs", "annotations/obs", "annotations/var"]

for endpoint in endpoints:
with self.subTest(endpoint):
Expand Down
11 changes: 0 additions & 11 deletions server/tests/unit/common/apis/test_api_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,6 @@ def test_genesets_config(self):
self.assertTrue(annotations_genesets_readonly)
self.assertEqual(annotations_genesets_summary_methods, ["mean"])

def test_get_genesets(self):
endpoint = "genesets"
for url_base in [self.TEST_URL_BASE, self.TEST_URL_BASE_SPARSE]:
with self.subTest(url_base=url_base):
url = f"{url_base}{endpoint}"
result = self.client.get(url, headers={"Accept": "application/json"})
self.assertEqual(result.status_code, HTTPStatus.OK)
self.assertEqual(result.headers["Content-Type"], "application/json")
result_data = json.loads(result.data)
self.assertIsNotNone(result_data["genesets"])

def test_get_summaryvar(self):
index_col_name = self.schema["schema"]["annotations"]["var"]["index"]
endpoint = "summarize/var"
Expand Down

0 comments on commit 31ce63c

Please sign in to comment.