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

Upgrade the aimsgb structure factory #1123

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Upgrade the aimsgb structure factory #1123

wants to merge 2 commits into from

Conversation

usaikia
Copy link
Contributor

@usaikia usaikia commented Jul 28, 2023

The current version of amisgb.build and aimsgb.info is not compatible with probably Python3.10. Here, I upgrade the aimsgb structure factory to make it compatible and also add some more features currently available in Aimsgb (e.g., to add vacuum spacing in the GB cell).

@@ -2,8 +2,10 @@
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.

from structuretoolkit.build import grainboundary, get_grainboundary_info
Copy link
Member

Choose a reason for hiding this comment

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

Please use the structure toolkit interface.

Copy link
Member

Choose a reason for hiding this comment

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

The interface is pretty similar and this is what is used by pyiron_atomistics in the background https://github.com/pyiron/structuretoolkit/blob/main/structuretoolkit/build/aimsgb.py

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I opened a jupyter notebook from the jupyterhub session runnig at cmti and tried to import from structuretoolkit.common.pymatgen import ase_to_pymatgen, pymatgen_to_ase and got this error ModuleNotFoundError: No module named 'structuretoolkit.common'

from structuretoolkit.build import grainboundary, get_grainboundary_info also gave me the error ImportError: cannot import name 'grainboundary' from 'structuretoolkit.build' (/u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.10/site-packages/structuretoolkit/build/__init__.py)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I got this. I have to modify the import statement from from structuretoolkit.build import grainboundary, get_grainboundary_info to from structuretoolkit.build.aimsgb import grainboundary_info, grainboundary_build

But, still can't figure out what is the new alternative of structuretoolkit.common.pymatgen import ase_to_pymatgen, pymatgen_to_ase

Copy link
Member

Choose a reason for hiding this comment

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

Now I am confused, because it is available in the official package https://github.com/pyiron/structuretoolkit/blob/main/structuretoolkit/common/pymatgen.py . Which version of structure toolkit is installed on cmti? You can check the version using conda list structuretoolkit

Copy link
Contributor Author

@usaikia usaikia Jul 29, 2023

Choose a reason for hiding this comment

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

The output of conda list structuretoolkit is as follows:

packages in environment at /u/system/SLES12/soft/pyiron/dev/anaconda3:

Name Version Build Channel
structuretoolkit 0.0.1 pyhd8ed1ab_1 conda-forge

Note: you may need to restart the kernel to use updated packages.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, this is a rather old version - the current version is 0.0.7.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-janssen Thanks! I noticed that the current incompatibility issue is coming from this line AseAtomsAdaptor.get_structure(initial_struct, cls=None). The option cls=None is no longer accepted. We can change it to AseAtomsAdaptor.get_structure(initial_struct) which will take the default value which is pymatgen.Structure

@samwaseda
Copy link
Member

Are you sure that it’s related to numpy? Because recently Aditya reported a problem with aimsgb and I fixed it here. I don’t know the current status, but if the new version is released the problem might get solved as well?

@usaikia
Copy link
Contributor Author

usaikia commented Jul 30, 2023

I believe the current error is coming from pymatgen side. In cmti, line no 80 of this file /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.10/site-packages/structuretoolkit/build/aimsgb.py which is exactly this line adapter.get_structure(atoms=initial_struct, cls=None) is giving me the error. To solve this issue, all we need to do is remove cls=None which will than use the default pymatgen.Structure automatically. But, now I can't find this exact line in the Github page. In the github page it is a different file.

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

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

Need black applied, and I see in the review comments that there are some other little issues going on, but overall it looks fine to me.

At least for info, where we're really just wrapping things, I wonder whether we can get away with the following such that the method always stays up to date with changes in the underlying wrapped function:

class AimsgbFactory:
    @staticmethod
    @functools.wraps(get_grain_boundary_info)
    def info(*args, table_view=False, **kwargs):
        if table_view:
            return print(get_grain_boundary_info(*args, **kwargs).__str__())
        else:
            return get_grain_boundary_info(*args, **kwargs)

This works like a charm when I make a little MWE in my notebook, but try it and see if it's good here.

"""
return get_grainboundary_info(axis=axis, max_sigma=max_sigma)
if table_view:
return print(GBInformation(axis, max_sigma, specific).__str__())
Copy link
Member

Choose a reason for hiding this comment

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

return print(...) looks super weird. Is it really not enough to just return __str__()? or print() without the return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liamhuber Thanks a lot for the feedback. I will implement the changes you suggested.

@mbruns91
Copy link

mbruns91 commented Aug 1, 2023

I tried to upgrade to structuretoolkit=0.0.6 on cmti. First I just did

$ mamba install sturcturetoolkit=0.0.6
...
  - pyiron_atomistics   0.2.66  pyhd8ed1ab_1     conda-forge                   
  + pyiron_atomistics   0.2.64  pyhd8ed1ab_0     conda-forge/noarch       260kB
  - pyiron_contrib      0.1.10  pyhd8ed1ab_0     conda-forge                   
  + pyiron_contrib       0.1.8  pyhd8ed1ab_2     conda-forge/noarch       167kB

which made mamba want to downgrade pyiron_atomistics and pyiron_contrib, which is kind of silly. So, my next shot was to check the versions of all pyiron packages installed,

$ conda list | grep pyiron
# packages in environment at /u/system/SLES12/soft/pyiron/dev/anaconda3/:
pyiron                    0.4.7              pyhd8ed1ab_1    conda-forge
pyiron-data               0.0.22               hd8ed1ab_0    conda-forge
pyiron_atomistics         0.2.66             pyhd8ed1ab_1    conda-forge
pyiron_base               0.5.36             pyhd8ed1ab_0    conda-forge
pyiron_contrib            0.1.10             pyhd8ed1ab_0    conda-forge

which revealed, that actually none of the pyiron packages is really up to date, so I tried to upgrade everything explicitly:

$ mamba install structuretoolkit=0.0.6 pyiron=0.5.0 pyiron-data=0.0.22 pyiron_atomistics=0.3.1 pyiron_base=0.6.3 pyiron_contrib=0.1.10
...
Encountered problems while solving:
  - package pyiron_base-0.6.3-pyhd8ed1ab_0 requires pysqa >=0.1.0, but none of the providers can be installed

So, why can't we just upgrade pysqa as well?!

$ mamba install structuretoolkit=0.0.6 pyiron=0.5.0 pyiron-data=0.0.22 pyiron_atomistics=0.3.1 pyiron_base=0.6.3 pyiron_contrib=0.1.10 pysqa=0.1.0
...
Encountered problems while solving:
  - package pysqa-0.1.0-pyhd8ed1ab_0 requires paramiko >=3.2.0, but none of the providers can be installed

All right, here we go again...

$ mamba install structuretoolkit=0.0.6 pyiron=0.5.0 pyiron-data=0.0.22 pyiron_atomistics=0.3.1 pyiron_base=0.6.3 pyiron_contrib=0.1.10 pysqa=0.1.0 'paramiko>=3.2.0'
...
Encountered problems while solving:
  - package pysqa-0.1.0-pyhd8ed1ab_0 requires paramiko >=3.2.0, but none of the providers can be installed

That didn't work as intended. So I tried just installing paramiko:

$ mamba install "paramiko>=3.2.0"
Encountered problems while solving:
  - package fabric3-1.14.post1-py_0 requires paramiko >=2.0,<3.0, but none of the providers can be installed

fabric3 this is the troublemaker!
At this point I need help. The most recent version on channels anaconda and conda-forge is fabric3=1.14post1 and was last updated 5 years ago.

As far as I can tell, it's just a legacy package, I did not find anything depending on it:

$ conda-tree whoneeds fabric3

returns nothing.

Shall I just uninstall it?

@mbruns91
Copy link

mbruns91 commented Aug 1, 2023

I uninstalled it. Now, all pyiron packages as well as structuretoolkit (and also some other crucial packages like pysqa) are up to date.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5776408730

  • 7 of 10 (70.0%) changed or added relevant lines in 1 file are covered.
  • 275 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.008%) to 67.46%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyiron_atomistics/atomistics/structure/factories/aimsgb.py 7 10 70.0%
Files with Coverage Reduction New Missed Lines %
pyiron_atomistics/vasp/interactive.py 22 42.11%
pyiron_atomistics/lammps/base.py 69 78.81%
pyiron_atomistics/vasp/base.py 184 65.3%
Totals Coverage Status
Change from base Build 5656328155: -0.008%
Covered Lines: 10890
Relevant Lines: 16143

💛 - Coveralls

@usaikia
Copy link
Contributor Author

usaikia commented Aug 6, 2023

@jan-janssen and @liamhuber thanks a lot for your suggestions! I have implemented them. I also noticed that some core methods of aimsgb are deprecated in the latest version. Should I open a pull request and upgrade structuretoolkit.build directly?

@stale
Copy link

stale bot commented Sep 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 17, 2023
@jan-janssen jan-janssen marked this pull request as draft February 14, 2024 15:20
@stale stale bot removed the stale label Feb 14, 2024
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.

6 participants