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

Make autodE compatible with Windows and change parallel process handling #202

Merged
merged 64 commits into from
Jan 16, 2023

Conversation

shoubhikraj
Copy link
Collaborator

@shoubhikraj shoubhikraj commented Nov 20, 2022

Major change: multiprocessing library replaced with concurrent.futures for Linux/macOS and loky for Windows

  • concurrent.futures has ProcessPoolExecutor with slightly different argument names, but uses multiprocessing backend, so there should be no difference in behaviour
  • Multiprocessing runs poorly on Windows due to issues with pickling, importing __main__ etc.; loky solves many of those issues

Minor change: timeout decorator in autode/utils.py is reimplemented with a switch for Windows

  • Without switch, there is no timeout as process creation is time-consuming
  • Setting Config.use_experimental_timeout = True will use a reusable process pool from loky to implement timeout

Other changes

  • Context manager added for temporary config

Tests on Windows: all success

TODO:

  • Some tests need to be modified so that they work on windows
  • Some tests are failling because of Windows file permission quirks - add extra code to deal with file permissions
  • Add continuous-integration on Windows
  • Add name to https://github.com/duartegroup/autodE#contributors
  • Pass the module configs to worker processes

@t-young31 t-young31 added this to the v1.4.0 milestone Nov 20, 2022
@t-young31 t-young31 changed the base branch from master to v1.4.0 November 21, 2022 08:48
@shoubhikraj shoubhikraj marked this pull request as ready for review November 21, 2022 11:04
@t-young31
Copy link
Member

it looks like the CI test where XTB calculations are run (pytest_codecov) are failing because there isn't sufficient memory on the runner. Don't understand why 16 GB is being required because Config.n_cores should be set to 1 before each test 😕 (tests/conftest.py). Nevertheless, I think the memory check should be on the total rather than the available, and let the OS deal with the consequences!

@t-young31
Copy link
Member

also looks like the linting is failing because black hasn't been run. if you follow the dev install instructions and install pre-commit it'll do it without having to think about it!

Copy link
Member

@t-young31 t-young31 left a comment

Choose a reason for hiding this comment

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

Looking great – have added some thoughts

autode/hessians.py Outdated Show resolved Hide resolved
autode/pes/relaxed.py Outdated Show resolved Hide resolved
autode/pes/unrelaxed.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
tests/test_hessian.py Outdated Show resolved Hide resolved
tests/test_wrappers/test_gaussian.py Show resolved Hide resolved
@t-young31 t-young31 added the enhancement New feature or request label Nov 21, 2022
@shoubhikraj
Copy link
Collaborator Author

it looks like the CI test where XTB calculations are run (pytest_codecov) are failing because there isn't sufficient memory on the runner. Don't understand why 16 GB is being required because Config.n_cores should be set to 1 before each test 😕 (tests/conftest.py). Nevertheless, I think the memory check should be on the total rather than the available, and let the OS deal with the consequences!

Thanks for the review! Is there anything I could locally check about the XTB test? I haven't modified anything in the conftest.py file, so not sure why it is not working. I used available memory because the OS is bound to consume some amount of memory at all times, so requesting the total amount of memory (by Orca or any other software) would increase the chances of crash. Is there any harm in using available memory, if it is available from psutil?

@t-young31
Copy link
Member

Is there anything I could locally check about the XTB test? I haven't modified anything in the conftest.py file, so not sure why it is not working.

I imagine it was broken before this PR and I just didn't spot it. If you find out why that would be awesome!

I used available memory because the OS is bound to consume some amount of memory at all times, so requesting the total amount of memory (by Orca or any other software) would increase the chances of crash. Is there any harm in using available memory, if it is available from psutil?

I don't think either the total or available memory is the right number because what you really want is the maximum amount that can be allocated to the calculation without kicking crucial stuff out of memory. I'd however be pretty strongly in favour of having it as the total because the available memory makes the chances that a calculation raising that runtime error non-deterministic... which would be super annoying. Say, If the OS could re-jig things and make it possible to run the calc. e.g. if I happen to have a load of tabs open in my browser and try to run something locally I'd rather they were kicked out than my calculation failing.

.github/workflows/pytest_cov.yml Outdated Show resolved Hide resolved
autode/config.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
autode/utils.py Outdated Show resolved Hide resolved
requirements.txt Show resolved Hide resolved
tests/test_utils.py Outdated Show resolved Hide resolved
@shoubhikraj
Copy link
Collaborator Author

The config should be picklable now, and the original format has been left unchanged. The pytest-codecov for patch is failing because of the parts of code that do not run on the main process. Not sure if it can be fixed.

Copy link
Member

@t-young31 t-young31 left a comment

Choose a reason for hiding this comment

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

I've got more comments – sorry. only suggestions really though. looks awesome overall 🚀

autode/utils.py Show resolved Hide resolved
install_xtb_ci.sh Outdated Show resolved Hide resolved
tests/test_calculation.py Outdated Show resolved Hide resolved
tests/test_graphs.py Show resolved Hide resolved
@t-young31 t-young31 merged commit 23af779 into duartegroup:v1.4.0 Jan 16, 2023
t-young31 added a commit that referenced this pull request Feb 20, 2023
…ing (#202)

* make autode compatible with windows: replace multiprocessing with joblib and loky

* remove comment autode/utils.py

* check total memory in utils

* use loky for parallel processing

* loky context is used for better handling of parallelisation

* fixes for timeout wrapper in POSIX

* use class instances instead of class attributes for Config

* pass parent Config state into child processes

* keep default timeout wrapper, also add new wrapper

* separate parallelisation scheme for windows, restore default for linux/mac

* fix test_config_in_worker_proc for posix

* codecov on windows

* add tests for config copy

* change config implementation for updating in worker process

* add context manager for temporary config, minor fix in experimental timeout for windows

* add tests for context manager

* use bash for installing xtb in CI runner

* add tests for cleanup after timeout

* exclude setup.py from codecov

* make config picklable and easily readable

* add test and minor fixes

* move xtb install script to .github/scripts

* use temporary_config for test_utils.py

* update changelog and contributor list

* resolve conflicts with v1.4.0

Co-authored-by: Tom Young <39765193+t-young31@users.noreply.github.com>
shoubhikraj added a commit to shoubhikraj/autodE that referenced this pull request Feb 21, 2023
* Ignore doc paths for code CI (duartegroup#235)

* Ignore doc paths for code CI

* Update PR template

* Add "ERROR" level to logging (duartegroup#231)

* add ERROR level to logging

* update docs for logging

* update tests for logging

* update changelog

* Fix parsing Qchem v6 output (duartegroup#234)

* Fix parsing Qchem v6 output

* Fix units for values div mul (duartegroup#242)

* Fix units for div mul

* Update changelog

* Update workflow (duartegroup#244)

* Fix xtb opt with cartesian coordinates (duartegroup#247)

* Fix xtb opt with cartesian coordinates

* Update changelog [skip actions]

* Remove hessian conversion on normal mode calculation (duartegroup#243)

* Ensure no unit conversion in hessian

* Use a copy for value and valuearray

* Raise exception on value `to` with inplace

* Add missed changelog updates

* Template for v1.4.0 (duartegroup#203)

* Make autodE compatible with Windows and change parallel process handling (duartegroup#202)

* make autode compatible with windows: replace multiprocessing with joblib and loky

* remove comment autode/utils.py

* check total memory in utils

* use loky for parallel processing

* loky context is used for better handling of parallelisation

* fixes for timeout wrapper in POSIX

* use class instances instead of class attributes for Config

* pass parent Config state into child processes

* keep default timeout wrapper, also add new wrapper

* separate parallelisation scheme for windows, restore default for linux/mac

* fix test_config_in_worker_proc for posix

* codecov on windows

* add tests for config copy

* change config implementation for updating in worker process

* add context manager for temporary config, minor fix in experimental timeout for windows

* add tests for context manager

* use bash for installing xtb in CI runner

* add tests for cleanup after timeout

* exclude setup.py from codecov

* make config picklable and easily readable

* add test and minor fixes

* move xtb install script to .github/scripts

* use temporary_config for test_utils.py

* update changelog and contributor list

* resolve conflicts with v1.4.0

Co-authored-by: Tom Young <39765193+t-young31@users.noreply.github.com>

* update docs (duartegroup#229)

* update docs for windows installation and temporary_config

* update docs for windows installation and temporary_config

* minor edit

Co-authored-by: Tom Young <39765193+t-young31@users.noreply.github.com>

* Autouse tempoary_config (duartegroup#236)

* minor fixes

---------

Co-authored-by: Tom Young <39765193+t-young31@users.noreply.github.com>
@shoubhikraj shoubhikraj mentioned this pull request Jun 8, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants