Sweep Class

Base class for sweep node.

This class should not be instantiated directly. Instead, it should be created via the builder function: sweep.

]

]]

]]

]

Inheritance
azure.ai.ml.entities._job.sweep.parameterized_sweep.ParameterizedSweep
Sweep
azure.ai.ml.entities._builders.base_node.BaseNode
Sweep

Constructor

Sweep(*, trial: CommandComponent | str | None = None, compute: str | None = None, limits: SweepJobLimits | None = None, sampling_algorithm: str | SamplingAlgorithm | None = None, objective: Objective | None = None, early_termination: BanditPolicy | MedianStoppingPolicy | TruncationSelectionPolicy | EarlyTerminationPolicy | str | None = None, search_space: Dict[str, Choice | LogNormal | LogUniform | Normal | QLogNormal | QLogUniform | QNormal | QUniform | Randint | Uniform] | None = None, inputs: Dict[str, Input | str | bool | int | float] | None = None, outputs: Dict[str, str | Output] | None = None, identity: Dict | ManagedIdentityConfiguration | AmlTokenConfiguration | UserIdentityConfiguration | None = None, queue_settings: QueueSettings | None = None, resources: dict | JobResourceConfiguration | None = None, **kwargs: Any)

Parameters

Name Description
trial
Required

The ID or instance of the command component or job to be run for the step.

compute
Required
str

The compute definition containing the compute information for the step.

limits
Required

The limits for the sweep node.

sampling_algorithm
Required
str

The sampling algorithm to use to sample inside the search space. Accepted values are: "random", "grid", or "bayesian".

objective
Required

The objective used to determine the target run with the local optimal hyperparameter in search space.

early_termination_policy
Required

The early termination policy of the sweep node.

search_space
Required

The hyperparameter search space to run trials in.

inputs
Required

Mapping of input data bindings used in the job.

outputs
Required

Mapping of output data bindings used in the job.

identity
Required

The identity that the training job will use while running on compute.

queue_settings
Required

The queue settings for the job.

resources
Required

Compute Resource configuration for the job.

Keyword-Only Parameters

Name Description
trial
Required
compute
Required
limits
Required
sampling_algorithm
Required
objective
Required
early_termination
Required
search_space
Required
inputs
Required
outputs
Required
identity
Required
queue_settings
Required
resources
Required

Methods

clear
copy
dump

Dumps the job content into a file in YAML format.

fromkeys

Create a new dictionary with keys from iterable and values set to value.

get

Return the value for key if key is in the dictionary, else default.

items
keys
pop

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

set_limits

Set limits for Sweep node. Leave parameters as None if you don't want to update corresponding values.

set_objective

Set the sweep object.. Leave parameters as None if you don't want to update corresponding values.

set_resources

Set resources for Sweep.

setdefault

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values

clear

clear() -> None.  Remove all items from D.

copy

copy() -> a shallow copy of D

dump

Dumps the job content into a file in YAML format.

dump(dest: str | PathLike | IO, **kwargs: Any) -> None

Parameters

Name Description
dest
Required
Union[<xref:PathLike>, str, IO[AnyStr]]

The local path or file stream to write the YAML content to. If dest is a file path, a new file will be created. If dest is an open file, the file will be written to directly.

Exceptions

Type Description

Raised if dest is a file path and the file already exists.

Raised if dest is an open file and the file is not writable.

fromkeys

Create a new dictionary with keys from iterable and values set to value.

fromkeys(value=None, /)

Positional-Only Parameters

Name Description
iterable
Required
value
Default value: None

Parameters

Name Description
type
Required

get

Return the value for key if key is in the dictionary, else default.

get(key, default=None, /)

Positional-Only Parameters

Name Description
key
Required
default
Default value: None

items

items() -> a set-like object providing a view on D's items

keys

keys() -> a set-like object providing a view on D's keys

pop

If the key is not found, return the default if given; otherwise, raise a KeyError.

pop(k, [d]) -> v, remove specified key and return the corresponding value.

popitem

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

popitem()

set_limits

Set limits for Sweep node. Leave parameters as None if you don't want to update corresponding values.

set_limits(*, max_concurrent_trials: int | None = None, max_total_trials: int | None = None, timeout: int | None = None, trial_timeout: int | None = None) -> None

Keyword-Only Parameters

Name Description
max_concurrent_trials
int

maximum concurrent trial number.

max_total_trials
int

maximum total trial number.

timeout
int

total timeout in seconds for sweep node

trial_timeout
int

timeout in seconds for each trial

set_objective

Set the sweep object.. Leave parameters as None if you don't want to update corresponding values.

set_objective(*, goal: str | None = None, primary_metric: str | None = None) -> None

Keyword-Only Parameters

Name Description
goal
str

Defines supported metric goals for hyperparameter tuning. Acceptable values are: "minimize" and "maximize".

primary_metric
str

Name of the metric to optimize.

set_resources

Set resources for Sweep.

set_resources(*, instance_type: str | List[str] | None = None, instance_count: int | None = None, locations: List[str] | None = None, properties: Dict | None = None, docker_args: str | None = None, shm_size: str | None = None) -> None

Keyword-Only Parameters

Name Description
instance_type

The instance type to use for the job.

instance_count

The number of instances to use for the job.

locations

The locations to use for the job.

properties

The properties for the job.

docker_args

The docker arguments for the job.

shm_size

The shared memory size for the job.

setdefault

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

setdefault(key, default=None, /)

Positional-Only Parameters

Name Description
key
Required
default
Default value: None

update

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

update([E], **F) -> None.  Update D from dict/iterable E and F.

values

values() -> an object providing a view on D's values

Attributes

base_path

The base path of the resource.

Returns

Type Description
str

The base path of the resource.

creation_context

The creation context of the resource.

Returns

Type Description

The creation metadata for the resource.

early_termination

The early termination policy for the sweep job.

Returns

Type Description

id

The resource ID.

Returns

Type Description

The global ID of the resource, an Azure Resource Manager (ARM) ID.

inputs

Get the inputs for the object.

Returns

Type Description

A dictionary containing the inputs for the object.

limits

Limits for sweep job.

Returns

Type Description

Limits for sweep job.

log_files

Job output files.

Returns

Type Description

The dictionary of log names and URLs.

name

Get the name of the node.

Returns

Type Description
str

The name of the node.

outputs

Get the outputs of the object.

Returns

Type Description

A dictionary containing the outputs for the object.

resources

Resources for sweep job.

Returns

Type Description

Resources for sweep job.

sampling_algorithm

Sampling algorithm for sweep job.

Returns

Type Description

Sampling algorithm for sweep job.

search_space

Dictionary of the hyperparameter search space.

Each key is the name of a hyperparameter and its value is the parameter expression.

Returns

Type Description

status

The status of the job.

Common values returned include "Running", "Completed", and "Failed". All possible values are:

  • NotStarted - This is a temporary state that client-side Run objects are in before cloud submission.

  • Starting - The Run has started being processed in the cloud. The caller has a run ID at this point.

  • Provisioning - On-demand compute is being created for a given job submission.

  • Preparing - The run environment is being prepared and is in one of two stages:

    • Docker image build

    • conda environment setup

  • Queued - The job is queued on the compute target. For example, in BatchAI, the job is in a queued state

    while waiting for all the requested nodes to be ready.

  • Running - The job has started to run on the compute target.

  • Finalizing - User code execution has completed, and the run is in post-processing stages.

  • CancelRequested - Cancellation has been requested for the job.

  • Completed - The run has completed successfully. This includes both the user code execution and run

    post-processing stages.

  • Failed - The run failed. Usually the Error property on a run will provide details as to why.

  • Canceled - Follows a cancellation request and indicates that the run is now successfully cancelled.

  • NotResponding - For runs that have Heartbeats enabled, no heartbeat has been recently sent.

Returns

Type Description

Status of the job.

studio_url

Azure ML studio endpoint.

Returns

Type Description

The URL to the job details page.

trial

The ID or instance of the command component or job to be run for the step.

Returns

Type Description

type

The type of the job.

Returns

Type Description

The type of the job.