# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Automatic Data Access Management 
#    In this tutorial we'll explore how to use User role to request data access from domain server.

# ### 1 - Import libraries

# +
from syft.grid.grid_client import connect
from syft.grid.connections.http_connection import HTTPConnection
from syft.core.node.domain.client import DomainClient

import syft as sy
import torch as th

sy.VERBOSE = False
# -

# ### 2 - Connect/Authenticate with the Domain server (Using User account)
# Now, we'll be connecting with the domain server as a user

client = connect(
    url="http://localhost:5000", # Domain Address
    credentials= {"email": "<EMAIL>", "password": "<PASSWORD>"}, # User Account
    conn_type= HTTPConnection, # HTTP Connection Protocol
    client_type=DomainClient) # Domain Client type

# ## 3 - Check the hosted/visible datasets to me

client.store.pandas

# ### 4 - Send our first data access request (Without success)

if len(client.store) > 0:
    t = client.store[0].get(
        request_block=True,
        timeout_secs=15,
        request_name="age_data",
        reason="I want to see the age data",
        delete_obj=False
    )
    sy.logger.critical("Finished requesting")

# ### 5 - Send it again (Success)

if len(client.store) > 0:
    t = client.store[0].get(
        request_block=True,
        timeout_secs=15,
        request_name="age_data",
        reason="I want to see the age data",
        delete_obj=False
    )
    sy.logger.critical("Finished requesting")

StarcoderdataJupyterScriptsDedupFiltered