Source code for pyiron_workflow.constant

from __future__ import annotations

import flowrep as fr

from pyiron_workflow import datatypes, execution


[docs] class Constant( datatypes.StaticNode[fr.schemas.ConstantRecipe, fr.schemas.ConstantData] ):
[docs] @classmethod def from_value( cls, value: fr.schemas.JSONABLE, label: fr.schemas.Label | None = None ): return cls( fr.schemas.ConstantRecipe(constant=value), "constant" if label is None else label, )
@classmethod def _result_type(cls) -> type[fr.schemas.ConstantData]: return fr.schemas.ConstantData
[docs] def evaluate( self, run: execution.Run[execution.ResultType], config: execution.RunConfig, ) -> execution.Run[execution.ResultType]: run.result = fr.tools.recipe2data(self.recipe) return run