Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Semi-autogenerated cli reference #172

Merged
merged 17 commits into from
Oct 5, 2022
Prev Previous commit
Next Next commit
move scripts, re-generate from latest docs
  • Loading branch information
mike0sv committed Sep 19, 2022
commit e6698387f5f188b43fb699aaca0932aab37e2aaa
1 change: 1 addition & 0 deletions content/docs/command-reference/apply-remote.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ usage: mlem apply-remote [-d <path>] [-p <path>] [--rev <commitish>]
Builtin clients:
- http
- rmq
- sagemaker
```

## Description
Expand Down
1 change: 1 addition & 0 deletions content/docs/command-reference/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ usage: mlem build [-m <path>] [-p <path>] [--rev <commitish>]
Builtin builders:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MODEL -> model

required / optional check how it's done in other docs

list with options - it was better the way it was done (compact, easier to read, etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required and optional are different things: required means you always should provide it, optional means it can have None value. Required optional means you will get error if you don't provide it, but you can set it to None. Not required not optional means there is a default value which is not None and you can't set it to None

also cli changed a bit, now mlem build * are subcommands (instead of argument). Also mlem build is a separate command (for building from saved config using -l). I will update this soon when I decide how to better reflect this (same with serve and apply-remote)

- docker
- docker_dir
- kubernetes
- pip
- whl
```
Expand Down
1 change: 1 addition & 0 deletions content/docs/command-reference/deployment/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ subcommands:
run Deploy a model to a target environment.
remove Stop and destroy deployed instance.
status Print status of deployed service.
wait Wait for status of deployed service
apply Apply a deployed model to data.
```

Expand Down
41 changes: 41 additions & 0 deletions content/docs/command-reference/deployment/wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# deployment wait

Wait for status of deployed service

## Synopsis

```usage
usage: mlem deployment wait [-p <path>]
[-s <[unknown|not_deployed|starting|crashed|stopped|running]>]
[-i <[unknown|not_deployed|starting|crashed|stopped|running]>]
[-p <float>] [-t <integer>] [-h]
path

arguments:
path Path to deployment meta
```

## Description

TODO

## Options

- `-p <path>`, `--project <path>` - Path to MLEM project [default: (none)]
- `-s <[unknown|not_deployed|starting|crashed|stopped|running]>`,
`--status <[unknown|not_deployed|starting|crashed|stopped|running]>` -
statuses to wait for [default: DeployStatus.RUNNING]
- `-i <[unknown|not_deployed|starting|crashed|stopped|running]>`,
`--intermediate <[unknown|not_deployed|starting|crashed|stopped|running]>` -
Possible intermediate statuses
- `-p <float>`, `--poll-timeout <float>` - Timeout between attempts [default:
1.0]
- `-t <integer>`, `--times <integer>` - Number of attempts. 0 -> indefinite
[default: 0]
- `-h`, `--help` - Show this message and exit.

## Example: Wait for deployment setup (after mlem deployment run command)

```cli
$ mlem deployment wait service_name -i starting
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

from pydantic import BaseModel, parse_obj_as

from _generate_cli_spec import Opt, Spec
from scripts.docs.cli_generate_spec import Opt, Spec

CLI_DOCS_PATH = "../../content/docs/command-reference"
DOC_AUTO_REPLACE = {
"MLEM Object": "[MLEM Object](/doc/user-guide/basic-concepts#mlem-objects)",
"MLEM project": "[MLEM project](/doc/user-guide/project-structure)"
Expand Down Expand Up @@ -114,7 +115,8 @@ def generate_doc(doc):


def generate_cli_command(name: str, spec: Spec):
with open(f"{name}.md", "r", encoding="utf8") as f:
path = os.path.join(CLI_DOCS_PATH, f"{name}.md")
with open(path, "r", encoding="utf8") as f:
data = f.read()

data = replace_section(data, "usage", generate_usage(spec),
Expand All @@ -126,7 +128,7 @@ def generate_cli_command(name: str, spec: Spec):
cmd_name = cmd_name[:-len(" index")]
data = replace_section(data, " " + cmd_name, generate_doc(spec.doc),
section_prefix="#")
with open(f"{name}.md", "w", encoding="utf8") as f:
with open(path, "w", encoding="utf8") as f:
f.write(data)


Expand All @@ -146,7 +148,7 @@ def main():


if __name__ == '__main__':
from _generate_cli_spec import main as spec_main
from scripts.docs.cli_generate_spec import main as spec_main

spec_main()
main()