cbatch

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlagNodes         uint32
	FlagCpuPerTask    float64
	FlagNtasksPerNode uint32
	FlagTime          string
	FlagMem           string
	FlagPartition     string
	FlagJob           string
	FlagAccount       string
	FlagQos           string
	FlagCwd           string
	FlagRepeat        uint32
	FlagNodelist      string
	FlagExcludes      string
	FlagGres          string
	FlagGetUserEnv    bool
	FlagExport        string
	FlagStdoutPath    string
	FlagStderrPath    string

	FlagWrappedScript string

	FlagExtraAttr string
	FlagMailType  string
	FlagMailUser  string

	FlagConfigFilePath string
	FlagJson           bool

	RootCmd = &cobra.Command{
		Use:     "cbatch [flags] file",
		Short:   "Submit batch job",
		Version: util.Version(),
		Args: func(cmd *cobra.Command, args []string) error {
			if cmd.Flags().Changed("wrap") {
				if len(args) != 0 {
					return errors.New("--wrap is exclusive with file name argument")
				}
			} else if len(args) != 1 {
				return errors.New("invalid number of arguments")
			}
			return nil
		},
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			util.DetectNetworkProxy()
		},
		Run: func(cmd *cobra.Command, args []string) {
			if FlagRepeat == 0 {
				log.Error("Invalid argument: --repeat must > 0.")
				os.Exit(util.ErrorCmdArg)
			}

			cbatchArgs := make([]CbatchArg, 0)
			shScript := ""

			if FlagWrappedScript == "" {
				shLines := make([]string, 0)
				if err := ParseCbatchScript(args[0], &cbatchArgs, &shLines); err != util.ErrorSuccess {
					os.Exit(err)
				}
				shScript = strings.Join(shLines, "\n")
			} else {
				shScript = FlagWrappedScript
			}

			ok, task := ProcessCbatchArgs(cmd, cbatchArgs)
			if !ok {
				os.Exit(util.ErrorCmdArg)
			}

			task.GetBatchMeta().ShScript = shScript
			task.Uid = uint32(os.Getuid())
			task.Gid = uint32(os.Getgid())
			task.CmdLine = strings.Join(os.Args, " ")

			util.SetPropagatedEnviron(task)

			task.Type = protos.TaskType_Batch
			if task.Cwd == "" {
				task.Cwd, _ = os.Getwd()
			}

			var err util.CraneCmdError
			if FlagRepeat == 1 {
				err = SendRequest(task)
			} else {
				err = SendMultipleRequests(task, FlagRepeat)
			}
			os.Exit(err)
		},
	}
)

Functions

func ConvertLSFRuntimeLimit

func ConvertLSFRuntimeLimit(t string) string

func ParseCbatchScript

func ParseCbatchScript(path string, args *[]CbatchArg, sh *[]string) util.CraneCmdError

Split the job script into two parts: the arguments and the shell script.

func ParseCmdArgs

func ParseCmdArgs()

func ProcessCbatchArgs

func ProcessCbatchArgs(cmd *cobra.Command, args []CbatchArg) (bool, *protos.TaskToCtld)

Merge and validate arguments from the file and the command line, then return the constructed TaskToCtld.

func SendMultipleRequests

func SendMultipleRequests(task *protos.TaskToCtld, count uint32) util.CraneCmdError

func SendRequest

func SendRequest(task *protos.TaskToCtld) util.CraneCmdError

Types

type CbatchArg

type CbatchArg struct {
	// contains filtered or unexported fields
}

type LineProcessor

type LineProcessor interface {
	Process(line string, sh *[]string, args *[]CbatchArg) error
}

Jump to

Keyboard shortcuts

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