schrodinger.tasks.cli module

class schrodinger.tasks.cli.TaskCLI

Bases: FuncChainMixin, ParamCLI

The command line interface for a task class. Subclass this class to define custom command line interfaces for task classes.

By default, the TaskCLI will generate argparse arguments for all atomic params in the task input.

See ParamCLI for details on customizing the arguments and the parser.

Job control options can be added to the parser by overriding defineJobControlOptions.

Defining a TaskCLI subclass in a module is enough to turn it into a command line script with both main and get_job_spec_from_args functions available. There is no need to instantiate the class. This behavior can be disabled by setting ADD_MODULE_FUNCTIONS = False.

Example usage:

# foo.py
class FooTask(jobtasks.ComboJobTask):
    ...

class FooCLI(TaskCLI):
    TaskClass = FooTask

    def customizeParamArgs(self):
        Ti = self.TaskClass.input
        self.updateParamArg(Ti.c1.x, name='-c1x', required=True)

A command line interface is available now at $SCHRODINGER/run foo.py -h.

Task preprocessors can be defined directly on a TaskCLI subclass using the @tasks.preprocessor decorator. The TaskCLI will automatically install these preprocessors on the task instance before running it.

TaskClass = NotImplemented
defineJobControlOptions() list[Options]

Return a list of job control options to add to the auto-generated argument parser. Subclasses may override to specify desired flags.

makeTaskFromArgs(argv: list[str]) AbstractTask

Make a task instance from command-line arguments.

makeTaskFromNamespace(namespace: Namespace) AbstractTask

Make and populate a task instance from a namespace of parsed args.

See ParamCLI.makeParamFromNamespace for details.

makeArgsFromTask(task) list[str]

Make a list of cmdline arguments from a task instance.

makeCmd(task: AbstractTask) list[str]

@overrides: ParamCLI. Return a command that invokes this TaskCLI using inputs from the given task instance. Expects the task to have already run preprocessing.

makeParser() ArgumentParser

@extends ParamCLI.

Add task options to the parser e.g. -HOST, -JOBNAME, -JOBID, etc.

getParserDescription() Optional[str]

Return a description for the parser to use. If the CLI has a docstring, it will be used, otherwise the docstring of the param class is used.

mainFunction(param: CompoundParam) int
getJobSpecFromArgs(argv: list[str]) JobSpecification

This method will automatically be added to the module as get_job_spec_from_args.

makeJobSpecBuilder(task: AbstractTask, argv: list[str]) JobSpecificationArgsBuilder

Make the job spec args builder from the given task and args. Override this method in a subclass to customize the job spec builder.

__init__()