class_docstr: Tuner is the recommended way of launching hyperparameter tuning jobs with Ray Tune.
  
  Args:
      trainable: The trainable to be tuned.
      param_space: Search space of the tuning job.
          One thing to note is that both preprocessor and dataset can be tuned here.
      tune_config: Tuning algorithm specific configs.
          Refer to ray.tune.tune_config.TuneConfig for more info.
      run_config: Runtime configuration that is specific to individual trials.
          If passed, this will overwrite the run config passed to the Trainer,
          if applicable. Refer to ray.train.RunConfig for more info.
  
  Usage pattern:
  
  .. code-block:: python
  
      from sklearn.datasets import load_breast_cancer
  
      from ray import tune
      from ray.data import from_pandas
      from ray.train import RunConfig, ScalingConfig
      from ray.train.xgboost import XGBoostTrainer
      from ray.tune.tuner import Tuner
  
      def get_dataset():
          data_raw = load_breast_cancer(as_frame=True)
          dataset_df = data_raw["data"]
          dataset_df["target"] = data_raw["target"]
          dataset = from_pandas(dataset_df)
          return dataset
  
      trainer = XGBoostTrainer(
          label_column="target",
          params={},
          datasets={"train": get_dataset()},
      )
  
      param_space = {
          "scaling_config": ScalingConfig(
              num_workers=tune.grid_search([2, 4]),
              resources_per_worker={
                  "CPU": tune.grid_search([1, 2]),
              },
          ),
          # You can even grid search various datasets in Tune.
          # "datasets": {
          #     "train": tune.grid_search(
          #         [ds1, ds2]
          #     ),
          # },
          "params": {
              "objective": "binary:logistic",
              "tree_method": "approx",
              "eval_metric": ["logloss", "error"],
              "eta": tune.loguniform(1e-4, 1e-1),
              "subsample": tune.uniform(0.5, 1.0),
              "max_depth": tune.randint(1, 9),
          },
      }
      tuner = Tuner(trainable=trainer, param_space=param_space,
          run_config=RunConfig(name="my_tune_run"))
      results = tuner.fit()
  
  To retry a failed tune run, you can then do
  
  .. code-block:: python
  
      tuner = Tuner.restore(results.experiment_path, trainable=trainer)
      tuner.fit()
  
  ``results.experiment_path`` can be retrieved from the
  :ref:`ResultGrid object <tune-analysis-docs>`. It can
  also be easily seen in the log output from your first run.
class_docstr_tok: ["Tuner","is","the","recommended","way","of","launching","hyperparameter","tuning","jobs","with","Ray","Tune",".","Args",":","trainable",":","The","trainable","to","be","tuned",".","param_space",":","Search","space","of","the","tuning","job",".","One","thing","to","note","is","that","both","preprocessor","and","dataset","can","be","tuned","here",".","tune_config",":","Tuning","algorithm","specific","configs",".","Refer","to","ray.tune.tune_config.TuneConfig","for","more","info",".","run_config",":","Runtime","configuration","that","is","specific","to","individual","trials",".","If","passed",",","this","will","overwrite","the","run","config","passed","to","the","Trainer",",","if","applicable",".","Refer","to","ray.train.RunConfig","for","more","info",".","Usage","pattern",":","..","code-block",":",":","python","from","sklearn.datasets","import","load_breast_cancer","from","ray","import","tune","from","ray.data","import","from_pandas","from","ray.train","import","RunConfig",",","ScalingConfig","from","ray.train.xgboost","import","XGBoostTrainer","from","ray.tune.tuner","import","Tuner","def","get_dataset","(",")",":","data_raw","=","load_breast_cancer","(","as_frame=True",")","dataset_df","=","data_raw","[","``","data","''","]","dataset_df","[","``","target","''","]","=","data_raw","[","``","target","''","]","dataset","=","from_pandas","(","dataset_df",")","return","dataset","trainer","=","XGBoostTrainer","(","label_column=","''","target","''",",","params=","{","}",",","datasets=","{","``","train","''",":","get_dataset","(",")","}",",",")","param_space","=","{","``","scaling_config","''",":","ScalingConfig","(","num_workers=tune.grid_search","(","[","2",",","4","]",")",",","resources_per_worker=","{","``","CPU","''",":","tune.grid_search","(","[","1",",","2","]",")",",","}",",",")",",","#","You","can","even","grid","search","various","datasets","in","Tune",".","#","``","datasets","''",":","{","#","``","train","''",":","tune.grid_search","(","#","[","ds1",",","ds2","]","#",")",",","#","}",",","``","params","''",":","{","``","objective","''",":","``","binary",":","logistic","''",",","``","tree_method","''",":","``","approx","''",",","``","eval_metric","''",":","[","``","logloss","''",",","``","error","''","]",",","``","eta","''",":","tune.loguniform","(","1e-4",",","1e-1",")",",","``","subsample","''",":","tune.uniform","(","0.5",",","1.0",")",",","``","max_depth","''",":","tune.randint","(","1",",","9",")",",","}",",","}","tuner","=","Tuner","(","trainable=trainer",",","param_space=param_space",",","run_config=RunConfig","(","name=","''","my_tune_run","''",")",")","results","=","tuner.fit","(",")","To","retry","a","failed","tune","run",",","you","can","then","do","..","code-block",":",":","python","tuner","=","Tuner.restore","(","results.experiment_path",",","trainable=trainer",")","tuner.fit","(",")","``","results.experiment_path","``","can","be","retrieved","from","the",":","ref",":","`","ResultGrid","object","<","tune-analysis-docs",">","`",".","It","can","also","be","easily","seen","in","the","log","output","from","your","first","run","."]
docstr: Checks whether a given directory contains a restorable Tune experiment.
  
  Usage Pattern:
  
  Use this utility to switch between starting a new Tune experiment
  and restoring when possible. This is useful for experiment fault-tolerance
  when re-running a failed tuning script.
  
  .. code-block:: python
  
      import os
      from ray.tune import Tuner
      from ray.train import RunConfig
  
      def train_fn(config):
          # Make sure to implement checkpointing so that progress gets
          # saved on restore.
          pass
  
      name = "exp_name"
      storage_path = os.path.expanduser("~/ray_results")
      exp_dir = os.path.join(storage_path, name)
  
      if Tuner.can_restore(exp_dir):
          tuner = Tuner.restore(exp_dir, trainable=train_fn, resume_errored=True)
      else:
          tuner = Tuner(
              train_fn,
              run_config=RunConfig(name=name, storage_path=storage_path),
          )
      tuner.fit()
  
  Args:
      path: The path to the experiment directory of the Tune experiment.
          This can be either a local directory or a remote URI
          (e.g. s3://bucket/exp_name).
  
  Returns:
      bool: True if this path exists and contains the Tuner state to resume from
docstr_tok: ["Checks","whether","a","given","directory","contains","a","restorable","Tune","experiment",".","Usage","Pattern",":","Use","this","utility","to","switch","between","starting","a","new","Tune","experiment","and","restoring","when","possible",".","This","is","useful","for","experiment","fault-tolerance","when","re-running","a","failed","tuning","script",".","..","code-block",":",":","python","import","os","from","ray.tune","import","Tuner","from","ray.train","import","RunConfig","def","train_fn","(","config",")",":","#","Make","sure","to","implement","checkpointing","so","that","progress","gets","#","saved","on","restore",".","pass","name","=","``","exp_name","''","storage_path","=","os.path.expanduser","(","``","~\/ray_results","''",")","exp_dir","=","os.path.join","(","storage_path",",","name",")","if","Tuner.can_restore","(","exp_dir",")",":","tuner","=","Tuner.restore","(","exp_dir",",","trainable=train_fn",",","resume_errored=True",")","else",":","tuner","=","Tuner","(","train_fn",",","run_config=RunConfig","(","name=name",",","storage_path=storage_path",")",",",")","tuner.fit","(",")","Args",":","path",":","The","path","to","the","experiment","directory","of","the","Tune","experiment",".","This","can","be","either","a","local","directory","or","a","remote","URI","(","e.g",".","s3",":","\/\/bucket\/exp_name",")",".","Returns",":","bool",":","True","if","this","path","exists","and","contains","the","Tuner","state","to","resume","from"]
code: def can_restore(
      cls,
      path: Union[str, os.PathLike],
      storage_filesystem: Optional[pyarrow.fs.FileSystem] = None,
  ) -> bool:
      """Checks whether a given directory contains a restorable Tune experiment.
  
      Usage Pattern:
  
      Use this utility to switch between starting a new Tune experiment
      and restoring when possible. This is useful for experiment fault-tolerance
      when re-running a failed tuning script.
  
      .. code-block:: python
  
          import os
          from ray.tune import Tuner
          from ray.train import RunConfig
  
          def train_fn(config):
              # Make sure to implement checkpointing so that progress gets
              # saved on restore.
              pass
  
          name = "exp_name"
          storage_path = os.path.expanduser("~/ray_results")
          exp_dir = os.path.join(storage_path, name)
  
          if Tuner.can_restore(exp_dir):
              tuner = Tuner.restore(exp_dir, trainable=train_fn, resume_errored=True)
          else:
              tuner = Tuner(
                  train_fn,
                  run_config=RunConfig(name=name, storage_path=storage_path),
              )
          tuner.fit()
  
      Args:
          path: The path to the experiment directory of the Tune experiment.
              This can be either a local directory or a remote URI
              (e.g. s3://bucket/exp_name).
  
      Returns:
          bool: True if this path exists and contains the Tuner state to resume from
      """
      fs, fs_path = get_fs_and_path(path, storage_filesystem)
      return _exists_at_fs_path(fs, os.path.join(fs_path, _TUNER_PKL))
  
imports: import logging
  import os
  from typing import Any, Callable, Dict, Optional, Type, Union, TYPE_CHECKING
  import pyarrow.fs
  import ray
  from ray.air.config import RunConfig
  from ray.air._internal.usage import AirEntrypoint
  from ray.air.util.node import _force_on_current_node
  from ray.train._internal.storage import _exists_at_fs_path, get_fs_and_path
  from ray.tune import TuneError
  from ray.tune.execution.experiment_state import _ResumeConfig
  from ray.tune.experimental.output import get_air_verbosity
  from ray.tune.result_grid import ResultGrid
  from ray.tune.trainable import Trainable
  from ray.tune.impl.tuner_internal import TunerInternal, _TUNER_PKL
  from ray.tune.tune_config import TuneConfig
  from ray.tune.progress_reporter import _prepare_progress_reporter_for_ray_client, _stream_client_output
  from ray.util import PublicAPI
label_desc: Use image node_id 3 for calling the Tuner obj's underlying member method code with example usage: obj.can_restore(cls, path, storage_filesystem) and returns: _exists_at_fs_path