import pickle
import os 

def load_client_profile(file_path):
    # load client profiles
    global_client_profile = {}
    if os.path.exists(file_path):
        with open(file_path, 'rb') as fin:
            # {clientId: [computer, bandwidth]}
            global_client_profile = pickle.load(fin)
    return global_client_profile

if __name__ == "__main__":
    device_conf_file = "/home/xschen/workspace/fd_learning/dataset/data/device_info/client_device_capacity"
    #device_conf_file = "/home/xschen/workspace/fd_learning/dataset/data/device_info/client_behave_trace"
    client_profiles = load_client_profile(file_path=device_conf_file)
    print(client_profiles)
    if client_profiles:
        first_profile = next(iter(client_profiles.items()))
        print(first_profile)