-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Docs] Add simple descriptions of function types: job and serving (#3586
- Loading branch information
1 parent
7859866
commit 0123ed7
Showing
7 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(job-function)= | ||
# Function of type `job` | ||
|
||
You can deploy a model using a `job` type function, which runs the code in a Kubernetes Pod. | ||
|
||
You can create (register) a `job` function with basic attributes such as code, requirements, image, etc. using the | ||
{py:meth}`~mlrun.projects.MlrunProject.set_function` method. | ||
You can also import an existing job function/template from the {ref}`function-hub`. | ||
|
||
Functions can be created from a single code, notebook file, or have access to the entire project context directory. | ||
(By adding the `with_repo=True` flag, the project context is cloned into the function runtime environment.) | ||
|
||
Examples: | ||
|
||
|
||
```python | ||
# register a (single) python file as a function | ||
project.set_function('src/data_prep.py', name='data-prep', image='mlrun/mlrun', handler='prep', kind="job") | ||
|
||
# register a notebook file as a function, specify custom image and extra requirements | ||
project.set_function('src/mynb.ipynb', name='test-function', image="my-org/my-image", | ||
handler="run_test", requirements=["scikit-learn"], kind="job") | ||
|
||
# register a module.handler as a function (requires defining the default sources/work dir, if it's not root) | ||
project.spec.workdir = "src" | ||
project.set_function(name="train", handler="training.train", image="mlrun/mlrun", kind="job", with_repo=True) | ||
``` | ||
|
||
To run the job: | ||
``` | ||
project.run_function("train") | ||
``` | ||
|
||
**See also** | ||
- [Create and register functions](../runtimes/create-and-use-functions.html) | ||
- [How to annotate notebooks (to be used as functions)](../runtimes/mlrun_code_annotations.html) | ||
- [How to run, build, or deploy functions](./run-build-deploy.html) | ||
- [Using functions in workflows](./build-run-workflows-pipelines.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(serving-function)= | ||
# Function of type `serving` | ||
|
||
Deploying models in MLRun uses the function type `serving`. You can create a serving function using the `set_function()` call from a notebook. | ||
You can also import an existing serving function/template from the {ref}`function-hub`. | ||
|
||
This example converts a notebook to a serving function, adds a model to it, and deploys it: | ||
|
||
```python | ||
serving = project.set_function(name="my-serving", func="my_serving.ipynb", kind="serving", image="mlrun/mlrun", handler="handler") | ||
serving.add_model(key="iris", model_path="https://s3.wasabisys.com/iguazio/models/iris/model.pkl", model_class="ClassifierModel") | ||
project.deploy_function(serving) | ||
``` | ||
|
||
|
||
**See also** | ||
- {ref}`Real-time serving pipelines (graphs) <serving-graph>`: higher level real-time graphs (DAG) over one or more Nuclio functions | ||
- {ref}`Serving graphs demos and tutorials <demos-serving>` | ||
- {ref}`Real-time serving <mlrun-serving-overview>` | ||
- {ref}`Serving pre-trained ML/DL models <serving-ml-dl-models>` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters