Skip to content

Commit

Permalink
Merge pull request #8 from mlops-club/enhancing-bentofile-json-schema
Browse files Browse the repository at this point in the history
Enhancing bentofile json schema
  • Loading branch information
phitoduck committed Mar 25, 2024
2 parents abb6d94 + 6d20d4b commit f74db7a
Show file tree
Hide file tree
Showing 21 changed files with 1,148 additions and 202 deletions.
1 change: 1 addition & 0 deletions .esilntignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.out.json
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.out.json
11 changes: 0 additions & 11 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,5 @@
"outFiles": ["${workspaceFolder}/out/**/*.js", "${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "tasks: watch-tests"
}
// {
// "name": "Extension Tests",
// "type": "extensionHost",
// "request": "launch",
// "runtimeExecutable": "${execPath}",
// "args": [
// "--extensionDevelopmentPath=${workspaceFolder}",
// "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
// ],
// "outFiles": ["${workspaceFolder}/out/test/**/*.js"]
// }
]
}
191 changes: 191 additions & 0 deletions bentofileSchema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Bentofile",
"description": "Schema for BentoML bentofile.yaml configuration",
"type": "object",
"properties": {
"service": {
"type": "string",
"pattern": "^\\s*([A-z_]+\\.?)+[A-z_]+:\\s*([A-z_][A-z0-9_]*)\\s*$",
"examples": ["path.to.service:MyService", "service:svc", "service:SVC"],
"markdownDescription": "#### service (required) \n\n This field points to the location of a [Service object](https://docs.bentoml.org/en/latest/guides/services.html). \n\nIt's typically defined as service: `\"service:class-name\"`.\n\n- `service`: The Python module, usually the `service.py` file.\n\n- `class-name`: The name of the class-based Service created in `service.py` and decorated with `@bentoml.service`. If you have multiple Services in service.py, you can specify the main Service receiving user requests in `bentofile.yaml`. \n\n Other Services will be started alongside this main Service. \n\n [Documentation](https://docs.bentoml.org/en/latest/guides/build-options.html#service)"
},
"description": {
"markdownDescription": "#### description (optional) \n\n The description field allows you to add documentation for your Bento service. \n\nThis documentation can be written in plain text or formatted using Markdown format. \n\n There are two ways to provide a description: \n\n 1. **Inline** \n\n You can directly write the description within the `bentofile.yaml` file using a multi-line string (denoted by `|`). \n\n This allows you to use Markdown formatting for enhanced readability. \n\n **Example:** \n\n ```yaml\n\n service: \"service:svc\"\n description: |\n \t## Description For My Bento \n\n \tUse **any markdown syntax** here!\n\n \t> BentoML is awesome!\n\n```\n\n\n 2. **External File** \n\n You can reference an external file containing the description. This is useful for longer descriptions or when you want to manage the documentation separately. The path to the file is specified using the `file: path/to/file.md` format. \n\n **Example:** \n\n ```yaml\n\n service: \"service:svc\"\n description: \"file: ./README.md\"\n\n``` \n\n Note: \n\n - For descriptions sourced from an external file, the path can be absolute or relative. \n - Ensure the referenced file exists at the specified location when running `bentoml build`. \n - For relative paths, the reference point is the `build_ctx`. By default, this is the directory where you execute the bentoml build command. \n\n [Documentation](https://docs.bentoml.org/en/latest/guides/build-options.html#description)",
"oneOf": [
{
"type": "string",
"description": "Inline description in plain text or Markdown format."
},
{
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path to an external file containing the description."
}
},
"required": ["path"]
}
]
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "Key-value pairs associated with the Bento or models."
},
"include": {
"type": "array",
"items": {
"type": "string"
},
"description": "Files to include in the Bento, supporting wildcard characters."
},
"exclude": {
"type": "array",
"items": {
"type": "string"
},
"description": "Files to exclude from the Bento, supports gitignore style patterns."
},
"python": {
"$ref": "#/definitions/pythonOptions"
},
"envs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": ["name", "value"]
},
"description": "Environment variables to inject into the Bento container."
},
"conda": {
"type": "object",
"properties": {
"channels": {
"type": "array",
"items": {
"type": "string"
},
"description": "Custom conda channels to use."
},
"dependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "Custom conda dependencies."
},
"pip": {
"type": "array",
"items": {
"type": "string"
},
"description": "Specific pip conda dependencies."
},
"environment_yml": {
"type": "string",
"description": "Path to a pre-existing conda environment.yml file."
}
}
},
"docker": {
"$ref": "#/definitions/dockerOptions"
}
},
"required": ["service"],
"definitions": {
"pythonOptions": {
"type": "object",
"properties": {
"packages": {
"type": "array",
"items": {
"type": "string"
}
},
"requirements_txt": {
"type": "string"
},
"lock_packages": {
"type": "boolean"
},
"index_url": {
"type": "string"
},
"no_index": {
"type": "boolean"
},
"trusted_host": {
"type": "array",
"items": {
"type": "string"
}
},
"find_links": {
"type": "array",
"items": {
"type": "string"
}
},
"extra_index_url": {
"type": "array",
"items": {
"type": "string"
}
},
"pip_args": {
"type": "string"
},
"wheels": {
"type": "array",
"items": {
"type": "string"
},
"description": "List of paths to wheels to include in the Bento."
}
},
"description": "Configuration for Python packages and environment."
},
"dockerOptions": {
"type": "object",
"properties": {
"distro": {
"type": "string"
},
"python_version": {
"type": "string"
},
"cuda_version": {
"type": "string"
},
"system_packages": {
"type": "array",
"items": {
"type": "string"
}
},
"setup_script": {
"type": "string"
},
"base_image": {
"type": "string"
},
"dockerfile_template": {
"type": "string"
}
},
"description": "Configuration for Docker image generation."
}
}
}
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bentoml",
"publisher": "mlops-club",
"version": "0.0.3",
"version": "0.0.4",
"displayName": "BentoML",
"icon": "src/resources/bentoml-logo.png",
"author": {
Expand Down Expand Up @@ -40,15 +40,19 @@
"vscode": "^1.83.0"
},
"categories": [
"Other"
"Data Science",
"Machine Learning"
],
"activationEvents": [],
"main": "./dist/extension.js",
"contributes": {
"yamlValidation": [
{
"fileMatch": "**/*bentofile.yaml",
"url": "./src/resources/yamlSchemas/bentofileSchema.json"
"fileMatch": [
"**/*bentofile.yaml",
"**/*bentofile.yml"
],
"url": "./src/resources/yamlSchemas/bentofileSchema.out.json"
}
],
"configuration": {
Expand Down Expand Up @@ -218,8 +222,8 @@
"compile": "webpack",
"watch": "webpack --watch",
"package": "webpack --mode production --devtool hidden-source-map",
"compile-tests": "tsc -p . --outDir out",
"watch-tests": "tsc -p . -w --outDir out",
"compile-tests": "rm -rf ./out/; tsc -p . --outDir out",
"watch-tests": "rm -rf ./out/; tsc -p . -w --outDir out",
"pretest": "npm run compile-tests && npm run compile && npm run lint",
"lint": "eslint src --ext ts --fix",
"format": "prettier --write ./",
Expand Down
8 changes: 8 additions & 0 deletions src/resources/yamlSchemas/NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
⚠️ Do not modify `bentofileSchema.json` manually! Modify `bentofileSchema.in.json`.

`bentofileSchema.json` is generated from `bentofileSchema.in.json` using `insert-markdown-into-input-json-files.ts`.

```bash
# bentofileSchema.in.json -> bentofileSchema.json
npm exec ts-node insert-markdown-into-input-json-files.ts
```

0 comments on commit f74db7a

Please sign in to comment.