Allow setting defaults through a config file.#279
Allow setting defaults through a config file.#279sunu wants to merge 7 commits intoscrapinghub:masterfrom
Conversation
Current coverage is
|
|
Hey @sunu, Thanks for the PR! There are some design decisions to make:
|
Yes, this makes a lot of sense. I just went for yaml because I find it somewhat more readable. Using ini files makes sense if we're already using them.
Good to know. Thanks. Will remember to use safe_load with yaml from now on.
How is this implemented? Should we hard-code the possible standard locations?
OK. Will add an option for that. |
|
What I wanted to ask earlier is that in this implementation we essentially read the config file every time settings is imported. So doesn't that count as blocking code? Or does it not matter because of the relatively small size? |
|
Hey @sunu!
Yes.
For config files it makes more sense to read them once and then return results from memory. Blocking doesn't matter because it is very quick to read a config file, and because it is usually read at startup when Splash is not serving requests yet. True non-blocking reads from disk are rarely used because usually you can't make reads from disk more efficient by sending several read requests in parallel. |
Also * Look for config files in some standard locations. * Add option to specify config file location at startup.
…onfigfile Conflicts: splash/render_options.py splash/server.py
|
Hello @kmike Also, should the config keys be case insensitive? I've overridden the default behavior to make them case sensitive, but let me know what the expected behavior is. |
|
Hey @sunu, I think using |
|
Hey @kmike, |
There was a problem hiding this comment.
this looks brittle.. It will require changing more code, but maybe we can make this path a Settings constructor parameter and don't create a global settings variable at module level? We can create it in server startup code (when the path is known) and pass it down to all components via function/method/constructor arguments instead.
Partly addresses #146