Skip to content
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

Merged
merged 7 commits into from
Jul 18, 2015

Conversation

desilinguist
Copy link
Member

  • 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:
  • Add unit tests for the above validation checks
  • Update tests to deal with the above changes
  • Update requirements_rtd.txt to install the latest version of ConfigParser (v3.5.0b2)

- 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
@desilinguist
Copy link
Member Author

@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
Copy link
Collaborator

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)

@aoifecahill
Copy link
Collaborator

This looks good to me, I didn't spot anything obvious that might cause problems.

@dan-blanchard
Copy link
Contributor

I did a little PEP8 clean up here and there, but otherwise this looks great! 👍

@desilinguist
Copy link
Member Author

Thanks, Dan! I will address Aoife's comment and merge soon as the build passes.

@dan-blanchard
Copy link
Contributor

I fixed the later comments to reflect the names of the functions, but I guess I missed that one.

@desilinguist
Copy link
Member Author

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?

@dan-blanchard
Copy link
Contributor

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.

@desilinguist
Copy link
Member Author

Okay, I will add that to this PR then and try to add some tests for it too.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.13% when pulling 653fc44 on feature/overhaul-config-parsing into 2ad3b65 on master.

1 similar comment
@landscape-bot
Copy link

Code Health
Repository health increased by 0.13% when pulling 653fc44 on feature/overhaul-config-parsing into 2ad3b65 on master.

- 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.
@desilinguist
Copy link
Member Author

@dan-blanchard and @aoifecahill, can you please take a look again? I just committed some changes to address #213.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.16% when pulling e508977 on feature/overhaul-config-parsing into 2ad3b65 on master.

@landscape-bot
Copy link

Code Health
Repository health increased by 0.16% when pulling 3a08303 on feature/overhaul-config-parsing into 2ad3b65 on master.


# 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('/')
Copy link
Contributor

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.

Copy link
Member Author

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.
@landscape-bot
Copy link

Code Health
Repository health increased by 0.16% when pulling aa2c341 on feature/overhaul-config-parsing into 2ad3b65 on master.

@desilinguist
Copy link
Member Author

I replaced the / with os.sep which should work on Windows too.


def test_config_parsing_relative_input_path():

train_dir = '../train'
Copy link
Contributor

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')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call.

@desilinguist
Copy link
Member Author

So, is this okay to be merged once I address your last comment?

@dan-blanchard
Copy link
Contributor

Definitely.
On Sat, Jul 18, 2015 at 10:39 AM Nitin Madnani notifications@github.com
wrote:

So, is this okay to be merged once I address your last comment?


Reply to this email directly or view it on GitHub
#246 (comment)
.

desilinguist added a commit that referenced this pull request Jul 18, 2015
…ul-config-parsing

Overhaul configuration file parsing
@desilinguist desilinguist merged commit 1ecd54a into master Jul 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants