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

⬆️ Update to aiida-core v1.4.2 #48

Merged
merged 17 commits into from
Oct 21, 2020
Merged

⬆️ Update to aiida-core v1.4.2 #48

merged 17 commits into from
Oct 21, 2020

Conversation

chrisjsewell
Copy link
Member

Also drop separate numpy install, since this should no longer be needed, in accordance with: aiidateam/aiida-core#4378

Also drop sperate numpy install , since this should no longer be needed, in accordance with: aiidateam/aiida-core#4378
@chrisjsewell
Copy link
Member Author

@ltalirz do you know if there was a reasoning behind this setuptools pinning ~=36.2:

- setuptools~=36.2

given that aiida-core's build dependency is setuptools>=40.8.0,<50: https://github.com/aiidateam/aiida-core/blob/bd6903d88a4d88077150763574784a1bc375c644/pyproject.toml#L2

@ltalirz
Copy link
Member

ltalirz commented Oct 13, 2020

@ltalirz do you know if there was a reasoning behind this setuptools pinning ~=36.2:

@chrisjsewell I saw that it was introduced by me and I can't remember a specific reason that would still be valid. I think it's safe to delete.

@ltalirz
Copy link
Member

ltalirz commented Oct 13, 2020

This failure with numpy 1.19.2 seems weird... the "test-install" worfklow on the aiida-core repo is still working fine: https://github.com/aiidateam/aiida-core/runs/1245377894?check_suite_focus=true#step:4:61

@chrisjsewell
Copy link
Member Author

As usual, it pymatgen being a pile ***. It looks like it requires cython to build, so will try adding cython to the virtulenv.

perhaps cython gets pre-installed on GH actions? 🤷

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Oct 14, 2020

Yeh that looks to have fixed it.

One thought I had, before realising the issue with pymatgen, is that perhaps it would be better to use the CI requirements files, to use specific versions of dependencies (rather than them possibly changing over time), i.e.

- name: Install aiida-core dependencies
  pip:
    requirements: "{{ aiida_source_folder }}/aiida-core/requirements/requirements-py-3.{{ ansible_python_version.split('.')[1] }}.txt"
    virtualenv: "{{ aiida_venv }}"
    # According to https://github.com/ansible/ansible/issues/52275
    virtualenv_command: /usr/bin/python3 -m venv

- name: Install aiida-core package and dependencies
  pip:
    name:
    - "{{ aiida_source_folder }}/aiida-core"
    virtualenv: "{{ aiida_venv }}"
    # According to https://github.com/ansible/ansible/issues/52275
    virtualenv_command: /usr/bin/python3 -m venv
    editable: true
    extra_args: "--no-deps"
  notify: reentry scan
  # this guard is necessary because, for some reason, installs with
  # 'editable: true' always show as "changed"
  when: git_checkout.changed

The drawback would be that you could no longer specify particular extras,
although this feature is not actually utilized when building quantum-mobile.

Thoughts @ltalirz?

@chrisjsewell
Copy link
Member Author

Hmm, I added a pip check final task. As you can see a few are failing (presumably they both have python 3.6) with: "notebook 5.7.10 has requirement nbconvert<6.0, but you have nbconvert 6.0.7."

@ltalirz
Copy link
Member

ltalirz commented Oct 14, 2020

perhaps it would be better to use the CI requirements files, to use specific versions of dependencies (rather than them possibly changing over time)

These would be the [tests] extra, right? Which translates to tests + rest + atomic_tools
https://github.com/aiidateam/aiida-core/blob/bd6903d88a4d88077150763574784a1bc375c644/setup.py#L30

Currently, the role defaults to even more extras:

aiida_extras:
- rest
- docs
- atomic_tools
- testing
- notebook

It seems to me that being able to select extras is useful and perhaps we should actually reduce the number of extras installed by default to rest + atomic_tools to save some space. jupyter stuff will anyhow come with the aiidalab role if desired (perhaps removing notebook will solve the pip check issue) + I don't think users will typically want to build the documentation or run tests. We could then use the variable to install the "tests" extra on CI, which would allow us to run AiiDA tests if we wanted to.

The installation of AiiDA with extras from scratch is tested on the test-install workflow for python 3.6-3.8
https://github.com/aiidateam/aiida-core/blob/bd6903d88a4d88077150763574784a1bc375c644/.github/workflows/test-install.yml#L158
so I'm a bit puzzled as to why it was failing here... as you mention, perhaps cython is preinstalled in the CI environment or perhaps the platform is somehow recognized to match a pymatgen wheel?
I'm therefore also not sure whether switching to the fixed versions of requirements would have solved this problem.

Finally, would it make sense to add your pip check to the test-install workflow on aiida-core?
https://github.com/aiidateam/aiida-core/blob/develop/.github/workflows/test-install.yml
Or is this already handled a priori by using the 2020-resolver? (and should we use it here as well?)

- wheel
- numpy==1.17.4
- cython # required by pymatgen
Copy link
Member

@ltalirz ltalirz Oct 14, 2020

Choose a reason for hiding this comment

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

So, to recap: I think the problem is that pymatgen still specifies its build dependencies (numpy) via an antiquated method, which results in easy_install being used instead of pip, which then requires numpy to be built from source (rather than just using a wheel).
I.e. just putting numpy here should probably also solve the problem and would be faster.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I'll give it a go thanks:
pymatgen does have numpy as a setup dependency not cython: https://github.com/materialsproject/pymatgen/blob/cea7587e40cff1d8b476601176b034d753301971/setup.py#L108

although feels weird that this is the dependency to build the cython files: https://github.com/materialsproject/pymatgen/blob/cea7587e40cff1d8b476601176b034d753301971/setup.py#L164

Copy link
Member Author

Choose a reason for hiding this comment

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

works 👍

@chrisjsewell
Copy link
Member Author

Finally, would it make sense to add your pip check to the test-install workflow on aiida-core?

I think it wouldn't hurt

cc @csadorf, FYI see above for some issues we've had; firstly with pymatgen install failing, then with pip check noting a notebook package version incompatibility

tasks/aiida-prepare.yml Outdated Show resolved Hide resolved
@chrisjsewell
Copy link
Member Author

chrisjsewell commented Oct 16, 2020

Ermm what the heck, @ltalirz molecule has suddenly broken 🤦 (maybe a new version release, I'll check)

Run molecule test
ERROR: Failed to pre-validate.

{'driver': [{'name': ['unallowed value docker']}]}

latest versions:

 Collecting ansible~=2.9
  Downloading ansible-2.10.1.tar.gz (25.9 MB)
Collecting docker
  Downloading docker-4.3.1-py2.py3-none-any.whl (145 kB)
Collecting molecule~=3.0
  Downloading molecule-3.1.2-py3-none-any.whl (235 kB)

last working:

Collecting ansible~=2.9
  Downloading ansible-2.10.1.tar.gz (25.9 MB)
Collecting docker
  Downloading docker-4.3.1-py2.py3-none-any.whl (145 kB)
Collecting molecule~=3.0
  Downloading molecule-3.0.8-py3-none-any.whl (279 kB)

@chrisjsewell
Copy link
Member Author

They moved the docker driver out of molecule core: ansible/molecule#2891 (comment)
That's not exactly a minor release is it!

@ltalirz
Copy link
Member

ltalirz commented Oct 16, 2020

Shame on them!

@ltalirz
Copy link
Member

ltalirz commented Oct 16, 2020

Poor geerlingguy did 87 commits in 87 repositories yesterday https://github.com/geerlingguy

@ltalirz
Copy link
Member

ltalirz commented Oct 16, 2020

Not very funny for him probably...

Perhaps he has an automated procedure for this? We may need to do the same.

They're not done via PRs, i.e. it's probably just a bash script iterating over all local repo folders.

@chrisjsewell
Copy link
Member Author

Or using the github API?

@chrisjsewell
Copy link
Member Author

Anyway I blame it all on @webknjaz 😝 (ansible/molecule#2891): ansible giveth and ansible taketh away

@webknjaz
Copy link

@chrisjsewell not my fault! I stopped maintaining molecule a long time ago. Blame @ssbarnea :)

@espenfl
Copy link
Collaborator

espenfl commented Oct 16, 2020

Poor geerlingguy did 87 commits in 87 repositories yesterday https://github.com/geerlingguy

Wow, that is indeed rather extensive. I suspect he does it from Ansible.

@ltalirz
Copy link
Member

ltalirz commented Oct 17, 2020

Ok, so this is what they suggest: https://github.com/openstack/tripleo-quickstart-extras/blob/a3cec1fd88f249b6997593f3e4d933c2f516d1cf/molecule-requirements.txt#L10
(one could also use molecule~=3.0.0).

@chrisjsewell Up to you whether you want to make the upgrade to 3.1 or just keep 3.0
This might be the only change needed for the transition: geerlingguy/ansible-role-helm@c8abca6

In the end, the fastest might be just to loop over local clones of all role repositories, commit and push.

@chrisjsewell
Copy link
Member Author

TBH its OK, because I'm going through all repos and applying marvel-nccr/quantum-mobile#132 anyway

@chrisjsewell
Copy link
Member Author

@ltalirz in a175318 I've solved the pip versioning issue 😄 (as long as the tests pass 🤞):

I now generate a pip constraints file from aiida-core's setup.json, then that is applied to all plugin installs, e.g. pip install -c constraints.txt aiida-plugin. This ensures no plugin can "override" the core version dependencies

@chrisjsewell
Copy link
Member Author

ah damn this worked locally 🤔

@chrisjsewell
Copy link
Member Author

haha @pradyun was just reading up on pip constraints and saw you snuck in tabs 👀

@chrisjsewell
Copy link
Member Author

success!

- notebook
aiida_data_folder: "${HOME}/.local/share/aiida"
aiida_templates_folder: "${HOME}/.local/share/aiida"
aiida_source_folder: "${HOME}/src"
aiida_examples_folder: "${HOME}"
aiida_venv: "${HOME}/.virtualenvs/aiida"
aiida_constraints_file: "{{ aiida_data_folder }}/constraints.txt"
# these are additional to those extracted from aiida-core and its extras
aiida_constraints:
Copy link
Member

Choose a reason for hiding this comment

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

Should this be removed?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see; we need to lock things down even further (?).
Should we be adding this constraint in the setup.json?

Copy link
Member Author

Choose a reason for hiding this comment

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

perhaps 🤷 (to the docs extra), I guess with the new pip --use-feature=2020-resolver it should resolve this and not allow such a broken environment to transpire. But without it, and with this particular set of extras it definitely creates a broken environment

Choose a reason for hiding this comment

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

@chrisjsewell that's why I advocate for having proper env requirements+pins managed by pip-tools instead of extras

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeh we do already have lock files for CI testing: https://github.com/aiidateam/aiida-core/tree/develop/requirements.
The problem is that we are not just trying to install aiida-core, we need to install a range of other plugin packages that might not be exactly compatible with these hard pinnings:

aiida_plugin_versions:
aiida_cp2k: "1.1.0"
aiida_fleur: "1.1.0"
aiida_bigdft: "0.2.1a2"
# aiida_gudhi: "0.1.0a3"
# aiida_phtools: "0.1.0a1"
aiida_quantumespresso: "3.1.0"
# aiida_raspa: "1.0.0a2"
aiida_siesta: "1.1.0"
aiida_yambo: "1.1.1"
aiida_wannier90: "2.0.1"
aiida_wannier90_workflows: "1.0.1"

Choose a reason for hiding this comment

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

Oh, so you need a combined lockfile, I guess... Just dump that to a file and use a few requirements sources to produce transitive pins? FWIW I think what confused me is the definition substitution (constraints vs requirements).

Copy link
Member Author

@chrisjsewell chrisjsewell Oct 21, 2020

Choose a reason for hiding this comment

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

Yeh exactly, I'm not completely sold on the current solution here, but at least now it is properly tested and produces a valid environment, which is a step forward 😬
So I am going to merge this as this, but anyway we have an open issue marvel-nccr/quantum-mobile#137 to consider this further, at which point I will definitely take into account your recommendation (thanks 🙏) and may well switch to some form of lock file

Copy link
Member Author

Choose a reason for hiding this comment

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

FYI @webknjaz you might be interested to see I now set up a full ~2 hour vagrant+ansible build running in GH Actions: https://github.com/marvel-nccr/quantum-mobile/runs/1286287172?check_suite_focus=true 😄

@@ -0,0 +1,37 @@
#!/usr/bin/env python
Copy link
Member

@ltalirz ltalirz Oct 21, 2020

Choose a reason for hiding this comment

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

Fine to keep it this parser here for the moment - eventually this should probably go to into https://github.com/aiidateam/aiida-core/tree/develop/utils

@@ -20,6 +20,16 @@
- item.name in aiida_pps.stdout
with_items: "{{ aiida_pseudopotentials }}"

- name: print aiida-core version
shell: "{{ aiida_venv }}/bin/pip show aiida-core"
changed_when: false
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 you don't even need this in verify.yml (of course fine to keep)

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought just in case a plugin tries to install a different version

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant the changed_when is not needed (it's fine to change things in verify.yml)

- wheel
- numpy==1.17.4
- numpy # required by pymatgen
Copy link
Member

@ltalirz ltalirz Oct 21, 2020

Choose a reason for hiding this comment

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

no pinning, are you sure? ;-)

I'd feel safer with pinning it to some recent minor version

Copy link
Member Author

Choose a reason for hiding this comment

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

It is only needed for the pymatgen install, it will be updated, if necessary, by the pip install of aiida-core. If you pin it, then you have to ensure it is compatible with aiidalab and aiida-core (a current issue in the full quantum mobile build)

Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

Great, thanks a lot @chrisjsewell

Just a few minor comments left, then we can merge this!

import sys

def remove_extra(req):
"""Extras are not allowed in constraints files, e.g. dep[extra]>0.1 -> dep>0.1 """

Choose a reason for hiding this comment

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

why is that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Ah, fair enough. Using pip-tools would fix that too.

@@ -0,0 +1,37 @@
#!/usr/bin/env python
"""Script to convert aiida setup.json to pip constraints file.

Choose a reason for hiding this comment

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

It's not constraints but rather requirements. You'd usually use https://github.com/jazzband/pip-tools to generate the pinned env deps aka constraints.

Choose a reason for hiding this comment

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

Also, pip-tools can generate pins from setup.py natively so you could just replace this script with an existing tool: https://github.com/jazzband/pip-tools#requirements-from-setuppy

Copy link
Member Author

@chrisjsewell chrisjsewell Oct 21, 2020

Choose a reason for hiding this comment

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

no that creates a lock file, with strict version pinning. we just want a constraints file, for when you run subsequent pip installs, i.e. these installs can change the version of packages if necessary, but only within the ranges specified by setup.json

Copy link

@webknjaz webknjaz Oct 21, 2020

Choose a reason for hiding this comment

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

@chrisjsewell true but the purpose of constraints file in pip is exactly that it should be a lock file. So that the usage would be pip install -r requirements.txt -c constraints.txt. The former should usually contain open-ended direct dependencies while the latter would pinpoint what exactly is allowed (it's best when there's also --require-hashes too), including the transitive deps too, making the virtualenv setup reproducible.

@ltalirz
Copy link
Member

ltalirz commented Oct 21, 2020

@chrisjsewell If it simplifies the constraints issue, the installation of the plugins could probably be done in one go (it would be good to use a mechanism that allows specifying a commit/tag from a github repo as a source of a package instead of a pypi version; at least historically that was often needed).

The per-plugin yaml files could then be reduced to just setting up the corresponding aiida code.

@chrisjsewell
Copy link
Member Author

@chrisjsewell If it simplifies the constraints issue, the installation of the plugins could probably be done in one go (it would be good to use a mechanism that allows specifying a commit/tag from a github repo as a source of a package instead of a pypi version; at least historically that was often needed).

The per-plugin yaml files could then be reduced to just setting up the corresponding aiida code.

Yeh as mentioned above I think I will merge this as is now, since it is definitely a step in the right direction. Then consider this further in marvel-nccr/quantum-mobile#137 (including how we integrate with aiidalab)

@chrisjsewell chrisjsewell merged commit 3c89fc0 into master Oct 21, 2020
@chrisjsewell chrisjsewell deleted the aiida-core/v1.4.2 branch October 21, 2020 13:05
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