Skip to content

Commit

Permalink
Deprecate post sample feature type (#112)
Browse files Browse the repository at this point in the history
* Replace deprecated methods using FeatureType and SampleType with DimensionType

* Remove and mark deprecated methods

* Remove unused component

* Add back deprecated FeatureType and SampleType methods expected in SharedApi but mark them deprecated

* Fix eslint no unused variables error
  • Loading branch information
jessica-cheng authored Nov 5, 2024
1 parent 5a52e84 commit 77ee6b1
Show file tree
Hide file tree
Showing 14 changed files with 147 additions and 770 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import { tableFormSchema } from "../models/tableDatasetFormSchema";
import {
DatasetParams,
DataType,
FeatureType,
Group,
InvalidPrioritiesByDataType,
SampleType,
UploadFileResponse,
DimensionType,
SampleDimensionType,
FeatureDimensionType,
} from "@depmap/types";
import ChunkedFileUploader from "./ChunkedFileUploader";

Expand Down Expand Up @@ -60,8 +61,7 @@ interface DatasetFormProps {
// clear_state_callback: (isSuccessfulSubmit: boolean) => void
// ) => void;
// datasetSubmissionError: string | null;
getFeatureTypes: () => Promise<FeatureType[]>;
getSampleTypes: () => Promise<SampleType[]>;
getDimensionTypes: () => Promise<DimensionType[]>;
getDataTypesAndPriorities: () => Promise<InvalidPrioritiesByDataType>;
getGroups: () => Promise<Group[]>;
uploadFile: (fileArgs: { file: File | Blob }) => Promise<UploadFileResponse>;
Expand All @@ -72,8 +72,7 @@ interface DatasetFormProps {

export default function DatasetForm(props: DatasetFormProps) {
const {
getFeatureTypes,
getSampleTypes,
getDimensionTypes,
getGroups,
getDataTypesAndPriorities,
uploadFile,
Expand All @@ -90,10 +89,12 @@ export default function DatasetForm(props: DatasetFormProps) {
const [fileIds, setFileIds] = useState<string[] | null>(null);
const [md5Hash, setMD5Hash] = useState<string | null>(null);

const [featureTypeOptions, setFeatureTypesOptions] = useState<FeatureType[]>(
[]
);
const [sampleTypeOptions, setSampleTypesOptions] = useState<SampleType[]>([]);
const [featureTypeOptions, setFeatureTypesOptions] = useState<
FeatureDimensionType[]
>([]);
const [sampleTypeOptions, setSampleTypesOptions] = useState<
SampleDimensionType[]
>([]);
const [groupOptions, setGroupsOptions] = useState<Group[]>([]);
const [
invalidPrioritiesByDataType,
Expand All @@ -108,13 +109,11 @@ export default function DatasetForm(props: DatasetFormProps) {
try {
const [
dataTypesPriorities,
featureTypes,
sampleTypes,
dimensionTypes,
groups,
] = await Promise.all([
getDataTypesAndPriorities(),
getFeatureTypes(),
getSampleTypes(),
getDimensionTypes(),
getGroups(),
]);

Expand All @@ -123,6 +122,12 @@ export default function DatasetForm(props: DatasetFormProps) {
name: dType,
};
});
const sampleTypes: SampleDimensionType[] = [];
const featureTypes: FeatureDimensionType[] = [];
dimensionTypes.map((dt: FeatureDimensionType | SampleDimensionType) =>
dt.axis === "sample" ? sampleTypes.push(dt) : featureTypes.push(dt)
);

setInvalidPrioritiesByDataType(dataTypesPriorities);
setDataTypeOptions(dataTypes);
setFeatureTypesOptions(featureTypes);
Expand All @@ -133,7 +138,7 @@ export default function DatasetForm(props: DatasetFormProps) {
// setInitFetchError(true);
}
})();
}, [getFeatureTypes, getSampleTypes, getGroups, getDataTypesAndPriorities]);
}, [getDimensionTypes, getGroups, getDataTypesAndPriorities]);

const formComponent = useMemo(() => {
const onSubmitForm = (formData: { [key: string]: any }) => {
Expand Down Expand Up @@ -176,10 +181,12 @@ export default function DatasetForm(props: DatasetFormProps) {
);
}
if (selectedFormat === "table") {
const dimensionTypeOptions: DimensionType[] = (featureTypeOptions as DimensionType[]).concat(
sampleTypeOptions
);
return (
<TableDatasetForm
featureTypes={featureTypeOptions}
sampleTypes={sampleTypeOptions}
dimensionTypes={dimensionTypeOptions}
groups={groupOptions}
dataTypes={dataTypeOptions}
invalidDataTypePriorities={invalidPrioritiesByDataType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { CustomDatasetMetadata } from "./DatasetMetadataForm";
import { FormGroup, ControlLabel } from "react-bootstrap";
import {
DataType,
FeatureType,
FeatureDimensionType,
Group,
InvalidPrioritiesByDataType,
SampleType,
SampleDimensionType,
} from "@depmap/types";
import { Option, TagInput } from "@depmap/common-components";
import { ActionMeta, ValueType } from "react-select";
Expand Down Expand Up @@ -202,8 +202,8 @@ const uiSchema: UiSchema = {
};

interface MatrixDatasetFormProps {
featureTypes: FeatureType[];
sampleTypes: SampleType[];
featureTypes: FeatureDimensionType[];
sampleTypes: SampleDimensionType[];
dataTypes: DataType[];
invalidDataTypePriorities: InvalidPrioritiesByDataType;
groups: Group[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import { CustomDatasetMetadata } from "./DatasetMetadataForm";
import { FormGroup, FormControl, ControlLabel } from "react-bootstrap";
import {
DataType,
FeatureType,
DimensionType,
Group,
InvalidPrioritiesByDataType,
SampleType,
} from "@depmap/types";

const CustomColumnsMetadata = function (props: FieldProps) {
Expand Down Expand Up @@ -138,8 +137,7 @@ function isObject(x: any) {
}

interface TableDatasetFormProps {
featureTypes: FeatureType[];
sampleTypes: SampleType[];
dimensionTypes: DimensionType[];
dataTypes: DataType[];
invalidDataTypePriorities: InvalidPrioritiesByDataType;
groups: Group[];
Expand All @@ -151,8 +149,7 @@ interface TableDatasetFormProps {
}

export function TableDatasetForm({
featureTypes,
sampleTypes,
dimensionTypes,
dataTypes,
invalidDataTypePriorities,
groups,
Expand All @@ -166,7 +163,7 @@ export function TableDatasetForm({
const [schema, setSchema] = React.useState<RJSFSchema | null>(null);

React.useEffect(() => {
const indexOptions = featureTypes.concat(sampleTypes).map((option) => {
const indexOptions = dimensionTypes.map((option) => {
return { title: option.name, const: option.name };
});
const dataTypeOptions = dataTypes.map((option) => {
Expand Down Expand Up @@ -195,7 +192,7 @@ export function TableDatasetForm({
},
};
setSchema(schemaWithOptions);
}, [featureTypes, sampleTypes, dataTypes, groups]);
}, [dataTypes, groups, dimensionTypes]);

React.useEffect(() => {
if (fileIds !== formData.file_ids || md5Hash !== formData.dataset_md5) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ export default function Datasets() {
} | null>(null);
const [showMetadataForm, setShowMetadataForm] = useState<boolean>(false);

// TODO: Remove
const getFeatureTypes = useCallback(() => dapi.getFeatureTypes(), [dapi]);
const getSampleTypes = useCallback(() => dapi.getSampleTypes(), [dapi]);

const getDimensionTypes = useCallback(() => dapi.getDimensionTypes(), [dapi]);
const postDimensionType = useCallback(
(dimTypeArgs: DimensionTypeAddArgs) => dapi.postDimensionType(dimTypeArgs),
Expand Down Expand Up @@ -177,8 +173,7 @@ export default function Datasets() {
formTitle = "Add Dataset";
datasetFormComponent = (
<DatasetForm
getFeatureTypes={getFeatureTypes}
getSampleTypes={getSampleTypes}
getDimensionTypes={getDimensionTypes}
getGroups={getGroups}
getDataTypesAndPriorities={getDataTypesAndPriorities}
uploadFile={postFileUpload}
Expand All @@ -203,9 +198,8 @@ export default function Datasets() {
datasetToEdit,
datasets,
getDataTypesAndPriorities,
getFeatureTypes,
getDimensionTypes,
getGroups,
getSampleTypes,
isEditDatasetMode,
postDatasetUpload,
postFileUpload,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as React from "react";
import {
FeatureType,
DimensionType,
Group,
InvalidPrioritiesByDataType,
SampleType,
UploadFileResponse,
} from "@depmap/types";
import DatasetForm from "../components/DatasetForm";
Expand All @@ -13,31 +12,28 @@ export default {
component: DatasetForm,
};

async function getFeatureTypes(): Promise<FeatureType[]> {
const featureTypes = [
async function getDimensionTypes(): Promise<DimensionType[]> {
const dimensionTypes = [
{
name: "generic",
display_name: "Generic",
id_column: "label",
dataset: null as any,
axis: "feature",
},
{
name: "gene",
display_name: "Gene",
id_column: "entrez_id",
dataset: null,
axis: "feature",
},
];
return featureTypes;
}

async function getSampleTypes(): Promise<SampleType[]> {
const sampleTypes = [
{
name: "depmap_model",
display_name: "Depmap Model",
id_column: "depmap_id",
dataset: null as any,
axis: "sample",
},
];
return sampleTypes;
return dimensionTypes as DimensionType[];
}

async function getGroups() {
Expand Down Expand Up @@ -72,15 +68,14 @@ async function uploadFile(): Promise<UploadFileResponse> {
return { file_id: `id-${counter}` };
}

async function uploadDataset(datasetParams) {
async function uploadDataset(datasetParams: any) {
console.log(datasetParams);
}

export function DatasetFormStory() {
return (
<DatasetForm
getFeatureTypes={getFeatureTypes}
getSampleTypes={getSampleTypes}
getDimensionTypes={getDimensionTypes}
getGroups={getGroups}
getDataTypesAndPriorities={getDataTypesAndPriorities}
uploadFile={uploadFile}
Expand Down
2 changes: 2 additions & 0 deletions frontend/packages/@depmap/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type {

export type {
DimensionType,
SampleDimensionType,
FeatureDimensionType,
DimensionTypeAddArgs,
DimensionTypeUpdateArgs,
} from "./src/DimensionType";
Expand Down
8 changes: 8 additions & 0 deletions frontend/packages/@depmap/types/src/DimensionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export interface DimensionType {
properties_to_index?: string[] | null;
}

export interface FeatureDimensionType extends DimensionType {
axis: "feature";
}

export interface SampleDimensionType extends DimensionType {
axis: "sample";
}

export interface DimensionTypeAddArgs {
name: string;
display_name: string;
Expand Down
4 changes: 4 additions & 0 deletions frontend/packages/@depmap/types/src/FeatureType.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* NOTE: Deprecated Type!! Do not use!
*/

import { Dataset } from "./Dataset";
import { AnnotationTypeMap } from "./Metadata";

Expand Down
3 changes: 3 additions & 0 deletions frontend/packages/@depmap/types/src/SampleType.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* NOTE: Deprecated Type!! Do not use!
*/
import { Dataset } from "./Dataset";
import { AnnotationTypeMap } from "./Metadata";

Expand Down
Loading

0 comments on commit 77ee6b1

Please sign in to comment.