Core Interface#
visionflow::ISample#
-
class ISample#
Abstract Sample interface definition.
Subclassed by visionflow::LazySample, visionflow::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.
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::DataNotFound – The property name not exist in the sample.
excepts::PropertyTypeMismatch – The type of the property data is not the same as the property type in the sample.
-
virtual std::shared_ptr<props::IProperty> &get_or_create(const ToolNodeId &property_name) = 0#
Get the property data specified by the name. Different 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.
-
virtual const std::map<ToolNodeId, std::string> &property_types() const = 0#
visionflow::Sample#
-
class Sample : public visionflow::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.
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::DataNotFound – The property name not exist in the sample.
excepts::PropertyTypeMismatch – The type of the property data is not the same as the property type in the sample.
-
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, through 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. Different 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.
-
explicit Sample(std::map<ToolNodeId, std::string> property_name_types)#
visionflow::LazySample#
-
class LazySample : public visionflow::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.
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::DataNotFound – The property name not exist in the sample.
excepts::PropertyTypeMismatch – The type of the property data is not the same as the property type in the sample.
-
virtual std::shared_ptr<props::IProperty> &get_or_create(const ToolNodeId &property_name) override#
Get the property data specified by the name. Different 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.
-
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
-
virtual const std::map<ToolNodeId, std::string> &property_types() const override#
visionflow::SampleDescriptor#
visionflow::Project#
-
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
-
ProjectDescriptor descriptor() const#
Get the descriptor of the project.
- Returns:
-
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:
excepts::InvalidToolType – If the tool type is not found.
excepts::ToolAlreadyExist – If the tool id is already used.
- Returns:
The id of the tool added.
-
std::string copy_tool(const std::string &origin_tool_id, const std::string ©_tool_id = "", const graph::CopyToolOptions ©_tool_options = {false, {}})#
Copy a tool from the stream graph and add it into the stream graph.
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.
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.
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:
visionflow::excepts::InvalidToolId – If origin_tool_id is empty.
visionflow::excepts::ToolNotFound – If tool id dose not exist.
visionflow::excepts::ToolAlreadyExist – If the tool id is already used.
- 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 ©_tool_options = {false, {}})#
Copy multiple tools from the stream graph and add them into the stream graph.
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.
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.
For tools that plan copies in origin_tools, the copied tool mapping relationships are automatically added to CopyToolOptions.tool_maps.
CopyToolOptions.tool_maps does not require the same type of tool, as long as it can be connected.
See also
- Parameters:
origin_tools – Original tool ids.
copy_tool_options – Copy tool options.
- Throws:
visionflow::excepts::InvalidToolId – If origin_tool_id is empty.
visionflow::excepts::ToolNotFound – If tool id dose not exist.
visionflow::excepts::ToolAlreadyExist – If the tool id is already used.
- 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:
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 an output data node of the tool, and the input data anchor of the second tool must be a virtual input port, and the two nodes must be data nodes, otherwise an excepts::InvalidConnection will be thrown. see DataEdge::is_tool_output and DataEdge::is_virtual_port() 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. To add new connection for multi_input node, you can pass a ToolNodeId without index to downstream. And to change an exist connection, you can pass a ToolNodeId contains index to downstream to specify the port to reconnection.
- 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 upstream to the downstream.
excepts::InvalidConnection – If the output data anchor of the first tool is not tool output node, or the input data anchor of the second tool is not a virtual input port.
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.
excepts::InActiveOutputNode – Throws if the downstream is an inactive tool output data node.
-
void disconnect(const ToolNodeId &upstream, const ToolNodeId &downstream)#
Disconnect the output node upstream and the virtual input node downstream. The downstream with or without index are both ok. But if downstream contains index, its redirect must be matched with the upstream, otherwise, excepts::InvalidNodeId wil be thrown.
- Parameters:
upstream – The ToolNodeId of the output data anchor to be disconnected.
downstream – The ToolNodeId of the input data anchor to be disconnected.
- 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 downstream is not a virtual input port.
excepts::InvalidNodeId – If the redirect to of downstream is not matched with the upstream.
-
bool auto_connect(const std::string &front_tool, const std::string &back_tool)#
Try to connect the given back_tool after the front_tool. This interface will intelligently attempt to connect all input ports of “back_tool” to the output ports of “front_tool” and its directly or indirectly dependent tools as reasonably as possible. It will return the established connection relationships, but it cannot guarantee that all connections can always be established. Even if connections are established, they may not be as expected. Therefore, we do not highly recommend using this interface. At the very least, you should only use this interface in very simple scenarios.
This interface follows the following rules for establishing connections: // TODO(hui.deng) complete the document.
- Parameters:
front_tool – The front tool to connect to.
back_tool – The back tool to be connected its input ports to the output ports of “front_tool” and its directly or indirectly dependent tools.
- Throws:
excepts::ToolNotFound – If tool id is not found.
excepts::LoopConnection – If there already exists a connection from the back_tool to the front_tool.
- Returns:
true If all connections can be established.
-
void disconnect(const ToolNodeId &downstream)#
Disconnect the redirect node specfied by downstream’s index. If downstream has no index, disconnect all the redirects.
Note
if the connection doesn’t exist, no error would occur.
- Parameters:
downstream – 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 downstream is not a virtual input port.
-
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:
excepts::InvalidToolId – If the old_tool_id or new_tool_id is empty.
excepts::ToolNotFound – If the tool named old_tool_id does not exist.
excepts::ToolAlreadyExist – If the tool named new_tool_id already exists. After rename tool, the mapping relationship between property name and column family in database will be updated, and three exceptions may be thrown:
visionflow::excepts::DatasetNotExists – If there is no mapping relationship between the property named and the column family.
visionflow::excepts::DatasetAlreadyExists – If the mapping between the new property name and the column family already exists.
visionflow::excepts::RocksDBError – If the property descriptor fails to read or write to the database.
-
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
-
ToolNodeId real_id(const ToolNodeId &node_id) const#
The redirect to node id of the virtual node, or itself for others.
- Parameters:
node_id – ToolNodeId specifying the node of the tool.
- Throws:
excepts::ToolNotFound – The tool does not exist in the graph.
excepts::NodeNotFound – The node does not exist in the graph.
excepts::InvalidConnection – The virtual node is not redirected.
- 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 sample sets.
- 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::StrategyOptions &strategy_options)#
Create a config runtime object.
- Parameters:
tool_node – The tool_node_id of the configurator.
strategy_options – StrategyOptions options specified by users.
- Returns:
-
Runtime create_runtime(const visionflow::runtime::IStrategy &strategy)#
Create a runtime object.
- Parameters:
strategy – RuntimeStrategy which specify the scope to be executed in stream graph.
- Returns:
-
void set_param(const ToolNodeId &tool_node, const visionflow::param::IParameter ¶m)#
Set the param object.
- Parameters:
tool_node – ToolNodeId specifying the node of the tool
param –
-
visionflow::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 visionflow::Buffer &context)#
Set the context object.
- Parameters:
tool_node – ToolNodeId specifying the node of the tool
context – the node context
-
void clear_context(const ToolNodeId &tool_node)#
Clear the context object of specified tool and node.
- Parameters:
tool_node – The tool node id of the tool.
-
std::shared_ptr<visionflow::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<visionflow::param::IParameter>
-
bool param_exist(const ToolNodeId &tool_node) const#
Check whether the parameter exists.
- Parameters:
tool_node – ToolNodeId specifying the node of the tool
- Throws:
excepts::NodeNotFound – If the node id is not found or the node is not a parameter node.
excepts::ToolNotFound – The tool does not exist in the graph.
excepts::InvalidConnection – If it is a virtual node that is not redirect to.
- 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.
-
BackupDescriptor get_backup_descriptor(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:
excepts::BackupAlreadyExists – If the backup named ‘backup_name’ already exists.
excepts::FileSystemError – If fail to create backup directory, or the ‘.vfpro’ file can not be opened.
excepts::BadMemoryAlloc – If fail to create backup directory.
excepts::LogicError – If no write permission.
excepts::CanNotOpenFile – If failed to open the backup ‘vflow~graph.vfbin’.
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 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:
excepts::BackupNotExists – If the backup_name is not exist.
excepts::LogicError – If no write permission.
excepts::FileSystemError – If the .vfpro file can not be opened, or failed to overwrite the current tool graph with the backup tool graph.
excepts::FileNotFound – If the backup ‘vflow~graph.vfbin’ does not exist.
excepts::CanNotOpenFile – If failed to open the backup ‘vflow~graph.vfbin’.
excepts::DeSerializeFailed – If failed to parse tool graph.
-
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:
excepts::LogicError – If no write permission.
excepts::FileSystemError – If the .vfpro 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 = "", bool force_replace = false) const#
Export the model and parameters.
- Parameters:
export_file_path – Destination path of the exported file, the file suffix of export_path must be .vfmodel.
password – Password for decompressing the exported file. This password is empty by default.
force_replace – If true, the export file will be overwritten if it already exists.
- Throws:
excepts::FileSystemError – IF fail to create tmp directory or the export file.
excepts::FileExisted – If the file already exists and force_replace is false.
-
void export_proj_template(const std::string &export_file_path) const#
Export project template, including all the tools and connections between tools, into a JSON file.
- Parameters:
export_file_path – Path of the exported file. If the suffix of export_path is not .json, such suffix will be added.
- Throws:
excepts::CanNotOpenFile – If fail to open the export file.
excepts::FileExisted – If the file already exists.
excepts::SerializeFailed – If failed to json-serialize backbone
-
void import_proj_template(const std::string &import_file_path)#
Import tools and connections from project template json file.
- Parameters:
import_file_path – Path to the template json file.
- Throws:
excepts::CanNotOpenFile – if failed to open the import file.
excepts::DeSerializeFailed – if failed to deserialize json file.
excepts::ToolAlreadyExist – Project::add_tool If error occurs when adding tool from template.
excepts::ToolNotFound – Project::connect If error occurs when rebuilding connections from template.
-
void activate_tool_output(const ToolNodeId &tool_node_id)#
Set a tool output data node as a active node.
- Parameters:
tool_node_id – ToolNodeId of the tool output data node.
- Throws:
excepts::ToolNotFound – If the tool id is not found.
excepts::NodeNotFound – If the node id is not found.
excepts::DataTypeMismatch – If the node is not a tool output node.
-
void deactivate_tool_output(const ToolNodeId &tool_node_id, bool force = false)#
Set a tool output data node as an inactive node.
Note
Exception will be thrown when the tool output data node has been connected already and the user does not mean to force deactivate it. And if the user deactivate it forcefully, all connection redirects this tool output data node will be disconnected.
- Parameters:
tool_node_id – ToolNodeId of the tool output data node.
force – Whether to force deactivate if the tool output data node has been connected already.
- Throws:
excepts::ToolNotFound – If the tool id is not found.
excepts::NodeNotFound – If the node id is not found.
excepts::DataTypeMismatch – If the node is not a tool output node.
excepts::OutputNodeHasBeenUsed – If the node has been connected already but the user does not deactivate it forcefully.
-
void save_user_data(const std::string &key, const Buffer &data, const std::string &bind_tool = {})#
Save any data customized by the user with the given key. The data can be bound to a tool if the tool is given. The data bound to the tool will be stored in the tool space and have the same lifecycle as the tool, and will be copied or deleted along with the tool when it is assisted or deleted.
- Parameters:
key – Any string to identify the data.
data – The data to be stored.
bind_tool – Tool id to store the data.
- Throws:
excepts::ToolNotFound – If the bind tool is given but not found.
-
Buffer read_user_data(const std::string &key, const std::string &bind_tool = {}) const#
Get user data saved before. Note that you should make sure the data exists before read it, otherwise an exception will be thrown.
- Parameters:
key – The string to identify the data.
bind_tool – Tool id
- Throws:
excepts::ToolNotFound – If the bind tool id not found.
excepts::DataNotFound – If Data not found.
- Returns:
Buffer user data.
-
void remove_user_data(const std::string &key, const std::string &bind_tool = {})#
Remove user data from the project or bound to the tool.
- Parameters:
key – The key of the data to be removed. Nothing will be done if the key not exists.
bind_tool – The tool id where the user data bind on. If empty, the data in the project space will be removed. And an exception will be thrown if the tool id is given but not found.
- Throws:
excepts::ToolNotFound – If the bind tool id not found.
-
bool user_data_exist(const std::string &key, const std::string &bind_tool = {}) const#
Check if the user data exists.
- Parameters:
key – Key.
bind_tool – Tool id
- Throws:
excepts::ToolNotFound – If the bind tool id is not found.
- Returns:
Return true if the key and data exists, false otherwise.
-
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 describe with Graphviz dot language
-
size_t file_size() const#
Get project’s size. Return the space occupied by file contents, not the space allocated by the system for the file, without considering the size of the folders contained in the path itself.
Project folder’s suffix is “.vflow”
This function only accumulate: (a) the file under “*.vflow/vflow~*” directory or (b) the file with filename “*.vflow/.vfpro”.
If no file satisfy above conditions, return 0. Not throw exceptions.
- Returns:
size_t
-
void refresh_brief_images()#
Refresh the brief images of the project using current input images. Existing brief images will be discarded.
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:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
- 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:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
- 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 ReadProjectDescriptor(const ProjectDescriptor &proj_desc)#
Read the ProjectDescriptor.
- Parameters:
proj_desc – project descriptor with workspace_token and project_name specified.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
- Returns:
The project descriptor read from project.
-
static ProjectDescriptor ReadProjectDescriptor(const std::string &proj_path)#
Read the ProjectDescriptor, same as ReadProjectDescriptor(const ProjectDescriptor &proj_desc)
- Parameters:
proj_path – The project path.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
-
static std::map<std::string, std::string> ToolTypes(const ProjectDescriptor &proj_desc, bool include_backups = false)#
Get tools’ name and type in both current project and its backups without opening the project.
Warning
Note that the project should not be opened when calling this interface, otherwise some unexpected error may occur.
- Parameters:
proj_desc – The project descriptor with workspace_token and project_name
include_backups – Include tools in backups or not. You can get all tools in the project include all backup versions by setting this parameter to true.
- Returns:
std::map<std::string, std::string> The dict of tools’ name and type.
-
static compatible::CompatLevel CompatibilityLevel(const ProjectDescriptor &proj_desc)#
Get the compatibility level between the project and current library version.
Warning
Note that the project should not be opened when calling this interface, otherwise some unexpected error may occur.
- Parameters:
proj_desc – The project descriptor with workspace_token as project_name specified.
- Returns:
compatible::CompatLevel The compatibility level between the project and current library version
-
static compatible::CompatLevel CompatibilityLevel(const std::string &proj_path)#
Get the compatibility level between the project and current library version.
Warning
Note that the project should not be opened when calling this interface, otherwise some unexpected error may occur.
- Parameters:
proj_path – The project path.
- Returns:
compatible::CompatLevel The compatibility level between the project and current library version
-
static std::string CompatibilityInfo(const ProjectDescriptor &proj_desc)#
Get the compatibility information between the project and current library version.
- Parameters:
proj_desc – The project descriptor with workspace_token as project_name specified.
- Returns:
std::string The compatibility information.
-
static std::string CompatibilityInfo(const std::string &proj_path)#
Get the compatibility information between the project and current library version.
- Parameters:
proj_path – The project path.
- Returns:
std::string The compatibility information.
-
static std::vector<std::string> UpgradePath(const ProjectDescriptor &proj_desc)#
Query the key library versions to upgrade the project to compatible with current library version.
- Parameters:
proj_desc – The project descriptor with workspace_token and project_name.
- Returns:
std::vector<std::string> The key library versions.
-
static std::vector<std::string> UpgradePath(const std::string &proj_path)#
Query the key library versions to upgrade the project to compatible with current library version.
- Parameters:
proj_path – The project path.
- Returns:
std::vector<std::string> The key library versions.
-
static void Upgrade(const ProjectDescriptor &proj_desc, const std::string &tmp_backup_dir = "", util::IProgressCallback *progress_bar = nullptr)#
Upgrade the project to the version supported by the current library. Please note that each library version supports only a previous or limited set of versions for direct upgrades. If you want to upgrade a project with an older version, please use the UpgradePath() interface to query the upgrade path and proceed step by step by upgrading to each library version listed in the upgrade path.
- Parameters:
proj_desc – The project descriptor with workspace_token and project_name.
tmp_backup_dir – The backup directory of old project before upgrading, should encoded in UTF-8. Default is empty which means no need to backup.
progress_bar – The upgrade process may take some time, and you can obtain real-time progress and actions of the upgrade by passing in a progress callback.
-
static void Upgrade(const std::string &proj_path, const std::string &tmp_backup_dir = "", util::IProgressCallback *progress_bar = nullptr)#
Upgrade the project to the version supported by the current library. Please note that each library version supports only a previous or limited set of versions for direct upgrades. If you want to upgrade a project with an older version, please use the UpgradePath() interface to query the upgrade path and proceed step by step by upgrading to each library version listed in the upgrade path.
- Parameters:
proj_path – The project path end with “.vflow”.
tmp_backup_dir – The backup directory of old project before upgrading, should encoded in UTF-8. Default is empty which means no need to backup.
progress_bar – The upgrade process may take some time, and you can obtain real-time progress and actions of the upgrade by passing in a progress callback.
-
static ProjectDescriptor Create(const ProjectDescriptor &proj_desc)#
Create project.
- Parameters:
proj_desc – Descriptor specifying the parent path and name of the project
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectAlreadyExists – The project already existed
- Returns:
ProjectDescriptor of created project (not open yet)
-
static std::unique_ptr<Project> Open(const ProjectDescriptor &proj_desc, const ProjectOptions &options = {})#
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 specify the parent path and name of the project
options – The project can be opened in different modes. The default mode is kNormally.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
excepts::CompatibilityError – The project data is not compatable with current library version and can not upgrade automatically.
- Returns:
std::unique_ptr<Project>
-
static std::unique_ptr<Project> Open(const std::string &proj_path, const ProjectOptions &options = {})#
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 “.vflow” suffix.
options – The project can be opened in different modes. The default mode is kNormally.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
excepts::CompatibilityError – The project data is not compatable with current library version and can not upgrade automatically.
- Returns:
std::unique_ptr<Project> the project handle.
-
static inline std::unique_ptr<Project> Open(const ProjectDescriptor &proj_desc, ProjectOpenMode open_mode)#
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 specify the parent path and name of the project
open_mode – The project can be opened in different modes. The default mode is kNormally.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
- Returns:
std::unique_ptr<Project>
-
static inline std::unique_ptr<Project> Open(const std::string &proj_path, ProjectOpenMode open_mode)#
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 “.vflow” suffix.
open_mode – The project can be opened in different modes. The default mode is kNormally.
- Throws:
excepts::InvalidArgument – The project descriptor is invalid,
excepts::ProjectNotExists – No such a project.
- Returns:
std::unique_ptr<Project> the project handle.
-
static size_t FileSize(const std::string &proj_path)#
Get project’s size. For details, please refer to visionflow::Project::file_size.
- Parameters:
proj_path – The path of project.
- Throws:
excepts::ProjectNotExists – No such a project.
- Returns:
size_t
-
static size_t FileSize(const ProjectDescriptor &proj_desc)#
Get project’s size. For details, please refer to visionflow::Project::file_size.
- Parameters:
proj_desc – The ProjectDescriptor.
- Throws:
excepts::ProjectNotExists – No such a project.
- Returns:
size_t
-
static void MoveProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#
Move the entire source project to the new path.
See also
ProjectDescriptor::IsValidProjectDescriptor, or move the project to its subdirectory.
- Parameters:
from_project_descriptor – The description of source project.
to_project_descriptor – The description of target project.
- Throws:
excepts::InvalidArgument – If the from_project_descriptor or to_project_descriptor is not a valid project description
excepts::ProjectNotExists – The source project does not exist.
excepts::ProjectAlreadyExists – The target project already exists.
excepts::ProjectLockExist – The source project is not in a normal closing state.
excepts::FileSystemError – The files move fails.
-
static void CopyProject(const ProjectDescriptor &from_project_descriptor, const ProjectDescriptor &to_project_descriptor)#
Copy the entire source project to a new path.
See also
ProjectDescriptor::IsValidProjectDescriptor, or copy the project to its subdirectory.
- Parameters:
from_project_descriptor – The description of source project.
to_project_descriptor – The description of target project.
- Throws:
excepts::InvalidArgument – It the from_project_descriptor or to_project_descriptor is not a valid project description
excepts::ProjectNotExists – The source project does not exist.
excepts::ProjectAlreadyExists – The target project already exists.
excepts::ProjectLockExist – The source project is not in a normal closing state.
excepts::FileSystemError – The files copy fails.
-
static void RemoveProject(const ProjectDescriptor &project_descriptor)#
Remove entire project.
See also
- Parameters:
project_descriptor – The description of the project.
- Throws:
excepts::InvalidArgument – It the project_descriptor is not a valid project description
-
ProjectDescriptor descriptor() const#
visionflow::Model#
-
class Model#
The Model interface to open and vfmodel file and create visionflow::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::InvalidFileFormat – If the file path is not a file or the file suffix is not .vfmodel.
excepts::CanNotOpenFile – If the model file cannot be opened.
- Parameters:
-
Runtime create_runtime(const visionflow::runtime::IStrategy &strategy)#
Create a runtime object.
- Parameters:
strategy – RuntimeStrategy 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<visionflow::param::IParameter>
-
void set_param(const ToolNodeId &tool_node, const visionflow::param::IParameter ¶m)#
Set the param object.
See also
- Parameters:
tool_node – ToolNodeId specifying the node of the tool.
param – the parameter type.
-
visionflow::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 visionflow::Buffer &context)#
Set the context object.
See also
- Parameters:
tool_node – ToolNodeId specifying the node of the tool.
context – the node context.
-
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 in the model.
- 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_id – ToolNodeId specifying the node of the tool.
- Throws:
excepts::ToolNotFound – The tool does not exist in the graph.
excepts::NodeNotFound – The node does not exist in the graph.
excepts::InvalidConnection – The virtual node is not redirected.
- Returns:
ToolNodeId The real id of the node.
-
bool is_changed() const#
Check if the model temporary cache contents changed after opening. If temporary cache contents changed, you should call resave_to() to make sure the changes take effect when you open the model file again.
- Returns:
bool Is the temporary model files changed after opening.
-
void resave_to(const std::string &path, const std::string &password = "", bool force_replace = false) const#
Re-save 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.
force_replace – If true, the export file will be overwritten if it already exists.
Public Static Functions
-
static ModelInfo ReadModelInfo(const std::string &path, const std::string &password = "")#
Get the infomation of the visionflow model corresponding to the path.
- Throws:
excepts::FileNotFound – If the model file path does not exist. Or, the .vfpro file does not exist in the model file package.
excepts::InvalidFileFormat – If the file path is not a file or the file suffix is not .vfmodel.
excepts::CanNotOpenFile – If the model file cannot be opened.
excepts::JsonParseError – The .vfpro file is not json format, or the ‘last_modified_time’ key-value pair does not exist in .vfpro, or the ‘visionflow_version’ key-value pair does not exist in .vfpro.
- Parameters:
- Returns:
ModelInfo The infomation of the visionflow model
-
static void Upgrade(const std::string &path, const std::string &password = "")#
Upgrade the model to the version supported by the current library. Please note that each library version supports only a previous or limited set of versions for direct upgrades. And Upgrading may affect the model’s performance. If possible, we suggest upgrading the corresponding project of the model and ensuring the effectiveness before re-exporting the model.
-
explicit Model(const std::string &path, const std::string &password = "")#
visionflow::ModelInfo#
-
struct ModelInfo#
The infomation of visionflow model.
visionflow::WorkSpace#
-
class WorkSpace#
Public Functions
-
explicit WorkSpace(const std::string &token)#
WorkSpace unique constructor.
See also
- Parameters:
token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.
- Throws:
excepts::InvalidArgument – Th workspace token is invalid,
excepts::FileSystemError – For the local workspace: folder does not exist and failed to create.
excepts::PermissionError – For the local workspace: no read and write permissions, or it is a system folder.
-
std::string token() const#
Get the token of the workspace.
- Returns:
std::string The token of the workspace.
-
std::string name() const#
Get the name of the workspace.
- Returns:
std::string The name of the workspace.
-
std::string sub_workspace_token(const std::string &sub_workspace_name) const#
Get sub-workspace token by name.
See also
- 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_workspace_names() const#
Get all first-level sub-workspace names.
- Returns:
std::vector<std::string> The names of first-level sub-workspace.
-
std::string create_sub_workspace(const std::string &sub_workspace_name)#
Create a first-level sub-workspace.
See also
- Parameters:
sub_workspace_name – The name of the sub-workspace to be created.
- Throws:
excepts::InvalidArgument – The workspace name is invalid,
excepts::FileSystemError – Local: if fails to create.
excepts::BadMemoryAlloc – Local: if fails to create.
excepts::SubWorkSpaceAlreadyExists – If the sub-workspace already exists.
- Returns:
std::string The name of the sub-workspace.
-
void remove_sub_workspace(const std::string &sub_workspace_name)#
Remove a first-level sub-workspace.
See also
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:
excepts::InvalidArgument – The workspace name is invalid,
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 new project and return project description information.
See also
- Parameters:
project_name – The name of the project.
project_remark – The remark of the project, empty by default.
- Throws:
excepts::InvalidArgument – The project name is invalid,
excepts::ProjectAlreadyExists – The 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.
See also
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:
excepts::InvalidArgument – The project name is invalid,
excepts::ProjectNotExists – The name of the project does not exist.
- Returns:
std::unique_ptr<Project>
-
void remove_project(const std::string &project_name)#
Remove the project.
See also
Note
If the name is empty or does not exist, nothing will be done.
- Parameters:
project_name – The name of the project.
- Throws:
excepts::InvalidArgument – The project name is invalid,
excepts::ProjectLockExist – 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.
-
size_t file_size() const#
Get workspace’s size. Return the space occupied by file contents, not the space allocated by the system for the file, without considering the size of the folders contained in the path itself.
Project folder’s suffix is “.vflow”
This function only accumulate: (a) the file under “*.vflow/vflow~*” directory or (b) the file with filename “*.vflow/.vfpro”.
If no file satisfy above conditions, return 0. Not throw exceptions.
- Returns:
size_t
-
int64_t created_time() const#
Time stamp when the workspace was created.
Note
Local: this function can only be used on windows.
- Throws:
excepts::FileSystemError – Local: failed to get the creation time of the workspace.
excepts::LogicError – Local: if called on linux.
-
int64_t last_modified_time() const#
Time stamp of the last modification of the workspace.
- Throws:
excepts::FileSystemError – Local: failed to get last modified time of the workspace.
Public Static Functions
-
static void CreateWorkSpace(const std::string &token)#
Create a new WorkSpace.
See also
- Parameters:
token – The token of the workspace (cloud: URL, local: directory), should be UTF-8 encoding.
- Throws:
excepts::InvalidArgument – The workspace name is invalid,
excepts::FileExisted – Local: the directory already exists.
excepts::FileSystemError – Local: The token of the workspace doesn’t exist and failed to create.
excepts::PermissionError – Local: no read and write permissions, or it is a system folder.
-
static void RemoveWorkSpace(const std::string &token)#
Remove the specified WorkSpace.
See also
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:
excepts::InvalidArgument – It workspace token is invalid,
excepts::FileSystemError – Local: if fail to remove the files in the WorkSpace.
-
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:
excepts::InvalidArgument – The from_ws_token or to_ws_token is invalid
excepts::WorkSpaceNotExists – The source workspace does not exist.
excepts::WorkSpaceAlreadyExists – The target workspace already exists.
excepts::FileSystemError – The files move fails.
-
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:
excepts::InvalidArgument – The from_ws_token or to_ws_token is invalid
excepts::WorkSpaceNotExists – The source workspace does not exist.
excepts::WorkSpaceAlreadyExists – The target workspace already exists.
excepts::FileSystemError – The files copy fails.
-
explicit WorkSpace(const std::string &token)#
visionflow::ProjectDescriptor#
-
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.
-
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.
-
int64_t last_modified_time#
The last modification timestamp of the project.
-
std::vector<visionflow::Image> brief_images#
Part of sample image for display.
-
std::string product_mark#
The product identifier, it identifies the product from which this project was created. When opening a project, the respective product may perform a mark check, and only projects with marks that are recognized by the respective product can be opened correctly.
Public Static Functions
-
static bool IsValidWorkSpaceToken(const std::string &token, std::string *error_message = nullptr)#
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 –
error_message – detailed error message.
- Returns:
true
- Returns:
false
-
static bool IsValidProjectName(const std::string &name, std::string *error_message = nullptr)#
A valid project name needs to meet the following conditions: 1.can’t be empty, 2.can’t start or end with a space character, 3.can’t contain the following special characters: {’', ‘/’, ‘:’, ‘*’, ‘?’, ‘”’, ‘<’, ‘>’, ‘|’}, 4.can’t exceed 200 characters in length.
- Parameters:
name –
error_message – detailed error message.
- Returns:
true
- Returns:
false
-
static bool IsValidWorkSpaceName(const std::string &name, std::string *error_message = nullptr)#
A valid workspace name needs to meet the following conditions: 1.can’t be empty, 2.can’t start or end with a space character, 3.can’t contain the following special characters: {’', ‘/’, ‘:’, ‘*’, ‘?’, ‘”’, ‘<’, ‘>’, ‘|’}, 4.can’t exceed 200 characters in length.
- Parameters:
name –
error_message – detailed error message.
- Returns:
true
- Returns:
false
-
static bool IsValidProjectDescriptor(const ProjectDescriptor &proj_desc, std::string *error_message = nullptr)#
A valid project descriptor needs to meet the following conditions: 1.the workspace_token should be valid.
See also
IsValidWorkSpaceToken, 2.the project_name should be valid
See also
- Parameters:
proj_desc –
error_message – detailed error message.
- Returns:
true
- Returns:
false
-
static bool IsLocalWorkspaceToken(const std::string &token)#
Determine whether it is a local workspace token.
- Parameters:
token –
- Returns:
true
- Returns:
false
-
std::string workspace_token#
visionflow::BackupDescriptor#
-
struct BackupDescriptor#
Backup version info.
visionflow::ProjectOpenMode#
-
enum visionflow::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#
visionflow::ProjectOptions#
-
struct ProjectOptions#
Options to open the project.
Public Members
-
ProjectOpenMode open_mode = kNormally#
The project can be opened in different modes. The default mode is kNormally.
-
bool auto_upgrade = false#
Due to the possibility of losing some data or affecting the project status during automatic upgrades, we do not automatically upgrade when opening a project by default. You can set this option to true to automatically upgrade it if it’s upgradable are when opening projects with mismatched versions. Note that automatic upgrades may not always be successful because there could be multiple versions that need to be upgraded between the project and the library.
-
std::string upgrade_tmp_backup_dir = {}#
Where to backup the project temporarily before upgrading. Due to upgrading may be failed and the project may be damaged, we will backup the the project into the directory specified by this option before upgrading. And if this option is not set, the temporary backup steps will be skipped.
-
bool auto_remove_upgrade_tmp_backup = true#
Whether to automatically remove the temporary backup after upgrading successfully. You can choose to keep the temporary backup created before upgrading until you manually remove it by setting this option to false.
-
ProjectOpenMode open_mode = kNormally#
visionflow::DataEdge#
-
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
Public Functions
-
std::string id() const#
Get data id in the tool.
- Returns:
std::string The data id.
-
bool is_virtual_port() const#
Get If the data edge is a virtual input port.
- Returns:
true if the data edge is a virtual input port.
- Returns:
false if the data edge is not a virtual input port.
-
size_t allow_max_connect() const#
Get the allowed max connect number of the virtual input port. 1 will be returned if the data edge is not a virtual input port.
- Returns:
size_t
-
std::vector<std::string> required_features() const#
Feature names this virtual input port required. Only data type provided the required features can connects to this port. If the data edge is not a virtual input port, an empty vector will be returned.
- Returns:
std::vector<std::string> the required features.
-
std::vector<ToolNodeId> redirects() 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 vector, 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::vector<ToolNodeId> The source tool node id.
-
std::string type() const#
Get the data type of the data edge. Only work when the data node is not a virtual input port.
Note
No meaning to get Virtual input nodes’ type.
- 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. Only work when the data node is not a virtual input port.
See also
Note
No meaning to get Virtual input nodes’ update time.
- Returns:
int64_t The last modified time of the data edge in utc timestamp. If the current environment system’s configuration not match any environments of context stored in Graph, return 0.
-
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.
-
bool is_tool_output() const#
Get the connect type of the data edge.
- Returns:
True if this data node is one of the tool ouput node.
-
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. An empty vector will be returned if the data edge is a virtual input port.
-
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.
-
bool is_active() const#
Check whether a data edge is active or inactive. Only work when the data node is not a virtual input port.
Active means it can be used by its downstream virtual_input data while inactive means it cannot be used by other nodes.
Note
No meaning to get Virtual input nodes’ is_active status.
- Returns:
bool if this data node is active of not.
-
std::string id() const#
visionflow::ComputeNode#
-
class ComputeNode#
ComputeNode Info.
Compute nodes are the core data processing units in the tool. a compute node will receive 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 under the current Environment system configurations.
- Returns:
int64_t The last modified time of the compute node in utc timestamp.If the current environment system’s configuration not match any environments of context stored in Graph, return 0.
-
std::vector<DataEdge> param_nodes() const#
Get parameter edges required by the compute node.
Note
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 and parameter edges required by the compute node.
See also
- Returns:
std::vector<DataEdge> The property and parameter edges required by the compute node.
-
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#
visionflow::ToolInfo#
-
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.
-
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 tool output data edges.
-
std::vector<DataEdge> data_edges() const#
Get all data edges, include the internal, output data and the virtual input nodes 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#
visionflow::ToolNodeId#
-
class ToolNodeId#
Public Functions
-
ToolNodeId(std::string tool_id, std::string node_id, int index = -1)#
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 contains ‘/’ and brackets. For example: “node_name” or “node_name_1” is valid, “node_name/foo” or “node_name[1]” is invalid.
index – Index suffix number, default -1 means no index suffix.
- Throws:
visionflow::excepts::InvalidNodeId – If the node name is invalid.
-
ToolNodeId(const std::string &concat_id)#
Construct a new Tool Node Id object with concatenated tool name and node name with ‘/’.
- Parameters:
concat_id – Tool name and node name concatenated 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
-
bool has_index() const#
Get if the node name has index suffix (index >= 0).
- Returns:
true If the node name has index suffix.
- Returns:
false If the node name has no index suffix.
-
int index() const#
Get the index suffix number.
- Returns:
int The index suffix number, return -1 if the node name has no index suffix.
-
ToolNodeId strip_index() const#
Get the ToolNodeId with no index suffix.
- Returns:
ToolNodeId with no index suffix.
-
std::string concat_id() const#
Get the concatenated tool name and node name with ‘/’. If has index return concatenated name with index enclosed in brackets at the end.
- Returns:
std::string
-
std::string full_id() const#
Get the full node name with tool name and index suffix enclosed in brackets if has index.
- Returns:
std::string The full node name with tool name and index suffix.
-
ToolNodeId operator[](int index) const#
Get another ToolNodeId with the given index suffix.
- 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 *error_message = nullptr)#
Check if the node name is valid.
- Parameters:
node_id – Node name.
error_message – 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, int index = -1)#
visionflow::Runtime#
-
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.
-
std::vector<int> used_device() const#
Get devices id used by the configurator.
- Returns:
std::vector<int> the used devices id.
-
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 without 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:
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(ISample &sample, bool async = true) 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 create numerous different threads to call the function in synchronous mode (setting the parameter
async
to false), but you can do so in asynchronous mode (setting the parameterasync
to true).- 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.
async – Inferring the sample in asynchronous mode or not.
-
void register_observer(runtime::IRuntimeObserver *observer) const#
Register an RuntimeObserver object into runtime.
- Parameters:
observer – runtime::RuntimeObserver
-
Sample create_sample() const#
visionflow::RuntimeSampleSetAdapter#
-
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.
Note
Will return end() 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::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.
See also
- 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.
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::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:
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.
visionflow::excepts::RocksDBError – throws if property get or put error occurs.
visionflow::excepts::PropertyTypeMismatch – throws if the property type not matched with DB’s.
-
using Iterator = SampleSetRuntimeAdapterIterator#
visionflow::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 – 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:
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#
visionflow::runtime::StrategyOptions#
-
struct StrategyOptions#
The users can indicate their preference for Runtime executing behaviors by configuring StrategyOptions.
Public Members
-
bool allow_auto_update = false#
Whether to use auto execute feature when some needed parameter_nodes have not been updated.
-
util::IProgressCallback *call_back = nullptr#
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.
-
bool allow_auto_update_rely_on_prop = false#
Whether to allow configurators which rely on property execute automatically to update some needed parameter_nodes. Default set to false.
-
size_t allow_max_gpu_num = 0xFFFF#
The max number of GPUs allowed to be used in the runtime or config runtime. If the real number of GPUs is smaller than or equal to this value, the runtime or config runtime will use all GPUs. If you run VisionFlow on a host without any NVIDIA GPU device, please set this option to 0 to avoid calling GPU-related interfaces and prevent crashes.
-
std::vector<int> specified_gpu_ids = {}#
The specified GPU ids. If the number of allowed GPUs exceeds the number of GPUs specified, other available GPUs will be found and selected automatically.
-
bool allow_run_on_cpu = false#
Whether to allow the runtime to run on CPU if GPU device is not available. Default set to false. And you must switch it to true if you want to execute runtime on CPU.
-
bool allow_auto_update = false#
visionflow::runtime::IStrategy#
-
struct 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 visionflow::runtime::AllTools, visionflow::runtime::SingleNode, visionflow::runtime::SingleTool, visionflow::runtime::Tools, visionflow::runtime::ToolsAndDepends
Public Functions
-
IStrategy() = default#
< Default constructor.
-
IStrategy &operator=(IStrategy &&rhs) = default#
Construct a IStrategy object with StrategyOptions.
-
inline explicit IStrategy(StrategyOptions _options)#
Default destructor.
-
virtual ~IStrategy() = default#
set the tool_id. The strategy options that user set.
visionflow::runtime::SingleTool#
-
struct SingleTool : public visionflow::runtime::IStrategy#
SingleTool Contains the information to check the execution feasibility construct an Runtime object for the range of a single tool.
Public Functions
-
SingleTool() = default#
< Default constructor
-
SingleTool &operator=(SingleTool &&rhs) = default#
Construct a SingleTool RuntimeStrategy.
-
explicit SingleTool(std::string _tool_id, StrategyOptions _options = {})#
the tool_id.
-
SingleTool() = default#
visionflow::runtime::SingleNode#
-
struct SingleNode : public visionflow::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
-
SingleNode()#
< Default constructor. A default tool_node_id “DefaultTool/DefaultNode” will be set.
-
SingleNode &operator=(SingleNode &&rhs) = default#
Construct a SingleNode with id of operator and options.
-
explicit SingleNode(ToolNodeId id, StrategyOptions _options = {})#
the tool_node_id of the operator.
-
SingleNode()#
visionflow::runtime::Tools#
-
struct Tools : public visionflow::runtime::IStrategy#
Strategy to run the tools specified by user. this strategy will not include the dependence of the specified tools.
visionflow::runtime::ToolsAndDepends#
-
struct ToolsAndDepends : public visionflow::runtime::IStrategy#
ToolsAndDepends Contains the information to check the execution feasibility construct an Runtime object for the range of multi-tools and their previous dependence.
Public Functions
-
ToolsAndDepends() = default#
< Default constructor
-
ToolsAndDepends &operator=(ToolsAndDepends &&rhs) = default#
Construct a ToolsAndDepends with ids of last tools and options.
-
explicit ToolsAndDepends(std::set<std::string> _tool_ids, StrategyOptions _options = {})#
the ids of last tools.
-
ToolsAndDepends() = default#
visionflow::runtime::AllTools#
-
struct AllTools : public visionflow::runtime::IStrategy#
AllTools Strategy allow user construct an Runtime to infer all tools in the graph by setting StrategyOptions.
visionflow::runtime::IRuntimeObserver#
-
class IRuntimeObserver#
IRuntimeObserver is a base class for observing the behaviors of Runtime.
Subclassed by visionflow::runtime::RuntimeProfiler
Public Functions
-
virtual ~IRuntimeObserver() = default#
< Default destructor.
-
inline virtual bool initialize(const std::vector<ToolNodeId> &nodes) noexcept#
Initialize the observer with the operator nodes’ id. Which will be called when the observer is registered to runtime.
- Parameters:
nodes – The operator nodes’ id.
- Returns:
true if initialization is successful.
- Returns:
false if initialization is failed.
-
virtual void run_before(const ToolNodeId &id, const ISample &sample) noexcept = 0#
Call this function before executing an operator. Note that this interface would be called by multiple threads at the same time, However, what can be promised is that two different threads will not simultaneously call this interface and IRuntimeObserver::run_after with the same node ID.
- Parameters:
id – The tool_node_id of the operator to be executed.
sample – The Sample passed to runtime to execute.
-
virtual void run_after(const ToolNodeId &id, const ISample &sample) noexcept = 0#
Call this function after executing an operator. Note that this interface would be called by multiple threads at the same time, However, what can be promised is that two different threads will not simultaneously call this interface and IRuntimeObserver::run_before with the same node ID.
- Parameters:
id – The tool_node_id of the operator to be executed.
sample – The Sample passed to runtime to execute.
-
virtual ~IRuntimeObserver() = default#
visionflow::runtime::RuntimeProfiler#
-
class RuntimeProfiler : public visionflow::runtime::IRuntimeObserver#
RuntimeProfiler records the execution time of each operator and tool.
Public Types
Public Functions
-
virtual bool initialize(const std::vector<ToolNodeId> &nodes) noexcept override#
Initialize the observer with the operator nodes’ id. Which will be called when the observer is registered to runtime.
- Parameters:
nodes – The operator nodes’ id.
- Returns:
true if initialization is successful.
- Returns:
false if initialization is failed.
-
virtual void run_before(const ToolNodeId &id, const ISample &sample) noexcept override#
Call this function before execute an operator.
- Parameters:
id – Id of the operator.
sample – Not used.
-
virtual void run_after(const ToolNodeId &id, const ISample &sample) noexcept override#
Call this function when the operator finish execution.
- Parameters:
id – Id of the operator.
sample – Not used.
-
std::string report(OutputFormat format = kJson) const#
Get the std::string of the report information. The Json format output will be like (milliseconds):
{ "average": 100, "total": 1000, "min": 10, "max": 120, "tools": [{ "tool_id": "Tool-1", "total": 10, "average": 1, "min": 0.5, "max": 11, "nodes": [ { "node_id": "node-1", "total": 7, "average" : 0.7 "min": 0.5, "max": 11, } ] }] }
- Parameters:
format – The format of the report string.
- Returns:
std::string The report information.
-
virtual bool initialize(const std::vector<ToolNodeId> &nodes) noexcept override#
visionflow::PropIDTypeMap#
-
using visionflow::PropIDTypeMap = std::map<ToolNodeId, std::string>#
property’s tool_node_id - property’s type
visionflow::ConfigureRuntime#
-
class ConfigureRuntime#
Configure Runtime definition.
The ConfigureRuntime class is used to execute a configurator
Public Functions
-
const ToolNodeId &node_id() const#
Get the configurator node’s ToolNodeId.
- Returns:
ToolNodeId The ToolNodeId of configurator node.
-
std::vector<int> used_device() const#
Get devices id used by the configurator.
- Returns:
std::vector<int> the used devices id.
-
const 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.
-
const 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.
-
const 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.
See also
- Parameters:
service – provide the initialize data confs::IService
-
TaskStatus execute(confs::IService &service)#
Execute 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.
-
const ToolNodeId &node_id() const#
visionflow::ConfigProjectImplAdapter#
-
class ConfigProjectImplAdapter : public visionflow::confs::IService#
Adapter for ConfigureRuntime and ProjectImpl.
This class is used to adapt ProjectImpl to ConfigureRuntime.
Subclassed by visionflow::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 should be valid during the whole life of the adapter. you should delete the object after the adapter destroyed 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 visionflow::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:
visionflow::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.
-
void set_progress_callback(util::IProgressCallback *callback)#
visionflow::ConfigureRuntimeProjectAdapter#
-
class ConfigureRuntimeProjectAdapter : public visionflow::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.
-
ConfigureRuntimeProjectAdapter(Project *project, const ConfigureRuntime &configurator)#
visionflow::ConfigureRuntimeProjectFilterAdapter#
-
class ConfigureRuntimeProjectFilterAdapter : public visionflow::confs::IService#
Adapter filter for ConfigureRuntime and ProjectImpl.
This class is used to adapt ProjectImpl to ConfigureRuntime.
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 should be valid during the whole life of the adapter. you should delete the object after the adapter destroyed 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 visionflow::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:
visionflow::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#
Get the output parameters generated by the configurator. The output parameters will not be automatically saved to the project. If you need to update them to the project, call.
See also
commit to confirm them manually.
- 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.
-
const std::shared_ptr<param::IParameter> &output_parameter(const ToolNodeId ¶m_name) const#
Get the specified output parameter.
- Parameters:
param_name –
- Throws:
excepts::DataNotFound – No such property set exists.
-
void commit()#
Save the output parameters generated by the configurator and configurator context into the project.
-
void set_filter_ids(const std::vector<uint32_t> &filter_ids)#
The data in filter ids will be filtered out.
- Parameters:
filter_ids –
-
void set_filter_script(const ToolNodeId &property_name, const std::string &filter_script)#
Set the filter script for the specified property.
Note
Have to be aware of that:
It needs to be a complete filter script that conforms to python syntax, and pay attention to indentation.
The name of the function must be ‘vflow_filter’, and there can be only one parameter with any name.
As for the function body, write your filter function, and finally return ‘true’ or ‘false’.
- Parameters:
property_name –
filter_script – Python filter script. eg:
R"( from visionflow.property import * def vflow_filter(data): return data.area() > 2 and data.name() == "test")"
- Throws:
excepts::DataNotFound – No such property set exists.
-
void set_progress_callback(util::IProgressCallback *callback)#
visionflow::util::IProgressCallback#
-
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 visionflow::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).
-
virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) = 0#
visionflow::util::DefaultProgressCallback#
-
class DefaultProgressCallback : public visionflow::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).
-
virtual TaskCtrlSignal on_progress(int total, int progress, const char *progress_info) override#
visionflow::detail::Factory#
visionflow::detail::CreatorMutableMixin#
-
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 visionflow::confs::Factory, visionflow::opers::Factory
visionflow::TaskStatus#
-
enum class visionflow::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)
-
enumerator kFinished = 0#
visionflow::TaskCtrlSignal#
-
enum class visionflow::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.
-
enumerator kContinue = 0#
visionflow::graph::DotInfoOptions#
-
struct DotInfoOptions#
User-defined node detail info option in dot language.
visionflow::graph::CopyToolOptions#
-
struct CopyToolOptions#
Copy tool options.