Core Interface#

struct ISample#

Subclassed by aidi::LazySample, aidi::Sample

Public Functions

virtual const std::map<ToolNodeId, std::string> &property_types() const = 0#

Get the property name-type name.

Returns:

std::map<ToolNodeId, std::string> const& The property name-type map.

virtual const std::string &property_type(const ToolNodeId &property_name) const = 0#

Get the property type specified by the name.

Parameters:

property_name – The property name.

Returns:

std::string The property type.

virtual bool exist_property_name(const ToolNodeId &property_name) const = 0#

Check if the property name is valid or not in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property name is valid, otherwise false.

virtual bool exist_property_data(const ToolNodeId &property_name) const = 0#

Check if property data exists in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property data exists, otherwise false.

virtual const std::shared_ptr<props::IProperty> &get(const ToolNodeId &property_name) const = 0#

Get the property specified by the name.

This function will return nullptr if the property data is not set, or an exception will be thrown if the property name is invalid.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property.

virtual void set(const ToolNodeId &property_name, const std::shared_ptr<props::IProperty> &property) = 0#

Set the property data specified by the name.

Note

The property data will not be copied, any change to the property data will be reflected in the sample after the call.

Parameters:
  • property_name – The property name.

  • property – The property data. The property data must be the same type as the property type.

Throws:
virtual std::shared_ptr<props::IProperty> &get_or_create(const ToolNodeId &property_name) = 0#

Get the property data specified by the name. Defferent from get, If the property data is not set, this function will try to create the property data by the property type.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual std::shared_ptr<props::IProperty> &recreate(const ToolNodeId &property_name) = 0#

Create a new property object specified by the property_name. This method will clean the property data and create a new empty one.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual SampleDescriptor &descriptor() = 0#

Get the sample descriptor.

Returns:

SampleDescriptor& The sample descriptor.

virtual const SampleDescriptor &descriptor() const = 0#

Get the sample descriptor.

Returns:

SampleDescriptor const& The sample descriptor.

class Sample : public aidi::ISample#

Sample is a collection of data that meet one of the definition of sample properties, a sample contains its own ID, input images and all the output data obtained by the input images after the tool processing.

Public Functions

explicit Sample(std::map<ToolNodeId, std::string> property_name_types)#

Construct a new Sample object with the property name-type map.

Parameters:

property_name_types – The property name-type map.

virtual const std::map<ToolNodeId, std::string> &property_types() const override#

Get the property name-type name.

Returns:

std::map<ToolNodeId, std::string> const& The property name-type map.

virtual const std::string &property_type(const ToolNodeId &property_name) const override#

Get the property type specified by the name.

Parameters:

property_name – The property name.

Returns:

std::string The property type.

virtual bool exist_property_name(const ToolNodeId &property_name) const override#

Check if the property name is valid or not in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property name is valid, otherwise false.

virtual bool exist_property_data(const ToolNodeId &property_name) const override#

Check if property data exists in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property data exists, otherwise false.

virtual const std::shared_ptr<props::IProperty> &get(const ToolNodeId &property_name) const override#

Get the property specified by the name.

This function will return nullptr if the property data is not set, or an exception will be thrown if the property name is invalid.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns:

std::shared_ptr<props::IProperty> The property.

virtual void set(const ToolNodeId &property_name, const std::shared_ptr<props::IProperty> &property) override#

Set the property data specified by the name.

Note

The property data will not be copied, any change to the property data will be reflected in the sample after the call.

Parameters:
  • property_name – The property name.

  • property – The property data. The property data must be the same type as the property type.

Throws:
PropVisitor operator[](const ToolNodeId &property_name)#

Get or set the property data specified by the name.

Parameters:

property_name – The property name.

Returns:

PropVisitor The property visitor, throught which you can get or set the property data.

virtual std::shared_ptr<props::IProperty> &get_or_create(const ToolNodeId &property_name) override#

Get the property data specified by the name. Defferent from get, If the property data is not set, this function will try to create the property data by the property type.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual std::shared_ptr<props::IProperty> &recreate(const ToolNodeId &property_name) override#

Create a new property object specified by the property_name. This method will clean the property data and create a new empty one.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual SampleDescriptor &descriptor() override#

Get the sample descriptor.

Returns:

SampleDescriptor& The sample descriptor.

virtual const SampleDescriptor &descriptor() const override#

Get the sample descriptor.

Returns:

SampleDescriptor const& The sample descriptor.

class PropVisitor#

Visitor to help to get or set property with subscript operator.

class LazySample : public aidi::ISample#

LazySample has the following features: It will cache the property data that has been read, written, and queried through it, so as to improve the efficiency of data reading, writing, and querying. (note: If the data in sample has been modified by other means in the meantime, it may cause a data out-of-sync problem).

Public Functions

virtual const std::map<ToolNodeId, std::string> &property_types() const override#

Get the property name-type name.

Returns:

std::map<ToolNodeId, std::string> const& The property name-type map.

virtual const std::string &property_type(const ToolNodeId &property_name) const override#

Get the property type specified by the name.

Parameters:

property_name – The property name.

Returns:

std::string The property type.

virtual bool exist_property_name(const ToolNodeId &property_name) const override#

Check if the property name is valid or not in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property name is valid, otherwise false.

virtual bool exist_property_data(const ToolNodeId &property_name) const override#

Check if property data exists in the sample.

Parameters:

property_name – The property name.

Returns:

bool True if the property data exists, otherwise false.

virtual const std::shared_ptr<props::IProperty> &get(const ToolNodeId &property_name) const override#

Get the property specified by the name.

This function will return nullptr if the property data is not set, or an exception will be thrown if the property name is invalid.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property.

virtual void set(const ToolNodeId &property_name, const std::shared_ptr<props::IProperty> &property) override#

Set the property data specified by the name.

Note

The property data will not be copied, any change to the property data will be reflected in the sample after the call.

Parameters:
  • property_name – The property name.

  • property – The property data. The property data must be the same type as the property type.

Throws:
virtual std::shared_ptr<props::IProperty> &get_or_create(const ToolNodeId &property_name) override#

Get the property data specified by the name. Defferent from get, If the property data is not set, this function will try to create the property data by the property type.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual std::shared_ptr<props::IProperty> &recreate(const ToolNodeId &property_name) override#

Create a new property object specified by the property_name. This method will clean the property data and create a new empty one.

Parameters:

property_name – The property name.

Throws:

excepts::DataNotFound – The property name not exist in the sample.

Returns:

std::shared_ptr<props::IProperty> The property data.

virtual SampleDescriptor &descriptor() override#

Get the sample descriptor.

Returns:

SampleDescriptor& The sample descriptor.

virtual const SampleDescriptor &descriptor() const override#

Get the sample descriptor.

Returns:

SampleDescriptor const& The sample descriptor.

Sample fetch() const#

Fetch the Sample, which will consistently get all the property data.

Returns:

Sample

const std::map<ToolNodeId, std::shared_ptr<props::IProperty>> &cached_properties() const#

Get all cached properties.

Returns:

NO_DISCARD const&

uint32_t id() const#

Get the sample id of the LazySample.

Returns:

NO_DISCARD

struct SampleDescriptor#

Sample descriptor to describe the sample’s attributes, including tags, created time, etc.

class Project#

Project is a unit of work and data management built to complete an actual defect inspect process. A project contains the process pipeline and data such as backup data and report data created for that stream.

Public Functions

~Project()#

Destroy the Project object and close the project.

ProjectDescriptor descriptor() const#

Get the descriptor of the project.

Returns:

ProjectDescriptor

void set_remark(const std::string &remark)#

Set the remark of the project.

Parameters:

remark – The remark of the project.

Throws:

excepts::LogicError – The project is opened with ProjectOpenMode::kReadOnly.

std::string add_tool(const std::string &tool_type, const std::string &tool_id = "")#

Add a new tool into the stream graph.

Parameters:
  • tool_type – The type of the tool to be added.Available tool_type is offered by ToolFactory

  • tool_id – The id of the tool to be added. It should be unique in the stream graph if you want to name it, otherwise an excepts::ToolAlreadyExist will be thrown. Or you can use the default argument (an empty string) to let the system generate a unique id automatically.

Throws:
Returns:

The id of the tool added.

std::string copy_tool(const std::string &origin_tool_id, const std::string &copy_tool_id = "", const graph::CopyToolOptions &copy_tool_options = {false, {}})#

Copy a tool from the stream graph and add it into the stream graph.

  1. If CopyToolOptions.auto_connect == false, it will only copy the data content and break the link with the stream graph. As a stand alone tool only.

  2. If CopyToolOptions.auto_connect == true, it will automatically connect to the stream graph along the original tool connection according to the CopyToolOptions.tool_maps relationship.

  3. CopyToolOptions.tool_maps does not require the same type of tool, as long as it can be connected.

Parameters:
  • origin_tool_id – Original tool id.

  • copy_tool_id – Copy tool id. If empty, _copy will be added to origin_tool_id. Multiple copies will be followed by a number.

  • copy_tool_options – Copy tool options.

Throws:
Returns:

std::string The real tool id of the copy_tool_id.

std::map<std::string, std::string> copy_tool_group(const std::set<std::string> &origin_tools, const graph::CopyToolOptions &copy_tool_options = {false, {}})#

Copy multiple tools from the stream graph and add them into the stream graph.

  1. If CopyToolOptions.auto_connect == false, it will only copy the data content and break the link with the stream graph. As a stand alone tool only one by one.

  2. If CopyToolOptions.auto_connect == true, it will automatically connect to the stream graph along the original tool connection according to the CopyToolOptions.tool_maps relationship.

  3. For tools that plan copies in origin_tools, the copied tool mapping relationships are automatically added to CopyToolOptions.tool_maps.

  4. CopyToolOptions.tool_maps does not require the same type of tool, as long as it can be connected.

    See also

    copy_tool()

Parameters:
  • origin_tools – Original tool ids.

  • copy_tool_options – Copy tool options.

Throws:
Returns:

std::map<std::string, std::string> The real tool ids of the copy tool ids.

void connect(const ToolNodeId &upstream, const ToolNodeId &downstream)#

Connect two tools together by connecting the output data anchor of the first tool (from_tool) to the input data anchor of the second tool (to_tool).

To connect two tools, You must follow the following rules:

  1. The two tools must have been added into the stream graph before, and The output data anchor and input data anchor should be exist in the first tool and the second tool respectively. otherwise excepts::ToolNotFound or excepts::NodeNotFound will be thrown.

  2. The two tools should have different ids, and there is no direct or indirect connection from the second tool to the first tool, otherwise an excepts::LoopConnection will be thrown.

  3. The connect type of the output data anchor of the first tool must be DataEdge::kMarkedOutput, and the input data anchor of the second tool must be DataEdge::kSingleVirtualInput, and the two nodes must be data nodes , otherwise an excepts::InvalidConnection will be thrown. see DataEdge::connect_type for more details.

  4. the provided features of the output data anchor of the first tool should be matched the required features of the input data anchor of the second tool, and the output data anchor of the first tool and the input data anchor of the second tool should have same cpt_tag, otherwise an excepts::DataTypeMismatch will be thrown.

  5. An output data anchor of a tool can connect to multiple input data anchors of other tools, but an input data anchor can only be connected to a single output data anchor. So it will be reset and reconnected if the input data anchor is already connected to another output data anchor and no exception is thrown.

ToolNodeId is a class that contains tool_id and node_id.

Note

Idempotence. Making multiple identical call has the same effect as making a single call .

Parameters:
  • upstream – The ToolNodeId of the output data anchor to be connected.

  • downstream – The ToolNodeId of the input data anchor to be connected.

Throws:
void disconnect(const ToolNodeId &tool_node)#

Disconnect the node of tool from its upstream tool.

Note

if the connection doesn’t exist, no error would occur.

Parameters:

tool_node – a ToolNodeId object specifying the node

Throws:
void remove_tool(const std::string &tool_id, bool remove_all_depends_on_this = false)#

Remove tool. All connections related to the tool will be disconnected.If no such a tool in stream graph, no error would occur.

Parameters:
  • tool_id – The id of the tool to be removed.

  • remove_all_depends_on_this – If true, all the tools that depends on the tool to be removed will be removed as well, default is false.

void rename_tool(const std::string &old_tool_id, const std::string &new_tool_id)#

Rename the tool.

Parameters:
  • old_tool_id – The old id of the tool.

  • new_tool_id – The new id of the tool.

Throws:
ToolInfo tool_info(const std::string &tool_id) const#

Get the tool info object according to tool id.

Parameters:

tool_id – Identifier of the tool added to project

Throws:

excepts::ToolNotFound – If the tool id is not found.

Returns:

ToolInfo

std::vector<std::string> tool_list() const#

Get the all tools added to project.

Returns:

std::vector<std::string> Identifiers of tools

ToolNodeId real_id(const ToolNodeId &node_id) const#

The redirect to node id of the virtual node, or itself for others.

Parameters:

node_idToolNodeId specifying the node of the tool.

Throws:
Returns:

ToolNodeId The real id of the node.

std::map<ToolNodeId, std::string> all_properties_name_type() const#

Get the name and type of all properties in SampleSet.

Returns:

a map with pair of property name and property type

std::vector<std::string> sample_sets_names() const#

Get names of all samplesets.

Returns:

std::vector<std::string> all sampleset names in this project

void add_sample_set(const std::string &name)#

Add a new sampleset into project.

Throws:

excepts::DatasetAlreadyExists – If name is empty or a sampleset with specified name already exists

Parameters:

name

SampleSet get_sample_set(const std::string &name)#

Get sampleset with specified name.

Note

SampleSet keep the reference of data in the project, therefore it should never be used beyond the lifetime of Project.

Parameters:

name – name of sampleset

Throws:

excepts::DatasetNotExists – if no such a sampleset

Returns:

SampleSet

ReadOnlySampleSet get_readonly_sample_set(const std::string &name) const#

Get ReadonlySampleSet which include all samples of the project.

Note

ReadOnlySampleSet keep the reference of data in the project, therefore it should never be used beyond the lifetime of Project.

Parameters:

name – name of sampleset

Throws:

excepts::DatasetNotExists – if no such a sampleset

Returns:

ReadOnlySampleSet

std::string main_sample_set_name() const#

Get the main sampleset name.

Returns:

std::string name

SampleSet main_sample_set()#

Get the main sampleset.

Returns:

SampleSet The main sample set, which is owned by the project, and should not be called after the project is closed.

ReadOnlySampleSet readonly_main_sample_set() const#

Get the read-only main sampleset.

Returns:

ReadOnlySampleSet The read-only main sample set, which is owned by the project, and should not be called after the project is closed.

void rename_sampleset(const std::string &old_name, const std::string &new_name)#

Rename sampleset.

Parameters:
  • old_name

  • new_name

void remove_sample_set(const std::string &name)#

remove sampleset and the data in it will be unrecoverable

Note

main sampleset is not allowed to remove

Throws:

excepts::LogicError – Can not remove main dataset

Parameters:

name

ConfigureRuntime create_config_runtime(const ToolNodeId &tool_node, const runtime::RuntimeStrategyOptions &strategy_options)#

Create a config runtime object.

Parameters:
  • tool_node – The tool_node_id of the configurator.

  • strategy_options – RuntimeStrategyOptions options specified by users.

Returns:

ConfigureRuntime

Runtime create_runtime(const aidi::runtime::IStrategy &strategy)#

Create a runtime object.

Parameters:

strategy – RuntimeStratey which specify the scope to be executed in stream graph.

Returns:

Runtime

void set_param(const ToolNodeId &tool_node, const aidi::param::IParameter &param)#

Set the param object.

Parameters:
  • tool_nodeToolNodeId specifying the node of the tool

  • param

aidi::Buffer get_context(const ToolNodeId &tool_node) const#

Get the context object.

Parameters:

tool_nodeToolNodeId specifying the node of the tool

Returns:

aidi::Buffer

void set_context(const ToolNodeId &tool_node, const aidi::Buffer &context)#

Set the context object.

Parameters:
  • tool_nodeToolNodeId specifying the node of the tool

  • context – the node context

std::shared_ptr<aidi::param::IParameter> get_param(const ToolNodeId &tool_node) const#

Get the param object of specified tool and node.

Parameters:

tool_nodeToolNodeId specifying the node of the tool

Returns:

std::shared_ptr<aidi::param::IParameter>

bool param_exist(const ToolNodeId &tool_node) const#

Check whether the parameter exists.

Parameters:

tool_nodeToolNodeId specifying the node of the tool

Throws:
Returns:

Returns true if the data exists, false otherwise.

std::vector<std::string> backup_names() const#

Get all backup names.

Returns:

std::vector<std::string> The name of backups.

std::string backup_remark(const std::string &backup_name) const#

Get the remark of the backup.

Parameters:

backup_name – The name of the backup.

Throws:

excepts::BackupNotExists – If the backup specified by the backup name does not exist.

Returns:

std::string The remark of the backup.

BackupDescriptor get_backup_desciptor(const std::string &backup_name) const#

Get the backup information specified by the backup name.

Parameters:

backup_name – The name of the backup.

Throws:

excepts::BackupNotExists – If the backup specified by the backup name does not exist.

Returns:

BackupDescriptor The backup information.

void set_backup_remark(const std::string &backup_name, const std::string &remark)#

Set the remark of the backup.

Parameters:
  • backup_name – The name of the backup.

  • remark – The remark of the backup.

Throws:

excepts::BackupNotExists – If the backup named ‘backup_name’ does not exist.

std::string create_backup(const std::string &backup_name = "", const std::string &remark = "")#

Make an overall backup of the Project.

Parameters:
  • backup_name – The name of the backup version. If empty, the current timestamp will be used as the name by default.

  • remark – The remark of the backup version.

Throws:
Returns:

std::string The name of the backup version.

void restore_backup(const std::string &backup_name)#

Restore a version backup and all its associated data.

Parameters:

backup_name – The ID of the backup version.

Throws:
void remove_backup(const std::string &backup_name)#

Remove the version backup and all its associated data.

Parameters:

backup_name – The name of the backup version.

Throws:
void export_model(const std::string &export_file_path, const std::string &password = "")#

Export the model and parameters.

Parameters:
  • export_file_path – Destination path of the exported file,the file suffix of export_path must be .aidimodel.

  • password – Password for decompressing the exported file. This password is empty by default.

Throws:
std::string to_graphviz(const graph::DotInfoOptions &info_option = {}) const#

Convert the project’s StreamGraph to a dot-language string.

Parameters:

info_option – The options of dot language node detail info to be showed.

Returns:

std::string The process graph describle with Graphviz dot language

Public Static Functions

static bool Exists(const ProjectDescriptor &proj_desc)#

Check whether a project exists.

Parameters:

proj_desc – the project descriptor

Throws:

excepts::InvalidArgument – The project descriptor is invalid,

Returns:

true

Returns:

false

static bool Closed(const ProjectDescriptor &proj_desc)#

Check if project closed normally.

Parameters:

proj_desc – the project descriptor.

Throws:
Returns:

true

Returns:

false

static bool ReadProjectDescriptorFromProject(ProjectDescriptor &proj_desc)#

Read the ProjectDescriptor.

Parameters:

proj_desc – project descriptor with workspace_token as project_name specified

Throws:
Returns:

true if Project exist and proj_desc field will update with project information

Returns:

false Fail to read project information, and proj_desc won’t update

static ProjectDescriptor Create(const ProjectDescriptor &proj_desc)#

Create project.

Parameters:

proj_desc – Descriptor specifying the parent path and name of the project

Throws:
Returns:

ProjectDescriptor of created project (not open yet)

static std::unique_ptr<Project> Open(const ProjectDescriptor &proj_desc, ProjectOpenMode open_mode = ProjectOpenMode::kNormally)#

The project can be opened in different modes.

There are a few things to note when opening the project. 1.When a project is opened normally, only one user is allowed to open the project at the same time. 2.When a project is opened in read-only mode,multiple users can read the project data at the same time. 3.When a project is opened in force-write mode, you can open a project with a lock,but not a project in use.

Parameters:
  • proj_desc – project descriptor specifiy the parent path and name of the project

  • open_mode – The project can be opened in different modes. The default mode is kNormally.

Throws:
Returns:

std::unique_ptr<Project>

static std::unique_ptr<Project> Open(const std::string &proj_path, ProjectOpenMode open_mode = ProjectOpenMode::kNormally)#

Open Project with project path. The project can be opened in different modes.

There are a few things to note when opening the project. 1.When a project is opened normally, only one user is allowed to open the project at the same time. 2.When a project is opened in read-only mode,multiple users can read the project data at the same time. 3.When a project is opened in force-write mode, you can open a project with a lock,but not a project in use.

Parameters:
  • proj_path – The project path, should include the “.aidi” suffix.

  • open_mode – The project can be opened in different modes. The default mode is kNormally.

Throws:
Returns:

std::unique_ptr<Project> the project handle.

class Model#

The Model interface to open and aidimodel file and create aidi::Runtime from it. For convenience, it also supports modifying some simple parameters in the model file and re-saving the model.

Public Functions

explicit Model(const std::string &path, const std::string &password = "")#

Construct a new Model object with model path and password.

Throws:
Parameters:
  • pathModel file path

  • passwordModel file password

Runtime create_runtime(const aidi::runtime::IStrategy &strategy)#

Create a runtime object.

Parameters:

strategy – RuntimeStratey which specify the scope to be executed in stream graph.

Returns:

Runtime

std::shared_ptr<param::IParameter> get_param(const ToolNodeId &tool_node) const#

Get the param object of specified tool and node.

Parameters:

tool_nodeToolNodeId specifying the node of the tool.

Returns:

std::shared_ptr<aidi::param::IParameter>

void set_param(const ToolNodeId &tool_node, const aidi::param::IParameter &param)#

Set the param object.

Parameters:
  • tool_nodeToolNodeId specifying the node of the tool.

  • param – the parameter type.

aidi::Buffer get_context(const ToolNodeId &tool_node) const#

Get the context object.

Parameters:

tool_nodeToolNodeId specifying the node of the tool.

Returns:

aidi::Buffer

void set_context(const ToolNodeId &tool_node, const aidi::Buffer &context)#

Set the context object.

Parameters:
  • tool_nodeToolNodeId specifying the node of the tool.

  • context – the node context.

void resave_to(const std::string &path, const std::string &password = "")#

Resave the model file to another path.

Parameters:
  • path – New path(utf-8 encoding) to the model file.

  • password – New password for model file.

class WorkSpace#

Public Functions

explicit WorkSpace(const std::string &token)#

WorkSpace unique constructor.

Parameters:

token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.

Throws:
std::string token() const#

Get the token of the workspace.

Returns:

std::string The token of the worksapce.

std::string name() const#

Get the name of the worksapce.

Returns:

std::string The name of the worksapce.

void rename(const std::string &new_name)#

Rename the workspace.

Parameters:

new_name – The new name of the worksapce.

Throws:
std::string sub_workspace_token(const std::string &sub_workspace_name) const#

Get sub-workspace token by name.

Parameters:

sub_workspace_name – The name of the sub-workspace.

Throws:

excepts::InvalidArgument – The workspace name is invalid,

Returns:

std::string The token of the sub-workspace.

std::vector<std::string> sub_worksapce_names() const#

Get all first-level sub-worksapce names.

Returns:

std::vector<std::string> The names of first-level sub-worksapce.

std::string create_sub_worksapce(const std::string &sub_workspace_name)#

Create a first-level sub-workspace.

Parameters:

sub_workspace_name – The name of the sub-workspace to be created.

Throws:
Returns:

std::string The name of the sub-workspace.

void remove_sub_worksapce(const std::string &sub_workspace_name)#

Remove a first-level sub-workspace.

Note

If the name is empty or does not exist, nothing will be done.

Parameters:

sub_workspace_name – The name of the sub-workspace to be removed.

Throws:
std::vector<ProjectDescriptor> project_descriptors() const#

Get all first-level project descriptors of the WorkSpace.

ProjectDescriptor create_project(const std::string &project_name, const std::string &project_remark = "")#

Create a new project and return project description information.

Parameters:
  • project_name – The name of the project.

  • project_remark – The remark of the project, empty by default.

Throws:
Returns:

ProjectDescriptor The descriptor of the project.

std::unique_ptr<Project> open_project(const std::string &project_name, ProjectOpenMode pro_open_mode = ProjectOpenMode::kNormally)#

Open an existing project.

Note

There are a few things to note when opening the project. 1.When a project is opened normally, only one user is allowed to open the project at the same time. 2.When a project is opened in read-only mode,multiple users can read the project data at the same time. 3.When a project is opened in force-write mode, you can open a project with a lock,but not a project in use.

Parameters:
  • project_name – The name of the project.

  • pro_open_mode – The project can be opened in different modes, kNormally by default.

Throws:
Returns:

std::unique_ptr<Project>

void remove_project(const std::string &project_name)#

Remove the project.

Note

If the name is empty or does not exist, nothing will be done.

Parameters:

project_name – The name of the project.

Throws:

Public Static Functions

static void CreateWorkSpace(const std::string &token)#

Create a new WorkSpace.

Parameters:

token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.

Throws:
static void RemoveWorkSpace(const std::string &token)#

Remove the specified WorkSpace.

Note

If the token is empty or does not exist, nothing will be done.

Parameters:

token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.

Throws:
static void MoveWorkSpace(const std::string &from_ws_token, const std::string &to_ws_token)#

Perform an overall move for the WorkSpace.

See also

ProjectDescriptor::IsValidWorkSpaceToken, or move the workspace to its subdirectory.

Note

There are four cases: 1.local to local, 2.local to cloud, 3.cloud to cloud, 4.cloud to local.

Parameters:
  • from_ws_token – The token of the source workspace.

  • to_ws_token – The token of the target workspace.

Throws:
static void CopyWorkSpace(const std::string &from_ws_token, const std::string &to_ws_token)#

Perform an overall copy for the WorkSpace.

See also

ProjectDescriptor::IsValidWorkSpaceToken, or copy the workspace to its subdirectory.

Note

There are four cases: 1.local to local, 2.local to cloud, 3.cloud to cloud, 4.cloud to local.

Parameters:
  • from_ws_token – The token of the source workspace.

  • to_ws_token – The token of the target workspace.

Throws:
static void CopyProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#

Perform an overall copy for the project.

See also

ProjectDescriptor::IsValidProjectDescriptor, or copy the project to its subdirectory.

Note

There are four cases: 1.local to local, 2.local to cloud, 3.cloud to cloud, 4.cloud to local.

Parameters:
  • from_project_descriptor – Descriptor of the source project.

  • to_project_descriptor – Descriptor of the target project.

Throws:
static void MoveProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#

Perform an overall move for the project.

See also

ProjectDescriptor::IsValidProjectDescriptor, or move the project to its subdirectory.

Note

There are four cases: 1.local to local, 2.local to cloud, 3.cloud to cloud, 4.cloud to local.

Parameters:
  • from_project_descriptor – Descriptor of the source project.

  • to_project_descriptor – Descriptor of the target project.

Throws:
struct ProjectDescriptor#

ProjectDescriptor.

Public Members

std::string workspace_token#

The workspace token which you can get with WorkSpace::token()

std::string project_name#

project name.

std::string remark#

User-defined project information which users can use it to express any project-related descriptive information.

std::string sdk_version#

SDK version used last time to open the project. This field is readonly and can only be set by the sdk, which means it’s not useful if you set it when you create a project.

int64_t created_time#

Time stamp when the project was created. This field is readonly and can only be set by the sdk, which means it’s not useful if you set it when you create a project.

std::string last_modified_time#

The last modification time of the project.

Public Static Functions

static bool IsValidWorkSpaceToken(const std::string &token)#

A valid workspace token needs to meet the following conditions: 1.can’t be empty, 2.can’t start or end with a null character, 3.can’t contain the following special characters: {‘*’, ‘?’, ‘”’, ‘<’, ‘>’, ‘|’}.

Parameters:

token

Throws:

excepts::InvalidArgument – If the token is invalid.

Returns:

true

Returns:

false

static bool IsValidProjectName(const std::string &name)#

A valid project name needs to meet the following conditions: 1.can’t be empty, 2.can’t start or end with a null character, 3.can’t contain the following special characters: {’', ‘/’, ‘:’, ‘*’, ‘?’, ‘”’, ‘<’, ‘>’, ‘|’}, 4.can’t exceed 200 characters in length.

Parameters:

name

Throws:

excepts::InvalidArgument – If the project name is invalid.

Returns:

true

Returns:

false

static bool IsValidWorkSpaceName(const std::string &name)#

A valid workspace name needs to meet the following conditions: 1.can’t be empty, 2.can’t start or end with a null character, 3.can’t contain the following special characters: {’', ‘/’, ‘:’, ‘*’, ‘?’, ‘”’, ‘<’, ‘>’, ‘|’}, 4.can’t exceed 200 characters in length.

Parameters:

name

Throws:

excepts::InvalidArgument – If the workspace name is invalid.

Returns:

true

Returns:

false

static bool IsValidProjectDescriptor(const ProjectDescriptor &pro_desc)#

A valid project descriptor needs to meet the following conditions: 1.the project name in the project descriptor is valid.

See also

IsValidProjectName, 2. the workspace token in the project descriptor is valid

Parameters:

pro_desc

Throws:

excepts::InvalidArgument – If the project descriptor is invalid.

Returns:

true

Returns:

false

struct BackupDescriptor#

Backup version info.

Public Members

std::string backup_id#

Unique id of the backup version.

std::string backup_name#

backup version name, which can be set by user.

std::string remark#

A remark message about the backup.

int64_t created_time#

The create time of the backup.

enum aidi::ProjectOpenMode#

Supports different modes to open the project.

Values:

enumerator kNormally = 0#

The project is opened normally, and the project data can be read and written.

enumerator kReadOnly = 1#

The project is opened in read-only mode, and the project data can only be read.

enumerator kForceWrite = 2#

The project is opened in force-write mode,and the project with the lock can be opened.

class DataEdge#

DataEdge interface class.

A tool consists of nodes and edges. The edges are the data flow between nodes, and the nodes are the data processing units. Our data would be two types of data: parameters used to configure the data processing units, and properties of a Sample generated by the data processing units.

See also

ComputeNode

Public Types

enum DataCptTag#

The concept type of the data edge. It can be a parameter or a property.

Values:

enumerator kParam#

Parameter type.

enumerator kProp#

Property type.

enum ConnectType#

The connect type of the data edge.

The connection relationship of the data edges in the tool may be one of the following four cases:

  1. kSingleVirtualInput: The data is an input of the tool, which means the data is generated by other tool and is used as an input of the tool. The actual data represented by the data edge does not belong to this tool, so we mark it as a “virtual

    input”.

  2. kMultiVirtualInput: The special input node which may contains multi-virtual_input nodes (eg: IntegrationTool) and we mark it as “multi-virtual input”.

  3. kMarkedOutput: The data is an output of the tool, which means the data is generated by this tool and will be used by other tools, We mark it as an “output” of this tool.

  4. kInternal: The data is generated in this tool and only used in this tool and will be used by other tools, so we mark it as a “internal” data.

Values:

enumerator kSingleVirtualInput#

Virtual input.

enumerator kMarkedOutput#

Output of this tool.

enumerator kInternal#

Internal data.

enumerator kMultiVirtualInput#

MultiVirtualInput node.

Public Functions

std::string id() const#

Get data id in the tool.

Returns:

std::string The data id.

std::string type() const#

Get the data type of the data edge.

Returns:

std::string The type of the data edge.

int64_t last_update_time() const#

Get last modified time of the data edge under the current Environment system configurations.

Throws:

excepts::DataNotFound – Throws if the current environment system’s configuration not match any environments of context stored in Graph.

Returns:

int64_t The last modified time of the data edge in utc timestamp.

DataCptTag cpt_tag() const#

Get concept type of the data edge, which can be a parameter or a property.

See also

DataCptTag

Returns:

DataCptTag The concept type of the data edge.

ConnectType connect_type() const#

Get the connect type of the data edge.

See also

ConnectType

Returns:

ConnectType The connect type of the data edge.

std::pair<std::string, std::string> redirect_to() const#

Get the data edge’s source node id if the data edge is a “virtual

input” data edge.

This function is only valid when the data edge is a “virtual

input” data edge and the “virtual input” data edge has been connected to a “output” data edge in another tool. If the data edge is not a “virtual

input” data edge, you will get an empty tool id, and if the data edge is a “virtual input” but not connected to any “output” data edge in another tool, you will get both empty tool id and empty data id.

Returns:

std::pair<std::string, std::string> The source tool id and source node id.

std::vector<ComputeNode> generated_by() const#

Get compute nodes that can generate the given data edge.

Note

As the data edge may be generated by multiple compute nodes although only one compute node will be executed at the same time, the size of the returned vector is not guaranteed to be 1. But in most cases, it is 1.

Returns:

std::vector<ComputeNode> Compute nodes that can generate the given data edge.

std::vector<ComputeNode> used_by() const#

Get compute nodes that use the given data edge.

Note

As the data edge may be used by multiple compute nodes, the size of the returned vector is not guaranteed to be 1.

Returns:

std::vector<ComputeNode> Compute nodes that use the given data edge.

class ComputeNode#

ComputeNode Info.

Compute nodes are the core data processing units in the tool. a compute node will reveive parameters and properties generated by other compute nodes and process the data to generate new parameters or properties.

See also

DataEdge

Public Types

enum ComputeCptTag#

The concept type of the compute node. It can be a operator to generate properties or a configurator to generate parameters.

Values:

enumerator kConf#

Configurator type.

enumerator kOper#

Operator type.

Public Functions

std::string id() const#

Get compute node id in the tool. The compute node id is unique in a tool.

Returns:

std::string The compute node id.

std::string type() const#

Get the compute node type of the compute node.

Returns:

std::string The type of the compute node.

int64_t last_update_time() const#

Get last modified time of the compute node in utc timestamp under the current Environment system configurations.

Throws:

excepts::DataNotFound – Throws if the current environment system’s configuration not match any environments of context stored in Graph.

Returns:

int64_t The last modified time of the compute node in utc timestamp.

std::vector<DataEdge> param_nodes() const#

Get parameter edges required by the compute node.

The parameter edges are the data edges that are used to configure the compute node. If a parameter edge is a kMultiVirtualInput node, it will return DataEdges with the redirect index suffix which represent this node’s NodePorts and itself.

Note

For example, a kMultiVirtualInput param_node has two redirect_to NodePort and its id is “Tool/param”, then three parameter edges: {“Tool/param”, “Tool/param[0]”,Tool/param[1]} will be return.

Returns:

std::vector<DataNode> The parameter edges required by the compute node, all concept type of the data edges returned are kParam.

std::vector<DataEdge> input_nodes() const#

Get property edges required by the compute node.

If a edge is a kMultiVirtualInput node, it will return DataEdges with the redirect index suffix which represent this node’s NodePorts and itself.

See also

param_nodes.

Returns:

std::vector<DataEdge> The property edges required by the compute node, all concept type of the data edges returned are kProp.

std::vector<DataEdge> output_nodes() const#

Get data edges generated by the compute node.

The data edges are the data edges that are generated by the compute node. If the compute node is a configurator, the generated data edges are parameters. If the compute node is an operator, the generated data edges are properties.

Returns:

std::vector<DataEdge> The data edges generated by the compute node. All concept type of the data edges returned are kParam or kProp according to the compute node’s concept type.

ComputeCptTag cpt_tag() const#

Get the compute node’s concept type.

Returns:

ComputeCptTag The concept type of the compute node.

class ToolInfo#

ToolInfo is a class that provides information about the tool.

Public Functions

std::string id() const#

Get tool id in the tool graph.

Returns:

std::string The tool id.

std::string type() const#

Get the tool type of the tool graph.

Returns:

std::string The type of the tool.

std::vector<DataEdge> input_edges() const#

Get virtual input data edges of the tool.

Returns:

std::vector<DataEdge> virtual input data edges of the tool. All the connect type of the data edges returned are kSingleVirtualInput.

std::vector<DataEdge> output_edges() const#

Get output data edges of the tool.

Returns:

std::vector<DataEdge> output data edges of the tool. All the connect type of the data edges returned are kMarkedOutput.

std::vector<DataEdge> data_edges() const#

Get all data Egdes in the tool.

Returns:

std::vector<DataEdge> All data edges in the tool.

std::vector<ComputeNode> compute_nodes() const#

Get all compute nodes in the tool.

Returns:

std::vector<ComputeNode> All compute nodes in the tool.

class ToolNodeId#

Public Functions

ToolNodeId(std::string tool_id, std::string node_id)#

Construct a new Tool Node Id object with tool name and node name.

Parameters:
  • tool_id – Tool name.

  • node_id – Node name, which should not contain ‘/’.

Throws:

aidi::excepts::InvalidNodeId – If the node name is invalid.

ToolNodeId(const std::string &concat_id)#

Construct a new Tool Node Id object with concated tool name and node name with ‘/’.

Parameters:

concat_id – Tool name and node name concated with ‘/’.

const std::string &tool_id() const#

Get the tool name.

Returns:

const std::string&

const std::string &node_id() const#

Get the node name. If has index return node name with index enclosed in brackets at the end.

Returns:

std::string

std::string concat_id() const#

Get the concated tool name and node name with ‘/’. If has index return concated name with index enclosed in brackets at the end.

Returns:

std::string

ToolNodeId operator[](size_t index) const#

Set index suffix to ToolNodeId.

Parameters:

index – The suffix index number to be set.

Returns:

ToolNodeId with index suffix.

Public Static Functions

static bool IsValidNodeId(const std::string &node_id, std::string *err_msg = nullptr)#

Check if the node name is valid.

Parameters:
  • node_id – Node name.

  • err_msg – Error message if the node name is invalid, otherwise empty.

Returns:

true If the node name is valid.

Returns:

false If the node name is invalid.

static int GetIndexAtEnd(const std::string &str)#

Get the index number enlarged in brackets at the end of string.

Parameters:

str – The string.

Returns:

int Return -1 if string has no substr “[0-9+]” at the end. Otherwise, return the index.

static std::string StripIndexSuffix(const std::string &str)#

Get the string without index suffix.

Parameters:

str

Returns:

std::string

class Runtime#

Runtime handle. It’s used to manage list of operator’s runtime. With this handle, user can inference samples without knowing the graph details of the stream and property details of the sample.

Public Functions

Sample create_sample() const#

Create a sample meeting the runtime’s properties requirements.

Returns:

Sample Created sample.

const PropIDTypeMap &required_properties() const#

Get the names and types of all properties required by the runtime.

Returns:

PropIDTypeMap All properties’s name-type map.

const PropIDTypeMap &input_properties() const#

Get the names and types of input properties required by the runtime.

Returns:

PropIDTypeMap Input properties’ name-type map.

const PropIDTypeMap &all_output_properties() const#

Get all output properties’ names and types.

Returns:

PropIDTypeMap Output properties’ name-type map.

const PropIDTypeMap &virtual_output_properties() const#

Get virtual output properties’ names and types.

“Virtual output” means the output property that cannot generate by runtime as the operator to generate it is an virtual operator and can not be run automatically. “Virtual output” should be set into the sample by user before you execute the sample, the virtual operator will only check if it’s meets the parameter requirements and throw an exception if it’s not.

Note

As the virtual output property can not generate by runtime automatically, and user also can not set it whitout it’s dependency properties which should be generated by runtime automatically, so we stipulate that in a runtime, virtual output properties cannot depend on other output properties, but only on input properties and other virtual properties, otherwise an exception will be thrown when create runtime.

Returns:

PropIDTypeMap The virtual output properties’s name-type map.

const PropIDTypeMap &final_output_properties() const#

Get final output properties’s names and types.

Returns:

PropIDTypeMap Final output properties’s name-type map.

bool is_meeting_requirement(const ISample &sample, std::string *error_message = nullptr) const#

Check if sample meets the runtime’s requirement.

Parameters:
  • sampleSample to be checked.

  • error_message[out] Error message if the sample does not meet the runtime requirement. If the sample meets the runtime requirement, this will be an empty string.

Returns:

bool True if the sample meets the runtime requirement, false if not.

void execute(ISample &sample) const#

Inference a sample, generate output properties from input properties in the sample, and check if virtual input properties meets the parameter requirements.

Note

Do not call this function in different threads at the same time.

Parameters:

sample[inout] The sample to be inferred, should contains all properties required by the runtime. You can create the sample by calling create_sample and set required input properties into it.

class RuntimeSampleSetAdapter#

Adapter class to adapt a sample set to a runtime.

The adapter will filter out all samples that are not meeting the runtime requirements, and will only read properties that are required by the runtime or write properties output by the runtime. Other properties not related to the runtime will be ignored unless you force write them by calling the update_all_related() method.

Public Types

using Iterator = SampleSetRuntimeAdapterIterator#

Iterator type to iterate all samples in the sample set.

Public Functions

RuntimeSampleSetAdapter(data::SampleSet *sample_set, const Runtime &runtime)#

Construct a new Sample Set Runtime Adapter object.

Note

The Adapter will reference the Sample Set during its life cycle, and you should make sure the adapter will be destroyed before the Sample Set.

Parameters:
  • sample_set – The Sample Set to adapt.

  • runtime – The Runtime to adapt to.

Iterator begin() const#

Get begin iterator to iterate all samples meeting the runtime’s requirements.

Throws:

excepts::SampleNotFound – throws if no sample meets the runtime’s requirements.

Returns:

const RuntimeSampleSetAdapter::Iterator

Iterator end() const#

Get end iterator.

Returns:

const RuntimeSampleSetAdapter::Iterator The SampleSetRuntimeAdapterIterator point to the end of the SampleSet which is an invalid iterator.

Sample get(const Iterator &iter) const#

Get the sample where the iterator is pointing to.

This method is only valid when the iterator is pointing to a valid sample, and will only return a sample only contains the input properties required by the runtime. If you want to retrieve the sample with all properties in the sample set, please use get_all_related() instead.

Parameters:

iter – The iterator to get the sample from.

Throws:

excepts::SampleNotFound – throws if the iterator is point to an empty sample or the sample does not meet the runtime’s requirements.

Returns:

Sample The sample where the iterator is pointing to.

Sample get(uint32_t id) const#

Get the sample by id.

This method is only valid when the sample id is valid, and will return a sample only contains the input properties required by the runtime. If you want to retrieve the sample with all properties in the sample set, please use get_all_related() instead.

Parameters:

id – The sample id

Throws:

excepts::SampleNotFound – throws if the sample with the given id not exist or does not meet the runtime’s requirements.

Returns:

Sample The sample data of the this id.

Sample get_all_related(const Iterator &iter) const#

Get the sample where the iterator is pointing to.

This method is only valid when the iterator is pointing to a valid sample, and will return a sample contains all properties related to runtime in the graph, which may cause more memory usage and performance loss as the adapter will read all properties of the sample from the database required by runtime. If you only care about the input properties of the runtime, please use get() instead.

See also

get()

Parameters:

iter – The iterator to get the sample from.

Throws:

excepts::SampleNotFound – throws if the iterator is point to an empty sample or the sample does not meet the runtime’s requirements.

Returns:

Sample The sample where the iterator is pointing to.

void update(uint32_t id, const ISample &sample)#

Update the sample set’s output properties with the sample.

Note

This function will only save the runtime’s output properties into the sample set, and runtime’s input properties and other un-related properties will not be saved. If you want to save all properties, please use update_all_related() instead.

Parameters:
  • id – The ID of the sample in the sample set.

  • sample – The sample to update the sample set’s properties.

Throws:
void update_all_related(uint32_t id, const ISample &sample)#

Update the all sample properties in sample set with the sample.

This function will update all sample properties related to the runtime in sample set, which may cause efficiency issues due to reading and writing more data then update. If you can ensure that properties not output by the runtime is not changed, you can use update() instead.

Parameters:
  • id – The ID of the sample in the sample set.

  • sample – The sample to update the sample set’s properties.

Throws:
class SampleSetRuntimeAdapterIterator#

Iterator to iterate all samples meeting the runtime’s requirements in the runtime sample set adapter.

Public Functions

bool is_valid() const#

Check if the iterator is pointing to a valid sample.

Returns:

true If the iterator is pointing to a valid sample.

Returns:

false If the iterator is not pointing to a valid sample.

bool operator==(const SampleSetRuntimeAdapterIterator &other) const#

Check if two iterators point to the same sample.

Parameters:

other – Another iterator.

Returns:

true if two iterators point to the same sample.

Returns:

false if two iterators point to different samples.

bool operator!=(const SampleSetRuntimeAdapterIterator &other) const#

Check if two iterators is not point to the same sample.

Parameters:

other – Another iterator.

Returns:

true if two iterators point to different samples.

Returns:

false if two iterators point to the same sample.

SampleSetRuntimeAdapterIterator &operator++() noexcept#

Move to next sample meeting the runtime’s requirements.

Returns:

SampleSetRuntimeAdapterIterator& The iterator after moving.

SampleSetRuntimeAdapterIterator operator++(int) noexcept#

Move to next sample meeting the runtime’s requirements.

Returns:

SampleSetRuntimeAdapterIterator The iterator before moving.

SampleSetRuntimeAdapterIterator &operator--() noexcept#

Move to previous sample meeting the runtime’s requirements.

Returns:

SampleSetRuntimeAdapterIterator& The iterator after moving.

SampleSetRuntimeAdapterIterator operator--(int) noexcept#

Move to previous sample meeting the runtime’s requirements.

Returns:

SampleSetRuntimeAdapterIterator The iterator before moving.

uint32_t id() const#

Get Sample ID.

Throws:

excepts::SampleNotFound – throws if the iterator is point to an empty sample or the sample not meet the runtime’s requirements.

Returns:

uint32_t The ID of the sample.

std::pair<uint32_t, Sample> operator*() const#

Read Sample from data::SampleSet database.

Note

This interface will only read properties required by runtime, so the sample returned would not contain all properties data in the database of the sample but only the input properties.

Throws:
Returns:

std::pair<uint32_t, Sample> The ID of the sample and the sample.

struct RuntimeStrategyOptions#

The users can indicate their preference for Runtime executing behaviors by configuring RuntimeStrategyOptions.

Public Members

bool allow_auto_update#

Whether to use auto execute feature when some needed parameter_nodes have not been updated.

util::IProgressCallback *call_back#

function pointer of Callback in auto-executing process.

bool allow_unrealized_oper = false#

Whether to allow unrealized operators exist in runtime. Default set to false.

bool ignore_update_time_requirement = false#

Whether to ignore the update status requirement of the nodes. Default set to false.

class IStrategy#

IStrategy is the information bridge between user and Runtime. The specific sub-class of IStrategy contains two kind of information:

  1. strategy class type (or class name);

  2. the required data to infer the subgraph provided by user;

Subclassed by aidi::runtime::AllTools, aidi::runtime::SingleNode, aidi::runtime::SingleTool, aidi::runtime::ToolsAndDepends

Public Functions

virtual RuntimeStrategyOptions options() const = 0#

get the strategy options the user set.

Returns:

RuntimeStrategyOptions strategy options.

class SingleTool : public aidi::runtime::IStrategy#

SingleTool Contains the information to check the execution feasibility construct an Runtime object for the range of a single tool.

Public Functions

virtual RuntimeStrategyOptions options() const override#

get the strategy options the user set.

Returns:

RuntimeStrategyOptions strategy options.

class SingleNode : public aidi::runtime::IStrategy#

SingleNode Contains the information to check the execution feasibility construct an Runtime object for the range of a single operator_node.

Public Functions

virtual RuntimeStrategyOptions options() const override#

get the strategy options the user set.

Returns:

RuntimeStrategyOptions strategy options.

class ToolsAndDepends : public aidi::runtime::IStrategy#

SingleNode Contains the information to check the execution feasibility construct an Runtime object for the range of a single operator_node.

Public Functions

virtual RuntimeStrategyOptions options() const override#

get the strategy options the user set.

Returns:

RuntimeStrategyOptions strategy options.

class AllTools : public aidi::runtime::IStrategy#

AllTools Strategy allow user construct an Runtime to infer all tools in the graph by setting RuntimeStrategyOptions.

Public Functions

virtual RuntimeStrategyOptions options() const override#

get the strategy options the user set.

Returns:

RuntimeStrategyOptions strategy options.

using aidi::PropIDTypeMap = std::map<ToolNodeId, std::string>#

property’s tool_node_id - property’s type

using aidi::PropIDTypeList = std::vector<std::pair<ToolNodeId, std::string>>#
class ConfigureRuntime#

Configure Runtime definition.

The ConfigureRuntime class is used to execute a configurator

Public Functions

virtual ~ConfigureRuntime() = default#

Destructor.

ToolNodeId node_id() const#

Get the configurator node’s ToolNodeId.

Returns:

ToolNodeId The ToolNodeId of configurator node.

std::vector<std::pair<ToolNodeId, std::string>> input_parameters() const#

Get input parameters’ ToolNodeId and types required by the configurator.

Returns:

std::vector<std::pair<ToolNodeId, std::string>> The parameters’ ToolNodeId and types.

std::vector<std::pair<ToolNodeId, std::string>> input_properties() const#

Get input properties’ ToolNodeId and types required by the configurator.

Returns:

std::vector<std::pair<ToolNodeId, std::string>> The properties’ ToolNodeId and types.

std::vector<std::pair<ToolNodeId, std::string>> output_parameters() const#

Get output parameters’ ToolNodeId and types required by the configurator.

Returns:

std::vector<std::pair<ToolNodeId, std::string>> The output parameters’ ToolNodeId and types.

void initialize(const confs::IService &service)#

Initialize the configurator runtime with previous context, input parameters generated by front configurator nodes and required input property set.

Parameters:

service – provide the initializ data confs::IService

TaskStatus execute(confs::IService &service)#

Excetute the configurator and generate output parameters and save output parameters and context to service.

Parameters:

service – store the params generated by the configurator.

Returns:

TaskStatus The execution status of the ConfigureRuntime. The kAbnormalAbort will be returned if the ConfigRuntime not be initialized before execute.

class ConfigProjectImplAdapter : public aidi::confs::IService#

Adapter for ConfigureRuntime and ProjectImpl.

This class is used to adapt ProjectImpl to ConfigureRuntime.

Subclassed by aidi::ConfigureRuntimeProjectAdapter

Public Functions

void set_progress_callback(util::IProgressCallback *callback)#

Set the progress callback object.

Note

A default callback will execute to logging every 5 seconds if no callback set.

Parameters:

callback – The pointer of progress callback object, which shoud be valid during the whole life of the adapter. you should delete the object after the adapter destoryed manually as it’s not managed by the adapter.

virtual bool context_exists() const override#

Check if previous context exists or not.

Returns:

true if previous context exists.

Returns:

false if previous context not exists.

virtual aidi::Buffer load_context() const override#

Get Context saved after the previous execution, which will be empty if it’s the first execution or the previous execution has not saved any context. You can call context_exists() to check if context exists before get it.

Returns:

aidi::Buffer The context buffer saved after the previous execution.

virtual void save_context(const Buffer &context) override#

Save current configurator context.

After the configure process success, you can call this method to save current context which maybe useful for the next execution.

Parameters:

context – The current configurator context.

virtual confs::IService::ParamList input_parameters() const override#

Get the input parameters required by the configurator.

Returns:

confs::IService::ParamList The input parameters required by the configurator.

virtual std::vector<const data::IReadOnlyPropertySet*> property_sets() const override#

Get the property set vector required by the configurator.

Returns:

std::vector<const data::IReadOnlyPropertySet *> The property set vector required by the configurator.

virtual void output_parameters(const confs::IService::ParamRefList &params) override#

Save the output parameters generated by the configurator into the project.

Parameters:

params – The output parameters generated by the configurator.

Throws:

excepts::ParamListSizeNotMatch – If the size of params is not equal to the size of output_params required by configurator.

virtual TaskCtrlSignal on_progress(int total, int progress, const std::string &progress_info) override#

Report the configure process status.

Parameters:
  • total – The total number of configure process. You can set total to 0 if you don’t know the total number, and -1 when error happens.

  • progress – The current progress of the configure process. You should make sure that progress is greater than 0 and less than or equal to total if total is not 0 and -1.

  • progress_info – The current progress message.

Throws:

excepts::ProgressNumError – If progress does not meet the requirements.

Returns:

TaskCtrlSignal Signal to control the task.

class ConfigureRuntimeProjectAdapter : public aidi::ConfigProjectImplAdapter#

Adapter for ConfigureRuntime and Project.

This class is used to adapt Project to ConfigureRuntime.

Public Functions

ConfigureRuntimeProjectAdapter(Project *project, const ConfigureRuntime &configurator)#

Construct a new ConfigureRuntime Adapter object.

Parameters:
  • project – The Project to adapt. You should make sure the project is not nullptr and will not be deleted before the adapter.

  • configurator – The ConfigureRuntime to adapt to.

class IProgressCallback#

Progress Callback Interface used to notify the progress of the task.

Developers should implement this interface and pass it to the task while executing task to get the progress of the task.

Subclassed by aidi::util::DefaultProgressCallback

Public Functions

virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) = 0#

Call when task status changed.

Parameters:
  • total – The total of task, which will be 0 if not known, and -1 if error. The total would change in the middle of task execution.

  • progress – The progress of task, greater than 0 and less than or equal to total if total is not 0 and -1.

  • progress_info – The progress message, formatted as json, content format like (Note that not all fields exist in the content):

    {
         "Loss": {
             "nacc": 0.704343,
             "pacc": 0.912434
         },
         "Time Left": 189.24,
         "Message": "Some string"
    }
    

Returns:

TaskCtrlSignal The signal to control the task (abort or continue executing).

class DefaultProgressCallback : public aidi::util::IProgressCallback#

DefaultProgressCallback provides the default on_progress callback function to ConfigureRuntimeProjectAdapter which writes the progress message into log every 5 seconds.

Public Functions

virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) override#

Call when task status changed.

Parameters:
  • total – The total of task, which will be 0 if not known, and -1 if error. The total would change in the middle of task execution.

  • progress – The progress of task, greater than 0 and less than or equal to total if total is not 0 and -1.

  • progress_info – The progress message, formatted as json, content format like (Note that not all fields exist in the content):

    {
         "Loss": {
             "nacc": 0.704343,
             "pacc": 0.912434
         },
         "Time Left": 189.24,
         "Message": "Some string"
    }
    

Returns:

TaskCtrlSignal The signal to control the task (abort or continue executing).

template<typename Meta, typename ConceptType>
class Factory#

Factory Template Class.

Template Parameters:
  • Meta – The meta information of the concept.

  • ConceptType – The concept type.

template<typename Meta, typename Creator>
class CreatorMutableMixin#

Mixin to provide interface to register and unregister creator function.

Template Parameters:
  • Meta – The meta information of the concept.

  • Creator – The creator function.

Subclassed by aidi::confs::Factory, aidi::opers::Factory

enum class aidi::TaskStatus#

Task status. This status value is returned at the end of a long-running task to indicate why the task has ended.

Values:

enumerator kFinished = 0#

Normal finished.

enumerator kAbortByCtrlSignal = 1#

Cancelled by user(caller)

enum class aidi::TaskCtrlSignal#

Signal to control the task. By returning this signal in the progress callback function, the user can control the continuation or abort of the task.

Values:

enumerator kContinue = 0#

Continue to run.

enumerator kStop = 1#

Stop the task and try to save parameters (trained model) if possible.

enumerator kAbort = 2#

Stop task as soon as possible.

struct DotInfoOptions#

User-defined node detail info option in dot language.

struct CopyToolOptions#

Copy tool options.

Public Members

bool auto_connect = false#

Whether to connect automatically.

std::map<std::string, std::string> tool_maps#

Tool id mapping. <original_tool, mapping_tool>