{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/mlos-config-mlos-jsonc-mlos-json5-mlos-json/_shared/latest--common-environment-subschemas.json",
  "title": "mlos_bench common Environment config subschemas",
  "description": "config elements common to several Environments.",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/microsoft/MLOS/main/mlos_bench/mlos_bench/config/schemas/environments/common-environment-subschemas.json",
    "sourceSha256": "972ba2b172a803365b7dc9f362e4cdfcf3f52d84ce55a794ac6d56fd89cfec51"
  },
  "$defs": {
    "common_environment_config": {
      "$comment": "A set of properties all Environment configs use.",
      "type": "object",
      "properties": {
        "tunable_params": {
          "type": "array",
          "description": "The names of tunable groups to reference (i.e., keys from the tunable params).",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "minItems": 0
        },
        "required_args": {
          "description": "Required arguments for the Environment to instantiate. These can be presented as environment variables for scripts to use.",
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true,
          "minItems": 1
        },
        "const_args": {
          "description": "Default argument value constants to use for the Environment when not overridden by globals.",
          "type": "object",
          "additionalProperties": {
            "$comment": "The value of any const_arg can be a string, number, boolean, or null, or an array of the same.",
            "type": [
              "string",
              "number",
              "boolean",
              "null",
              "array"
            ],
            "items": {
              "$comment": "The value of any const_arg list can be a string, number, boolean, or null.",
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          }
        }
      },
      "minProperties": 1
    },
    "command_lines": {
      "type": "array",
      "description": "The command lines to execute.",
      "items": {
        "$comment": "TODO: Add support for array syntax for command lines that execute without a shell.",
        "type": [
          "string"
        ]
      },
      "minItems": 1
    },
    "setup_run_teardown_configs": {
      "type": "object",
      "properties": {
        "setup": {
          "description": "The command lines to execute for the setup phase.",
          "$ref": "#/$defs/command_lines"
        },
        "run": {
          "description": "The command lines to execute for the run phase.",
          "$ref": "#/$defs/command_lines"
        },
        "teardown": {
          "description": "The command lines to execute for the teardown phase.",
          "$ref": "#/$defs/command_lines"
        },
        "results_stdout_pattern": {
          "description": "A regex to parse the stdout of the run phase for results.",
          "type": "string"
        }
      }
    },
    "shell_param_type": {
      "description": "All parameters must be valid shell variable names, else use shell_env_params_rename.",
      "type": "string",
      "pattern": "^[a-zA-Z_][a-zA-Z0-9_]+$"
    },
    "shell_env_params_config": {
      "type": "object",
      "properties": {
        "shell_env_params": {
          "description": "An explicit list of parameters (and their values) to pass to the shell as environment variables.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/shell_param_type"
          },
          "uniqueItems": true,
          "minItems": 1
        },
        "shell_env_params_rename": {
          "description": "An explicit mapping of environment variable names from params to be populated with the parameter values and passed to the shell commands.",
          "type": "object",
          "propertyNames": {
            "$ref": "#/$defs/shell_param_type"
          },
          "additionalProperties": {
            "type": "string"
          }
        }
      }
    },
    "file_download_config": {
      "type": "object",
      "properties": {
        "from": {
          "description": "Remote path to download the file from.",
          "type": "string"
        },
        "to": {
          "description": "Local path to download the file to.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ],
      "unevaluatedProperties": false
    },
    "file_upload_config": {
      "type": "object",
      "properties": {
        "from": {
          "description": "Local path to upload the file from.",
          "type": "string"
        },
        "to": {
          "description": "Remote path to upload the file to.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ],
      "unevaluatedProperties": false
    }
  }
}
