kd.konfig.ref_copy#
- kauldron.konfig.ref_copy(
- cfg: kauldron.konfig.ref_utils._T,
One-way recursive copy of the
ConfigDict.Usage:
train_ds = konfig.ConfigDict(dict( src=dict( name='mnist', split='train', ), shuffle=True, batch_size=32, )) test_ds = konfig.ref_copy(train_ds) # Updating the copy won't update `train_ds` test_ds.src.split = 'test' test_ds.shuffle = False # Updating the original config update the ref_copy train_ds.batch_size = 128 assert test_ds.batch_size == 128
Caveat: If the original dict is updated after being copied, only the existing non-dict attributes will be propagated to the copy.
# New attribute train_ds.new_attribute = 123 assert not hasattr(test_ds, 'new_attribute') # Overwritte dict train_ds.src = dict( name='imagenet', split='train', ) assert test_ds.src.name == 'mnist'
- Parameters:
cfg – The dict to recursivelly copy
- Returns:
The copied config.