Skip to content

Commit

Permalink
Merge pull request #26 from paulsaxe/main
Browse files Browse the repository at this point in the history
Adding Docker build and release, plus code to use it.
  • Loading branch information
paulsaxe authored Feb 26, 2024
2 parents f10072e + 922d8cf commit 6aa6ed6
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 10 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/Docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Docker

on:
workflow_dispatch:
push:
branches:
- "main"

jobs:
docker:
name: Docker
uses: molssi-seamm/devops/.github/workflows/Docker.yaml@main
with:
image : molssi-seamm/seamm-psi4
description: An Psi4 executable packaged for use with SEAMM or standalone
platforms: linux/amd64
secrets: inherit
10 changes: 10 additions & 0 deletions .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ jobs:
with:
src : psi4_step
secrets: inherit

docker:
name: Docker
needs: release
uses: molssi-seamm/devops/.github/workflows/Docker.yaml@main
with:
image : molssi-seamm/seamm-psi4
description: An Psi4 executable packaged for use with SEAMM or standalone
platforms: linux/amd64
secrets: inherit
8 changes: 8 additions & 0 deletions devtools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM molssi/mamba141

COPY ./environment.yml /root/environment.yml

RUN mamba env update -f /root/environment.yml

WORKDIR /home
CMD ["psi4", "mopac.dat"]
8 changes: 8 additions & 0 deletions devtools/docker/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: base
channels:
- conda-forge
dependencies:
- python
- geometric
- psi4

35 changes: 35 additions & 0 deletions psi4_step/data/psi4.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Configuration options for how to run Psi4

[local]
# The code to use. This may maybe more than just the name of the code, and variables in braces
# {} will be expanded. For example:
# code = mpiexec -np {NTASKS} lmp_mpi
# would expand {NTASKS} to the number of tasks and run the command
code = psi4 -n {NTASKS}

# The type of local installation to use. Options are:
# conda: Use a conda environment
# modules: Use the modules system
# local: Use a local installation
# By default SEAMM installs Psi4 using conda.
installation = conda

# The Conda environment to use. This is the name or full path of the environment to use.
conda-environment = seamm-psi4

# The modules to load to run Psi4. This is a list of strings, each of which
# is a module to load. For example, to load the modules psi4 and openmpi,
# you would use:
# modules = psi4 openmpi
# modules =

[docker]
# The code to use. This may maybe more than just the name of the code, and variables in braces
# {} will be expanded. For example:
# code = mpiexec -np {NTASKS} lmp_mpi
# would expand {NTASKS} to the number of tasks and run the command
code = psi4 -n {NTASKS}

# The name and location of the Docker container to use, optionally with the version
container = ghcr.io/molssi-seamm/seamm-psi4:{version}

40 changes: 32 additions & 8 deletions psi4_step/psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"""

import configparser
import importlib
import json
import logging
from pathlib import Path
import pprint
import shutil

import psi4_step
import seamm
Expand Down Expand Up @@ -454,17 +456,39 @@ def run(self):
else:
executor = self.flowchart.executor

# Read configuration file for Psi4
ini_dir = Path(seamm_options["root"]).expanduser()
full_config = configparser.ConfigParser()
full_config.read(ini_dir / "psi4.ini")
# Read configuration file for Psi4 if it exists
executor_type = executor.name
full_config = configparser.ConfigParser()
ini_dir = Path(seamm_options["root"]).expanduser()
path = ini_dir / "psi4.ini"

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

# If the section we need doesn't exists, get the default
if not path.exists() or executor_type not in full_config:
resources = importlib.resources.files("psi4_step") / "data"
ini_text = (resources / "psi4.ini").read_text()
full_config.read_string(ini_text)

# Getting desperate! Look for an executable in the path
if executor_type not in full_config:
raise RuntimeError(
f"No section for '{executor_type}' in Psi4 ini file "
f"({ini_dir / 'psi4.ini'})"
)
path = shutil.which("psi4")
if path is None:
raise RuntimeError(
f"No section for '{executor_type}' in Psi4 ini file "
f"({ini_dir / 'psi4.ini'}), nor in the defaults, nor "
"in the path!"
)
else:
full_config[executor_type] = {
"installation": "local",
"code": f"{path} -n {{NTASKS}}",
}

config = dict(full_config.items(executor_type))
# Use the matching version of the seamm-psi4 image by default.
config["version"] = self.version

printer.important(
self.indent
Expand Down
4 changes: 2 additions & 2 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ def get_config_from_root(root):
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.SafeConfigParser()
parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory

def get(parser, name):
Expand Down

0 comments on commit 6aa6ed6

Please sign in to comment.