From 040fe92fe49f850158dae56d85b7902ccc3adec5 Mon Sep 17 00:00:00 2001 From: Nathan LeRoy Date: Tue, 3 Dec 2024 20:39:53 -0500 Subject: [PATCH 1/2] remove bedms, for now --- pephub/routers/api/v1/namespace.py | 14 +-- pephub/routers/api/v1/project.py | 102 +++++++++--------- requirements/requirements-all.txt | 2 +- .../modals/standardize-metadata.tsx | 10 +- .../project/project-page-header-bar.tsx | 17 ++- 5 files changed, 72 insertions(+), 73 deletions(-) diff --git a/pephub/routers/api/v1/namespace.py b/pephub/routers/api/v1/namespace.py index f6a489ae..68935194 100644 --- a/pephub/routers/api/v1/namespace.py +++ b/pephub/routers/api/v1/namespace.py @@ -42,7 +42,7 @@ from ....helpers import parse_user_file_upload, split_upload_files_on_init_file from ...models import FavoriteRequest, ProjectJsonRequest, ProjectRawModel -from bedms.const import AVAILABLE_SCHEMAS +# from bedms.const import AVAILABLE_SCHEMAS load_dotenv() @@ -459,10 +459,10 @@ async def get_archive(namespace: str, agent: PEPDatabaseAgent = Depends(get_db)) return result -@namespace.get( - "/standardizer-schemas", - summary="Get all available schemas from BEDMS", -) -async def get_schemas(namespace: str, agent: PEPDatabaseAgent = Depends(get_db)): +# @namespace.get( +# "/standardizer-schemas", +# summary="Get all available schemas from BEDMS", +# ) +# async def get_schemas(namespace: str, agent: PEPDatabaseAgent = Depends(get_db)): - return AVAILABLE_SCHEMAS +# return AVAILABLE_SCHEMAS diff --git a/pephub/routers/api/v1/project.py b/pephub/routers/api/v1/project.py index 5d873229..5b9965cb 100644 --- a/pephub/routers/api/v1/project.py +++ b/pephub/routers/api/v1/project.py @@ -62,7 +62,7 @@ ) from .helpers import verify_updated_project -from bedms import AttrStandardizer +# from bedms import AttrStandardizer _LOGGER = logging.getLogger(__name__) @@ -1180,53 +1180,53 @@ def delete_full_history( ) -@project.post( - "/standardize", - summary="Standardize PEP metadata column headers", - response_model=StandardizerResponse, -) -async def get_standardized_cols( - pep: dict = Depends(get_project), - schema: str = "", -): - """ - Standardize PEP metadata column headers using BEDms. - - :param pep: PEP string to be standardized - :param schema: Schema for AttrStandardizer - - :return dict: Standardized results - """ - - if schema == "" or schema not in ["ENCODE", "BEDBASE", "FAIRTRACKS"]: - raise HTTPException( - status_code=404, - detail="Schema not available! Available schemas are ENCODE, BEDBASE and FAIRTRACKS.", - ) - - if len(pep["_sample_dict"]) > MAX_STANDARDIZED_PROJECT_SIZE: - # raise HTTPException( - # status_code=400, - # detail=f"Project is too large. Cannot standardize. " - # f"Limit is {MAX_STANDARDIZED_PROJECT_SIZE} samples.", - # ) - prj = peppy.Project.from_dict( - { - "_config": pep["_config"], - "_sample_dict": pep["_sample_dict"][:50], - } - ) - else: - prj = peppy.Project.from_dict(pep) - model = AttrStandardizer(repo_id=BEDMS_REPO_URL, model_name=schema.lower()) - - try: - results = model.standardize(pep=prj) - except Exception as e: - _LOGGER.error(f"Error standardizing PEP. {e}") - raise HTTPException( - status_code=400, - detail=f"Error standardizing PEP.", - ) - - return StandardizerResponse(results=results) +# @project.post( +# "/standardize", +# summary="Standardize PEP metadata column headers", +# response_model=StandardizerResponse, +# ) +# async def get_standardized_cols( +# pep: dict = Depends(get_project), +# schema: str = "", +# ): +# """ +# Standardize PEP metadata column headers using BEDms. + +# :param pep: PEP string to be standardized +# :param schema: Schema for AttrStandardizer + +# :return dict: Standardized results +# """ + +# if schema == "" or schema not in ["ENCODE", "BEDBASE", "FAIRTRACKS"]: +# raise HTTPException( +# status_code=404, +# detail="Schema not available! Available schemas are ENCODE, BEDBASE and FAIRTRACKS.", +# ) + +# if len(pep["_sample_dict"]) > MAX_STANDARDIZED_PROJECT_SIZE: +# # raise HTTPException( +# # status_code=400, +# # detail=f"Project is too large. Cannot standardize. " +# # f"Limit is {MAX_STANDARDIZED_PROJECT_SIZE} samples.", +# # ) +# prj = peppy.Project.from_dict( +# { +# "_config": pep["_config"], +# "_sample_dict": pep["_sample_dict"][:50], +# } +# ) +# else: +# prj = peppy.Project.from_dict(pep) +# model = AttrStandardizer(repo_id=BEDMS_REPO_URL, model_name=schema.lower()) + +# try: +# results = model.standardize(pep=prj) +# except Exception as e: +# _LOGGER.error(f"Error standardizing PEP. {e}") +# raise HTTPException( +# status_code=400, +# detail=f"Error standardizing PEP.", +# ) + +# return StandardizerResponse(results=results) diff --git a/requirements/requirements-all.txt b/requirements/requirements-all.txt index 25631478..29f11d50 100644 --- a/requirements/requirements-all.txt +++ b/requirements/requirements-all.txt @@ -16,4 +16,4 @@ fastembed numpy<2.0.0 slowapi cachetools>=4.2.4 -bedms>=0.2.0 \ No newline at end of file +# bedms>=0.2.0 \ No newline at end of file diff --git a/web/src/components/modals/standardize-metadata.tsx b/web/src/components/modals/standardize-metadata.tsx index d1904b7c..f464421f 100644 --- a/web/src/components/modals/standardize-metadata.tsx +++ b/web/src/components/modals/standardize-metadata.tsx @@ -228,7 +228,7 @@ export const StandardizeMetadataModal = (props: Props) => { }), }} // @ts-ignore - options={schemaOptions?.map(option => ({ value: option, label: option }))} + options={schemaOptions?.map((option) => ({ value: option, label: option }))} defaultValue={selectedOption} value={selectedOption} onChange={(selectedOption) => { @@ -252,11 +252,11 @@ export const StandardizeMetadataModal = (props: Props) => { {maxColsExceeded && ( -
-

+

+

Note: - Your project has nine or more columns. - Due to server constraints, standardization of nine or more columns on PEPhub may take some time. Please be patient. + Your project has nine or more columns. Due to server constraints, standardization of nine or more + columns on PEPhub may take some time. Please be patient.

)} diff --git a/web/src/components/project/project-page-header-bar.tsx b/web/src/components/project/project-page-header-bar.tsx index cd12dae0..b8c94d5d 100644 --- a/web/src/components/project/project-page-header-bar.tsx +++ b/web/src/components/project/project-page-header-bar.tsx @@ -13,14 +13,14 @@ import { useAddStar } from '../../hooks/mutations/useAddStar'; import { useRemoveStar } from '../../hooks/mutations/useRemoveStar'; import { useNamespaceStars } from '../../hooks/queries/useNamespaceStars'; import { useProjectAnnotation } from '../../hooks/queries/useProjectAnnotation'; +import { useSampleTable } from '../../hooks/queries/useSampleTable'; +import { useStandardizeModalStore } from '../../hooks/stores/useStandardizeModalStore'; import { copyToClipboard, getOS, numberWithCommas } from '../../utils/etc'; import { canEdit } from '../../utils/permissions'; import { downloadZip } from '../../utils/project'; import { ProjectHistoryModal } from '../modals/project-history'; import { ProjectHeaderBarPlaceholder } from './placeholders/project-header-bar-placeholder'; -import { ProjectStars } from './project-stars' -import { useStandardizeModalStore } from '../../hooks/stores/useStandardizeModalStore' -import { useSampleTable } from '../../hooks/queries/useSampleTable' +import { ProjectStars } from './project-stars'; type Props = { sampleTable: ReturnType['data']; @@ -146,10 +146,9 @@ export const ProjectHeaderBar = (props: Props) => {
- {projectInfo && !isLoading ? + {projectInfo && !isLoading ? ( - : null - } + ) : null} @@ -204,13 +203,13 @@ export const ProjectHeaderBar = (props: Props) => { {!projectInfo.pop && ( <> setShowProjectHistoryModal(true)}> - + History - setShowStandardizeMetadataModal(true)}> + {/* setShowStandardizeMetadataModal(true)}> Standardize - + */} )} setShowDeletePEPModal(true)}> From 62997ed069060f4b8a9dd0dbab3bce206b4d1204 Mon Sep 17 00:00:00 2001 From: Nathan LeRoy Date: Tue, 3 Dec 2024 20:44:21 -0500 Subject: [PATCH 2/2] bump version --- pephub/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pephub/_version.py b/pephub/_version.py index 745162e7..23f00709 100644 --- a/pephub/_version.py +++ b/pephub/_version.py @@ -1 +1 @@ -__version__ = "0.14.2" +__version__ = "0.14.3"