-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul configuration file parsing #246
Conversation
- Use a new custom parser class `SKLLConfigParser` based on `ConfigParser`. - Move all of the configuration parsing code to `config.py` and out of `experiments.py`. - Add a `validate()` method to the config parser that raises a KeyError if: - unrecognized options are specified - options are specified in more than one section - options are specified in the wrong section - Add unit tests for the above validation checks - Update test files to deal with the above changes - Update `requirements_rtd.txt` to install the latest version of `ConfigParser` (v3.5.0b2)
…onfig-parsing Conflicts: skll/experiments.py tests/test_classification.py tests/utils.py
@dan-blanchard please do look at this one too since it's a somewhat major change. |
train_dir = join(_my_dir, 'train') | ||
output_dir = join(_my_dir, 'output') | ||
|
||
# make a simple config file that has an invalid option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: comment should be updated to reflect that the problem with this config is that there is a duplicate key (that comes from the fill_in_config_options method)
This looks good to me, I didn't spot anything obvious that might cause problems. |
I did a little PEP8 clean up here and there, but otherwise this looks great! 👍 |
Thanks, Dan! I will address Aoife's comment and merge soon as the build passes. |
I fixed the later comments to reflect the names of the functions, but I guess I missed that one. |
Sweet! Thanks for that! Actually, I just realized I didn't address #213 in this PR. Do you think that's important for this new release? |
It would be nice to have fixed for this release, since we know it's bitten some new users when trying to follow the tutorial. |
Okay, I will add that to this PR then and try to add some tests for it too. |
|
1 similar comment
|
- Get the absolute path of the config file right at the start. - Look for and create all files/paths relative to the (absolute) config file path. - Add two new unit tests. - Fix an issue with how the default value of `class_map` was being handled due to the updated defaults.
@dan-blanchard and @aoifecahill, can you please take a look again? I just committed some changes to address #213. |
|
|
|
||
# get all the input paths and directories (without trailing slashes) | ||
train_path = config.get("Input", "train_directory").rstrip('/') | ||
test_path = config.get("Input", "test_directory").rstrip('/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been in there since the beginning so I guess it has never worked?
- Replace `abspath()` with `realpath()` when getting the full path of the config file. - Strip out `os.sep` instead of slashes from the end of paths.
|
I replaced the |
|
||
def test_config_parsing_relative_input_path(): | ||
|
||
train_dir = '../train' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be:
train_dir = join('..', 'train')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good call.
So, is this okay to be merged once I address your last comment? |
Definitely.
|
…ul-config-parsing Overhaul configuration file parsing
SKLLConfigParser
based onConfigParser
.config.py
and out ofexperiments.py
.validate()
method to the config parser that raises aKeyError
if:requirements_rtd.txt
to install the latest version ofConfigParser
(v3.5.0b2)