Skip to content

h.set_config(..., ..., over_write=True) #821

@drewoldag

Description

@drewoldag

Feature request
The set_config Hyrax method is explicitly meant to merge the new setting into the existing settings. Most of the time this is exactly what you want to do.

However, there are times, such as when setting the data_request, that it's not useful to merge the config, instead it would be more useful to simply overwrite it.

Here's the current behavior:

data_request = {'train': 'data_0': {...}}
h.set_config('data_request', data_request)

print(h.config['data_request'])
>> data_request{ train{ 

data_request = {'train': 'data_1': {...}}
h.set_config('data_request', data_request)

print(h.config['data_request'])
>> data_request{ train{ data_0 { ... }, data_1 { ... } } }

The expectation would be that train would contain only data_1 at the end of the process, but we see that data_1 and been merged into train data_group.

Thus I propose that we could implement a over_write flag in set_config.

def set_config(dotted_string: str, new_value: any, over_write=False)

When over_write==True the value at dotted_string in the config is completely replaced by the new_value. If over_write==False then we use the current logic.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions