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 tox configuration #4355

Merged
merged 5 commits into from
Sep 9, 2020
Merged

Conversation

chrisjsewell
Copy link
Member

Surprised no one has looked to add this before.
tox is a ubiquitous test automation tool,
simply pip/conda install tox then run e.g. tox -- tests/tools/groups/test_paths.py and it will set up your test environment (or re-use the cached one) and run pytest.
Massively helpful when you are working across multiple repositories with different test environments!

Want to run against a different python version / backend? tox -e py38-sqla -- tests/tools/groups/test_paths.py
Want to test the docs? tox -e docs-clean or tox -e docs-update

@codecov
Copy link

codecov bot commented Sep 4, 2020

Codecov Report

Merging #4355 into develop will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #4355   +/-   ##
========================================
  Coverage    79.32%   79.32%           
========================================
  Files          468      468           
  Lines        34713    34713           
========================================
  Hits         27533    27533           
  Misses        7180     7180           
Flag Coverage Δ
#django 72.94% <ø> (+0.01%) ⬆️
#sqlalchemy 72.15% <ø> (-<0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0094f70...60a9a6e. Read the comment docs.

@sphuber
Copy link
Contributor

sphuber commented Sep 4, 2020

The utils.dependency_management.generate_pyproject_toml is giving you shit here ;) It assumed that the [build-system] is the only key in our pyproject.toml and will regenerate it from scratch, thereby deleting your added tox config. You will have to adapt that function to at worst recreate the [build-system] section.

On another note, is that literal string syntax currently the only way that tox can be configured through the pyproject.toml? 🤮

Edit: found that they are considering it, but it is not on the list of priorities

@greschd
Copy link
Member

greschd commented Sep 4, 2020

Tagging @csadorf, guess it's time to pick this discussion back up.

@chrisjsewell
Copy link
Member Author

Edit: found that they are considering it

yeh but hey at least it can go in there 🤷

assumed that the [build-system] is the only key in our pyproject.toml and will regenerate it from scratch

what is this madness lol, maybe it would just be better to just check that it is consistent with setup.json in the pre-commit rather than rebuilding

Alternatively, for now, I could add a tox.ini and move the contents of pytest.ini into it; keeping the same net number of files 😉

@sphuber
Copy link
Contributor

sphuber commented Sep 4, 2020

what is this madness lol, maybe it would just be better to just check that it is consistent with setup.json in the pre-commit rather than rebuilding

Alternatively, for now, I could add a tox.ini and move the contents of pytest.ini into it; keeping the same net number of files wink

Nonono, in the long run we definitely want to start relying more heavily on pyproject.toml (in my opinion) and so anyway we will have to address the fact that it is plainly overwritten now. No point in pushing this further down the line.

@chrisjsewell
Copy link
Member Author

Yeh was just trying to lazy lol.
FYI, I've been working quite closely with the main maintainer of pip recently (pradyunsg, who added all the new resolver stuff).
He's pretty big on pyproject.toml, and also https://flit.readthedocs.io for packaging
https://flit.readthedocs.io/ (not that I expect aiida-core to use it, but worth a look if you're interested)

@csadorf
Copy link
Contributor

csadorf commented Sep 4, 2020

what is this madness lol, maybe it would just be better to just check that it is consistent with setup.json in the pre-commit rather than rebuilding

It is likely possibly to improve the logic, but I also have only so much time to spend on these things. Feel free to create a PR with an improved logic, the validator function is already implemented.

Concerning tox, I moved away from it in the vast majority of my projects, because I had more trouble with it then gaining from it. But if it works well here, I see no reason why not to include it.

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Sep 4, 2020

because I had more trouble with it then gaining from it. But if it works well here, I see no reason why not to include it.

Interesting, I've being using it on about 10 different projects, including aiida-core, and it's worked like a charm
(in particular using with the tox-conda plugin)

@csadorf
Copy link
Contributor

csadorf commented Sep 4, 2020

because I had more trouble with it then gaining from it. But if it works well here, I see no reason why not to include it.

Interesting, I've being using it on about 10 different projects, including aiida-core, and it's worked like a charm
(in particular using with the tox-conda plugin)

It's been a few years since I touched it so possible that it improved or maybe I didn't use it right or maybe there was some other reason that it didn't fit and I decided to abandon it. So, just to emphasize: no qualms with applying it here if it works well. 👍

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Sep 4, 2020

It's been a few years ... so possible that it improved

yeh quite possibly, I only "discovered" it recently and am now wondering how I lived without it lol

Ok well I will try to make the pre-commit fix here

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Sep 9, 2020

Ok well I will try to make the pre-commit fix here

All done.
As you'll see, I've moved from toml to tomlkit for read/write of pyproject.toml. This is because it preserves formatting and comments, which toml does not (uiri/toml#77).

@@ -161,37 +161,43 @@ def generate_environment_yml():


@cli.command()
def generate_pyproject_toml():
def update_pyproject_toml():
"""Generate 'pyproject.toml' file."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adjust the doc-string as well to reflect the change in function.

utils/dependency_management.py Outdated Show resolved Hide resolved
@chrisjsewell chrisjsewell requested a review from csadorf September 9, 2020 12:16
csadorf
csadorf previously approved these changes Sep 9, 2020
Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

Thx a lot!

@chrisjsewell chrisjsewell merged commit 759d666 into aiidateam:develop Sep 9, 2020
@chrisjsewell chrisjsewell deleted the add-tox branch September 9, 2020 14:11
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