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

add cli options for config file management #33

Merged
merged 16 commits into from
Apr 1, 2020

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Mar 18, 2020

fixes #30
fixes #8
fixes #13

Add cli option:

--testing-config-action: Read config file if present ('read'), require config file ('require') or generate new config file ('generate').
--regenerate-test-data: Regenerate test data

A few things left to do:

  • add docs
  • use type hints more?

@ltalirz ltalirz changed the title add cli options for config file management [WIP] add cli options for config file management Mar 18, 2020
Add cli option:

  --require-aiida-testing-config: raise exception, if
testing configuration is not found or if required code labels are
missing.
  --write-aiida-testing-config: write template of config file to disk
that contains labels of required codes.
@ltalirz ltalirz changed the title [WIP] add cli options for config file management add cli options for config file management Mar 30, 2020
@ltalirz ltalirz requested a review from greschd March 30, 2020 00:30
@ltalirz
Copy link
Member Author

ltalirz commented Mar 30, 2020

Just to point out that some strange stuff was going on with github actions (see e.g. the ci results of "add test for regeneration of test data").

Also, on my computer, the 4 tests that involve running the CalcJob fail with error messages

$ cd tests; pytest

...

    def check_diff_output(result):
        """
        Checks the result from a diff calculation against a reference.
        """
        diff_res_lines = tuple([
            line.strip() for line in result['diff'].get_content().splitlines() if line.strip()
        ])
>       assert diff_res_lines == (
            "1,2c1", "< Lorem ipsum dolor..", "<", "---",
            "> Please report to the ministry of silly walks."
        )
E       AssertionError: assert () == ('1,2c1', '< ...silly walks.')
E         Right contains 5 more items, first extra item: '1,2c1'
E         Use -v to get the full diff

(i.e. check_diff is empty for those). Haven't figured out why yet.

Make sure path to data directory exists and is absolute.
This fixes my local tests.
@ltalirz
Copy link
Member Author

ltalirz commented Mar 31, 2020

This seems to have been fixed by requiring the data directory to be an absolute path.

Paths may contain spaces etc.
@greschd greschd self-assigned this Mar 31, 2020
 + remove leftover comment
@ltalirz ltalirz requested a review from greschd March 31, 2020 11:58
Copy link
Member

@greschd greschd left a comment

Choose a reason for hiding this comment

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

Very nice, thanks! I've added a few minor comments.

For regenerating the data, I think the "export cache" feature will need a similar flag, but they should probably be independent: Maybe we should rename --regenerate-test-data to something like --regenerate-mock-code-data, to distinguish them?

aiida_testing/_config.py Outdated Show resolved Hide resolved
aiida_testing/mock_code/_fixtures.py Show resolved Hide resolved
):
ignore_files: ty.Iterable[str] = ('_aiidasubmit.sh'),
executable_name: str = '',
config: dict = testing_config,
Copy link
Member

Choose a reason for hiding this comment

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

Are config, config_action and regenerate_test_data here passed just for being able to test the fixture internally, or do we expect users to set them?

I'm not really sure if there's an established convention for that, but maybe we could indicate this by a leading underscore in the kwarg names (_config, _config_action, _regenerate_test_data)?

Copy link
Member Author

Choose a reason for hiding this comment

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

done!

config_action :
If 'require', raise ValueError if config dictionary does not specify path of executable.
If 'generate', add new key (label) to config dictionary.
generate_config :
Copy link
Member

Choose a reason for hiding this comment

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

The generate_config parameter doesn't exist, and regenerate_test_data is missing in the docstring.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, fixed!

@ltalirz ltalirz requested a review from greschd April 1, 2020 10:51
greschd
greschd previously approved these changes Apr 1, 2020
Copy link
Member

@greschd greschd left a comment

Choose a reason for hiding this comment

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

Thanks! Do you want to create a new issue for the "add docs" part?

@ltalirz
Copy link
Member Author

ltalirz commented Apr 1, 2020

happy to add them in here, now that we've agreed on the names

@ltalirz ltalirz merged commit bea61f0 into aiidateam:develop Apr 1, 2020
@greschd
Copy link
Member

greschd commented Apr 1, 2020

fixes #30
fixes #8
fixes #13

Drei auf einen Streich! Nice 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants