Skip to content

Commit

Permalink
Add kwargs pass through in init if child classes need special args
Browse files Browse the repository at this point in the history
  • Loading branch information
amc-corey-cox committed Nov 8, 2024
1 parent d8fb3b4 commit 02da771
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/koza/io/writer/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
edge_properties: List[str] = None,
sssom_config: SSSOMConfig = None,
skip_checks: bool = False,
kwargs: dict = None,
):
"""Do not override this method; implement `init` instead."""
self.output_dir = output_dir
Expand All @@ -30,7 +31,8 @@ def __init__(
self.skip_checks = skip_checks
self.converter = KGXConverter()

self.init()
kwargs = kwargs or {}
self.init(**kwargs)

def write(self, entities: Iterable):
nodes, edges = self.converter.convert(entities)
Expand Down Expand Up @@ -61,7 +63,7 @@ def check_extra_fields(row_keys: Tuple, columns: Tuple) -> None:
raise ValueError(f"Extra fields found in row: {sorted(set(row_keys) - set(columns))}")

@abstractmethod
def init(self):
def init(self, **kwargs):
pass

@abstractmethod
Expand Down

0 comments on commit 02da771

Please sign in to comment.