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

Refactor the Orbital code and fix bugs #2737

Merged

Conversation

giovannipizzi
Copy link
Member

The code was not tested (and now we add tests)
Moreover, the code required quite some cleanup and
refactoring.
Now the code should be cleaner (even if probably still
not perfect). The intended aim of this commit is to avoid
breaking backward-compatibility.

This fixes #2419

@giovannipizzi
Copy link
Member Author

Marked as [WIP] because I'd like @DanielMarchand to test if now this works (you can check out the branch in my fork) and if I didn't change the API.

Also, @sphuber: I apparently get some weird errors from prospector in my tests (at least In my previous runs, like cyclic imports etc.) - is this related to the caching of pip or to something else?

@coveralls
Copy link

Coverage Status

Coverage decreased (-5.4%) to 65.057% when pulling de8ccf0f3ea08f82f540441aefd67102c90ff886 on giovannipizzi:fix_2419_realhydrogen_orbitals into 899d803 on aiidateam:develop.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-5.4%) to 65.057% when pulling de8ccf0f3ea08f82f540441aefd67102c90ff886 on giovannipizzi:fix_2419_realhydrogen_orbitals into 899d803 on aiidateam:develop.

@coveralls
Copy link

coveralls commented Apr 10, 2019

Coverage Status

Coverage increased (+0.4%) to 70.919% when pulling 85442e8 on giovannipizzi:fix_2419_realhydrogen_orbitals into d0ab2b8 on aiidateam:develop.

@DanielMarchand
Copy link
Contributor

DanielMarchand commented Apr 10, 2019

Marked as [WIP] because I'd like @DanielMarchand to test if now this works (you can check out the branch in my fork) and if I didn't change the API.

I have just tested and the import works now! Thanks!!

@giovannipizzi giovannipizzi changed the title [WIP] Refactor the Orbital code and fix bugs Refactor the Orbital code and fix bugs Apr 10, 2019
@giovannipizzi
Copy link
Member Author

@sphuber I fixed your comments and I also added a couple more tests - I think this is ready to be merged (if tests pass)

@sphuber
Copy link
Contributor

sphuber commented Apr 10, 2019

@giovannipizzi the linter is known to be a bit buggy when it comes to cyclic imports. It is a bit weird that touching other files seems to trigger it. You could just try to add the disable statement in one of the files that it highlights as problematic. The only thing I can see quickly is that aiida.engine.processes.ports import validate_link_label from aiida.orm.utils.links and in that same module, LinkManager.nested calls from aiida.engine.processes.ports import PORT_NAMESPACE_SEPARATOR. I thought that if these things are within the scope of methods they should be lazily called and so fine.

@giovannipizzi
Copy link
Member Author

The thing that is actually needed is PORT_NAMESPACE_SEPARATOR. Can I move it one level up, in aiida/engine/processes/__init__.py? Anyway it's used also in aiida/engine/processes/process.py so it seems to me that it is a more appropriate place, and this would avoid the cyclic import?
Should I move also PORT_NAME_MAX_CONSECUTIVE_UNDERSCORES?

@sphuber
Copy link
Contributor

sphuber commented Apr 11, 2019

The thing that is actually needed is PORT_NAMESPACE_SEPARATOR. Can I move it one level up, in aiida/engine/processes/__init__.py? Anyway it's used also in aiida/engine/processes/process.py so it seems to me that it is a more appropriate place, and this would avoid the cyclic import?
Should I move also PORT_NAME_MAX_CONSECUTIVE_UNDERSCORES?

👍 Seems fair enough

@giovannipizzi
Copy link
Member Author

I added a commit that should solve the cyclic import problem - to avoid other analogous problems, the right approach seems to be to define the constants in a submodule constants.py and then expose the relevant values one level up.

@giovannipizzi
Copy link
Member Author

py3.6 linter is pickier... and the problem got worse!
https://travis-ci.org/giovannipizzi/aiida_core/jobs/518832224#L1541
Any further suggestions?

The intended aim of this commit is to avoid breaking backward compatibility
while refactoring the existing code to model atomic orbitals and add tests.
@sphuber sphuber force-pushed the fix_2419_realhydrogen_orbitals branch from 383d19a to b50d061 Compare April 13, 2019 19:57
The function is general enough to justify it being defined in `aiida.common`
alongside with the `LinkType` enum. In addition, this prevents cyclic
imports problems between the `aiida.engine` and `aiida.orm` modules.
@sphuber sphuber force-pushed the fix_2419_realhydrogen_orbitals branch from b50d061 to 85442e8 Compare April 13, 2019 20:14
@sphuber
Copy link
Contributor

sphuber commented Apr 13, 2019

@giovannipizzi I ended up fixing the problem in a different way, no more cyclic imports

@sphuber sphuber self-requested a review April 13, 2019 20:38
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

thanks a lot @giovannipizzi

@sphuber sphuber merged commit 6b6bf9d into aiidateam:develop Apr 13, 2019
@giovannipizzi giovannipizzi deleted the fix_2419_realhydrogen_orbitals branch April 16, 2019 10:41
@sphuber
Copy link
Contributor

sphuber commented May 29, 2019

Thanks a lot @DanielMarchand

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.

OrbitalFactory('realhydrogen') broken
4 participants