Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Remove cli examples and add link to docs page #408

Merged
merged 12 commits into from
Oct 5, 2022
16 changes: 0 additions & 16 deletions mlem/cli/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ def apply(
):
"""Apply a model to data. The result will be saved as a MLEM object to `output` if
provided. Otherwise, it will be printed to `stdout`.

Examples:
mike0sv marked this conversation as resolved.
Show resolved Hide resolved
Apply local mlem model to local mlem data
$ mlem apply mymodel mydata --method predict --output myprediction

Apply local mlem model to local data file
$ mlem apply mymodel data.csv --method predict --import --import-type pandas[csv] --output myprediction

Apply a version of remote model to a version of remote data
$ mlem apply models/logreg --project https://github.com/iterative/example-mlem --rev main
data/test_x --data-project https://github.com/iterative/example-mlem --data-rev main
--method predict --output myprediction
"""
from mlem.api import apply

Expand Down Expand Up @@ -145,10 +133,6 @@ def apply(
help="""Apply a deployed-model (possibly remotely) to data. The results will be saved as
a MLEM object to `output` if provided. Otherwise, it will be printed to
`stdout`.

Examples:
Apply hosted mlem model to local mlem data
$ mlem apply-remote http mydata -c host="0.0.0.0" -c port=8080 --output myprediction
""",
cls=mlem_group("runtime"),
subcommand_metavar="client",
Expand Down
8 changes: 0 additions & 8 deletions mlem/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@
help="""
Build models into re-usable assets you can distribute and use in production,
such as a Docker image or Python package.

Examples:
Build docker image from model
$ mlem build mymodel docker -c server.type=fastapi -c image.name=myimage

Create build docker_dir declaration and build it
$ mlem declare builder docker_dir -c server=fastapi -c target=build build_dock
$ mlem build mymodel --load build_dock
""",
cls=mlem_group("runtime", aliases=["export"]),
subcommand_metavar="builder",
Expand Down
10 changes: 1 addition & 9 deletions mlem/cli/checkenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ def checkenv(
project: Optional[str] = option_project,
rev: Optional[str] = option_rev,
):
"""Check that current environment satisfies object requrements

Examples:
Check local object
$ mlem checkenv mymodel

Check remote object
$ mlem checkenv https://github.com/iterative/example-mlem/models/logreg
"""
"""Check that current environment satisfies object requrements"""
meta = load_meta(path, project, rev, follow_links=True, load_value=False)
if isinstance(meta, (MlemModel, MlemData)):
meta.checkenv()
Expand Down
7 changes: 0 additions & 7 deletions mlem/cli/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ def clone(
):
"""Copy a MLEM Object from `uri` and
saves a copy of it to `target` path.

Examples:
Copy remote model to local directory
$ mlem clone models/logreg --project https://github.com/iterative/example-mlem --rev main mymodel

Copy remote model to remote MLEM project
$ mlem clone models/logreg --project https://github.com/iterative/example-mlem --rev main mymodel --tp s3://mybucket/mymodel
"""
from mlem.api.commands import clone

Expand Down
7 changes: 2 additions & 5 deletions mlem/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def config_set(
):
"""Set configuration value

Examples:
$ mlem config set pandas.default_format csv
Documentation: <https://mlem.ai/doc/command-reference/config>
mike0sv marked this conversation as resolved.
Show resolved Hide resolved
"""
fs, path = get_fs(project or "")
project = find_project_root(path, fs=fs)
Expand Down Expand Up @@ -70,9 +69,7 @@ def config_get(
):
"""Get configuration value

Examples:
$ mlem config get pandas.default_format
$ mlem config get pandas.default_format --project https://github.com/iterative/example-mlem/
Documentation: <https://mlem.ai/doc/command-reference/config>
"""
fs, path = get_fs(project or "")
project = find_project_root(path, fs=fs)
Expand Down
4 changes: 0 additions & 4 deletions mlem/cli/declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
declare = Typer(
name="declare",
help="""Declares a new MLEM Object metafile from config args and config files.

Examples:
Create heroku deployment
$ mlem declare env heroku production --api_key <...>
""",
cls=mlem_group("object"),
subcommand_metavar="subtype",
Expand Down
35 changes: 4 additions & 31 deletions mlem/cli/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ def deploy_run(
):
"""Deploy a model to a target environment. Can use an existing deployment
declaration or create a new one on-the-fly.

Examples:
Create new deployment
$ mlem declare env heroku staging -c api_key=...
$ mlem deploy run service_name -m model -t staging -c name=my_service

Deploy existing meta
$ mlem declare env heroku staging -c api_key=...
$ mlem declare deployment heroku service_name -c app_name=my_service -c model=model -c env=staging
$ mlem deploy run service_name
"""
from mlem.api.commands import deploy

Expand All @@ -84,11 +74,7 @@ def deploy_remove(
path: str = Argument(..., help="Path to deployment meta"),
project: Optional[str] = option_project,
):
"""Stop and destroy deployed instance.

Examples:
$ mlem deployment remove service_name
"""
"""Stop and destroy deployed instance."""
deploy_meta = load_meta(path, project=project, force_type=MlemDeployment)
deploy_meta.remove()

Expand All @@ -98,11 +84,7 @@ def deploy_status(
path: str = Argument(..., help="Path to deployment meta"),
project: Optional[str] = option_project,
):
"""Print status of deployed service.

Examples:
$ mlem deployment status service_name
"""
"""Print status of deployed service."""
with no_echo():
deploy_meta = load_meta(
path, project=project, force_type=MlemDeployment
Expand Down Expand Up @@ -131,11 +113,7 @@ def deploy_wait(
0, "-t", "--times", help="Number of attempts. 0 -> indefinite"
),
):
"""Wait for status of deployed service

Examples:
$ mlem deployment status service_name
"""
"""Wait for status of deployed service"""
with no_echo():
deploy_meta = load_meta(
path, project=project, force_type=MlemDeployment
Expand All @@ -161,12 +139,7 @@ def deploy_apply(
index: bool = option_index,
json: bool = option_json,
):
"""Apply a deployed model to data.

Examples:
$ mlem deployment apply service_name
"""

"""Apply a deployed model to data."""
with set_echo(None if json else ...):
deploy_meta = load_meta(
path, project=project, rev=rev, force_type=MlemDeployment
Expand Down
8 changes: 5 additions & 3 deletions mlem/cli/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

@dev.callback()
def dev_callback():
"""Developer utility tools"""
"""Developer utility tools

Documentation: <https://mlem.ai/doc/contributing/core>
"""


@mlem_command(parent=dev, aliases=["fi"])
Expand All @@ -24,8 +27,7 @@ def find_implementations_diff(
"""Loads `root` module or package and finds implementations of MLEM base classes
Shows differences between what was found and what is registered in entrypoints

Examples:
$ mlem dev fi
Documentation: <https://mlem.ai/doc/contributing/core>
"""
exts = {e.entry for e in load_entrypoints().values()}
impls = set(find_abc_implementations(root)[MLEM_ENTRY_POINT])
Expand Down
13 changes: 1 addition & 12 deletions mlem/cli/import_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ def import_object(
index: bool = option_index,
external: bool = option_external,
):
"""Create a `.mlem` metafile for a model or data in any file or directory.

Examples:
Create MLEM data from local csv
$ mlem import data/data.csv data/imported_data --type pandas[csv]

Create MLEM model from local pickle file
$ mlem import data/model.pkl data/imported_model

Create MLEM model from remote pickle file
$ mlem import models/logreg --project https://github.com/iterative/example-mlem --rev no-dvc data/imported_model --type pickle
"""
"""Create a `.mlem` metafile for a model or data in any file or directory."""
from mlem.api.commands import import_object

import_object(
Expand Down
15 changes: 1 addition & 14 deletions mlem/cli/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,7 @@ def ls(
False, "-i", "--ignore-errors", help="Ignore corrupted objects"
),
):
"""List MLEM objects inside a MLEM project.


Examples:
$ mlem list https://github.com/iterative/example-mlem
$ mlem list -t models
"""
"""List MLEM objects inside a MLEM project."""
from mlem.api.commands import ls

if type_filter == "all":
Expand Down Expand Up @@ -123,13 +117,6 @@ def pretty_print(
):
"""Display all details about a specific MLEM Object from an existing MLEM
project.

Examples:
Print local object
$ mlem pprint mymodel

Print remote object
$ mlem pprint https://github.com/iterative/example-mlem/models/logreg
"""
with set_echo(None if json else ...):
meta = load_meta(
Expand Down
8 changes: 1 addition & 7 deletions mlem/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ def init(
metavar=PATH_METAVAR,
)
):
"""Initialize a MLEM project.

Examples:
$ mlem init
$ mlem init some/local/path
$ mlem init s3://bucket/path/in/cloud
"""
"""Initialize a MLEM project."""
from mlem.api.commands import init

init(path)
7 changes: 0 additions & 7 deletions mlem/cli/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ def link(
):
"""Create a link (read alias) for an existing MLEM Object, including from
remote MLEM projects.

Examples:
Add alias to local object
$ mlem link my_model latest

Add remote object to your project without copy
$ mlem link models/logreg --source-project https://github.com/iteartive/example-mlem remote_model
"""
from mlem.api.commands import link

Expand Down
Loading