def test_set_script_from_file(use_cluster):
    sent_script = read_script_from_file()
    c = Client(None, use_cluster)
    c.set_script_from_file(
        "test-script-file", osp.join(file_path, "./data_processing_script.txt")
    )
    returned_script = c.get_script("test-script-file")
    assert sent_script == returned_script
Example #2
0
def setup_resnet(model, device, batch_size, address, cluster=True):
    """Set and configure the PyTorch resnet50 model for inference

    :param model: path to serialized resnet model
    :type model: str
    :param device: CPU or GPU
    :type device: str
    :param batch_size: batch size for the Orchestrator (batches of batches)
    :type batch_size: int
    :param cluster: true if using a cluster orchestrator
    :type cluster: bool
    """
    client = Client(address=address, cluster=cluster)
    client.set_model_from_file("resnet_model", model, "TORCH", device,
                               batch_size)
    client.set_script_from_file("resnet_script",
                                "../imagenet/data_processing_script.txt",
                                device)
import os.path as osp
from smartredis import Client

# Construct a string holding the script file location
file_path = osp.dirname(osp.abspath(__file__))
script_path = osp.join(file_path, "./data_processing_script.txt")

# Connect to the Redis database
db_address = "127.0.0.1:6379"
client = Client(address=db_address, cluster=False)

# Place the script in the database
client.set_script_from_file(
    "test-script-file", osp.join(file_path, "./data_processing_script.txt")
)
Example #4
0
def test_bad_script_file(use_cluster):
    c = Client(None, use_cluster)
    with pytest.raises(FileNotFoundError):
        c.set_script_from_file("key", "not-a-file")