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

use python script to setup all codes #706

Merged
merged 2 commits into from
Apr 30, 2024

Conversation

superstar54
Copy link
Member

@superstar54 superstar54 commented Apr 30, 2024

It takes 1-2 sec to set up a code, and we have 14 codes (pw, dos, pp, ph, etc.), so around 20 sec in total. Which is not good, and it takes too long to load the container.

I looked into the issue and found that most of the time is used to set up the verdi command, profile and database. Thus it's would be good to combine all code set up as one.

Since the code setup is run in a different thread, thus, using the InstalledCode directly will fail when storing the code, as I tested in #695. This PR uses the python -c command to run in the subprocess.

The total time to set up all 14 codes is now reduced to 3-5 seconds. Most importantly, setting more codes will not increase the time too much. This is a temporary solution, but it is better than no solution. We can use the InstalledCode in the future when we fix the thread problem.

@superstar54
Copy link
Member Author

superstar54 commented Apr 30, 2024

Hi @AndresOrtegaGuerrero , you can test this by deleting some of the codes (not used yet by QEApp), and install them again.

#!/bin/bash
verdi code delete "epw-7.2@localhost" "neb-7.2@localhost" "open_grid-7.2@localhost" "ph-7.2@localhost" "pw2gw-7.2@localhost" "pw2wannier90-7.2@localhost" "q2r-7.2@localhost"
time python -m aiidalab_qe install-qe



def _generate_string_to_setup_code(code_name, computer_name="localhost"):
"""Generate the python string to setup a code for a given computer."""
try:
load_code(f"{code_name}-{QE_VERSION}@localhost")
Copy link
Member

@AndresOrtegaGuerrero AndresOrtegaGuerrero Apr 30, 2024

Choose a reason for hiding this comment

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

Should it be load_code(f"{code_name}-{QE_VERSION}@{computer_name}") . ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are right.



def _generate_string_to_setup_code(code_name, computer_name="localhost"):
"""Generate the python string to setup a code for a given computer."""

Choose a reason for hiding this comment

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

Generate the python string to setup an AiiDA code for a given computer. Tries to load an existing code and if not existent, generates Python code to create and store a new code setup.

@AndresOrtegaGuerrero
Copy link
Member

Should this PR be dependent on the aiida-core version?

@AndresOrtegaGuerrero
Copy link
Member

This was my test

Codes are setup!

real 0m7.560s
user 0m12.340s
sys 0m0.465s

@superstar54
Copy link
Member Author

Hi @AndresOrtegaGuerrero , thanks for the review. I made the changes as you suggested.

Should this PR be dependent on the aiida-core version?

It could be if the Python API of AiiDA changes, e.g., InstalledCode, but for the moment, it should be safe.

@superstar54
Copy link
Member Author

This was my test
Codes are setup!
real 0m7.560s
user 0m12.340s
sys 0m0.465s

Thanks for the test. You can try to run this in the main branch, and check the time difference.

Copy link
Member

@AndresOrtegaGuerrero AndresOrtegaGuerrero left a comment

Choose a reason for hiding this comment

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

LGTM, my test show less time

@superstar54 superstar54 merged commit 6651c8b into aiidalab:main Apr 30, 2024
14 checks passed
@superstar54 superstar54 deleted the setup_codes_in_one_shot branch April 30, 2024 10:56
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.

None yet

2 participants