<commit_before>
#include <gloperate/scripting/PipelineApi.h>

#include <vector>
#include <sstream>
#include <string>
#include <iostream>

#include <gloperate/viewer/ViewerContext.h>
#include <gloperate/viewer/RenderSurface.h>
#include <gloperate/pipeline/Stage.h>
#include <gloperate/pipeline/AbstractInputSlot.h>
#include <gloperate/pipeline/AbstractData.h>


namespace gloperate
{


PipelineApi::PipelineApi(ViewerContext * viewerContext)
: cppexpose::Object("pipeline")
, m_viewerContext(viewerContext)
{
    // Register functions
    addFunction("getName",    this, &PipelineApi::getName);
    addFunction("getStages",  this, &PipelineApi::getStages);
    addFunction("getInputs",  this, &PipelineApi::getInputs);
    addFunction("getOutputs", this, &PipelineApi::getOutputs);
    addFunction("getValue",   this, &PipelineApi::getValue);
}

PipelineApi::~PipelineApi()
{
}

std::string PipelineApi::getName(const std::string & name)
{
    Stage * stage = getStage(name);

    return stage->name();
}

cppexpose::Variant PipelineApi::getStages(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();

    if (!stage->isPipeline()) {
        return lst;
    }

    Pipeline * pipeline = static_cast<Pipeline*>(stage);

    for (auto * subStage : pipeline->stages())
    {
        lst.asArray()->push_back(subStage->name());
    }
    return lst;
}

cppexpose::Variant PipelineApi::getInputs(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();

    for (auto * input : stage->inputs())
    {
        lst.asArray()->push_back(input->name());
    }

    return lst;
}

cppexpose::Variant PipelineApi::getOutputs(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();
    for (auto * output : stage->outputs())
    {
        lst.asArray()->push_back(output->name());
    }
    return lst;
}

std::string PipelineApi::getValue(const std::string & path)
{
    cppexpose::AbstractProperty * property = getProperty(path);
    if (property) {
        return property->toString();
    } else {
        return "";
    }
}<commit_msg>Include parameters and proxy outputs in UI<commit_after>
#include <gloperate/scripting/PipelineApi.h>

#include <vector>
#include <sstream>
#include <string>
#include <iostream>

#include <gloperate/viewer/ViewerContext.h>
#include <gloperate/viewer/RenderSurface.h>
#include <gloperate/pipeline/Stage.h>
#include <gloperate/pipeline/AbstractInputSlot.h>
#include <gloperate/pipeline/AbstractData.h>


namespace gloperate
{


PipelineApi::PipelineApi(ViewerContext * viewerContext)
: cppexpose::Object("pipeline")
, m_viewerContext(viewerContext)
{
    // Register functions
    addFunction("getName",    this, &PipelineApi::getName);
    addFunction("getStages",  this, &PipelineApi::getStages);
    addFunction("getInputs",  this, &PipelineApi::getInputs);
    addFunction("getOutputs", this, &PipelineApi::getOutputs);
    addFunction("getValue",   this, &PipelineApi::getValue);
}

PipelineApi::~PipelineApi()
{
}

std::string PipelineApi::getName(const std::string & name)
{
    Stage * stage = getStage(name);

    return stage->name();
}

cppexpose::Variant PipelineApi::getStages(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();

    if (!stage->isPipeline()) {
        return lst;
    }

    Pipeline * pipeline = static_cast<Pipeline*>(stage);

    for (auto * subStage : pipeline->stages())
    {
        lst.asArray()->push_back(subStage->name());
    }
    return lst;
}

cppexpose::Variant PipelineApi::getInputs(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();

    for (auto * input : stage->inputs())
    {
        lst.asArray()->push_back(input->name());
    }

    for (auto * parameter : stage->parameters())
    {
        lst.asArray()->push_back(parameter->name());
    }

    return lst;
}

cppexpose::Variant PipelineApi::getOutputs(const std::string & name)
{
    Stage * stage = getStage(name);

    cppexpose::Variant lst = cppexpose::Variant::array();

    for (auto * output : stage->outputs())
    {
        lst.asArray()->push_back(output->name());
    }

    for (auto * proxyOutput : stage->proxyOutputs())
    {
        lst.asArray()->push_back(proxyOutput->name());
    }

    return lst;
}

std::string PipelineApi::getValue(const std::string & path)
{
    cppexpose::AbstractProperty * property = getProperty(path);
    if (property) {
        return property->toString();
    } else {
        return "";
    }
}
{'fraction_non_alphanumeric': 0.15570129045906494, 'fraction_numerical': 0.0, 'mean_word_length': 4.100323624595469, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7551670', 'n_tokens_mistral': 1549, 'n_tokens_neox': 1503, 'n_words': 266}