vineetbansal / wbi

0 stars 0 forks source link

Configuration driven off a yaml file #5

Closed vineetbansal closed 11 months ago

vineetbansal commented 11 months ago

For a large project like this, we're going to be using "magical" numbers and configuration settings all over place. Instead of spreading around these values across our code, something like a config.yaml file will allow us to collect all of these in one place, and allow us to use (as a made up example), config.flash_finder.interval in our code if we need to access it.

The contained unit tests show how to use this.

I've used .ini, .json files etc. over the years, but realized that .yaml is the best in terms of flexibility - arbitrarily nested structures, lists etc, along with comments (json doesn't have support for comments so it's a big pain).

This also shows how to use importlib_resources to access data files that we package with our code.

This PR will likely fail because config.yaml is not being packaged with our code. If you can fix this, that would be great.

vineetbansal commented 11 months ago

I'm curious why the CI didn't fail since we're not packaging up config.yaml in our package afaik. Maybe I'm missing something here..

anushka255 commented 11 months ago

I was trying to make sense of what you said about the config.yaml file not being packaged too. Cause you put it in src/wbi folder. Did you mean something else by it?

vineetbansal commented 11 months ago

I meant that when we went through the exercise of how to include arbitrary files in your package when doing a pip install, in this case:

[tool.setuptools.package-data]
wbi = ["data/*"]

There's nothing here that tells setuptools that config.yaml needs to be included. Yet it needs to be (since all wbi configuration would go in there) and it seems to be (since tests are passing), so I'm wondering why it's being included without us specifying it, or maybe somehow we're not testing the functionality against the installed version of wbi.