update integration tests

This commit is contained in:
bohanjason 2019-10-31 03:05:10 -04:00 committed by Dana Van Aken
parent 1808a7a50a
commit 8bb3de85e7
3 changed files with 23 additions and 25 deletions

View File

@ -182,21 +182,16 @@ class Session(BaseModel):
class SessionKnobManager(models.Manager):
@staticmethod
def get_knobs_for_session(session, only_session_knobs=False):
def get_knobs_for_session(session):
# Returns a dict of the knob
knobs = KnobCatalog.objects.filter(dbms=session.dbms)
knob_dicts = list(knobs.values())
session_knob_dicts = []
for i, _ in enumerate(knob_dicts):
if SessionKnob.objects.filter(session=session, knob=knobs[i]).exists():
new_knob = SessionKnob.objects.filter(session=session, knob=knobs[i])[0]
knob_dicts[i]["minval"] = new_knob.minval
knob_dicts[i]["maxval"] = new_knob.maxval
knob_dicts[i]["tunable"] = new_knob.tunable
session_knob_dicts.append(new_knob)
if only_session_knobs:
knob_dicts = session_knob_dicts
else:
knob_dicts = [knob for knob in knob_dicts if knob["tunable"]]
return knob_dicts

View File

@ -544,8 +544,7 @@ def configuration_recommendation(recommendation_input):
X_max = np.empty(X_scaled.shape[1])
X_scaler_matrix = np.zeros([1, X_scaled.shape[1]])
session_knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session,
only_session_knobs=True)
session_knobs = SessionKnob.objects.get_knobs_for_session(newest_result.session)
# Set min/max for knob values
for i in range(X_scaled.shape[1]):

View File

@ -1069,24 +1069,28 @@ def create_test_website(request): # pylint: disable=unused-argument
test_project = Project.objects.create(user=test_user, name='ottertune_test_project',
creation_time=now(), last_update=now())
# create no tuning session
Session.objects.create(name='test_session_no_tuning', tuning_session='no_tuning_session',
s1 = Session.objects.create(name='test_session_no_tuning', tuning_session='no_tuning_session',
dbms_id=1, hardware=test_hardware, project=test_project,
creation_time=now(), last_update=now(), user=test_user,
upload_code='ottertuneTestNoTuning')
set_default_knobs(s1)
# create gpr session
Session.objects.create(name='test_session_gpr', user=test_user, tuning_session='tuning_session',
s2 = Session.objects.create(name='test_session_gpr', tuning_session='tuning_session',
dbms_id=1, hardware=test_hardware, project=test_project,
creation_time=now(), last_update=now(), algorithm=AlgorithmType.GPR,
upload_code='ottertuneTestTuningGPR')
upload_code='ottertuneTestTuningGPR', user=test_user)
set_default_knobs(s2)
# create dnn session
Session.objects.create(name='test_session_dnn', user=test_user, tuning_session='tuning_session',
s3 = Session.objects.create(name='test_session_dnn', tuning_session='tuning_session',
dbms_id=1, hardware=test_hardware, project=test_project,
creation_time=now(), last_update=now(), algorithm=AlgorithmType.DNN,
upload_code='ottertuneTestTuningDNN')
upload_code='ottertuneTestTuningDNN', user=test_user)
set_default_knobs(s3)
# create ddpg session
Session.objects.create(name='test_session_ddpg', tuning_session='tuning_session',
s4 = Session.objects.create(name='test_session_ddpg', tuning_session='tuning_session',
dbms_id=1, hardware=test_hardware, project=test_project,
creation_time=now(), last_update=now(), user=test_user,
upload_code='ottertuneTestTuningDDPG', algorithm=AlgorithmType.DDPG)
set_default_knobs(s4)
response = HttpResponse("Success: create test website successfully")
return response