Skip to content

Commit

Permalink
Refactor _extract_global_metadata() (#452)
Browse files Browse the repository at this point in the history
This PR does 3 things:

1. Makes `_extract_global_metadata()` private
2. Removes the part in the definition where it adds a `CURIE_MAP` since
this is subsequently popped off
3. Updates the return type to be more accurate
  • Loading branch information
cthoyt authored Oct 9, 2023
1 parent 2ce7779 commit c403512
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/sssom/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
COLUMN_INVERT_DICTIONARY,
COMMENT,
CONFIDENCE,
CURIE_MAP,
MAPPING_JUSTIFICATION,
MAPPING_SET_ID,
MAPPING_SET_SOURCE,
Expand Down Expand Up @@ -68,7 +67,7 @@
get_converter,
)
from .sssom_document import MappingSetDocument
from .typehints import MetadataType, PrefixMap, get_default_metadata
from .typehints import MetadataType, get_default_metadata

logging = _logging.getLogger(__name__)

Expand Down Expand Up @@ -149,8 +148,7 @@ def from_mapping_set_document(cls, doc: MappingSetDocument) -> "MappingSetDataFr
return cls(df=pd.DataFrame(), converter=doc.converter)

df = pd.DataFrame(get_dict_from_mapping(mapping) for mapping in doc.mapping_set.mappings)
meta = extract_global_metadata(doc)
meta.pop(CURIE_MAP, None)
meta = _extract_global_metadata(doc)

# remove columns where all values are blank.
df.replace("", np.nan, inplace=True)
Expand Down Expand Up @@ -1010,14 +1008,13 @@ def get_file_extension(file: Union[str, Path, TextIO]) -> str:
return "tsv"


def extract_global_metadata(msdoc: MappingSetDocument) -> Dict[str, PrefixMap]:
def _extract_global_metadata(msdoc: MappingSetDocument) -> MetadataType:
"""Extract metadata.
:param msdoc: MappingSetDocument object
:return: Dictionary containing metadata
"""
# TODO mark as private
meta = {CURIE_MAP: msdoc.prefix_map}
meta = {}
ms_meta = msdoc.mapping_set
for key in [
slot
Expand Down

0 comments on commit c403512

Please sign in to comment.