def test_yaml_server_loading(): file_path = "yaml/konduit.yaml" server = server_from_file(file_path) try: running_server = server_from_file(file_path, start_server=True) finally: running_server.stop()
def test_word_tokenizer_serving_from_file(): file_path = "yaml/konduit_word_tokenizer_minimal.yaml" server = server_from_file(file_path) try: running_server = server_from_file(file_path, start_server=True) finally: running_server.stop()
def test_wordpiece_tokenizer_serving_two_steps(): file_path = "yaml/konduit_wordpiece_tokenizer_two_steps.yaml" server = server_from_file(file_path) try: running_server = server_from_file(file_path, start_server=True) finally: running_server.stop()
def test_tensor_flow_serving(): file_path = "yaml/konduit_tensorflow.yaml" try: server = server_from_file(file_path=file_path) finally: server.stop() del server
def test_dl4j_samediff_serving(): file_path = "yaml/konduit_samediff.yaml" try: server = server_from_file(file_path=file_path) finally: server.stop() del server
def test_tf_simple_serving(): file_path = "yaml/konduit_tf_simple.yaml" try: server = server_from_file(file_path=file_path) finally: server.stop() del server
def test_json_minimal_loading(): file_path = "yaml/konduit_minimal.json" try: server = server_from_file(file_path, use_yaml=False, start_server=True) client = client_from_file(file_path, use_yaml=False) finally: server.stop() del server, client
def serve(config, start_server): """Serve a pipeline from a konduit configuration""" from konduit.load import store_pid from konduit.load import server_from_file server = server_from_file(file_path=config, start_server=start_server) store_pid(config, server.process.pid) logging.info(">>> Started a Konduit server with PID " + str(server.process.pid))
def test_yaml_server_python_prediction(): try: konduit_yaml_path = "yaml/konduit_tf_inference.yaml" img = np.load("../data/input_layer.npy") server = server_from_file(konduit_yaml_path, start_server=True) client = client_from_file(konduit_yaml_path) predicted = client.predict(data_input={"input_layer": img}) result = dict(zip(np.arange(10), predicted[0].round(3))) # {0: 0.0, 1: 0.0, 2: 0.001, 3: 0.001, 4: 0.0, 5: 0.0, 6: 0.0, 7: 0.998, 8: 0.0, 9: 0.0} assert round(result.get(7) * 1000) == 998 server.stop() finally: server.stop()
def test_pid_creation_removal(): file_path = "yaml/konduit.yaml" running_server = server_from_file(file_path, start_server=True) # store the pid of this server and forget the Python object pid = running_server.process.pid store_pid(file_path=file_path, pid=running_server.process.pid) del running_server # retrieve the pid internally and kill the process recov_pid = pop_pid(file_path=file_path) assert pid == recov_pid stop_server_by_pid(recov_pid)
def test_tensor_flow_serving(): file_path = "yaml/konduit_tensorflow.yaml" server = server_from_file(file_path=file_path) del server
def test_dl4j_samediff_serving(): file_path = "yaml/konduit_samediff.yaml" server = server_from_file(file_path=file_path) del server
def test_dl4j_cg_serving(): file_path = "yaml/konduit_dl4j_cg.yaml" server = server_from_file(file_path=file_path) del server
def test_tf_simple_serving(): file_path = "yaml/konduit_tf_simple.yaml" server = server_from_file(file_path=file_path) del server
def test_keras_serving(): file_path = "yaml/konduit_keras.yaml" server = server_from_file(file_path=file_path) del server
def test_yaml_minimal_loading(): file_path = "yaml/konduit_minimal.yaml" server = server_from_file(file_path, use_yaml=True, start_server=True) client = client_from_file(file_path, use_yaml=True) del server, client