Skip to content

chore: implement yaml settings inheritance#618

Merged
jansegre merged 8 commits intomasterfrom
chore/yaml-inheritance
May 24, 2023
Merged

chore: implement yaml settings inheritance#618
jansegre merged 8 commits intomasterfrom
chore/yaml-inheritance

Conversation

@glevco
Copy link
Contributor

@glevco glevco commented May 19, 2023

Acceptance Criteria

  • Implement new deep_merge() dict utils function
  • Implement new validated_named_tuple_from_dict() utils function
  • Implement new dict_from_extended_yaml() utils function, allowing parsing of extensible yaml files
  • Improve dict_from_yaml() utils function, adding error handling
  • Update HathorSettings parsing to use new utils functions

This change resolves #614. Now, yaml settings support an inheritance mechanism that can be used to create custom configurations by changing just a subset of settings attributes.

For example, in the hathor/conf/my_network.yml file:

extends: mainnet.yml

NETWORK_NAME: my_network

Then, if this file is set in --config-yaml or HATHOR_CONFIG_YAML, settings would behave exactly like mainnet settings, and only the NETWORK_NAME would be changed. Changing specific nested attributes is also supported.

Both relative and absolute file paths are supported (relative from the yaml file location, or from a custom root if the custom_root arg is set).

@glevco glevco requested a review from jansegre as a code owner May 19, 2023 04:58
@glevco glevco self-assigned this May 19, 2023
@glevco glevco requested a review from msbrogli as a code owner May 19, 2023 04:58
@codecov
Copy link

codecov bot commented May 19, 2023

Codecov Report

Merging #618 (17eacb2) into master (d7508e0) will increase coverage by 0.14%.
The diff coverage is 97.51%.

❗ Current head 17eacb2 differs from pull request most recent head 688c29b. Consider uploading reports for the commit 688c29b to get more accurate results

@@            Coverage Diff             @@
##           master     #618      +/-   ##
==========================================
+ Coverage   83.63%   83.78%   +0.14%     
==========================================
  Files         232      238       +6     
  Lines       19826    19990     +164     
  Branches     2714     2735      +21     
==========================================
+ Hits        16582    16749     +167     
+ Misses       2644     2642       -2     
+ Partials      600      599       -1     
Impacted Files Coverage Δ
hathor/manager.py 70.60% <0.00%> (-0.05%) ⬇️
hathor/builder/cli_builder.py 70.27% <40.00%> (-0.16%) ⬇️
hathor/conf/settings.py 97.05% <93.33%> (-0.05%) ⬇️
hathor/event/event_manager.py 90.74% <100.00%> (ø)
hathor/event/model/event_data.py 100.00% <100.00%> (ø)
hathor/event/storage/event_storage.py 100.00% <100.00%> (ø)
hathor/event/storage/memory_storage.py 100.00% <100.00%> (ø)
hathor/event/storage/rocksdb_storage.py 94.18% <100.00%> (+0.28%) ⬆️
hathor/event/websocket/request.py 100.00% <100.00%> (ø)
hathor/exception.py 100.00% <100.00%> (ø)
... and 8 more

... and 2 files with indirect coverage changes

@glevco glevco force-pushed the chore/yaml-inheritance branch from 32b1a34 to 5533c70 Compare May 19, 2023 14:55
@glevco glevco requested a review from msbrogli May 19, 2023 14:56
msbrogli
msbrogli previously approved these changes May 19, 2023
@glevco glevco force-pushed the chore/yaml-inheritance branch from 5533c70 to 7abde54 Compare May 19, 2023 19:14
@glevco glevco requested a review from msbrogli May 19, 2023 19:14
@glevco glevco force-pushed the chore/yaml-inheritance branch 2 times, most recently from 9a41c03 to 0bd2a67 Compare May 23, 2023 20:03
@glevco glevco requested a review from jansegre May 23, 2023 20:03
jansegre
jansegre previously approved these changes May 23, 2023
@glevco glevco force-pushed the chore/yaml-inheritance branch from 17eacb2 to 688c29b Compare May 24, 2023 14:43
@jansegre jansegre merged commit 9f30280 into master May 24, 2023
@jansegre jansegre deleted the chore/yaml-inheritance branch May 24, 2023 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Implement a inherit mechanism for yaml settings

3 participants