Core Interface#
-
class Sample#
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<std::string, 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.
-
const std::map<std::string, std::string> &property_types() const#
Get the property name-type name.
- Returns:
std::map<std::string, std::string> const& The property name-type map.
-
const std::string &property_type(const std::string &property_name) const#
Get the property type specified by the name.
- Parameters:
property_name – The property name.
- Returns:
std::string The property type.
-
bool exist_property_name(const std::string &property_name) const#
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.
-
bool exist_property_data(const std::string &property_name) const#
Check if property data exists in the sample.
- Parameters:
property_name – The property name.
- Returns:
bool True if the property data exists, otherwise false.
-
const std::shared_ptr<props::IProperty> &get(const std::string &property_name) const#
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::InvalidArgument – The property name not exist in the sample.
- Returns:
std::shared_ptr<props::IProperty> The property.
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:
excepts::InvalidArgument – The property name not exist in the sample or the type of the property data is not the same as the property type in the sample.
-
std::shared_ptr<props::IProperty> &get_or_create(const std::string &property_name)#
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::InvalidArgument – The property name not exist in the sample.
- Returns:
std::shared_ptr<props::IProperty> The property data.
-
SampleDescriptor &descriptor()#
Get the sample descriptor.
- Returns:
SampleDescriptor& The sample descriptor.
-
const SampleDescriptor &descriptor() const#
Get the sample descriptor.
- Returns:
SampleDescriptor const& The sample descriptor.
-
explicit Sample(std::map<std::string, std::string> property_name_types)#
-
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
-
std::string add_tool(const std::string &tool_type, const std::string &tool_id = "")#
Get the descriptor of this project.
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:
excepts::InvalidToolType – If the tool type is not found.
excepts::ToolAlreadyExist – If the tool id is already used.
- Returns:
ProjectDescriptor of this project.
- Returns:
The id of the tool added.
-
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:
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.
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.
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::kVirtualInput, and the two nodes must be data nodes , otherwise an excepts::InvalidConnection will be thrown. see DataEdge::connect_type for more details.
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.
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:
excepts::ToolNotFound – If any tool id is not found.
excepts::NodeNotFound – If any data anchor of the tool is not found.
excepts::LoopConnection – If there already exists a connection from the input_id to the output_id.
excepts::InvalidConnection – If the output data anchor of the first tool is not DataEdge::kMarkedOutput, or the input data anchor of the second tool is not DataEdge::kVirtualInput
excepts::DataTypeMismatch – If provided features of the output data anchor of the first tool do not satisfy required features of the input data anchor of the second tool,or the output data anchor of the first tool and the input data anchor of the second tool should have different cpt_tag.
-
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:
excepts::ToolNotFound – If tool id is not found.
excepts::NodeNotFound – If any data anchor of the tool is not found.
excepts::InvalidConnection – If node_id of input_id is not a ToolInfo::VirtualInput data node.
-
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.
-
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:
-
std::vector<std::string> tool_list() const#
Get the all tools added to project.
- Returns:
std::vector<std::string> Identifiers of tools
-
std::map<std::string, std::string> all_properties_name_type() const#
Get the descriptor of this project.
Get the name and type of all properties in SampleSet
- Returns:
ProjectDescriptor of this project.
- 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.
See also
- 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:
-
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:
-
void set_param(const ToolNodeId &tool_node, const aidi::param::IParameter ¶m)#
Set the param object.
- Parameters:
tool_node – ToolNodeId specifying the node of the tool
param –
-
aidi::Buffer get_context(const ToolNodeId &tool_node) const#
Get the context object.
- Parameters:
tool_node – ToolNodeId specifying the node of the tool
- Returns:
-
void set_context(const ToolNodeId &tool_node, const aidi::Buffer &context)#
Set the context object.
- Parameters:
tool_node – ToolNodeId 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_node – ToolNodeId specifying the node of the tool
- Returns:
std::shared_ptr<aidi::param::IParameter>
-
std::vector<std::string> backup_ids() const#
Get all backup ids.
- Returns:
std::vector<std::string> The id of backups.
-
std::string create_backup()#
Make an overall backup of the Project.
- Throws:
excepts::FileSystemError – If fail to create backup directory.
excepts::BadMemoryAlloc – If fail to create backup directory.
excepts::LogicError – If no write permission.
excepts::FileSystemError – If the .aidipro file can not be opened.
excepts::CanNotOpenFile – If failed to open the backup ‘aidi~graph.aidibin’.
excepts::SerializeFailed – If failed to serialize stream graph.
excepts::RocksDBError – If BackupEngine fails to initialize or fails to create a version backup.
- Returns:
std::string The ID of the backup version.
-
void restore_backup(const std::string &backup_id)#
Restore a version backup and all its associated data.
- Parameters:
backup_id – The ID of the backup version.
- Throws:
excepts::BackupNotExists – If the backup_id is not exist.
excepts::LogicError – If no write permission.
excepts::FileSystemError – If the .aidipro file can not be opened.
excepts::FileNotFound – If the backup ‘aidi~graph.aidibin’ does not exist.
excepts::CanNotOpenFile – If failed to open the backup ‘aidi~graph.aidibin’.
excepts::DeSerializeFailed – If failed to parse tool graph.
-
void remove_backup(const std::string &backup_id)#
Remove the version backup and all its associated data.
- Parameters:
backup_id – The ID of the backup version.
- Throws:
excepts::LogicError – If no write permission.
excepts::FileSystemError – If the .aidipro file can not be opened.
excepts::FileSystemError – IF fail to remove backup directory.
excepts::BadMemoryAlloc – IF fail to remove backup directory.
-
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:
excepts::FileSystemError – IF fail to create tmp directory or the export file.
excepts::FileExisted – If the file already exists.
Public Static Functions
-
static bool Exists(const ProjectDescriptor &proj_desc)#
Check whether a project exists.
- Parameters:
proj_desc – the project descriptor
- Returns:
true
- Returns:
false
-
static bool Closed(const ProjectDescriptor &proj_desc)#
Check if project closed normally.
- Parameters:
proj_desc – the project descriptor.
- 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
- 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:
excepts::FileExisted – if project already existed
- Returns:
ProjectDescriptor of created project (not open yet)
-
static std::unique_ptr<Project> Open(const ProjectDescriptor &proj_desc, ProjectOpenMode proj_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
proj_mode – The project can be opened in different modes. The default mode is kNormally.
- Throws:
excepts::FileNotFound – if no such a project
- Returns:
std::unique_ptr<Project>
-
std::string add_tool(const std::string &tool_type, const std::string &tool_id = "")#
-
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:
excepts::FileNotFound – If the model file path does not exist.
excepts::InvalidArgument – If the file path is not a file or the file suffix is not .aidimodel.
excepts::CanNotOpenFile – If the model file cannot be opened.
- Parameters:
-
Runtime create_runtime(const aidi::runtime::IStrategy &strategy)#
Create a runtime object.
See also
- Parameters:
strategy – RuntimeStratey which specify the scope to be executed in stream graph.
- Returns:
-
std::shared_ptr<param::IParameter> get_param(const ToolNodeId &tool_node) const#
Get the param object of specified tool and node.
See also
- Parameters:
tool_node – ToolNodeId specifying the node of the tool.
- Returns:
std::shared_ptr<aidi::param::IParameter>
-
void set_param(const ToolNodeId &tool_node, const aidi::param::IParameter ¶m)#
Set the param object.
See also
- Parameters:
tool_node – ToolNodeId specifying the node of the tool.
param – the parameter type.
-
aidi::Buffer get_context(const ToolNodeId &tool_node) const#
Get the context object.
See also
- Parameters:
tool_node – ToolNodeId specifying the node of the tool.
- Returns:
-
void set_context(const ToolNodeId &tool_node, const aidi::Buffer &context)#
Set the context object.
See also
- Parameters:
tool_node – ToolNodeId 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.
See also
- Parameters:
path – New path(utf-8 encoding) to the model file.
password – New password for model file.
-
explicit Model(const std::string &path, const std::string &password = "")#
-
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:
excepts::FileNotFound – Local: if it doesn’t exist, and failed to create.
excepts::InvalidArgument – Local: if the token is not a directory.
excepts::PermissionError – Local: if don’t have read and write permissions.
-
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:
excepts::WorkSpaceAlreadyExist – Local: if the worksapce already exists.
excepts::FileSystemError – Local: if rename the worksapce failed.
-
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.
- Returns:
std::string
-
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:
excepts::FileSystemError – Local: if fails to create.
excepts::BadMemoryAlloc – Local: if fails to create.
excepts::SubWorkSpaceAlreadyExist – If the sub-worksapce already exists.
- 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.
- Parameters:
sub_workspace_name – The name of the sub-workspace to be removed.
- Throws:
excepts::FileSystemError – Local: if fails to remove all.
excepts::BadMemoryAlloc – Local: if fails to remove all.
-
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 project object.
- Parameters:
project_name – The name of the project.
project_remark – The remark of the project.
- Throws:
excepts::FileExisted – If project already existed.
- 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, and the default mode is kNormally.
- Throws:
excepts::FileNotFound – If no such a project.
- Returns:
std::unique_ptr<Project>
-
void remove_project(const std::string &project_name)#
Remove a Project.
- Parameters:
project_name – The name of the project.
- Throws:
excepts::AIDIProLockExist – If the project is not in a normal closing state.
excepts::FileSystemError – Local: if fails to remove all.
excepts::BadMemoryAlloc – Local: if fails to remove all.
Public Static Functions
-
static void CreateWorkSpace(const std::string &token)#
Create a WorkSpace.
- Parameters:
token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.
- Throws:
excepts::FileExisted – Local: if the directory already exists.
excepts::FileNotFound – Local: if it doesn’t exist, and failed to create.
excepts::InvalidArgument – Local: if the token is not a directory.
excepts::PermissionError – Local: if don’t have read and write permissions.
-
static void RemoveWorkSpace(const std::string &token)#
Remove the specified WorkSpace.
- Parameters:
token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.
- Throws:
excepts::FileSystemError – Local: if fail to remove the WorkSpace.
-
static void MoveWorkSpace(const std::string &from_ws_token, const std::string &to_ws_token)#
Move a WorkSpace.
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:
excepts::FileNotFound – If the source workspace does not exist.
excepts::FileExisted – If the target workspace already exists.
excepts::FileSystemError – If workspace move fails.
-
static void CopyWorkSpace(const std::string &from_ws_token, const std::string &to_ws_token)#
Copy a WorkSpace.
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:
excepts::FileNotFound – If the source workspace does not exist.
excepts::FileExisted – If the target workspace already exists.
excepts::FileSystemError – If workspace copy fails.
-
static void CopyProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#
Perform an overall copy for a project.
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:
excepts::FileNotFound – If the source project does not exist.
excepts::FileExisted – If the target project already exists.
excepts::AIDIProLockExist – If the source project is not in a normal closing state.
excepts::FileSystemError – If project copy fails.
-
static void MoveProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#
Perform an overall move for a project.
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:
excepts::FileNotFound – If the source project does not exist.
excepts::FileExisted – If the target project already exists.
excepts::AIDIProLockExist – If the source project is not in a normal closing state.
excepts::FileSystemError – If project move fails.
-
explicit WorkSpace(const std::string &token)#
-
struct 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.
-
std::string created_time#
Time to create the project.
-
std::string last_modified_time#
The last modification time of the project.
-
std::string workspace_token#
-
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.
-
enumerator kNormally = 0#
-
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
Public Types
-
enum DataCptTag#
The concept type of the data edge. It can be a parameter or a property.
See also
Values:
-
enumerator kParam#
Parameter type.
-
enumerator kProp#
Property type.
-
enumerator kParam#
-
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 three cases:
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”.
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.
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 kVirtualInput#
Virtual input.
-
enumerator kMarkedOutput#
Output of this tool.
-
enumerator kInternal#
Internal data.
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.
- 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
- Returns:
DataCptTag The concept type of the data edge.
-
ConnectType connect_type() const#
Get the connect type of the data edge.
See also
- 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.
-
enum DataCptTag#
-
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
Public Types
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.
- 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.
- 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.
- 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.
-
std::string id() const#
-
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 kVirtualInput.
-
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.
-
std::string id() const#
-
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.
- Returns:
const std::string&
-
std::string concat_id() const#
Get the concated tool name and node name with ‘/’.
- Returns:
std::string
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.
-
ToolNodeId(std::string tool_id, std::string node_id)#
-
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 vill 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 Sample &sample, std::string *error_message = nullptr) const#
Check if sample meets the runtime’s requirement.
- Parameters:
sample – Sample 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(Sample &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.
-
Sample create_sample() const#
-
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)#
-
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:
-
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.
See also
- Parameters:
iter – The iterator to get the sample from.
- Throws:
excepts::InvalidIterator – 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.
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
- Parameters:
iter – The iterator to get the sample from.
- Throws:
excepts::InvalidIterator – 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 Sample &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:
excepts::SampleNotFound – throws if the sample with id not exists in sampleset.
excepts::DataNotFound – throws if the sample has empty property which should be generated by Runtime after executing.
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:
excepts::SampleNotFound – throws if the sample with id not exists in sampleset.
aidi::excepts::RocksDBError – throws if property get or put error occurs.
aidi::excepts::PropertyTypeMismatch – throws if the property type not matched with DB’s.
-
using Iterator = SampleSetRuntimeAdapterIterator#
-
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 – The other iterator.
- Returns:
true if two iterators point to the same sample.
- Returns:
false if two iterators point to different samples.
-
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::InvalidIterator – 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.
- Throws:
excepts::InvalidIterator – throws if the iterator is invalid.
excepts::RocksDBError – throws if RocksDB cannot fetch the data.
- Returns:
std::pair<uint32_t, Sample> The ID of the sample and the sample.
-
bool is_valid() const#
-
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.
-
utils::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 allow_auto_update#
-
class IStrategy#
IStrategy is the information bridge between user and Runtime. The specific sub-class of IStrategy contains two kind of information:
strategy class type (or class name);
the required data to infer the subgraph provided by user;
Subclassed by aidi::runtime::SingleNode, aidi::runtime::SingleTool
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.
-
virtual RuntimeStrategyOptions options() const override#
-
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.
-
virtual RuntimeStrategyOptions options() const override#
-
using aidi::PropIDTypeMap = std::map<ToolNodeId, std::string>#
property’s tool_node_id - property’s type
-
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::map<ToolNodeId, std::string> input_parameters() const#
Get input parameters’ ToolNodeId and types required by the configurator.
- Returns:
std::map<ToolNodeId, std::string> The parameters’ ToolNodeId and types.
-
std::map<ToolNodeId, std::string> input_properties() const#
Get input properties’ ToolNodeId and types required by the configurator.
- Returns:
std::map<ToolNodeId, std::string> The properties’ ToolNodeId and types.
-
std::map<ToolNodeId, std::string> output_parameters() const#
Get output parameters’ ToolNodeId and types required by the configurator.
- Returns:
std::map<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.
See also
- 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.
See also
- 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.
-
virtual ~ConfigureRuntime() = default#
-
class ConfigureRuntimeProjectAdapter : public aidi::confs::IService#
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.
-
void set_progress_callback(utils::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 ¶ms) 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.
-
ConfigureRuntimeProjectAdapter(Project *project, const ConfigureRuntime &configurator)#
-
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::utils::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 info message string of task.
- Returns:
TaskCtrlSignal The signal to control the task (abort or continue executing).
-
virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) = 0#
-
class DefaultProgressCallback : public aidi::utils::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 info message string of task.
- Returns:
TaskCtrlSignal The signal to control the task (abort or continue executing).
-
virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) override#
-
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