Exemplo n.º 1
0
def test_no_unnecessary_exec_eval():
    _c2a.value = 0
    _c2b.value = 0
    f2a()
    assert dds.eval(f2b) == "a11"
    assert dds.eval(f2b) == "a11"
    assert _c2b.value == 1
Exemplo n.º 2
0
def test_2():
    """ Authorized objects are taken into account """
    global fun_2_obj
    assert dds.eval(fun_2_f1) is None
    fun_2_obj = 1
    assert dds.eval(fun_2_f1) is None
    assert fun_2_counter.value == 2, fun_2_counter.value
Exemplo n.º 3
0
def test_3():
    """ Unauthorized objects are not taken into account """
    global fun_3_obj
    assert dds.eval(fun_3_f1) is None
    fun_3_obj = UnsupportedOperation("b")
    assert dds.eval(fun_3_f1) is None
    assert fun_3_counter.value == 1, fun_3_counter.value
Exemplo n.º 4
0
def test_args():
    with pytest.raises(DDSException) as e:
        f2(3)
    assert e.value.error_code == DDSErrorCode.ARG_IN_DATA_FUNCTION
    with pytest.raises(DDSException) as e:
        dds.eval(f2_1)
    assert e.value.error_code == DDSErrorCode.ARG_IN_DATA_FUNCTION
Exemplo n.º 5
0
def test_args():
    # TODO: these tests are just checking that the calls are processed
    # They should also check that the function is not retriggered again.
    assert dds.keep(spath, fun_args, 1, 2) == 3
    assert dds.keep(spath, fun_args, 1, b=2) == 3
    assert dds.keep(spath, fun_args, a=1, b=2) == 3
    assert dds.eval(fun_args_outer) == 3
    assert dds.eval(fun_args, 1, 2) == 3
    assert dds.eval(fun_args, a=1, b=2) == 3
Exemplo n.º 6
0
def test():
    assert f() == "a"
    assert _c.value == 1
    assert dds.eval(f) == "a"
    assert _c.value == 1
    assert f1() == "a"
    assert _c.value == 1
    assert dds.eval(f1) == "a"
    assert _c.value == 1
Exemplo n.º 7
0
def test():
    fun()
    assert _c.value == 1
    dds.keep(_p, f)
    assert _c.value == 1
    dds.eval(f)
    assert _c.value == 1
    dds.eval(f2)
    assert _c.value == 1
Exemplo n.º 8
0
def test_4():
    """ Authorized objects are taken into account """
    global fun_4_obj
    assert dds.eval(fun_4_f) is None
    assert fun_4_counter1.value == 1
    assert fun_4_counter2.value == 1
    fun_4_obj = 1
    assert dds.eval(fun_4_f) is None
    assert fun_4_counter1.value == 1
    assert fun_4_counter2.value == 2
Exemplo n.º 9
0
def test_5():
    """ Chained calls are reevaluated """
    global fun_5_obj
    assert dds.eval(fun_5_f) is None
    assert fun_5_counter1.value == 1
    assert fun_5_counter2.value == 1
    fun_5_obj = 1
    assert dds.eval(fun_5_f) is None
    assert fun_5_counter1.value == 2
    # This function comes later but has no argument -> no need to reevaluate
    assert fun_5_counter2.value == 1
Exemplo n.º 10
0
def test():
    fun1()
    assert _c.value == 1
    fun2()
    assert _c.value == 1
    dds.eval(fun2)
    assert _c.value == 1
    fun3()
    assert _c.value == 2
    dds.eval(fun3)
    assert _c.value == 2
Exemplo n.º 11
0
def test_2_simple_eval():
    _c2a.value = 0
    _c2b.value = 0
    assert f2() == "a11"
    assert _c2a.value == 1
    assert _c2b.value == 1
    assert dds.eval(f2) == "a11"
    assert _c2a.value == 1
    assert _c2b.value == 1
Exemplo n.º 12
0
def test_2():
    assert dds.eval(f2_wrap) == "A"
Exemplo n.º 13
0
def test_3():
    assert dds.eval(fun_3, 3) == "A3"
Exemplo n.º 14
0
def test():
    assert dds.eval(fun) == function1()
    print(locals())
    print(globals())
Exemplo n.º 15
0
def test_1():
    assert dds.eval(f2) == "A"
Exemplo n.º 16
0
def test():
    assert dds.eval(fun) == "a"
Exemplo n.º 17
0
def test_sklearn():
    """ Unauthorized objects are not taken into account """
    dds.eval(pipeline)
    dds.eval(pipeline)
Exemplo n.º 18
0
def test_8():
    """ Using various objects does not cause an error """
    assert dds.eval(fun_8_f1) is None
Exemplo n.º 19
0
def test_exec_then_eval():
    _c2a.value = 0
    _c2b.value = 0
    f2a()
    assert dds.eval(f2b) == "a11"
Exemplo n.º 20
0
def test_kargs_2():
    assert dds.eval(f2_1) == 3
    assert dds.eval(f2_2) == 3
Exemplo n.º 21
0
def test_gh140_biglists():
    """ Using big objects throws an error """
    # TODO: more comprehensive test on lists. They are still seen as external dependencies
    with pytest.raises(dds.DDSException) as e:
        dds.eval(fun_9)
    assert e.value.error_code == dds.structures.DDSErrorCode.SEQUENCE_TOO_LONG
Exemplo n.º 22
0
def test_1():
    """ Unauthorized objects do not trigger errors """
    assert dds.eval(fun_1_f1) is None
Exemplo n.º 23
0
def test_arrays():
    assert len(dds.eval(f6)) == 0
Exemplo n.º 24
0
                                                        y,
                                                        test_size=0.2,
                                                        random_state=42)

    clf = dds.keep("/wine-quality/my_model", build_model, X_train, y_train)

    stats = dds.keep("/wine-quality/my_model_stats.json", model_stats, clf,
                     X_test, y_test)

    print("*** done ***")
    return stats


dds.codecs.databricks.displayGraph(pipeline)

# COMMAND ----------

dds.eval(pipeline)

# COMMAND ----------

# MAGIC %md ## Load Artifacts from DDS

# COMMAND ----------

dds.load("/wine-quality/my_model")

# COMMAND ----------

dds.load("/wine-quality/my_model_stats.json")
Exemplo n.º 25
0
def test_4():
    assert dds.eval(f4_wrap) == "A12"
Exemplo n.º 26
0
def test():
    dds.eval(fun)
    assert _c.value == 1
Exemplo n.º 27
0
def test_5():
    assert dds.eval(f5_wrap) == "0"
    u.unreachable_var = 1
    assert dds.eval(f5_wrap) == "0"
Exemplo n.º 28
0
def test_gh131():
    with pytest.raises(DDSException) as e:
        eval(f)
    assert e.value.error_code == DDSErrorCode.OVERLAPPING_PATH
Exemplo n.º 29
0
def test_compare():
    assert dds.eval(f_compare) == "True"
Exemplo n.º 30
0
def test_kargs_1():
    assert dds.eval(f1_1) == 6
    assert dds.eval(f1_2) == 6