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

Remove all files from the pre-commit exclude list #4196

Merged
merged 1 commit into from
Jul 1, 2020

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Jun 23, 2020

Fixes #2207 and fixes #3885

@codecov
Copy link

codecov bot commented Jun 24, 2020

Codecov Report

Merging #4196 into develop will increase coverage by 0.06%.
The diff coverage is 52.60%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4196      +/-   ##
===========================================
+ Coverage    79.11%   79.16%   +0.06%     
===========================================
  Files          467      468       +1     
  Lines        34492    34463      -29     
===========================================
- Hits         27284    27280       -4     
+ Misses        7208     7183      -25     
Flag Coverage Δ
#django 71.08% <48.82%> (+0.06%) ⬆️
#sqlalchemy 71.92% <50.22%> (+0.01%) ⬆️
Impacted Files Coverage Δ
aiida/backends/djsite/queries.py 92.79% <ø> (ø)
aiida/backends/sqlalchemy/migrations/env.py 80.65% <0.00%> (ø)
...ons/07fac78e6209_drop_computer_transport_params.py 100.00% <ø> (ø)
...ns/12536798d4d3_trajectory_symbols_to_attribute.py 95.66% <ø> (ø)
...grations/versions/162b99bca4a2_drop_dbcalcstate.py 91.67% <ø> (ø)
...30c8430131_drop_node_columns_nodeversion_public.py 100.00% <ø> (ø)
...61acd560_data_migration_legacy_job_calculations.py 100.00% <ø> (ø)
...sions/37f3d4882837_make_all_uuid_columns_unique.py 91.31% <ø> (ø)
...migrations/versions/5a49629f0d45_dblink_indices.py 100.00% <ø> (ø)
...ations/versions/61fc0913fae9_remove_node_prefix.py 100.00% <ø> (ø)
... and 85 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 52bd5ad...6c251bd. Read the comment docs.

@sphuber sphuber added the pr/on-hold PR should not be merged label Jun 24, 2020
@sphuber sphuber force-pushed the fix/pre-commit-exclude branch 5 times, most recently from 8e2ff02 to e2a183b Compare June 24, 2020 11:39
@sphuber sphuber changed the title Remove files from the pre-commit exclude list Remove all files from the pre-commit exclude list Jun 24, 2020
@sphuber
Copy link
Contributor Author

sphuber commented Jun 24, 2020

@ramirezfranciscof and @chrisjsewell this bad boy is ready to go!

chrisjsewell
chrisjsewell previously approved these changes Jun 24, 2020
Copy link
Member

@chrisjsewell chrisjsewell left a comment

Choose a reason for hiding this comment

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

Nice 👌

@sphuber
Copy link
Contributor Author

sphuber commented Jun 24, 2020

To anyone reading this Note that this should not be merged!

@ltalirz
Copy link
Member

ltalirz commented Jun 30, 2020

That's fantastic @sphuber :-)

One small question: I notice that you moved (in a previous PR) the pylint hook from local to repo: https://github.com/PyCQA/pylint- but then of course you are still using language: system since it needs to see AiiDA and its dependencies.
Just wondering: what are the benefits of this? Does this not install a separate virtual environment with pylint inside that is never used?
I.e. would it not be better to move the pylint hook back under the local ones?

P.S. I'm curious - did removing the exclude list surface any bugs?

@sphuber
Copy link
Contributor Author

sphuber commented Jun 30, 2020

That's fantastic @sphuber :-)

Combination of OCD and procrastination is one heck of a drug ;)

One small question: I notice that you moved (in a previous PR) the pylint hook from local to repo: https://github.com/PyCQA/pylint- but then of course you are still using language: system since it needs to see AiiDA and its dependencies.
Just wondering: what are the benefits of this? Does this not install a separate virtual environment with pylint inside that is never used?
I.e. would it not be better to move the pylint hook back under the local ones?

As you said, we need to run this with language: system such that we don't get spurious import-error warnings. However, we also want to run with a very specific version of pylint because changes in that version can cause differences between local and CI environment and therefore annoying CI failures. We used to "solve" this by pinning the requirement in the requirements. However, this would cause problems when developing multiple packages in the same virtual environment. Often there would be version conflicts. So you would run pre-commit with aiida-core and so that would require a specific pylint version, but then aiida-quantumespresso would be still on a different version and so when you commit, pre-commit would fail. By using the remote hook, the separate virtual environment solves these dependency incompatibilities. I think this is worth the little overhead, because anyway the environment is cached.

P.S. I'm curious - did removing the exclude list surface any bugs?

Yes, plenty! Mostly in the data plugins. They are under tested and are some of the oldest code in aiida-core.

@ltalirz
Copy link
Member

ltalirz commented Jun 30, 2020

However, we also want to run with a very specific version of pylint because changes in that version can cause differences between local and CI environment and therefore annoying CI failures. We used to "solve" this by pinning the requirement in the requirements.

Perhaps I'm wrong, but I believe the version (and executable) of pylint that you are using is the one installed by the pre-commit extra of aiida-core, not the version installed by the pylint repo.
At least that's how I understand what is written here: https://pre-commit.com/#system

Otherwise, how are they mixing the two python environments?
Or asked the other way around: If it was using the pylint version from the hook repo, then why do we still need it in the pre-commit requirements?

However, this would cause problems when developing multiple packages in the same virtual environment. Often there would be version conflicts

This point I fully support, i.e. I'm all for moving linters, formatters etc. into separate environments where we can.
I'm just not sure it's possible with pylint.

@chrisjsewell
Copy link
Member

not the version installed by the pylint repo

yeh pretty sure thats the case

This point I fully support, i.e. I'm all for moving linters, formatters etc. into separate environments if we can.

Just in case you didn't know, you can get pre-commit to install additional packages into its environment with: https://pre-commit.com/#config-additional_dependencies. But thats probably not an adequate cure for the import-error warnings

@sphuber sphuber removed the pr/on-hold PR should not be merged label Jul 1, 2020
@sphuber sphuber requested a review from chrisjsewell July 1, 2020 20:37
Comment on lines 23 to 24
- repo: https://github.com/PyCQA/pylint
rev: pylint-2.5.2
Copy link
Member

Choose a reason for hiding this comment

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

were we going to move this into the local repo, as suggested by @ltalirz ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But then we are back to the situation where we have to pin an exact version which will collide with any other projects you might have in the same virtual env. Is there no way to address this? I am not sure if this current solution actually allowed for this or if it had the same limitation and I just never noticed the collision

Copy link
Member

Choose a reason for hiding this comment

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

I think we still are in this situation - the only difference being that now we create an additional virtual environment that is never used

Copy link
Member

Choose a reason for hiding this comment

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

but as we discussed, I'm under the impression that, because of language: system, it is already using the virtual env version of the package not the one that is installed in the pre-commit env

Copy link
Member

Choose a reason for hiding this comment

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

to use the one in the pre-commit env, you would have to either ignore errors regarding dependency installs, or also install them dependencies into the pre-commit environment, using https://pre-commit.com/#config-additional_dependencies

Copy link
Member

Choose a reason for hiding this comment

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

@chrisjsewell not sure whether you replied to my comment or seb's - anyhow I did mean we create an additional pre-commit environment that is never used, i.e. we are saying the same thing.

As for your following comment, I don't think either of those are viable solutions, i.e. we can just move the hook back under local

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it back to local

Copy link
Member

Choose a reason for hiding this comment

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

not sure whether you replied to my comment or seb's

seb's

I don't think either of those are viable solutions

yep agree, just outlining the possible option 👍

Except for the documentation of course, which should remain excluded.

Also move the `pylint` pre-commit hook back under `local`. The idea by
putting it under the remote repos was to profit from the separate
virtual environment that is created with the exact version specified in
order to prevent clashes with requirements of other projects being
developed in the same virtual environment. However, this approach leads
to many spurious false positive import-errors because `pylint` cannot
find all other third party dependencies. This can be fixed by specifying
`language: system`, but this just forces the normal virtual environment
to be used, rendering the whole point of using the remote repos moot.
@sphuber sphuber merged commit 855ae82 into aiidateam:develop Jul 1, 2020
@sphuber sphuber deleted the fix/pre-commit-exclude branch July 1, 2020 21:20
Comment on lines +36 to 42
hooks:
- id: pylint
name: pylint
language: system
exclude: *exclude_files

hooks:
Copy link
Member

@ltalirz ltalirz Jul 11, 2020

Choose a reason for hiding this comment

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

@sphuber I didn't review this PR but I think you might have just disabled pylint there (hooks key used twice)...

Copy link
Member

Choose a reason for hiding this comment

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

The configured hook doesn't actually work - you'll need to add

entry: pylint

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads-up @ltalirz ! That is indeed a required key but normally that should raise a an error when the file is parsed

An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='local')
==> At key: hooks
==> At Hook(id='pylint')
=====> Missing required key: entry

The bigger problem is that I accidentally defined the hooks key twice. The first one, containing the pylint config simply gets overridden, which is why pylint is never actually run. I will create a PR to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See PR #4258

Copy link
Member

Choose a reason for hiding this comment

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

The bigger problem is that I accidentally defined the hooks key twice.

Right. That's what I wrote above, no? ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You did, but not in the original post. I read it on my email, which only ever send the first version. So you edit didn't show up Guess I could have noticed when responding here though :)

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