Skip to content

Commit

Permalink
Stopped using typer.option to get real defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaper committed May 24, 2022
1 parent 9fb1be9 commit a431598
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions cat_merge/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@
log = logging.getLogger(__name__)


# Using typer options causes a TyperOption to be passed in place of the default,
# details: https://github.com/tiangolo/typer/issues/106
# We could make a second function to wrap defaults?

def merge(
name: str = typer.Option("merged-kg", help="Name of the resulting knowledge graph"),
input_dir: str = typer.Option(None, help="Optional directory containing node and edge files"),
edges: List[str] = typer.Option(None, help="Optional list of edge files"),
nodes: List[str] = typer.Option(None, help="Optional list of node files"),
mapping: str = typer.Option(None, help="Optional SSSOM mapping file"),
output_dir: str = typer.Option("merged-output", help="Directory to output knowledge graph"),
merge_delimiter: str = typer.Option("|", help="Delimiter to use when merging categories and properties on duplicates")
):
name: str = "merged-kg",
input_dir: str = None, # Optional directory containing node and edge files
edges: List[str] = None, # Optional list of edge files
nodes: List[str] = None, # Optional list of node files
mapping: str = None, # Optional SSSOM mapping file
output_dir: str = "merged-output", # Directory to output knowledge graph
merge_delimiter: str = "|" # Delimiter to use when merging categories and properties on duplicates
):

print(f"""\
Merging KG files...
name: {name}
input_dir: {input_dir}
nodes: {nodes}
edges: {edges}
mapping: {mapping}
output_dir: {output_dir}
""")

print("Reading node and edge files")
if isinstance(nodes, List) and len(nodes) > 0 and isinstance(edges, List) and len(edges) > 0:
if nodes is not None and len(nodes) > 0 \
and edges is not None and len(edges) > 0:
node_dfs = read_dfs(nodes)
edge_dfs = read_dfs(edges)
elif input_dir is not None:
Expand All @@ -39,7 +45,7 @@ def merge(

mapping_df = None
if mapping is not None:
mapping_df = read_df()
mapping_df = read_df(mapping)

print("Merging...")
kg = merge_kg(node_dfs=node_dfs, edge_dfs=edge_dfs, mapping=mapping_df, merge_delimiter=merge_delimiter)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cat-merge"
version = "0.1.9"
version = "0.1.10"
description = ""
authors = [
"Monarch Initiative <[email protected]>",
Expand Down

0 comments on commit a431598

Please sign in to comment.