Flow#

A Flow in ConverSight is the core component of the system. Similar to tasks, Flows take inputs, perform operations and generate outcomes. Flows act as managers, coordinating tasks for efficient execution, making complex tasks achievable within ConverSight. It’s crucial to note that a Flow maybe made up entirely of Tasks or SubFlows.

When dealing with multiple tasks organizing them into a Flow is helpful. This enables tasks to run sequentially or parallelly, tailored to your needs. Think of a Flow as a series of steps leading to a result. By using a Flow, tasks are executed systematically and effectively, helping you reach your goals efficiently.

Flows are identical to functions. They can accept inputs, perform work and output results. The Flow starts with with Flow() as flow. When a function designates into a flow, its behaviour changes, granting it the following benefits:

  • Input arguments types can be validated.

  • Retries can be performed on failure using the re-run the flow option from the Flow Run Status in the ConverSight platform .

  • Timeouts can be enforced to prevent unintentional, long-running workflows.

When you need multiple tasks to accomplish your requirements, all tasks can be grouped or combined into a flow. Flow maybe composed of tasks or subflows.

To watch the video, click on Creating a Flow.

Create#

Inorder to create a Flow you must first create tasks and register them. Task creation and registration are thoroughly addressed in Tasks.

For example:
The code snippet below shows the tasks that are created.

from conversight import task, TaskLibrary, Context

tsk = TaskLibrary()

@task

def division(ctx: Context,x: int, y: int) -> float:

    '''This is division task.'''

    try:

        ctx.log.info("Division has started")

        return (x / y)

    except Exception as err:

        ctx.log.error(f"Exception in division_task ==> {err}")

        return err
../../../../_images/Flow_Task1_Creation.png

Creating Task 1 for Flow Creation#

@task

def addition(ctx: Context,x: int, y: int) -> int:

    '''This is addition task.'''

    try:

        ctx.log.info("Addition has started")

        return (x + y)

    except Exception as err:

        ctx.log.error(f"Exception in addition_task ==> {err}")

        return err
../../../../_images/Flow_Task2_Creation.png

Creating Task 2 for Flow Creation#

Register these tasks using the register() command.

division.register(libraryName="Arithmetic", description="Simple Division", sourceControl="edit", apiAccess=False, deployable=False, athenaAccess=False, taskType="generic", debug=False)

addition.register(libraryName="Arithmetic", description="Simple Addition", sourceControl="edit", apiAccess=False, deployable=False, athenaAccess=False, taskType="generic", debug=False)
../../../../_images/Task_Registration_Flow.png

Task Registration for Flow#

Now let’s import TaskLibrary, Flow and Parameter from conversight library which is essential to create a Flow. Parameter is a function used to define input arguments of the Flow.

from conversight import TaskLibrary, Flow, Parameter
tsk = TaskLibrary()
../../../../_images/Importing_Libraries.png

Importing#

  • Flows can be created using the python with statement. Clicking on the Shift + Tab keys simultaneously after typing the Parameter() function displays the input arguments required for that parameter. Default Value for the parameter is an optional argument, if not provided None will be passed.

Syntax:

with Flow(description, tags) as flow:
    x = Parameter(ParameterName, Default_Value) #default value is an optional parameter
    y = Parameter(ParameterName, Default_Value)
    z = Parameter(ParameterName, Default_Value)

    d = tsk.Arithmetic.division(x,y)
    a = tsk.Arithmetic.addition(d,z)
../../../../_images/Flow_Parameter_HelpGuide.png

Parameter HelpGuide#

NOTE
The name of the flow should not include the term "flow" within it. For instance, you are not permitted to generate a name such as "flow_sample."

The following are the input arguments required to create a Flow.

Argument

Description

flowName

The name of the flow we have created. If not specified, the last flow name will be taken.

description

Textual explanation that provides context, details or information about the Task.

tags

Provide any tags associated with the task for easy identification.

../../../../_images/Flow_Syntax.png

Flow Syntax#

Run#

Once the Flow is created, it can be executed using the run() method. This method uses default values as parameters within the Flow context if they are specified. Otherwise, users have the option to input custom arguments when utilizing the run() method.

flow.run() 
#this will execute the Flow and the provide the output based on the default values
../../../../_images/Flow_Run.png

Running a Flow#

../../../../_images/Flow_Run_Custom_Values.png

Running a Flow#

Register#

Once we recieve the output, we can register the current Flow using the register() method. Shift + Tab displays information about the input arguements required to register a flow.

Argument

Description

libraryName

The library where the flow needs to be registered. It cannot be empty and spaces are not allowed. If the given library name is not present in the conversight, it will be created automatically.

flowName

The name of the flow we have created. If not specified, the last flow name will be taken.

description

Textual explanation or summary that provides context, details or information about the Flow created.

debug

This will give more insights on the response/error.

../../../../_images/Flow_Register_Help_Guide.png

Registering a Flow#

flow.register(libraryName, flowName, description, debug)
../../../../_images/Flow_Register.png

Flow Registered#

Once the flow is registered, we can import the FlowLibrary and use the different flow management features.

from conversight import FlowLibrary
flw = FlowLibrary()

Promote#

Promoting a Flow to different levels, such as “O”, “U” or “P”.

“O” represents the organization level, “U” represents the user level and “P” represents the platform level. Before promoting a task, it should be registered.

flw.FlowLibraryName.Flowname.promote()
#this will promote the latest version of flow to "O", "U" or "P" level as specified.
../../../../_images/Flow_Promote.png

A Flow has now been created and registered and promoted. If you plan to reuse this Flow, it will be saved in the FlowLibrary. FlowLibrary is a catalog in ConverSight that includes all of the available Flows organized by library.

Additional Functions#

Flow has additional functions similar to tasks. The additional functions available are:

  1. Run

  2. Register

  3. Promote

  4. Get Versions

  5. Set Version

  6. Delete Version

  7. Delete

../../../../_images/Flow_Additional_Functions.png

Additional Functions#

Run#

This function is used to execute the Flow and obtain the output.

flw.FlowLibraryName.Flowname.run()
#this will execute the Flow and the Output will be [15.5]
../../../../_images/Flow_Run.png

Running a Flow#

Register#

We can register the current Flow using the register() method.

flow.register(libraryName, flowName, description, debug)
../../../../_images/Flow_Register.png

Flow Registered#

Promote#

This function is used to promote the Flow to “U”, “O” or “P” level. It promotes the most recent version of the Flow by default.

flw.FlowLibraryName.Flowname.Promote()
#this will promote the latest version of flow to "O", "U" or "P" level as specified.
../../../../_images/Flow_Promote.png

Get Versions#

The Get Versions function returns a list of all available versions for a Flow.

flw.FlowLibraryName.Flowname.getVersions()
#this will provide the list of versions available for the flow "Flowname"
../../../../_images/Flow_GetVersions.png

Set Version#

The Set Version function is used to set a Flow’s version as specified by the user.

flw.FlowLibraryName.Flowname.setVersion()
#this will set the version of flow which is specified within ()
../../../../_images/Flow_SetVersion.png

Delete Version#

A particular version of a Flow is deleted using this function.

flw.FlowLibraryName.Flowname.deleteversion()
#this will delete the version of flow which is specified within ()
../../../../_images/Flow_DeleteVersion.png

Delete#

With this function, the Flow and all of its versions are permanently deleted. It will request for confirmation of the Flow name before deleting the Flow. The Flow will be deleted after we provide its name and click delete.

flw.FlowLibraryName.Flowname.delete()
#this will delete the flow "Flowname"