tests/stress/client/stress_experiment.py
def worker(worker_id, storage, space_type, size):
    """Run trials until experiment is done

    Parameters
    ----------
    worker_id: int
        ID of the worker. This is used to distinguish logs from different workers.
    storage: str
        See `get_experiment`.
    space_type: str
        See `get_experiment`.
    size: int
        See `get_experiment`.

    """
    try:
        experiment = get_experiment(storage, space_type, size)

        assert experiment.version == 1, experiment.version

        print(f"{worker_id: 6d} enters")

        num_trials = 0
        while not experiment.is_done:
            try:
                trial = experiment.suggest()
            except SampleTimeout:
                trial = None

            if trial is None:
                break

            results = f(trial.params["x"], worker_id)
            num_trials += 1
            experiment.observe(trial, results=results)

        print(f"{worker_id: 6d} leaves | is done? {experiment.is_done}")
    except DatabaseTimeout as e:
        print(f"{worker_id: 6d} timeouts and leaves")
        return num_trials
    except Exception as e:
        print(f"{worker_id: 6d} crashes")
        traceback.print_exc()
        return None

    return num_trials
Run trials until experiment is done

    Parameters
    ----------
    worker_id: int
        ID of the worker. This is used to distinguish logs from different workers.
    storage: str
        See `get_experiment`.
    space_type: str
        See `get_experiment`.
    size: int
        See `get_experiment`.

    
Run trials until experiment is done
Parameters

int
ID of the worker. This is used to distinguish logs from different workers.
storage: str
See `get_experiment`.
Run trials until experiment is done Parameters int ID of the worker . This is used to distinguish logs from different workers . storage : str See ` get_experiment ` .
def worker(worker_id, storage, space_type, size):
    try:
        experiment = get_experiment(storage, space_type, size)
        assert experiment.version == 1, experiment.version
        print(f"{worker_id: 6d} enters")
        num_trials = 0
        while not experiment.is_done:
            try:
                trial = experiment.suggest()
            except SampleTimeout:
                trial = None
            if trial is None:
                break
            results = f(trial.params["x"], worker_id)
            num_trials += 1
            experiment.observe(trial, results=results)
        print(f"{worker_id: 6d} leaves | is done? {experiment.is_done}")
    except DatabaseTimeout as e:
        print(f"{worker_id: 6d} timeouts and leaves")
        return num_trials
    except Exception as e:
        print(f"{worker_id: 6d} crashes")
        traceback.print_exc()
        return None
    return num_trials
def worker ( worker_id , storage , space_type , size ) : try : experiment = get_experiment ( storage , space_type , size ) assert experiment . version == 1 , experiment . version print ( f"{worker_id: 6d} enters" ) num_trials = 0 while not experiment . is_done : try : trial = experiment . suggest ( ) except SampleTimeout : trial = None if trial is None : break results = f ( trial . params [ "x" ] , worker_id ) num_trials += 1 experiment . observe ( trial , results = results ) print ( f"{worker_id: 6d} leaves | is done? {experiment.is_done}" ) except DatabaseTimeout as e : print ( f"{worker_id: 6d} timeouts and leaves" ) return num_trials except Exception as e : print ( f"{worker_id: 6d} crashes" ) traceback . print_exc ( ) return None return num_trials
Run trials until experiment is done
Parameters
Run trials until experiment is done Parameters
"""Run trials until experiment is done

    Parameters
    ----------
    worker_id: int
        ID of the worker. This is used to distinguish logs from different workers.
    storage: str
        See `get_experiment`.
    space_type: str
        See `get_experiment`.
    size: int
        See `get_experiment`.

    """
worker_id
storage
space_type
size