Skip to content

Commit

Permalink
Stop ignoring unused keyword arguments (#2451)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2451

In the process of auditing cases where Ax silently ignores incorrect keyword arguments, I fixed the easier cases.

Reviewed By: Balandat

Differential Revision: D57250405

fbshipit-source-id: d4733320158950638489a46a3822fa9c39418dca
  • Loading branch information
esantorella authored and facebook-github-bot committed May 12, 2024
1 parent 40c61e8 commit 424dc52
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
3 changes: 1 addition & 2 deletions ax/early_stopping/strategies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from logging import Logger
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type
from typing import Dict, Iterable, List, Optional, Sequence, Set, Tuple, Type

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -115,7 +115,6 @@ def should_stop_trials_early(
self,
trial_indices: Set[int],
experiment: Experiment,
**kwargs: Dict[str, Any],
) -> Dict[int, Optional[str]]:
"""Decide whether to complete trials before evaluation is fully concluded.
Expand Down
3 changes: 1 addition & 2 deletions ax/early_stopping/strategies/percentile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pyre-strict

from logging import Logger
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
from typing import Dict, Iterable, List, Optional, Set, Tuple

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -92,7 +92,6 @@ def should_stop_trials_early(
self,
trial_indices: Set[int],
experiment: Experiment,
**kwargs: Dict[str, Any],
) -> Dict[int, Optional[str]]:
"""Stop a trial if its performance is in the bottom `percentile_threshold`
of the trials at the same step.
Expand Down
3 changes: 1 addition & 2 deletions ax/early_stopping/strategies/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pyre-strict

from logging import Logger
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
from typing import Dict, Iterable, List, Optional, Set, Tuple

import pandas as pd
from ax.core.experiment import Experiment
Expand Down Expand Up @@ -84,7 +84,6 @@ def should_stop_trials_early(
self,
trial_indices: Set[int],
experiment: Experiment,
**kwargs: Dict[str, Any],
) -> Dict[int, Optional[str]]:
"""Stop a trial if its performance doesn't reach a pre-specified threshold
by `min_progression`.
Expand Down
4 changes: 1 addition & 3 deletions ax/global_stopping/strategies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def __init__(
self.inactive_when_pending_trials = inactive_when_pending_trials

@abstractmethod
def _should_stop_optimization(
self, experiment: Experiment, **kwargs: Any
) -> Tuple[bool, str]:
def _should_stop_optimization(self, experiment: Experiment) -> Tuple[bool, str]:
"""
Decide whether to stop optimization.
Expand Down
4 changes: 1 addition & 3 deletions ax/global_stopping/strategies/improvement.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# pyre-strict

from logging import Logger
from typing import Any, Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Tuple

import numpy as np
from ax.core.base_trial import BaseTrial, TrialStatus
Expand Down Expand Up @@ -87,7 +87,6 @@ def _should_stop_optimization(
experiment: Experiment,
trial_to_check: Optional[int] = None,
objective_thresholds: Optional[List[ObjectiveThreshold]] = None,
**kwargs: Dict[str, Any],
) -> Tuple[bool, str]:
"""
Check if the objective has improved significantly in the past
Expand All @@ -110,7 +109,6 @@ def _should_stop_optimization(
If no thresholds are provided, they are automatically inferred. They are
only inferred once for each instance of the strategy (i.e. inferred
thresholds don't update with additional data).
kwargs: Unused.
Returns:
A Tuple with a boolean determining whether the optimization should stop,
Expand Down
3 changes: 1 addition & 2 deletions ax/models/torch/randomforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from __future__ import annotations

from typing import Any, List, Optional, Tuple
from typing import List, Optional, Tuple

import numpy as np
import torch
Expand Down Expand Up @@ -73,7 +73,6 @@ def cross_validate( # pyre-ignore [14]: not using metric_names or ssd
self,
datasets: List[SupervisedDataset],
X_test: Tensor,
**kwargs: Any,
) -> Tuple[Tensor, Tensor]:
Xs, Ys, Yvars = _datasets_to_legacy_inputs(datasets=datasets)
cv_models: List[RandomForestRegressor] = []
Expand Down

0 comments on commit 424dc52

Please sign in to comment.