Skip to content

Commit f4768f2

Browse files
authored
Rename the configurations (#64)
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 7e245d2 commit f4768f2

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

alphatrion/trial/trial.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@ class TrialConfig(BaseModel):
5858
after which experiment will be stopped. Default is -1 (no early stopping). \
5959
Count each time when calling log_metrics with the monitored metric.",
6060
)
61-
max_run_number: int = Field(
61+
max_runs_per_trial: int = Field(
6262
default=-1,
63-
description="Maximum number of runs for the trial. \
63+
description="Maximum number of runs for each trial. \
6464
Default is -1 (no limit). Count by the finished runs.",
6565
)
6666
monitor_metric: str | None = Field(
6767
default=None,
68-
description="The metric to monitor for saving the best checkpoint. \
69-
Required if save_on_best is True.",
68+
description="The metric to monitor together with other configurations \
69+
like early_stopping_runs and save_on_best. \
70+
Required if save_on_best is true or early_stopping_runs > 0.",
7071
)
7172
monitor_mode: str = Field(
7273
default="max",
@@ -116,7 +117,7 @@ class Trial:
116117
"_running_tasks",
117118
# Only work when early_stopping_runs > 0
118119
"_early_stopping_counter",
119-
# Only work when max_run_number > 0
120+
# Only work when max_runs_per_trial > 0
120121
"_total_runs_counter",
121122
)
122123

@@ -315,12 +316,12 @@ def start_run(self, call_func: callable) -> Run:
315316

316317
task.add_done_callback(lambda t: self._running_tasks.pop(run.id, None))
317318
task.add_done_callback(lambda t: self._runs.pop(run.id, None))
318-
if self._config.max_run_number > 0:
319+
if self._config.max_runs_per_trial > 0:
319320
task.add_done_callback(
320321
lambda t: (
321322
setattr(self, "_total_runs_counter", self._total_runs_counter + 1),
322323
self.cancel()
323-
if self._total_runs_counter >= self._config.max_run_number
324+
if self._total_runs_counter >= self._config.max_runs_per_trial
324325
else None,
325326
)
326327
)

tests/integration/test_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ async def fake_work(value: float):
353353
name="trial-with-max-run-number",
354354
config=alpha.TrialConfig(
355355
monitor_metric="accuracy",
356-
max_run_number=5,
356+
max_runs_per_trial=5,
357357
),
358358
) as trial:
359359
while not trial.cancelled():

0 commit comments

Comments
 (0)