This repository provides instructions for installing and running AutoMech from source, as a developer.
If you are a brand new AutoMech developer, start by following the instructions in Appendix A to fork the AutoMech repositories.
The following steps only need to be done once per machine.
- Clone this
amech-dev
repository wherever you want your AutoMech source code to live andcd
into it before continuing.1
git clone https://github.com/Auto-Mech/amech-dev.git
cd amech-dev/
- If you haven't already, follow the instructions in Appendix B to install Pixi. This will be your package manager for AutoMech development. Then run the following command to create the Pixi environment for this project.
pixi install
- If you haven't already, follow the instructions in
Appendix C to set up SSH authentication with
your GitHub account.
Then run the following Pixi task to download the repositories for each of the five
AutoMech modules into
src/
and check out theirdev
branches. (The bash script for this task is inscripts/
and can be modified as needed.)
pixi run download
- Run the following Pixi task install each of the main AutoMech modules into your Pixi environment in edit mode.
pixi run install
- Check that the installation worked by running the following help command. You should see some documentation for the AutoMech CLI.
pixi shell # activate the environment
automech --help
- Set the following environment variable in your
~/.bashrc
file to turn off Python output buffering.
export PYTHONUNBUFFERED=1
To test that the code is operational, you can run the "simple" example provided in the MechDriver repository as follows.
pixi shell # activate the environment
cd src/mechdriver/examples/quick/
automech run &> out.log &
Running automech run --help
will allow you to see the options for this command.
If you want to activate this Pixi environment from within a shell script, the best way to do that is with the following command:
eval "$(pixi shell-hook --manifest-path /path/to/amech-dev/pixi.toml)"
You will need to edit the path to point to wherever you cloned this repository.
To see available MechAnalyzer commands for things like stereoexpansion and sorting, run mechanalyzer --help
.
To run AutoMech (or another command) on a node to which you have SSH access, you can use the following Pixi task:
pixi run node <node> <log file> <command>
If unspecified, the default command is "automech run" and the default log file is "out.log".
Examples:
pixi run node csed-0001 # run AutoMech
pixi run node csed-0001 out.log "g16 run.inp run.out" # run Gaussian
The data generated here is compressed and stored in the MechDriver repository to be used on step 2.
pixi run test setup # create clean run directories
pixi run test els <node> # run data generation on a node, e.g. csed-0005
pixi run test status # check data generation progress
This step uses the data from step 1 to run an end-to-end workflow with the code.
pytest -v src/mechdriver/tests/
Although this works with old data, step 1 should be regularly re-run to catch any bugs related to electronic structure data generation. This is currently an honor system.
If you followed the instructions above, you are running AutoMech directly from the
source code in src/
and can make changes to it as needed.
This repository provides two helper scripts for interacting with these repositories all at once...
Script 1: Update. Run the following script early (i.e. before you make changes) and often to stay in sync with other developers and avoid merge conflicts.2
pixi run update
Script 2: Check for changes. Run the following script to see which repositories you have changed.3
pixi run git status
Development workflow.
Other commands, such as git add
and git commit
, should be run manually inside the
individual repositories.
The recommended development workflow is as follows:
pixi run update
- update early and often- Make changes to the code...
- Run the code to test your changes...
pixi run git status
- see where you made changescd src/<repository directory>
- enter a repository with changes (do this for each one)git add --patch
- answer the prompts to decide which changes to keepgit checkout .
- discard the remaining changesgit commit
- write a meaningful commit message with your choice of text editor, which can be configured as follows:git config --global core.editor "vim"
(don't use-m
!)git pull --rebase upstream dev
- make sure you are up to date with the central repositorygit push origin dev
- you may need to add--force
if the rebase pulled in changes- On GitHub, submit a pull request with your changes.
As always, small, frequent commits are preferable to large, infrequent ones.
You can build the AutoMech conda package as follows:
pixi run build
If one of the C/C++/Fortran codes in src/automech-toolbox
needs to be updated, you
would first run the following:
pixi run -e build build-toolbox
For the AutoMech-Toolbox codes, note that the MESS executables are not compiled from source. Instead, they are downloaded from the MESS GitHub page and will need to be updated there if MESS has changed.
At the end, the build script will print the appropriate command for you to upload the
package to Anaconda.org, which should look something like the following.
Note that you will need to set the ANACONDA_API_KEY
environment variable with your API
key from Anaconda.org.
export ANACONDA_API_KEY=<API token>
rattler-build upload anaconda -o Auto-Mech output/noarch/*.conda
To get started as a new developer, log into GitHub (or create an account) and follow these instructions to fork the following five repositories:
This repository is set up to use Pixi for package management. You can install Pixi by running the following command:
curl -fsSL https://pixi.sh/install.sh | bash
This script will update your ~/.bash_profile
and you may need to restart your shell
for the changes to take effect.
The main Pixi commands to be aware of are as follows.
pixi install
: Creates (or updates) an environment in a project directory using apixi.toml
file.pixi shell
: Activates a project environment.pixi add <package name>
: Adds a package to a project environment.
Note:
Adding packages to an environment will automatically update your pixi.toml
and
pixi.lock
files with the new dependencies.
If other users will need these in order to run the code, be sure to submit a pull
request with these changes to the main amech-dev repository.
Other developers will then be able to run pixi install
again to update their environments.
See here for further Pixi documentation.
To communicate with your forked GitHub repositories, you will need to generate an SSH key for your machine and add it to your GitHub account. This will allow you to push to your GitHub forks without a password. Follow these two steps to get set up:
- Follow these instructions to generate a new SSH key, if you haven't already. (You can ignore the other instructions on the linked page.)
- Follow these instructions to add the new key to your GitHub account.
Footnotes
-
If changes are made to the
amech-dev
repository, you can update usinggit pull origin main
. Developers who may want to contribute to this repository should follow the usual procedure to fork and clone, adding the centralAuto-Mech
repo as theupstream
remote. In this case, you will update youramech-dev
repository usinggit pull --rebase upstream main && git push --force origin main
. ↩ -
If syncing your own fork between different machines, you can specify the remote and branch to update against, i.e.
pixi run update origin dev
(the default isupstream dev
). You can also add the--force
flag to overwrite the history on your GitHub fork when it gets out of sync, i.e.pixi run update upstream dev --force
. ↩ -
This script simply runs
git status
in each repository. If you want to run a different command, you can pass it as an argument, i.e.pixi run git branch -v
to see which branches are checked out. ↩