34 lines
955 B
Python
34 lines
955 B
Python
import json
|
|
from core.node import Node
|
|
from core.compatibility_result import CompatibilityResult, CompatibilityLevel
|
|
|
|
|
|
class FeatureWriteRequirement:
|
|
data_type: str = "table"
|
|
|
|
def check(self, provided):
|
|
if provided.data_type != self.data_type:
|
|
return CompatibilityResult(
|
|
level=CompatibilityLevel.ERROR,
|
|
message="FeatureWriter requires feature table input"
|
|
)
|
|
return CompatibilityResult(
|
|
level=CompatibilityLevel.OK,
|
|
message="Compatible"
|
|
)
|
|
|
|
|
|
class FeatureWriter(Node):
|
|
def __init__(self, output_path: str):
|
|
self.output_path = output_path
|
|
|
|
super().__init__(
|
|
name="FeatureWriter",
|
|
inputs={"features": FeatureWriteRequirement()},
|
|
outputs={}
|
|
)
|
|
|
|
def run(self, features):
|
|
with open(self.output_path, "w", encoding="utf-8") as f:
|
|
json.dump(features, f, indent=2)
|