tune.concepts.flow

tune.concepts.flow.judge

class Monitor[source]

Bases: object

finalize()[source]
Return type

None

initialize()[source]
Return type

None

on_get_budget(trial, rung, budget)[source]
Parameters
Return type

None

on_judge(decision)[source]
Parameters

decision (tune.concepts.flow.judge.TrialDecision) –

Return type

None

on_report(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

None

class NoOpTrailJudge(monitor=None)[source]

Bases: tune.concepts.flow.judge.TrialJudge

Parameters

monitor (Optional[Monitor]) –

can_accept(trial)[source]
Parameters

trial (tune.concepts.flow.trial.Trial) –

Return type

bool

get_budget(trial, rung)[source]
Parameters
Return type

float

judge(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

tune.concepts.flow.judge.TrialDecision

class RemoteTrialJudge(entrypoint)[source]

Bases: tune.concepts.flow.judge.TrialJudge

Parameters

entrypoint (Callable[[str, Dict[str, Any]], Any]) –

can_accept(trial)[source]
Parameters

trial (tune.concepts.flow.trial.Trial) –

Return type

bool

get_budget(trial, rung)[source]
Parameters
Return type

float

judge(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

tune.concepts.flow.judge.TrialDecision

property report: Optional[tune.concepts.flow.report.TrialReport]
class TrialCallback(judge)[source]

Bases: object

Parameters

judge (tune.concepts.flow.judge.TrialJudge) –

entrypoint(name, kwargs)[source]
Parameters

kwargs (Dict[str, Any]) –

Return type

Any

class TrialDecision(report, budget, should_checkpoint, reason='', metadata=None)[source]

Bases: object

Parameters
property budget: float
property metadata: Dict[str, Any]
property reason: str
property report: tune.concepts.flow.report.TrialReport
property should_checkpoint: bool
property should_stop: bool
property trial: tune.concepts.flow.trial.Trial
property trial_id: str
class TrialJudge(monitor=None)[source]

Bases: object

Parameters

monitor (Optional[Monitor]) –

can_accept(trial)[source]
Parameters

trial (tune.concepts.flow.trial.Trial) –

Return type

bool

get_budget(trial, rung)[source]
Parameters
Return type

float

judge(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

tune.concepts.flow.judge.TrialDecision

property monitor: tune.concepts.flow.judge.Monitor
reset_monitor(monitor=None)[source]
Parameters

monitor (Optional[tune.concepts.flow.judge.Monitor]) –

Return type

None

tune.concepts.flow.report

class TrialReport(trial, metric, params=None, metadata=None, cost=1.0, rung=0, sort_metric=None, log_time=None)[source]

Bases: object

The result from running the objective. It is immutable.

Parameters
  • trial (tune.concepts.flow.trial.Trial) – the original trial sent to the objective

  • metric (Any) – the raw metric from the objective output

  • params (Any) – updated parameters based on the trial input, defaults to None. If none, it means the params from the trial was not updated, otherwise it is an object convertible to TuningParametersTemplate by to_template()

  • metadata (Optional[Dict[str, Any]]) – metadata from the objective output, defaults to None

  • cost (float) – cost to run the objective, defaults to 1.0

  • rung (int) – number of rungs in the current objective, defaults to 0. This is for iterative problems

  • sort_metric (Any) – the metric for comparison, defaults to None. It must be smaller better. If not set, it implies the metric is sort_metric and it is smaller better

  • log_time (Any) – the time generating this report, defaults to None. If None, current time will be used

Attention

This class is not for users to construct directly.

copy()[source]

Copy the current object.

Returns

the copied object

Return type

tune.concepts.flow.report.TrialReport

Note

This is shallow copy, but it is also used by __deepcopy__ of this object. This is because we disable deepcopy of TrialReport.

property cost: float

The cost to run the objective

fill_dict(data)[source]

Fill a row of StudyResult with the report information

Parameters

data (Dict[str, Any]) – a row (as dict) from StudyResult

Returns

the updated data

Return type

Dict[str, Any]

generate_sort_metric(min_better, digits)[source]

Construct a new report object with the new derived``sort_metric``

Parameters
  • min_better (bool) – whether the current metric() is smaller better

  • digits (int) – number of digits to keep in sort_metric

Returns

a new object with the updated value

Return type

tune.concepts.flow.report.TrialReport

property log_time: datetime.datetime

The time generating this report

property metadata: Dict[str, Any]

The metadata from the objective output

property metric: float

The raw metric from the objective output

property params: tune.concepts.space.parameters.TuningParametersTemplate

The parameters used by the objective to generate the metric()

reset_log_time()[source]

Reset log_time() to now

Return type

tune.concepts.flow.report.TrialReport

property rung: int

The number of rungs in the current objective, defaults to 0. This is for iterative problems

property sort_metric: float

The metric for comparison

property trial: tune.concepts.flow.trial.Trial

The original trial sent to the objective

property trial_id: str

tune.concepts.flow.trial.Trial.trial_id()

with_cost(cost)[source]

Construct a new report object with the new cost

Parameters

cost (float) – new cost

Returns

a new object with the updated value

Return type

tune.concepts.flow.report.TrialReport

with_rung(rung)[source]

Construct a new report object with the new rung

Parameters

rung (int) – new rung

Returns

a new object with the updated value

Return type

tune.concepts.flow.report.TrialReport

with_sort_metric(sort_metric)[source]

Construct a new report object with the new sort_metric

Parameters

sort_metric (Any) – new sort_metric

Returns

a new object with the updated value

Return type

tune.concepts.flow.report.TrialReport

class TrialReportHeap(min_heap)[source]

Bases: object

Parameters

min_heap (bool) –

pop()[source]
Return type

tune.concepts.flow.report.TrialReport

push(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

None

values()[source]
Return type

Iterable[tune.concepts.flow.report.TrialReport]

class TrialReportLogger(new_best_only=False)[source]

Bases: object

Parameters

new_best_only (bool) –

property best: Optional[tune.concepts.flow.report.TrialReport]
log(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

None

on_report(report)[source]
Parameters

report (tune.concepts.flow.report.TrialReport) –

Return type

bool

tune.concepts.flow.trial

class Trial(trial_id, params, metadata=None, keys=None, dfs=None)[source]

Bases: object

The input data collection for running an objective. It is immutable.

Parameters
  • trial_id (str) – the unique id for a trial

  • params (Any) – parameters for tuning, an object convertible to TuningParametersTemplate by to_template()

  • metadata (Optional[Dict[str, Any]]) – metadata for tuning, defaults to None. It is set during the construction of TuneDataset

  • keys (Optional[List[str]]) – partitions keys of the TuneDataset, defaults to None

  • dfs (Optional[Dict[str, Any]]) – dataframes extracted from TuneDataset, defaults to None

Attention

This class is not for users to construct directly. Use Space instead.

copy()[source]

Copy the current object.

Returns

the copied object

Return type

tune.concepts.flow.trial.Trial

Note

This is shallow copy, but it is also used by __deepcopy__ of this object. This is because we disable deepcopy of Trial.

property dfs: Dict[str, Any]

Dataframes extracted from TuneDataset

property keys: List[str]

Partitions keys of the TuneDataset

property metadata: Dict[str, Any]

Metadata of the trial

property params: tune.concepts.space.parameters.TuningParametersTemplate

Parameters for tuning

property trial_id: str

The unique id of this trial

with_dfs(dfs)[source]

Set dataframes for the trial, a new Trial object will be constructed and with the new dfs

Parameters

dfs (Dict[str, Any]) – dataframes to attach to the trial

Return type

tune.concepts.flow.trial.Trial

with_params(params)[source]

Set parameters for the trial, a new Trial object will be constructed and with the new params

Parameters

params (Any) – parameters for tuning

Return type

tune.concepts.flow.trial.Trial