Skip to content

add base class#18

Merged
mmaelicke merged 6 commits intomainfrom
add-config-manager
Mar 1, 2022
Merged

add base class#18
mmaelicke merged 6 commits intomainfrom
add-config-manager

Conversation

@mmaelicke
Copy link
Member

@mmaelicke mmaelicke commented Feb 23, 2022

The Config class is the first of two base classes to handle configuration and data in a more flexible way. The Config is based on the collections.Mapping, which makes it iterable and similar to a dict. It is populated with default values, which are also accessible through class attributes, and can take an arbitrary amount of settings.

Example

from ruins import core

# create default config
conf = core.Config()

It is also possible to load a config form a JSON file. This will not necessarily be needed in this app, but might turn out helpful in future developments

conf = core.Config(path='/path/to/json')

For both cases existing configuration can be overwritten and any kwarg can be added.

conf = core.Config(debug=True, foo='bar')

print(conf.debug)   # True
print(conf['foo'])     # bar

This PR closes #11

@mmaelicke mmaelicke added this to the Implement data storage API milestone Feb 23, 2022
@mmaelicke mmaelicke requested a review from AlexDo1 February 23, 2022 06:24
@mmaelicke mmaelicke self-assigned this Feb 23, 2022
Using pip install in editable mode in CI config
@codecov
Copy link

codecov bot commented Feb 24, 2022

Codecov Report

Merging #18 (8b8660c) into main (2e20f1a) will increase coverage by 7.92%.
The diff coverage is 96.87%.

Impacted file tree graph

@@           Coverage Diff            @@
##            main     #18      +/-   ##
========================================
+ Coverage   0.00%   7.92%   +7.92%     
========================================
  Files          3       4       +1     
  Lines        359     391      +32     
========================================
+ Hits           0      31      +31     
- Misses       359     360       +1     
Impacted Files Coverage Δ
ruins/core/config.py 96.87% <96.87%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2e20f1a...8b8660c. Read the comment docs.

@mmaelicke mmaelicke requested a review from lucfr February 25, 2022 05:28
@mmaelicke mmaelicke mentioned this pull request Feb 25, 2022
@mmaelicke mmaelicke merged commit 4625216 into main Mar 1, 2022
@mmaelicke mmaelicke deleted the add-config-manager branch March 1, 2022 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

create basic config class

3 participants