ai2_kit.core.script module#

pydantic model ai2_kit.core.script.BashScript[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "BashScript",
   "type": "object",
   "properties": {
      "template": {
         "anyOf": [
            {
               "$ref": "#/$defs/BashTemplate"
            },
            {
               "type": "null"
            }
         ]
      },
      "steps": {
         "items": {
            "anyOf": [
               {
                  "type": "string"
               },
               {
                  "$ref": "#/$defs/BashStep"
               }
            ]
         },
         "title": "Steps",
         "type": "array"
      }
   },
   "$defs": {
      "BashStep": {
         "additionalProperties": false,
         "properties": {
            "cmd": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  }
               ],
               "title": "Cmd"
            },
            "cwd": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cwd"
            },
            "checkpoint": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Checkpoint"
            },
            "exit_on_error": {
               "default": true,
               "title": "Exit On Error",
               "type": "boolean"
            }
         },
         "required": [
            "cmd"
         ],
         "title": "BashStep",
         "type": "object"
      },
      "BashTemplate": {
         "additionalProperties": false,
         "properties": {
            "shebang": {
               "default": "#!/bin/bash",
               "title": "Shebang",
               "type": "string"
            },
            "header": {
               "default": "",
               "title": "Header",
               "type": "string"
            },
            "setup": {
               "default": "",
               "title": "Setup",
               "type": "string"
            },
            "teardown": {
               "default": "",
               "title": "Teardown",
               "type": "string"
            }
         },
         "title": "BashTemplate",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "template",
      "steps"
   ]
}

Config:
  • extra: str = forbid

Fields:
field steps: Sequence[str | BashStep] [Required]#
field template: BashTemplate | None [Required]#
render()[source]#
pydantic model ai2_kit.core.script.BashStep[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "BashStep",
   "type": "object",
   "properties": {
      "cmd": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            }
         ],
         "title": "Cmd"
      },
      "cwd": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Cwd"
      },
      "checkpoint": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Checkpoint"
      },
      "exit_on_error": {
         "default": true,
         "title": "Exit On Error",
         "type": "boolean"
      }
   },
   "additionalProperties": false,
   "required": [
      "cmd"
   ]
}

Config:
  • extra: str = forbid

Fields:
field checkpoint: str | None = None#
field cmd: str | List[str] [Required]#
field cwd: str | None = None#
field exit_on_error: bool = True#
render()[source]#
pydantic model ai2_kit.core.script.BashTemplate[source]#

Bases: BaseModel

Show JSON schema
{
   "title": "BashTemplate",
   "type": "object",
   "properties": {
      "shebang": {
         "default": "#!/bin/bash",
         "title": "Shebang",
         "type": "string"
      },
      "header": {
         "default": "",
         "title": "Header",
         "type": "string"
      },
      "setup": {
         "default": "",
         "title": "Setup",
         "type": "string"
      },
      "teardown": {
         "default": "",
         "title": "Teardown",
         "type": "string"
      }
   },
   "additionalProperties": false
}

Config:
  • extra: str = forbid

Fields:
field header: str = ''#
field setup: str = ''#
field shebang: str = '#!/bin/bash'#
field teardown: str = ''#
ai2_kit.core.script.eoe_step(cmd: str)[source]#

exit on error step

ai2_kit.core.script.exit_on_error_statment(v='__EXITCODE__')[source]#
ai2_kit.core.script.make_gpu_parallel_steps(step_groups: List[Sequence[str | BashStep] | BashStep | str])[source]#