Skip to content

Commit

Permalink
remove bedms, for now
Browse files Browse the repository at this point in the history
  • Loading branch information
nleroy917 committed Dec 4, 2024
1 parent 4c700a2 commit 040fe92
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 73 deletions.
14 changes: 7 additions & 7 deletions pephub/routers/api/v1/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
102 changes: 51 additions & 51 deletions pephub/routers/api/v1/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)
from .helpers import verify_updated_project

from bedms import AttrStandardizer
# from bedms import AttrStandardizer

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion requirements/requirements-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ fastembed
numpy<2.0.0
slowapi
cachetools>=4.2.4
bedms>=0.2.0
# bedms>=0.2.0
10 changes: 5 additions & 5 deletions web/src/components/modals/standardize-metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -252,11 +252,11 @@ export const StandardizeMetadataModal = (props: Props) => {
</form>

{maxColsExceeded && (
<div className='row'>
<p className='text-sm mt-3 mb-1'>
<div className="row">
<p className="text-sm mt-3 mb-1">
<strong>Note: </strong>
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.
</p>
</div>
)}
Expand Down
17 changes: 8 additions & 9 deletions web/src/components/project/project-page-header-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof useSampleTable>['data'];
Expand Down Expand Up @@ -146,10 +146,9 @@ export const ProjectHeaderBar = (props: Props) => {
</button>
</div>
</div>
{projectInfo && !isLoading ?
{projectInfo && !isLoading ? (
<ProjectStars project={projectInfo} isStarred={isStarred} starNumber={projectInfo.stars_number} />
: null
}
) : null}
<Dropdown>
<Dropdown.Toggle size="sm" variant="dark">
<i className="bi bi-gear-fill me-1"></i>
Expand Down Expand Up @@ -204,13 +203,13 @@ export const ProjectHeaderBar = (props: Props) => {
{!projectInfo.pop && (
<>
<Dropdown.Item onClick={() => setShowProjectHistoryModal(true)}>
<i className="me-1 bi bi-stopwatch" />
<i className="me-1 bi bi-stopwatch" />
History
</Dropdown.Item>
<Dropdown.Item onClick={() => setShowStandardizeMetadataModal(true)}>
{/* <Dropdown.Item onClick={() => setShowStandardizeMetadataModal(true)}>
<i className="me-1 bi bi-magic"></i>
Standardize
</Dropdown.Item>
</Dropdown.Item> */}
</>
)}
<Dropdown.Item className="text-danger" onClick={() => setShowDeletePEPModal(true)}>
Expand Down

0 comments on commit 040fe92

Please sign in to comment.