core

Basic utilities

Base Variables

BASE_URL
'https://fed-ledger-prod.flock.io/api/v1/'

Health Check


source

check_flock

 check_flock ()
check_flock()
True

GPU Info


source

get_gpu_info

 get_gpu_info ()
gpu_info = get_gpu_info()
assert isinstance(gpu_info, AttrDict)
test_eq(gpu_info.gpu_count, 0)
test_eq(gpu_info.cuda_available, False)
gpu_info
{'cuda_available': False, 'gpu_count': 0}

JSON -> DataFrame

We can convert one-level nested JSON object with pd.json_normalize.


source

pd_parse

 pd_parse (d)
df = pd_parse({"Feature 1": {"sub": "Hey", "sub2": "You"}, "Feature 2": {"sub": "Hey", "sub2": "You"}})
df
Feature 1_sub Feature 1_sub2 Feature 2_sub Feature 2_sub2
0 Hey You Hey You
test_eq(df.columns.tolist(), ["Feature 1_sub", "Feature 1_sub2", "Feature 2_sub", "Feature 2_sub2"])
test_eq(df.iloc[0]["Feature 1_sub2"], "You")