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

Bugfix: initial version of dftbplus.ini #38

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.7.29 -- Bugfix: initial version of dftbplus.ini
* The initial version of dftbplus.ini was not generated correctly if it was
missing. This caused a crash when running DFTB+.

2024.4.24 -- Finalized support for Docker containers
* Fixed issues and tested running in containers.
* Add CI to make a Docker image for DFTB+
Expand Down
1 change: 1 addition & 0 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
# molsystem requires, and only available via Conda.
- hsd-python
- seamm
- seamm-installer
- seamm-util
- tabulate

Expand Down
35 changes: 18 additions & 17 deletions dftbplus_step/dftbplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import importlib
import json
import logging
import os
from pathlib import Path
import pprint # noqa: F401
import shutil
Expand Down Expand Up @@ -491,14 +492,19 @@ def get_exe_config(self):
ini_dir = Path(self.global_options["root"]).expanduser()
path = ini_dir / "dftbplus.ini"

if path.exists():
full_config.read(ini_dir / "dftbplus.ini")

# If the section we need doesn't exists, get the default
if not path.exists() or executor_type not in full_config:
# If the config file doesn't exists, get the default
if not path.exists():
resources = importlib.resources.files("dftbplus_step") / "data"
ini_text = (resources / "dftbplus.ini").read_text()
full_config.read_string(ini_text)
txt_config = seamm_util.Configuration(path)
txt_config.from_string(ini_text)

# Work out the conda info needed
txt_config.set_value("local", "conda", os.environ["CONDA_EXE"])
txt_config.set_value("local", "conda-environment", "seamm-dftbplus")
txt_config.save()

full_config.read(ini_dir / "dftbplus.ini")

# Getting desperate! Look for an executable in the path
if executor_type not in full_config:
Expand All @@ -510,17 +516,12 @@ def get_exe_config(self):
"in the path!"
)
else:
full_config[executor_type] = {
"installation": "local",
"code": str(path),
}

# If the ini file does not exist, write it out!
if not path.exists():
with path.open("w") as fd:
full_config.write(fd)
printer.normal(f"Wrote the DFTB+ configuration file to {path}")
printer.normal("")
txt_config = seamm_util.Configuration(path)
txt_config.add_section(executor_type)
txt_config.set_value(executor_type, "installation", "local")
txt_config.set_value(executor_type, "code", str(path))
txt_config.save()
full_config.read(ini_dir / "dftbplus.ini")

self._exe_config = dict(full_config.items(executor_type))
# Use the matching version of the seamm-dftbplus image by default.
Expand Down
Loading