Skip to content

Commit

Permalink
Add basic error logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Jan 23, 2024
1 parent fee0214 commit f121f97
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 226 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ emle-server --backend torchani
When using the `orca` backend, you will also need to specify the path to the
*real* `orca` exectubale using the `--orca-path` command-line argument, or the
`EMLE_ORCA_PATH` environment variable. (To check that EMLE is running, look for
an `emle_log.txt` file in the working directory, where. The input for `orca` will
a log or settings file in the working directory.) The input for `orca` will
be taken from the `&orc` section of the `sander` configuration file, so use this
to specify the method, etc.

Expand Down Expand Up @@ -206,11 +206,18 @@ are electron charge.

## Logging

Energies can be written to a log file using the `--log` command-line argument or
the `EMLE_LOG` environment variable. This should be an integer specifying the
frequency at which energies are written. (The default is 1, i.e. every step
is logged.) The output will look something like the following, where the
columns specify the current step, the in vacuo energy and the total energy.
Energies can be written to a file using the `--energy-file` command-line argument
or the `EMLE_ENERGY_FILE` environment variable. The frequency of logging can be
specified using `--energy-frequency` or `EMLE_ENERGY_FREQUENCY`. This should be an
integer specifying the frequency at which energies are written. (The default is
1, i.e. every step is logged.) The output will look something like the following,
where the columns specify the current step, the in vacuo energy and the total
energy.

General log messages are written to the file specified by the `--log-file` or
`EMLE_LOG_FILE` options. (The default is `emle_log.txt`.) The log level can be
adjusted by using the `--log-level` or `EMLE_LOG_LEVEL` options. For performance,
the default log level is set to `ERROR`.

```
# Step E_vac (Eh) E_tot (Eh)
Expand Down Expand Up @@ -288,9 +295,9 @@ Alternatively, if two values are passed then these will be used as initial and
final values of λ, with the additional `--interpolate-steps` option specifying
the number of steps (calls to the server) over which λ will be linearly
interpolated. (This can also be specified using the `EMLE_INTERPOLATE_STEPS`
environment variable.) In this case the `emle_log.txt` file will contain output
similar to that shown below. The columns specify the current step, the current
λ value, the energy at the current λ value, and the pure MM and EMLE energies.
environment variable.) In this case the log file will contain output similar
to that shown below. The columns specify the current step, the current λ value,
the energy at the current λ value, and the pure MM and EMLE energies.

```
# Step λ E(λ) (Eh) E(λ=0) (Eh) E(λ=1) (Eh)
Expand Down
33 changes: 29 additions & 4 deletions bin/emle-server
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ external_backend = os.getenv("EMLE_EXTERNAL_BACKEND")
plugin_path = os.getenv("EMLE_PLUGIN_PATH")
device = os.getenv("EMLE_DEVICE")
try:
log = int(os.getenv("EMLE_LOG"))
energy_frequency = int(os.getenv("EMLE_ENERGY_FREQUENCY"))
except:
log = 1
energy_frequency = 1
energy_file = os.getenv("EMLE_energy_file")
log_level = os.getenv("EMLE_LOG_LEVEL")
log_file = os.getenv("EMLE_LOG_FILE")
save_settings = os.getenv("EMLE_SAVE_SETTINGS")
orca_template = os.getenv("EMLE_ORCA_TEMPLATE")
deepmd_model = os.getenv("EMLE_DEEPMD_MODEL")
Expand Down Expand Up @@ -131,7 +134,10 @@ env = {
"orca_path": orca_path,
"restart": restart,
"orca_template": orca_template,
"log": log,
"energy_frequency": energy_frequency,
"energy_file": energy_file,
"log_level": log_level,
"log_file": log_file,
"save_settings": save_settings,
}

Expand Down Expand Up @@ -275,11 +281,30 @@ parser.add_argument(
required=False,
)
parser.add_argument(
"--log",
"--energy-frequency",
type=int,
help="The frequency of logging energies to file",
required=False,
)
parser.add_argument(
"--energy-file",
type=str,
help="The file to log energies to",
required=False,
)
parser.add_argument(
"--log-level",
type=str,
help="The logging level",
choices=["TRACE", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
required=False,
)
parser.add_argument(
"--log-file",
type=str,
help="The file to log to",
required=False,
)
parser.add_argument(
"--save-settings",
action=argparse.BooleanOptionalAction,
Expand Down
Loading

0 comments on commit f121f97

Please sign in to comment.