def test_main_search_clear_existing(trials):
    # -- main_search (the CLI) has no way of specifying an
    #    exp_key of None.
    assert trials._exp_key == "hello"
    doc = hyperopt.tests.test_base.ok_trial(70, 0)
    doc["exp_key"] = "hello"
    trials.insert_trial_doc(doc)
    print "Setting up trials with exp_key", doc["exp_key"]
    options = FakeOptions(
        bandit_argfile="",
        bandit_algo_argfile="",
        exp_key=doc["exp_key"],
        clear_existing=True,
        steps=0,
        block=True,
        workdir=None,
        poll_interval=1,
        max_queue_len=1,
        mongo=as_mongo_str("localhost:22334/foo"),
    )
    args = ("hyperopt.bandits.n_arms", "hyperopt.Random")

    def input():
        return "y"

    trials.refresh()
    assert len(trials) == 1
    main_search_helper(options, args, input=input)
    trials.refresh()
    assert len(trials) == 0
Example #2
0
def test_main_search_clear_existing(trials):
    # -- main_search (the CLI) has no way of specifying an
    #    exp_key of None.
    assert trials._exp_key == 'hello'
    doc = hyperopt.tests.test_base.ok_trial(70, 0)
    doc['exp_key'] = 'hello'
    trials.insert_trial_doc(doc)
    print 'Setting up trials with exp_key', doc['exp_key']
    options = FakeOptions(
        bandit_argfile='',
        bandit_algo_argfile='',
        exp_key=doc['exp_key'],
        clear_existing=True,
        steps=0,
        block=True,
        workdir=None,
        poll_interval=1,
        max_queue_len=1,
        mongo=as_mongo_str('localhost:22334/foo'),
    )
    args = ('hyperopt.bandits.n_arms', 'hyperopt.Random')

    def input():
        return 'y'

    trials.refresh()
    assert len(trials) == 1
    main_search_helper(options, args, input=input)
    trials.refresh()
    assert len(trials) == 0
Example #3
0
def test_main_search_runs(trials):
    options = FakeOptions(
            bandit_argfile='',
            bandit_algo_argfile='',
            exp_key=None,
            clear_existing=False,
            steps=0,
            block=True,
            workdir=None,
            poll_interval=1,
            max_queue_len=1,
            mongo=as_mongo_str('localhost:22334/foodb'),
            )
    args = ('hyperopt.bandits.n_arms', 'hyperopt.Random')
    main_search_helper(options, args)
Example #4
0
def test_main_search_driver_attachment(trials):
    options = FakeOptions(
            bandit_argfile='',
            bandit_algo_argfile='',
            exp_key='hello',
            clear_existing=False,
            steps=0,
            block=True,
            workdir=None,
            poll_interval=1,
            max_queue_len=1,
            mongo=as_mongo_str('localhost:22334/foo'),
            )
    args = ('hyperopt.bandits.n_arms', 'hyperopt.Random')
    main_search_helper(options, args, cmd_type='D.A.')
    print trials.handle.gfs._GridFS__collection
    assert 'driver_attachment_hello.pkl' in trials.attachments
def test_main_search_driver_reattachment(trials):
    # pretend we already attached a different bandit
    trials.attachments["driver_attachment_hello.pkl"] = cPickle.dumps((1, 2, 3))
    options = FakeOptions(
        bandit_argfile="",
        bandit_algo_argfile="",
        exp_key="hello",
        clear_existing=False,
        steps=0,
        block=True,
        workdir=None,
        poll_interval=1,
        max_queue_len=1,
        mongo=as_mongo_str("localhost:22334/foo"),
    )
    args = ("hyperopt.bandits.n_arms", "hyperopt.Random")
    main_search_helper(options, args, cmd_type="D.A.")
def test_main_search_driver_attachment(trials):
    options = FakeOptions(
        bandit_argfile="",
        bandit_algo_argfile="",
        exp_key="hello",
        clear_existing=False,
        steps=0,
        block=True,
        workdir=None,
        poll_interval=1,
        max_queue_len=1,
        mongo=as_mongo_str("localhost:22334/foo"),
    )
    args = ("hyperopt.bandits.n_arms", "hyperopt.Random")
    main_search_helper(options, args, cmd_type="D.A.")
    print trials.handle.gfs._GridFS__collection
    assert "driver_attachment_hello.pkl" in trials.attachments
Example #7
0
def test_main_search_driver_reattachment(trials):
    # pretend we already attached a different bandit
    trials.attachments['driver_attachment_hello.pkl'] = cPickle.dumps(
            (1, 2, 3))
    options = FakeOptions(
            bandit_argfile='',
            bandit_algo_argfile='',
            exp_key='hello',
            clear_existing=False,
            steps=0,
            block=True,
            workdir=None,
            poll_interval=1,
            max_queue_len=1,
            mongo=as_mongo_str('localhost:22334/foo'),
            )
    args = ('hyperopt.bandits.n_arms', 'hyperopt.Random')
    main_search_helper(options, args, cmd_type='D.A.')
Example #8
0
def test_main_search_driver_reattachment(trials):
    # pretend we already attached a different bandit
    trials.attachments['driver_attachment_hello.pkl'] = cPickle.dumps(
            (1, 2, 3))
    options = FakeOptions(
            bandit_argfile='',
            bandit_algo_argfile='',
            exp_key='hello',
            clear_existing=False,
            steps=0,
            block=True,
            workdir=None,
            poll_interval=1,
            max_queue_len=1,
            mongo=as_mongo_str('localhost:22334/foo'),
            )
    args = ('hyperopt.bandits.TwoArms', 'hyperopt.Random')
    main_search_helper(options, args, cmd_type='D.A.')
Example #9
0
def test_main_search_clear_existing(trials):
    doc = hyperopt.tests.test_base.ok_trial(70, 0)
    doc['exp_key'] = 'hello'
    trials.insert_trial_doc(doc)
    options = FakeOptions(
            bandit_argfile='',
            bandit_algo_argfile='',
            exp_key=doc['exp_key'],
            clear_existing=True,
            steps=0,
            block=True,
            workdir=None,
            poll_interval=1,
            max_queue_len=1,
            mongo=as_mongo_str('localhost:22334/foo'),
            )
    args = ('hyperopt.bandits.n_arms', 'hyperopt.Random')
    def input():
        return 'y'
    trials.refresh()
    assert len(trials) == 1
    main_search_helper(options, args, input=input)
    trials.refresh()
    assert len(trials) == 0