AI Pipelines
opengate_data.ai_pipelines.ai_pipelines
AIPipelinesBuilder
AIPipelinesBuilder Objects
Builder pipelines
with_organization_name
Specify the organization name.
Arguments:
organization_namestr - The name of the organization.
Returns:
AIPipelinesBuilder- Returns self for chaining.
Example:
with_identifier
Specify the identifier for the pipeline.
Arguments:
identifierstr - The identifier for the pipeline.
Returns:
AIPipelinesBuilder- Returns self for chaining.
Example:
with_env
Specify the environment variable.
Arguments:
data_envstr - The environment variable.
Returns:
AIPipelinesBuilder- Returns self for chaining.
Example:
with_find_by_name
Specify the name to find.
Arguments:
find_namestr - The name of the pipeline.
Returns:
AIPipelinesBuilder- Returns self for chaining.
Example:
with_config_file
Sets up the configuration file (.ini).
This method allows specifying a configuration file, a section within that file, and a key to retrieve a specific value from the section.
Arguments:
config_filestr - The path to the.ini configuration file.sectionstr - The section name within the.ini file where the desired configuration is located.config_keystr - The key within the specified section whose value will be retrieved.
Raises:
TypeError- If the provided config_file is not a string.TypeError- If the provided section is not a string.TypeError- If the provided config_key is not a string.
Example:
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
with_prediction
Prediction with a model
Arguments:
data_predictiondict - Prediction
Raises:
TypeError- If the prediction is not a dict.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
Example:
with_name
Name a new pipeline
Arguments:
namestr - Name a new pipeline
Raises:
TypeError- If the name is not a string.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
Example:
add_action
Add action name and type of model or transform exist.
Arguments:
file_namestr - The name of the file representing the action.type_actionstr | None - The type of the action, either ‘MODEL’ or ‘TRANSFORMER’. If None, it will be inferred from the file extension.
Raises:
TypeError- If file_name is not a string.TypeError- If type_action is not a string or None.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
Example:
build
This method prepares the builder to execute the collection by ensuring all necessary configurations are set and validates the overall integrity of the build. It should be called before executing the collection to ensure that the configuration is complete and valid.
The build process involves checking that mandatory fields such as the device identifier are set. It also ensures that method calls that are incompatible with each other (like build and build_execute) are not both used.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining, enabling further actions likeexecute.
Raises:
ValueError- If required configurations are missing or if incompatible methods are used together.
Notes:
This method should be used as a final step before execute to prepare the operations search configuration. It does not modify the state but ensures that the builder’s state is ready for execution.
Example:
build_execute
Executes the data sets search immediately after building the configuration.
This method is a shortcut that combines building and executing in a single step.
Returns:
dict- A dictionary containing the execution response which includes the status code and potentially other metadata about the execution.
Raises:
ValueError- Ifbuildhas already been called on this builder instance.
Example:
create
Creates a new pipeline.
This method prepares the request to create a new pipeline using the specified configuration in the object. It is necessary to define the name (with_name) and actions (add_action) before calling this method.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
find_all
Retrieves all available pipelines.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
find_one
Finds a specific pipeline by its identifier.
This method prepares the request to find a specific pipeline based on its identifier. The identifier is obtained automatically if not explicitly defined or can be obtained from a configuration file or environment variables.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
update
Updates an existing pipeline.
This method prepares the request to update an existing pipeline. It is necessary to define the organization’s name (with_organization_name) and the pipeline’s name (with_name) before calling this method.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
delete
Deletes an existing pipeline.
This method prepares the request to delete an existing pipeline. It is necessary to define the organization’s name (with_organization_name) and the pipeline’s identifier (with_identifier) before calling this method.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
prediction
Performs a prediction with a model.
This method prepares the request to perform a prediction using the model associated with the specified pipeline. It is necessary to define the organization’s name (with_organization_name), the pipeline’s identifier (with_identifier), and provide prediction data (with_prediction) before calling this method.
Returns:
AIPipelinesBuilder- Returns the same object to allow method chaining.
Example:
save
Save the model configuration.
This method sets up the AIPipelinesBuilder instance to save the configuration of a model associated with the specified organization. It configures the URL endpoint for the save operation and sets the operation type to ‘save’.
Returns:
AIPipelinesBuilder- The instance of the AIModelsBuilder class itself, allowing for method chaining.
Example:
set_config_file_identifier
Selects the operation that writes the pipeline identifier into a configuration file.
It stores the identifier given to with_identifier() under the section
and key named with with_config_file(), so a later run can pick the
pipeline up from the file instead of carrying its identifier in the code.
The key must already exist in the file.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
Example:
set_env_identifier
Selects the operation that writes the pipeline identifier into the
.env file.
It stores the identifier given to with_identifier() under the variable
named with with_env(), so a later run can pick the pipeline up from the
environment. The variable must already exist in the .env file.
Returns:
AIPipelinesBuilder- Returns itself to allow for method chaining.
Raises:
ValueError- If the variable is not in the.envfile.
Example:
execute
Execute the configured operation and return the response.
This method executes the operation that has been configured using the builder pattern. It ensures that the build method has been called and that it is the last method invoked before execute. Depending on the configured method (e.g., create, find, update, delete), it calls the appropriate internal execution method.
Returns:
requests.Response- The response object from the executed request.
Raises:
Exception- If thebuildmethod has not been called or if it is not the last method invoked beforeexecute.ValueError- If the configured method is unsupported.
Example: