Skip to content

Commit

Permalink
Update name
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Oct 7, 2023
1 parent 6ad0ee2 commit b603218
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/sssom/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

from sssom.constants import (
DEFAULT_VALIDATION_TYPES,
PrefixMapModeType,
MergeMode,
SchemaValidationType,
_get_sssom_schema_object,
)
Expand Down Expand Up @@ -172,7 +172,7 @@ def convert(input: str, output: TextIO, output_format: str):
default="metadata_only",
show_default=True,
required=True,
type=click.Choice(get_args(PrefixMapModeType), case_sensitive=False),
type=click.Choice(get_args(MergeMode), case_sensitive=False),
help="Defines whether the prefix map in the metadata should be extended or replaced with "
"the SSSOM default prefix map.",
)
Expand Down Expand Up @@ -205,7 +205,7 @@ def parse(
input: str,
input_format: str,
metadata: str,
prefix_map_mode: PrefixMapModeType,
prefix_map_mode: MergeMode,
clean_prefixes: bool,
strict_clean_prefixes: bool,
output: TextIO,
Expand All @@ -218,7 +218,7 @@ def parse(
output=output,
input_format=input_format,
metadata_path=metadata,
prefix_map_mode=prefix_map_mode,
merge_mode=prefix_map_mode,
clean_prefixes=clean_prefixes,
strict_clean_prefixes=strict_clean_prefixes,
embedded_mode=embedded_mode,
Expand Down
8 changes: 4 additions & 4 deletions src/sssom/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
]

UNKNOWN_IRI = "http://w3id.org/sssom/unknown_prefix/"
PrefixMapModeType = Literal["metadata_only", "sssom_default_only", "merged"]
PREFIX_MAP_MODE_METADATA_ONLY: PrefixMapModeType = "metadata_only"
PREFIX_MAP_MODE_SSSOM_DEFAULT_ONLY: PrefixMapModeType = "sssom_default_only"
PREFIX_MAP_MODE_MERGED: PrefixMapModeType = "merged"
MergeMode = Literal["metadata_only", "sssom_default_only", "merged"]
PREFIX_MAP_MODE_METADATA_ONLY: MergeMode = "metadata_only"
PREFIX_MAP_MODE_SSSOM_DEFAULT_ONLY: MergeMode = "sssom_default_only"
PREFIX_MAP_MODE_MERGED: MergeMode = "merged"
ENTITY_REFERENCE = "EntityReference"

# Slot Constants
Expand Down
20 changes: 10 additions & 10 deletions src/sssom/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
PREFIX_MAP_MODE_MERGED,
PREFIX_MAP_MODE_METADATA_ONLY,
PREFIX_MAP_MODE_SSSOM_DEFAULT_ONLY,
MergeMode,
MetadataType,
PrefixMapModeType,
SchemaValidationType,
get_default_metadata,
)
Expand Down Expand Up @@ -61,7 +61,7 @@ def parse_file(
output: TextIO,
input_format: Optional[str] = None,
metadata_path: Optional[str] = None,
prefix_map_mode: Optional[PrefixMapModeType] = None,
merge_mode: Optional[MergeMode] = None,
clean_prefixes: bool = True,
strict_clean_prefixes: bool = True,
embedded_mode: bool = True,
Expand All @@ -74,15 +74,15 @@ def parse_file(
:param input_format: The string denoting the input format.
:param metadata_path: The path to a file containing the sssom metadata (including prefix_map)
to be used during parse.
:param prefix_map_mode: Defines whether the prefix map in the metadata should be extended or replaced with
:param merge_mode: Defines whether the prefix map in the metadata should be extended or replaced with
the SSSOM default prefix map.
:param clean_prefixes: If True (default), records with unknown prefixes are removed from the SSSOM file.
:param strict_clean_prefixes: If True (default), clean_prefixes() will be in strict mode.
:param embedded_mode:If True (default), the dataframe and metadata are exported in one file (tsv), else two separate files (tsv and yaml).
:param mapping_predicate_filter: Optional list of mapping predicates or filepath containing the same.
"""
raise_for_bad_path(input_path)
converter, meta = read_metadata(path=metadata_path, mode=prefix_map_mode)
converter, meta = read_metadata(path=metadata_path, merge_mode=merge_mode)
parse_func = get_parsing_function(input_format, input_path)
mapping_predicates = None
# Get list of predicates of interest.
Expand Down Expand Up @@ -134,13 +134,13 @@ def split_file(input_path: str, output_directory: Union[str, Path]) -> None:


def read_metadata(
path: Union[None, str, Path] = None, *, mode: Optional[PrefixMapModeType] = None
path: Union[None, str, Path] = None, *, merge_mode: Optional[MergeMode] = None
) -> Tuple[Converter, MetadataType]:
"""
Load SSSOM metadata from a YAML file, and then augment it with default prefixes.
:param path: The metadata file in YAML format
:param mode: one of metadata_only, sssom_default_only, merged
:param merge_mode: one of metadata_only, sssom_default_only, merged
:return: A converter and remaining metadata from the YAML file
"""
if path is None:
Expand All @@ -152,14 +152,14 @@ def read_metadata(
metadata = dict(ChainMap(metadata, get_default_metadata()))
converter = Converter.from_prefix_map(metadata.pop(CURIE_MAP, {}))

if mode is None or mode == PREFIX_MAP_MODE_METADATA_ONLY:
if merge_mode is None or merge_mode == PREFIX_MAP_MODE_METADATA_ONLY:
converter = curies.chain([_get_built_in_prefix_map(), converter])
elif mode == PREFIX_MAP_MODE_SSSOM_DEFAULT_ONLY:
elif merge_mode == PREFIX_MAP_MODE_SSSOM_DEFAULT_ONLY:
converter = get_converter()
elif mode == PREFIX_MAP_MODE_MERGED:
elif merge_mode == PREFIX_MAP_MODE_MERGED:
converter = curies.chain([_get_built_in_prefix_map(), converter, get_converter()])
else:
raise ValueError(f"Invalid prefix map mode: {mode}")
raise ValueError(f"Invalid prefix map mode: {merge_mode}")

return converter, metadata

Expand Down
2 changes: 1 addition & 1 deletion tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def test_parse_obographs_merged(self):
with open(outfile, "w") as f:
parse_file(
input_path=hp_json,
prefix_map_mode="merged",
merge_mode="merged",
clean_prefixes=True,
input_format="obographs-json",
metadata_path=hp_meta,
Expand Down

0 comments on commit b603218

Please sign in to comment.