Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Handle case when identifier type isn't in feature map
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy committed Oct 4, 2023
1 parent 407fa61 commit 550d8ca
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions wyvern/entities/feature_entities.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

import logging
from typing import Dict, List, Optional

import polars as pl
Expand All @@ -9,6 +10,8 @@
from wyvern.entities.identifier import Identifier
from wyvern.wyvern_typing import WyvernFeature

logger = logging.getLogger(__name__)


class FeatureData(BaseModel, frozen=True):
"""
Expand Down Expand Up @@ -80,6 +83,12 @@ def get_features(
identifier_list: List[str],
feature_names: List[str],
) -> pl.DataFrame:
if identifier_type not in self.feature_map:
logger.warning(
f"Identifier type {identifier_type} not found in feature map. "
f"Current identifier types: {self.feature_map.keys()}",
)
return pl.DataFrame()
df = self.feature_map[identifier_type]
# Filter the dataframe by both identifier_type and identifier
df = df.filter(pl.col("identifier").is_in(identifier_list))
Expand Down

0 comments on commit 550d8ca

Please sign in to comment.