execute

package
v1.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ExecuteCmd = &cobra.Command{
	Use:   "execute",
	Short: "Execute a workflow",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		if util.SpaceName == "" {
			util.SpaceName = "Playground"
		}
		path := util.FormatPath()
		if path == "" {
			if len(args) == 0 {
				fmt.Println("Workflow name or path must be specified!")
				return
			}
			path = strings.Trim(args[0], "/")
		} else {
			if len(args) > 0 {
				fmt.Println("Please use either path or flag syntax for the platform objects.")
				return
			}
		}

		fleet = util.GetFleetInfo(fleetName)
		if fleet == nil {
			return
		}
		var version *types.WorkflowVersionDetailed
		if workflowYAML != "" {

			version = readWorkflowYAMLandCreateVersion(workflowYAML, newWorkflowName, path)
		} else {

			version = prepareForExec(path)
		}
		if version == nil {
			fmt.Println("Couldn't find or create the workflow version!")
			os.Exit(0)
		}

		allNodes, roots = CreateTrees(version, false)

		if executionMachines == (types.Machines{}) {
			if maxMachines {
				executionMachines = version.MaxMachines
			} else if machineConfiguration != "" {
				machines, err := parseMachineConfiguration(machineConfiguration)
				if err != nil {
					fmt.Printf("Error: %s\n", err)
					os.Exit(1)
				}

				if len(fleet.Machines) == 3 {

					executionMachines = machines

					if machines.Default != nil {
						fmt.Printf("Error: you need to use the small-medium-large format to specify the numbers of machines (e.g. 1-2-3)")
						os.Exit(1)
					}
				} else {

					executionMachines, err = handleSingleMachineType(*fleet, machines)
					if err != nil {
						fmt.Printf("Error: %s\n", err)
						os.Exit(1)
					}
				}
			} else {
				executionMachines = setMachinesToMinimum(version.MaxMachines)
			}
		}

		outputNodes := make([]string, 0)
		if outputNodesFlag != "" {
			outputNodes = strings.Split(outputNodesFlag, ",")
		}

		if !maxMachinesTypeCompatible(executionMachines, version.MaxMachines) {
			fmt.Println("Workflow maximum machines types are not compatible with config machines!")
			fmt.Println("Workflow max machines: " + FormatMachines(version.MaxMachines, true))
			fmt.Println("Config machines: " + FormatMachines(executionMachines, true))
			os.Exit(0)
		}

		createRun(version.ID, fleet.ID, watch, outputNodes, outputsDirectory)
	},
}

ExecuteCmd represents the execute command

Functions

func CreateTrees

func CreateTrees(wfVersion *types.WorkflowVersionDetailed, includePrimitiveNodes bool) (map[string]*types.TreeNode, []*types.TreeNode)

func FormatMachines

func FormatMachines(machines types.Machines, inline bool) string

func GetAvailableMachines

func GetAvailableMachines(fleetName string) types.Machines

func GetLatestWorkflowVersion

func GetLatestWorkflowVersion(workflowID uuid.UUID, fleetID uuid.UUID) *types.WorkflowVersionDetailed

func GetRunByID

func GetRunByID(id uuid.UUID) *types.Run

func GetSubJobs

func GetSubJobs(runID uuid.UUID) []types.SubJob

func PrintTrees

func PrintTrees(roots []*types.TreeNode, allNodes *map[string]*types.TreeNode, showParameters bool, table bool) string

func WatchRun

func WatchRun(runID uuid.UUID, downloadPath string, nodesToDownload map[string]output.NodeInfo, filesToDownload []string, timestampOnly bool, machines *types.Machines, showParameters bool)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL