Esempio n. 1
0
def test___init__():
    hook = sy.TorchHook(torch)

    tensor = torch.tensor([1, 2, 3, 4])

    worker_id = int(10e10 * random.random())
    alice_id = f"alice{worker_id}"
    alice = VirtualWorker(hook, id=alice_id)
    worker_id = int(10e10 * random.random())
    bob = VirtualWorker(hook, id=f"bob{worker_id}")
    worker_id = int(10e10 * random.random())
    charlie = VirtualWorker(hook, id=f"charlie{worker_id}")
    worker_id = int(10e10 * random.random())
    dawson = VirtualWorker(hook, id=f"dawson{worker_id}", data=[tensor])

    # Ensure adding data on signup functionality works as expected
    assert tensor.owner == dawson

    assert bob.get_worker(alice_id).id == alice.id
    assert bob.get_worker(alice).id == alice.id
    assert bob.get_worker(charlie).id == charlie.id

    bob.get_worker("the_unknown_worker")

    bob.add_worker(alice)
Esempio n. 2
0
def test___init__():
    hook = sy.TorchHook(torch)

    alice = VirtualWorker(hook, id="alice")
    bob = VirtualWorker(hook, id="bob", known_workers={alice.id: alice})
    charlie = VirtualWorker(hook, id="charlie")

    assert bob.get_worker("alice").id == alice.id
    assert bob.get_worker(alice).id == alice.id
    assert bob.get_worker(charlie).id == charlie.id

    bob.get_worker("the_unknown_worker")

    bob.add_worker(alice)
Esempio n. 3
0
def test___init__():
    hook = sy.TorchHook(torch)

    tensor = torch.tensor([1, 2, 3, 4])

    alice = VirtualWorker(hook, id="alice")
    bob = VirtualWorker(hook, id="bob")
    charlie = VirtualWorker(hook, id="charlie")
    dawson = VirtualWorker(hook, id="dawson", data=[tensor])

    # Ensure adding data on signup functionality works as expected
    assert tensor.owner == dawson

    assert bob.get_worker("alice").id == alice.id
    assert bob.get_worker(alice).id == alice.id
    assert bob.get_worker(charlie).id == charlie.id

    bob.get_worker("the_unknown_worker")

    bob.add_worker(alice)