|
|
|
|
@ -158,11 +158,36 @@ class JSONDataSetCollection(DataSetCollection):
|
|
|
|
|
filepath=str(filepath))
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JSONDataSet(AbstractDataSet):
|
|
|
|
|
def __init__(self, filepath: str):
|
|
|
|
|
self._filepath = filepath
|
|
|
|
|
|
|
|
|
|
def _load(self) -> Dict:
|
|
|
|
|
with open(self._filepath, 'r') as fp:
|
|
|
|
|
return json.load(fp)
|
|
|
|
|
|
|
|
|
|
def _save(self, data: Dict) -> None:
|
|
|
|
|
with open(self._filepath, 'w') as fp:
|
|
|
|
|
json.dump(data, fp, sort_keys=True, indent=4)
|
|
|
|
|
|
|
|
|
|
def _describe(self) -> Dict[str, Any]:
|
|
|
|
|
return dict(filepath=self._filepath)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FullJSONDataSetCollection(DataSetCollection):
|
|
|
|
|
def _load(self) -> dict[str, JSONDataSet]:
|
|
|
|
|
"kedro's API loader method"
|
|
|
|
|
self.datasets = dict()
|
|
|
|
|
for filepath in sorted(self._folderpath.glob("*.xml")):
|
|
|
|
|
self.datasets[filepath.stem] = JSONDataSet(
|
|
|
|
|
filepath=str(filepath))
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#class TextDataSet:
|
|
|
|
|
# """loads/saves data from/to a text file using an underlying filesystem
|
|
|
|
|
|
|
|
|
|
# example usage
|
|
|
|
|
|
|
|
|
|
# >>> string_to_write = "This will go in a file."
|
|
|
|
|
# >>>
|
|
|
|
|
# >>> data_set = TextDataSet(filepath="test.md")
|
|
|
|
|
@ -183,19 +208,3 @@ class JSONDataSetCollection(DataSetCollection):
|
|
|
|
|
|
|
|
|
|
# def _describe(self) -> Dict[str, Any]:
|
|
|
|
|
# return dict(filepath=self._filepath)
|
|
|
|
|
|
|
|
|
|
#class JSONDataSet(AbstractDataSet):
|
|
|
|
|
# def __init__(self, filepath: str):
|
|
|
|
|
# self._filepath = filepath
|
|
|
|
|
|
|
|
|
|
# def _load(self) -> Dict:
|
|
|
|
|
# with open(self._filepath, 'r') as fp:
|
|
|
|
|
# return json.load(fp)
|
|
|
|
|
|
|
|
|
|
# def _save(self, data: Dict) -> None:
|
|
|
|
|
# with open(self._filepath, 'w') as fp:
|
|
|
|
|
# json.dump(data, fp, sort_keys=True, indent=4)
|
|
|
|
|
|
|
|
|
|
# def _describe(self) -> Dict[str, Any]:
|
|
|
|
|
# return dict(filepath=self._filepath)
|
|
|
|
|
|
|
|
|
|
|