diff --git a/.github/workflows/push-tests.yml b/.github/workflows/push-tests.yml index 98bc24bdb0aea..0d2c53043a615 100644 --- a/.github/workflows/push-tests.yml +++ b/.github/workflows/push-tests.yml @@ -83,7 +83,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -142,7 +142,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -201,7 +201,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -260,7 +260,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -316,7 +316,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -372,7 +372,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* @@ -431,7 +431,7 @@ jobs: fetch-depth: 2 - name: Get changed files id: changed-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.3.0 with: files: | Dockerfile* diff --git a/backend/layers/processing/process_validate.py b/backend/layers/processing/process_validate.py index 58220fa6390a4..bdd9921b0b407 100644 --- a/backend/layers/processing/process_validate.py +++ b/backend/layers/processing/process_validate.py @@ -117,12 +117,11 @@ def get_spatial_metadata(self, spatial_dict: Dict[str, Any]) -> Optional[Spatial """ is_single = spatial_dict.get("is_single") has_fullres = False - # schema validation ensures nested 'fullres' key is only included when is_single is True - if is_single: - # schema validation ensures there can only be one other key in uns["spatial"] if "is_single" is True - library_id = [key for key in spatial_dict if key != "is_single"][0] - if "fullres" in spatial_dict[library_id]["images"]: - has_fullres = True + spatial_library_ids = [key for key in spatial_dict if key != "is_single"] + # schema validation ensures there can only be at max, one other key in uns["spatial"] if "is_single" is True + library_id = spatial_library_ids.pop() if spatial_library_ids else None + if library_id and "images" in spatial_dict[library_id] and "fullres" in spatial_dict[library_id]["images"]: + has_fullres = True return SpatialMetadata(is_single=bool(is_single), has_fullres=has_fullres) @logit diff --git a/frontend/.gitignore b/frontend/.gitignore index 5fedafacaafbc..0044c90ec0e84 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -87,18 +87,8 @@ loginState.json public/sitemap* public/robots.txt -# Cell Guide -src/views/CellGuide/common/fixtures/allCellTypeDescriptions.json -src/views/CellGuide/common/fixtures/allCellTypeDescriptionsSEO.json -src/views/CellGuide/common/fixtures/allCellTypeMarkerGenes.json -src/views/CellGuide/common/fixtures/allCellTypeOwlDescriptions.json -src/views/CellGuide/common/fixtures/allCellTypes.json -src/views/CellGuide/common/fixtures/allEnrichedGenes/ -src/views/CellGuide/common/fixtures/allSourceData.json -src/views/CellGuide/common/fixtures/allTissueDescriptions.json -src/views/CellGuide/common/fixtures/allTissues.json -src/views/CellGuide/common/fixtures/ontologyTree.json -src/views/CellGuide/common/fixtures/ontologyTreeStatePerCellType.json -src/views/CellGuide/common/fixtures/ontologyTreeStatePerTissue.json - -certificates \ No newline at end of file +# Filter descendants +src/components/common/Filter/descendant_mappings/cell_type_descendants.json +src/components/common/Filter/descendant_mappings/tissue_descendants.json + +certificates diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 435816aa81b2e..5890f5ab2949e 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -18,14 +18,25 @@ RUN apt-get update && apt-get install -y make wget \ lsb-release xdg-utils nano vim procps moreutils ripgrep \ && rm -rf /var/lib/apt/lists/* +# Create the directory `make retrieve-descendants` expects before running npm ci, which runs `make retrieve-descendants` +# as a preinstall script +RUN mkdir -p src/components/common/Filter/descendant_mappings + +COPY Makefile ./ COPY package*.json ./ RUN npm ci --verbose --no-optional && npm cache clean --force + ENV PATH /opt/node_app/node_modules/.bin:$PATH # -- TODO, we should try turning this back on later. # ADD --chown=node . /corpora-frontend ADD . /corpora-frontend + +# Explicitly copy the JSON files from the earlier steps +RUN cp -r /opt/node_app/src/components/common/Filter/descendant_mappings/* /corpora-frontend/src/components/common/Filter/descendant_mappings/ + WORKDIR /corpora-frontend + ADD ./src/configs/build.js src/configs/configs.js RUN mkdir -p node_modules RUN ln -sf /opt/node_app/node_modules/* /opt/node_app/node_modules/.bin ./node_modules/. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 88f6ae35895ec..d709719a8979c 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "cellxgene-data-portal", "version": "0.1.0", + "hasInstallScript": true, "license": "MIT", "dependencies": { "@blueprintjs/core": "^5.8.2", diff --git a/frontend/package.json b/frontend/package.json index 9129a02f72cf8..8eb40cf3c7c9c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -118,8 +118,7 @@ ], "license": "MIT", "scripts": { - "predev": "make retrieve-descendants", - "prebuild": "make retrieve-descendants", + "preinstall": "make retrieve-descendants", "dev": "next dev --experimental-https", "build": "NODE_OPTIONS=\"--max_old_space_size=2048\" next build", "start": "next start", diff --git a/frontend/src/components/common/Filter/descendant_mappings/cell_type_descendants.json b/frontend/src/components/common/Filter/descendant_mappings/cell_type_descendants.json deleted file mode 100644 index 9e26dfeeb6e64..0000000000000 --- a/frontend/src/components/common/Filter/descendant_mappings/cell_type_descendants.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/frontend/src/components/common/Filter/descendant_mappings/tissue_descendants.json b/frontend/src/components/common/Filter/descendant_mappings/tissue_descendants.json deleted file mode 100644 index 9e26dfeeb6e64..0000000000000 --- a/frontend/src/components/common/Filter/descendant_mappings/tissue_descendants.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/frontend/src/global.d.ts b/frontend/src/global.d.ts index 4b0f4cfcec335..baa8fa2292779 100644 --- a/frontend/src/global.d.ts +++ b/frontend/src/global.d.ts @@ -20,3 +20,13 @@ namespace HubSpotFormAPI { } declare const hbspt: HubSpotFormAPI.HubSpot; + +declare module "src/components/common/Filter/descendant_mappings/cell_type_descendants.json" { + const value: { [key: string]: string[] }; + export default value; +} + +declare module "src/components/common/Filter/descendant_mappings/tissue_descendants.json" { + const value: { [key: string]: string[] }; + export default value; +} diff --git a/tests/unit/processing/test_extract_metadata.py b/tests/unit/processing/test_extract_metadata.py index b59da6a98c972..163cbea3b91e0 100644 --- a/tests/unit/processing/test_extract_metadata.py +++ b/tests/unit/processing/test_extract_metadata.py @@ -290,7 +290,7 @@ def test_get_spatial_metadata__is_single_and_fullres_true(self): } self.assertEqual(self.pdv.get_spatial_metadata(spatial_dict), SpatialMetadata(is_single=True, has_fullres=True)) - def test_get_spatial_metadata__is_single_true_fullres_false(self): + def test_get_spatial_metadata__is_single_true_and_fullres_false(self): spatial_dict = { "is_single": True, "dummy_library_id": {"images": {}}, @@ -299,6 +299,12 @@ def test_get_spatial_metadata__is_single_true_fullres_false(self): self.pdv.get_spatial_metadata(spatial_dict), SpatialMetadata(is_single=True, has_fullres=False) ) + def test_get_spatial_metadata__is_single_true_and_no_library_id(self): + spatial_dict = {"is_single": np.bool_(True)} + self.assertEqual( + self.pdv.get_spatial_metadata(spatial_dict), SpatialMetadata(is_single=True, has_fullres=False) + ) + def test_get_spatial_metadata__is_single_false(self): spatial_dict = {"is_single": np.bool_(False)} self.assertEqual(