ml function create

Create a function with the defined payload. A function is code that can be deployed as an online or batch deployment.

Syntax

cpd-cli ml function create \
[--context=<catalog-project-or-space-id>] \
[--cpd-config=<cpd-config-location>] \
[--cpd-scope=<cpd-config-location>] \
[--custom=<map<key,value>>] \
[--description=<resource-description>] \
[--jmes-query=<jmespath-query>] \
[--model-references=<function-model-references>] \
[--name=<resource-name>] \
[--output=json|yaml|table] \
[--output-file=<output-file-location>] \
--profile=<cpd-configuration-profile-name> \
[--project-id=<cpd-project-id>] \
[--quiet] \
[--raw-output=true|false] \
[--sample-scoring-input=<sample-scoring-data>] \
[--schemas=<expected-data-schemas>] \
--software-spec=<software-specification> \
--space-id=<space-identifier> \
[--tags=<tag1,tag2,...>] \
[--type=<function-type>] \
[--verbose]

Arguments

The ml function create command has no arguments.

Options

Option Description
--context Specify the configuration context 
name.
Status
Optional.
Syntax
--context=<catalog-project-or-space-id>
Default value
Not applicable.
Valid values
A valid configuration context name.
--cpd-config The Cloud Pak for Data
configuration location (for example, $HOME/.cpd-cli/config).
Status
Required.
Syntax
--cpd-config=<cpd-config-location>
Default value
No default.
Valid values
A valid Cloud Pak for Data configuration location.
--cpd-scope The Cloud Pak for Data space, project, or catalog scope (for example, cpd://default-context/spaces/7bccdda4-9752-4f37-868e-891de6c48135).
Status
Optional.
Syntax
--cpd-scope=<cpd-config-location>
Default value
No default.
Valid values
A valid Cloud Pak for Data space, project, or catalog scope.
--custom Specify user-defined properties as key-value pairs.
Status
Optional.
Syntax
--custom=<map<key,value>>
Default value
No default.
Valid values
Valid key-value pairs.
--description Specify a resource
 description.
Status
Optional.
Syntax
--description=<resource-description>
Default value
No default.
Valid values
A valid resource description.

--help

-h

Display command help.
Status
Optional.
Syntax
--help
Default value
No default.
Valid values
Not applicable.
--jmes-query Provide a JMESPath query to customize the output.
Status
Optional.
Syntax
--jmes-query=<jmespath-query>
Default value
No default.
Valid values
A valid JMESPath query.
--model-references Specify a list of model references (if any) that are used by the function. The specified references are provided by the function owner and are used only for tracking usage.
Status
Optional.
Syntax
--model-references=<function-model-references>
Default value
No default.
Valid values
A valid list of model references.
--name Specify a resource name.
Status
Required.
Syntax
--name=<resource-name>
Default value
No default.
Valid values
A valid resource name.
--output Specify an output format. Valid formats include json, yaml, or text (the default format).
Status
Optional.
Syntax
--output=json|yaml|text
Default value
text
Valid values
json|yaml|text
--output-file Specify a file path where all output is redirected.
Status
Required.
Syntax
--output-file=<output-file-location>
Default value
No default.
Valid values
A valid output file path location.
--profile The profile-name from the Cloud Pak for Data configuration.
Status
Required.
Syntax
--profile=<cpd-configuration-profile-name>
Default value
default
Valid values
Any valid profile name from the Cloud Pak for Data configuration.
--project-id Specify a Cloud Pak for Data project instance that contains the resource.
Status
Optional.
Syntax
--project-id=<cpd-project-id>
Default value
No default.
Valid values
Any valid project ID.
--quiet Suppress verbose messages.
Status
Optional.
Syntax
--quiet
Default value
No default.
Valid values
Not applicable.
--raw-output When set to true, single values in
 JSON output mode are not surrounded by quotes.
Status
Optional.
Syntax
--raw-output=true|false
Default value
false
Valid values
false
Single values in JSON output mode are surrounded by quotes.
true
Single values in JSON output mode are not surrounded by quotes.
--sample-scoring-input Specify the sample scoring data.
Status
Optional.
Syntax
--sample-scoring-input=<sample-scoring-data>
Default value
No default.
Valid values
Valid sample scoring data.
--schemas Specify the expected data schemas. Schemas that are defined here take precedent over any schemas that are provided in the data references.
Status
Optional.
Syntax
--schemas=<expected-data-schemas>
Default value
No default.
Valid values
A valid array of expected data schemas.
--software-spec Specify a software specification (SoftwareSpecRel object).
Status
Required.
Syntax
--software-spec=<software-specification>
Default value
No default.
Valid values
A valid software specification (SoftwareSpecRel object).
--space-id Specify a space identifier.
Status
Required.
Syntax
--space-id=<space-identifier>
Default value
No default.
Valid values
A valid space identifier.
--tags Specify tags that can be used when searching for resources.
Status
Optional.
Syntax
--tags=<tag1,tag2,...>
Default value
No default.
Valid values
A valid list of comma-separated resource tags.
--type Specify a function type to create. Only the 'python' type is currently supported. Functions expect a *.gzip file that contains a python file that defines the function. The Python functions specify what must be run when the function is deployed and what must be run when the scoring function is called. You can customize what preparation Watson Machine Learning does in the environment when you deploy the function, as well as what steps Watson Machine Learning takes to generate the output when you later call the API. The function consists of the outer function (any place that is not within the score function) and the inner score function. The code that sits in the outer function runs when the function is deployed. The environment is then frozen and ready to be used whenever the online scoring or batch inline job processing API is called. The code that sits in the inner score function runs when the online scoring or batch inline job processing API is called (in the environment customized by the outer function).
The following Python example illustrates the behavior:
><python code used to set up the environment> \
>\
>def score(payload): \
>    df_payload = pd.DataFrame(payload["values"]) \
>    df_payload.columns = payload["fields"] \
>    ... \
>    output = {"result" : res} \
>    return output \
>\
>return score.

For more information, see Deploying Python functions in Watson Machine Learning.

Status
Optional.
Syntax
--type=<function-type>
Default value
No default.
Valid values
A valid function type value.
--verbose Logs include more detailed messages.
Status
Optional.
Syntax
--verbose
Default value
No default.
Valid values
Not applicable.