Neuralyzer::Transforms::V2::DataManagerPipelineExecutor
Neuralyzer::Transforms::V2::DataManagerPipelineExecutor
Executor that runs V2 pipelines with DataManager integration. More…
#include <DataManagerIntegration.hpp>
Public Classes
| Name | |
|---|---|
| struct | PipelineSegment Represents a segment of consecutive steps that can be fused. |
Public Functions
| Name | |
|---|---|
| DataManagerPipelineExecutor(DataManager * data_manager) Construct executor with DataManager pointer. |
|
| bool | loadFromJson(nlohmann::json const & json_config) Load pipeline configuration from JSON object. |
| bool | loadFromJsonFile(std::string const & json_file_path) Load pipeline configuration from JSON file. |
| V2PipelineResult | execute(const V2PipelineProgressCallback & progress_callback =[nullptr]) Execute the loaded pipeline. |
| V2StepResult | executeStep(size_t step_index, const std::function< void(int)> & progress_callback =[nullptr]) Execute a single step by index. |
| std::vector< std::string > | validate() const Validate the loaded pipeline configuration. |
| std::vector< DataManagerStepDescriptor > const & | getSteps() const Get the loaded pipeline steps. |
| std::optional< DataManagerPipelineMetadata > const & | getMetadata() const Get pipeline metadata. |
| void | clear() Clear the current pipeline configuration. |
| std::vector< PipelineSegment > | buildSegments() const Build fusible segments from consecutive steps. |
| bool | canFuseStep(size_t step_index) const Check if a step can be fused with the previous step. |
| bool | stepsAreChained(size_t prev_step, size_t curr_step) const Check if consecutive steps form a data dependency chain. |
Detailed Description
class Neuralyzer::Transforms::V2::DataManagerPipelineExecutor;Executor that runs V2 pipelines with DataManager integration.
This class bridges the gap between the V2 transform system and DataManager:
- Loads pipeline configuration from JSON (V1-compatible format)
- Retrieves input data from DataManager using input_key
- Executes transforms using V2TransformPipeline
- Stores results back to DataManager using output_key
Example usage: ```cpp
DataManager dm; // … populate dm with data …
DataManagerPipelineExecutor executor(&dm); if (executor.loadFromJson(json_config)) { auto result = executor.execute(); if (result.success) { // Results are now in DataManager } }
## Public Functions Documentation
### function DataManagerPipelineExecutor
```cpp
explicit DataManagerPipelineExecutor(
DataManager * data_manager
)
Construct executor with DataManager pointer.
Parameters:
- data_manager Non-owning pointer to the DataManager; the executor stores this pointer but does not take ownership or delete the object.
Precondition:
- data_manager must not be null (enforcement: exception)
- The DataManager object pointed to by data_manager must remain valid and not be destroyed for the entire lifetime of this executor (enforcement: none) [IMPORTANT]
function loadFromJson
bool loadFromJson(
nlohmann::json const & json_config
)Load pipeline configuration from JSON object.
Parameters:
- json_config JSON value to parse. No structural precondition is imposed by this function — schema validation is performed internally and failure is reported via the return value.
Return: true if the complete configuration was loaded successfully.
Postcondition:
- If returns true, getSteps() returns the complete parsed pipeline (enforcement: runtime_check — parseJsonFormat validates all required fields).
- If returns false, steps_ may be partially populated (steps before the first failing step are retained). The executor must not be used for execution without a subsequent successful loadFromJson() or clear() call (enforcement: none) [IMPORTANT]
Any previously loaded configuration is cleared before parsing begins. Any valid nlohmann::json value is accepted; values that do not conform to the expected schema cause the function to return false rather than throw. All exceptions from parsing are caught internally and result in a false return.
function loadFromJsonFile
bool loadFromJsonFile(
std::string const & json_file_path
)Load pipeline configuration from JSON file.
Parameters:
- json_file_path Path to a readable file containing a valid JSON pipeline configuration.
Return: true if the file was opened, parsed, and the pipeline loaded successfully.
Precondition:
- json_file_path must not be empty (enforcement: runtime_check — empty string causes ifstream::open to fail, triggering the is_open() guard)
- The file at json_file_path must exist and be readable by the current process (enforcement: runtime_check — guarded by !file.is_open() early return)
- The file content must be valid JSON (enforcement: exception — nlohmann::json parse errors are caught and converted to false return)
- The parsed JSON must contain a “steps” array conforming to the pipeline schema (enforcement: runtime_check — propagated from loadFromJson/parseJsonFormat)
Postcondition: If returns false, steps_ may be partially populated (same postcondition as loadFromJson). The executor must not be used for execution without a subsequent successful load or clear() call (enforcement: none) [IMPORTANT]
Opens the file at json_file_path, parses its contents as JSON, and delegates to loadFromJson(). Any previously loaded configuration is cleared before parsing begins. All I/O and parse errors are caught internally and result in a false return rather than a throw.
function execute
V2PipelineResult execute(
const V2PipelineProgressCallback & progress_callback =nullptr
)Execute the loaded pipeline.
Parameters:
- progress_callback Optional callable invoked before each step and once on completion. May be null/empty (tested before every call). If provided, must not capture references that may be invalidated during execution (enforcement: none) [LOW]
Return: V2PipelineResult describing overall and per-step outcomes.
Precondition:
- A successful loadFromJson() or loadFromJsonFile() call must have completed before calling execute(); executing a partially-loaded pipeline (from a failed load) produces partial or incorrect results (enforcement: none) [IMPORTANT]
- The DataManager passed to the constructor must still be valid (enforcement: none — propagated from constructor) [IMPORTANT]
Postcondition:
- If steps_ is empty, returns success=true with steps_completed=0 and total_steps=0 (empty pipeline is considered trivially successful).
- If progress_callback is provided and steps_ is empty, it is invoked with step_index=-1 (completion sentinel). Callbacks should handle negative step_index values (enforcement: none) [LOW]
Iterates over all enabled steps, delegating each to executeStep(). Steps whose enabled field is explicitly set to false are skipped. All exceptions from individual steps are caught internally; the result struct carries success/failure state and per-step error messages.
function executeStep
V2StepResult executeStep(
size_t step_index,
const std::function< void(int)> & progress_callback =nullptr
)Execute a single step by index.
Parameters:
- step_index Zero-based index of the step to execute.
- progress_callback Currently unused. Reserved for future per-step progress reporting.
Return: V2StepResult describing success/failure and timing.
Note: The progress_callback parameter is accepted but currently unused — it is never invoked inside this function. Per-step progress reporting is handled by the enclosing execute() call.
Precondition:
- step_index must be less than steps_.size() (enforcement: runtime_check — guarded by bounds check returning failure result)
- steps_[step_index].input_key must name a key present in the DataManager or in temporary_data_ (for single-input steps) (enforcement: runtime_check — missing key is detected by getInputData() and reported as failure)
- steps_[step_index].transform_name must be registered in ElementRegistry (enforcement: runtime_check — unregistered name causes executeTransform() to return nullopt, reported as failure)
- The DataManager passed to the constructor must still be valid (enforcement: none — propagated from constructor) [IMPORTANT]
- For multi-input steps, all keys in additional_input_keys must also be present in DataManager or temporary_data_ (enforcement: runtime_check — propagated through executeMultiInputStep())
Retrieves the step at step_index, fetches its input data from the DataManager or from temporary storage (outputs of prior steps), runs the registered transform, and stores the result. All errors are returned in the result struct rather than thrown.
function validate
std::vector< std::string > validate() constValidate the loaded pipeline configuration.
Return: Empty vector if the pipeline is valid; otherwise one diagnostic string per error. An empty steps_ vector is considered valid and returns an empty vector.
Precondition: Must be called after a successful loadFromJson() or loadFromJsonFile() to be meaningful. Calling on an empty or partially-loaded pipeline returns the errors for whatever steps_ currently contains (enforcement: none) [LOW]
Postcondition:
- Return value is empty if and only if all of the following hold for every step: transform_name is registered in ElementRegistry, and input_key is non-empty (enforcement: runtime_check).
- Does not modify any member state; safe to call multiple times (enforcement: static — declared const).
Checks each step against the ElementRegistry and verifies that required fields are non-empty. Does not access the DataManager — input key existence is not verified at this stage (that would require runtime data). Does not throw; always returns a (possibly empty) vector.
function getSteps
inline std::vector< DataManagerStepDescriptor > const & getSteps() constGet the loaded pipeline steps.
function getMetadata
inline std::optional< DataManagerPipelineMetadata > const & getMetadata() constGet pipeline metadata.
function clear
void clear()Clear the current pipeline configuration.
Postcondition:
- steps_ is empty (enforcement: static — std::vector::clear() guarantee).
- metadata_ has no value (enforcement: static — std::optional::reset() guarantee).
- temporary_data_ is empty (enforcement: static — std::unordered_map::clear() guarantee).
- data_manager_ is unchanged (enforcement: static — not touched by this function).
Resets steps_, metadata_, and temporary_data_ to empty/default state. Does not affect the DataManager pointer or any data stored in the DataManager itself. Safe to call at any time, including on a default-constructed or partially-loaded executor.
function buildSegments
std::vector< PipelineSegment > buildSegments() constBuild fusible segments from consecutive steps.
Analyzes the pipeline and groups consecutive fusible steps together. Returns a vector of segments that can be executed independently.
function canFuseStep
bool canFuseStep(
size_t step_index
) constCheck if a step can be fused with the previous step.
Parameters:
- step_index Zero-based index of the step to test.
Return: false if step_index is out of bounds, the step has multiple inputs, the transform_name is not registered, or the transform is a container or time-grouped transform. Returns true only for single-input element-level transforms.
Note:
- This function only inspects the transform type of the step at
step_index. It does NOT verify that a previous step exists or that the two steps are actually chained — callers must additionally call stepsAreChained() to confirm data dependency. buildSegments() handles both checks correctly. - A step_index of 0 will return true for a fusible element transform even though there is no preceding step. Callers are responsible for not calling canFuseStep(0) as the first step in a segment (enforcement: none) [LOW]
Precondition:
- step_index < steps_.size() is not required — out-of-bounds returns false (enforcement: runtime_check).
- steps_ must have been populated by a successful loadFromJson() call for the result to be meaningful (enforcement: none) [LOW]
A step can be fused if:
- It is an element-level transform (not time-grouped, not container)
- It has a single input
- Its input comes from the previous step’s output
function stepsAreChained
bool stepsAreChained(
size_t prev_step,
size_t curr_step
) constCheck if consecutive steps form a data dependency chain.
Parameters:
- prev_step Zero-based index of the upstream step.
- curr_step Zero-based index of the downstream step.
Return: true if and only if both indices are in bounds, curr_step > prev_step, and steps_[curr_step].input_key equals the effective output key of steps_[prev_step].
Precondition:
- Neither index is required to be in bounds — out-of-bounds returns false (enforcement: runtime_check).
- curr_step > prev_step is not required — equal or reversed indices return false (enforcement: runtime_check).
- steps_ must have been populated by a successful loadFromJson() call for the result to be meaningful (enforcement: none) [LOW]
Postcondition: Does not modify any member state; safe to call multiple times (enforcement: static — declared const).
Returns true if step[i]’s input_key matches step[i-1]’s output_key or step[i-1]’s step_id (for temporary data).
The previous step’s effective output key is:
- steps_[prev_step].output_key if set and non-empty, otherwise
- steps_[prev_step].step_id (temporary storage key convention).
Updated on 2026-11-13 at 20:25:41 +0000