From a077180fe1722782469782ca172d0a88544cf6d9 Mon Sep 17 00:00:00 2001 From: anders-albert Date: Wed, 13 Nov 2024 09:32:44 +0100 Subject: [PATCH] refactor: new interface --- cognite/neat/_session/_read.py | 7 ++++--- cognite/neat/_session/engine/_interface.py | 17 ++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cognite/neat/_session/_read.py b/cognite/neat/_session/_read.py index 9b203adb2..8a61aed11 100644 --- a/cognite/neat/_session/_read.py +++ b/cognite/neat/_session/_read.py @@ -146,9 +146,10 @@ def __call__(self, io: Any) -> IssueList: class CSVReadAPI(BaseReadAPI): def __call__(self, io: Any, type: str, primary_key: str) -> None: engine = import_engine() - engine.set.file(io) - engine.set.type(type) - engine.set.primary_key(primary_key) + engine.set.source = ".csv" + engine.set.file = io + engine.set.type = type + engine.set.primary_key = primary_key extractor = engine.create_extractor() self._state.instances.store.write(extractor) diff --git a/cognite/neat/_session/engine/_interface.py b/cognite/neat/_session/engine/_interface.py index b6bdd888d..d6d476c7b 100644 --- a/cognite/neat/_session/engine/_interface.py +++ b/cognite/neat/_session/engine/_interface.py @@ -1,5 +1,5 @@ from collections.abc import Iterable -from typing import Any, ClassVar, Protocol +from typing import Any, Protocol from rdflib import Literal, URIRef @@ -8,18 +8,17 @@ class Extractor(Protocol): def extract(self) -> Iterable[tuple[URIRef, URIRef, Literal | URIRef]]: ... -class SetterAPI(Protocol): - def file(self, io: Any) -> None: ... - - def type(self, type: str) -> None: ... - - def primary_key(self, key: str) -> None: ... +class ConfigAPI(Protocol): + source: str | None + file: Any | None + type: str | None + primary_key: str | None class NeatEngine(Protocol): - version: ClassVar[str] = "1.0.0" + version: str = "1.0.0" @property - def set(self) -> SetterAPI: ... + def set(self) -> ConfigAPI: ... def create_extractor(self) -> Extractor: ...