Updated on 2024-10-29 GMT+08:00

Configuring Workflow Parameters

Description

A workflow parameter is a placeholder object that can be configured when the workflow runs. The following data types are supported: int, str, bool, float, Enum, dict, and list. You can display fields (such as algorithm hyperparameters) in a phase as placeholders in a transparent way. You can modify and use the default values that are set for them.

Parameter Overview (Placeholder)

Parameter

Description

Mandatory

Data Type

name

Parameter name, which must be globally unique.

Yes

str

placeholder_type

Parameter type. The mapping between placeholder types and actual data types:

PlaceholderType.INT -> int

PlaceholderType.STR -> str

PlaceholderType.BOOL -> bool

PlaceholderType.FLOAT -> float

PlaceholderType.ENUM -> Enum

PlaceholderType.JSON -> dict

PlaceholderType.LIST -> list

  • When the type is PlaceholderType.ENUM, the enum_list field cannot be empty.
  • When the type is PlaceholderType.LIST, the placeholder_format field cannot be empty and can only be set to str, int, float, or bool, indicating the data types in the list.

Yes

PlaceholderType

default

Default parameter value. The data type must be the same as that of placeholder_type.

No

Any

placeholder_format

Supported data formats. Currently, obs, flavor, train_flavor, swr, and pacific are supported.

No

str

delay

Whether parameters are set when the workflow is running. The default value is False, indicating that parameters are set before the workflow runs. If the value is True, parameters are set in an action of the phase where they are needed.

No

bool

description

Parameter description.

No

str

enum_list

List of enumerated values of a parameter. This parameter is mandatory only for parameters of PlaceholderType.ENUM type.

No

list

constraint

Constraints on parameters. This parameter only supports the constraints of training specifications and is not visible to you.

No

dict

required

Whether the parameter is mandatory.

  • The default value is True.
  • This parameter cannot be set to False for Delay.

This parameter is optional at the frontend during execution.

No

bool

Examples

  • Integer parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_int", placeholder_type=wf.PlaceholderType.INT, default=1, description="This is an integer parameter.")
  • String parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_str", placeholder_type=wf.PlaceholderType.STR, default="default_value", description="This is a string parameter.")
  • Bool parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_bool", placeholder_type=wf.PlaceholderType.BOOL, default=True, description="This is a bool parameter.")
  • Float parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_float", placeholder_type=wf.PlaceholderType.FLOAT, default=0.1, description="This is a float parameter.")
  • Enumeration parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_enum", placeholder_type=wf.PlaceholderType.ENUM, default="a", enum_list=["a", "b"], description="This is an enumeration parameter.")
  • Dictionary parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_dict", placeholder_type=wf.PlaceholderType.JSON, default={"key": "value"}, description="This is a dictionary parameter.")
  • List parameter
    from modelarts import workflow as wf
    wf.Placeholder(name="placeholder_list", placeholder_type=wf.PlaceholderType.LIST, default=[1, 2], placeholder_format="int", description="This is a list parameter and its value is an integer.")