# Automate a sequence of projects

While Lokad does its best to perform operations as fast as possible, many operations take several minutes or even more to complete. Therefore, in order to avoid keeping you waiting while the results are being computed, Lokad provides scheduling capabilities to auto-trigger processes on a scheduled basis. In addition, the process sometimes requires a whole sequence of operations to be performed in the correct order. As a result, Lokad also offers orchestration capacities to define a sequence of operations to be executed.

## Project sequences

With a Lokad account, multiple types of projects can be created. In particular, it is possible to create a project sequence by selecting:

This type of project can be configured for both scheduling and orchestration purposes. Once the new project is created, click Edit to start modifying your project.

### Configuring an automated run

The sequence project can be executed either manually - by clicking Run like any other project - or automatically through its own execution schedule. By default, when a sequence project is created, the scheduled execution is disabled. In order to enable the scheduled execution, two options are available: you can check the Scheduled or the On file changes box and then click Save.

### Setting a schedule

When using a time schedule, it is possible to choose between two types of frequencies (either daily or weekly) and to define the time and the applicable time zone. The time should be entered as a 24h entry (aka 13:00 is 1PM).

We typically suggest to have a master sequence that is executed every night (after midnight in the dominant time zone business-wise). This sequence starts with refreshing the data - assuming that Lokad has a data connector - and ends with the various reports. This pattern ensures that you get “fresh” Lokad numbers every morning.

### Setting a trigger based on file changes

Alternatively, a file upload can be used to trigger the sequence run. File paths must begin with / and the file name can contain one * wildcard. Subfolders of the specified path are not taken into account.

This sequence scheduling can support several trigger patterns, meaning that the sequence will run each time a file corresponding to one of them is uploaded or updated. If a sequence is intended to run every day at the end of an FTP transfer of a series of files, we suggest to use the last file of the FTP list (possibly a dummy file) as trigger path.

### Configuring the orchestration

Once the new project sequence has been created, it is possible to define the actual sequence of projects to be executed. First, you need to select the project to be part of the sequence. This can be achieved by clicking the button Add projects. The sequence mode of execution can be set to Sequence or Parallel.

Each project comes with a few settings:

• Continue if failed indicates whether the sequence should proceed with the next project in the list if the previous project has failed to complete successfully. This setting can typically be checked if the rest of the sequence has no strict dependency on the failing project.
• Skip if more recent than N minutes is used to speed up the execution of long sequences. For example, refreshing a data source can take up to several hours, but if the data source has already been refreshed in the last 12 hours, there is no need to refresh it again.

### File action (move, copy, delete)

On top of defining the actual sequence of projects to be executed, you can create the whole workflow of file actions that will be performed by your runflow. Numerous types of file actions can be executed, i.e., a sequence can move, copy, and delete files and entire folders that match a selected pattern. To perform a file action, you need to access your sequence and click on the Edit button:

Then click on Add file action which is located at the bottom of your runflow:

Once a file action is initiated, you are able to move, copy, and delete files and folders. Just select and apply the actions of your interest:

Here we present an example of deleting all the files from the path /clean/OptimizationPO/*:

Confirm your action by clicking on the Create button. Now, decide when the action should be executed, e.g., before all other scripts of Orchestration are run. Remember to save your edited runflow. Use file actions mindfully, especially when deleting the entire folders. Enjoy the sequence executing the projects and file actions for you.