Skip to content

Commit

Permalink
πŸ“š Update README.md
Browse files Browse the repository at this point in the history
Update the `README.md` instructions to the latest changes. Also includes a
minor change in the `init` command, which now uses the `default` input of the
`Prompt.ask` method. This means the user can simply press enter to use the
shell detected from the `SHELL` environment variable.
  • Loading branch information
mbercx committed Jun 8, 2023
1 parent 2b57b99 commit 8f3d5ea
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 37 deletions.
137 changes: 102 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,72 @@ Tool for managing AiiDA "projects" - Python environments tailored to AiiDA with
|---|


## Usage

## Installation

1. Easy to install globally via `pipx`:
The package can be installed globally with `pipx`:

```console
aiida@prnmarvelsrv3:~$ pipx install aiida-project
installed package aiida-project 0.3.0, Python 3.8.10
These binaries are now globally available
pipx install aiida-project
```
```console
installed package aiida-project 0.4.0, installed using Python 3.9.16
These apps are now globally available
- aiida-project
done! ✨ 🌟 ✨
```

2. Create projects with their own virtual environment, and immediately install `aiida-core` and the plugins you need:
See the [`pipx` installation instructions](https://pypa.github.io/pipx/installation/) if you haven't already installed `pipx`.

## Usage

After installing `aiida-project`, run the `init` command to get started:

```console
aiida@prnmarvelsrv3:~$ aiida-project create firstproject --plugins aiida-quantumespresso
✨ Creating the project environment and directory.
πŸ”§ Adding the AiiDA environment variables to the activate script.
βœ… Success! Project created.
πŸ’Ύ Installing the latest release of the AiiDA core module.
πŸ’Ύ Installing aiida-quantumespresso
aiida-project init
```
```console
πŸ‘‹ Hello there! Which shell are you using? [bash/zsh/fish] (zsh):

βœ¨πŸš€ AiiDA-project has been initialised! πŸš€βœ¨

Info: For the changes to take effect, run the following command:

source /Users/mbercx/.zshrc

or simply open a new terminal.
```

This will also add the `cda` function to your shell startup file, so you can easily switch projects.
Note that you'll have to source your e.g. `.zshrc` file for this function to be accessible!

### `create`

3. Supports virtualenv for now, integrated with virtualenvwrapper (`conda`/`mamba` support coming soon!):
After initialising, you can create new projects with their own virtual environment and project directory using the `create` command.
The latest version of `aiida-core` will also be installed automatically, along with any plugins you specify with the `--plugin` option:

```console
aiida@prnmarvelsrv3:~$ workon firstproject
aiida-project create firstproject --plugin aiida-quantumespresso
```
```console
✨ Creating the project directory and environment using the Python binary:
/opt/homebrew/Cellar/python@3.11/3.11.3/Frameworks/Python.framework/Versions/3.11/bin/python3.11
πŸ”§ Adding the AiiDA environment variables to the activate script.
βœ… Success: Project created.
πŸ’Ύ Installing the latest release of the AiiDA core module.
πŸ’Ύ Installing `aiida-quantumespresso` from the PyPI.
```

4. Automatically sets some typical AiiDA UNIX environment variables, like AIIDA_PATH and the shell completion (bash for now, `zsh`/`fish` support coming soon!):
You can then activate the project using the `cda` command described above:

```console
(firstproject) aiida@prnmarvelsrv3:~$ cd $AIIDA_PATH
cda firstproject
```

5. Automatically sets up a well-organised directory structure, which can be configured globally:
Next to activating the Python virtual environment, this will also change the directory to the one for the project.
`aiida-project` automatically sets up a directory structure, which we intend to be made configurable globally:

```console
(firstproject) aiida@prnmarvelsrv3:~/project/firstproject$ tree -a
(firstproject) ~/project/firstproject$ tree -a
.
β”œβ”€β”€ .aiida
β”‚ β”œβ”€β”€ access
Expand All @@ -61,7 +87,62 @@ aiida@prnmarvelsrv3:~$ workon firstproject
9 directories, 1 file
```

6. For now it just installs AiiDA and plugins, but in the future we want it to be able to also automatically set up the AiiDA database, repository and default profile.
**Note:** You may not have the [`tree`](https://en.wikipedia.org/wiki/Tree_(command)) command installed on your system.

### `destroy`

Projects can be cleaned up by using `aiida-project destroy`.
First `deactivate` the environment:

```console
deactivate firstproject
```

Next you can run the `destroy` command:

```console
aiida-project destroy firstproject
```
```console
❗️ Are you sure you want to delete the entire firstproject project? This cannot be undone! [y/N]: y
Succes: Project with name firstproject has been destroyed.
```

This will remove both the virtual environment, as well as the whole project folder:

```console
~/project$ tree -a
.
└── .aiida_projects
β”œβ”€β”€ conda
└── virtualenv

3 directories, 0 files
```

## Other features

### `virtualenvwrapper` integration

If you are already using `virtualenvwrapper`, the virtual environments will be installed in the same directory as the one used by `virtualenvwrapper` (i.e. `$WORKON_HOME`).
So you can then also use the

```console
aiida@prnmarvelsrv3:~$ workon firstproject
```

### Environment configuration

Automatically sets some typical AiiDA UNIX environment variables, like AIIDA_PATH and the shell completion (`bash`/`zsh` for now, `fish` support coming soon!):

```console
$ echo $AIIDA_PATH
/Users/mbercx/project/firstproject
```

## Future goals

* For now it just installs AiiDA and plugins, but in the future we want it to be able to also automatically set up the AiiDA database, repository and default profile.

```console
(firstproject) aiida@prnmarvelsrv3:~/project/firstproject$ verdi status
Expand All @@ -71,7 +152,7 @@ aiida@prnmarvelsrv3:~$ workon firstproject
Report: Configure a profile by running `verdi quicksetup` or `verdi setup`.
```

7. Projects are pydantic data models, and are stored as JSON in the .aiida_projects directory. Over time it should be possible to completely regenerate a project based on this file, but that’s still a work in progress:
* Projects are pydantic data models, and are stored as JSON in the .aiida_projects directory. Over time it should be possible to completely regenerate a project based on this file, but that’s still a work in progress:

```console
(firstproject) aiida@prnmarvelsrv3:~/project/firstproject$ cd ..
Expand All @@ -83,17 +164,3 @@ Report: Configure a profile by running `verdi quicksetup` or `verdi setup`.

2 directories, 1 file
```

8. Projects can be cleaned up by using `aiida-project destroy`:

```console
(firstproject) aiida@prnmarvelsrv3:~/project$ aiida-project destroy firstproject
Are you sure you want to delete the entire firstproject project? This cannot be undone! [y/N]: y
(firstproject) aiida@prnmarvelsrv3:~/project$ tree -a
.
└── .aiida_projects
β”œβ”€β”€ conda
└── virtualenv

3 directories, 0 files
```
6 changes: 4 additions & 2 deletions aiida_project/commands/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def init(shell: Optional[ShellType] = None):

if not shell_str:
shell_str = os.environ.get("SHELL")
detected_shell = shell_str.split("/")[-1] if shell_str else None
prompt_message = "πŸ‘‹ Hello there! Which shell are you using?"
prompt_message += f" [blue]({shell_str.split('/')[-1]} detected)" if shell_str else ""
shell_str = prompt.Prompt.ask(
prompt=prompt_message, choices=[shell_type.value for shell_type in ShellType]
prompt=prompt_message,
choices=[shell_type.value for shell_type in ShellType],
default=detected_shell,
)

if shell_str == "fish":
Expand Down

0 comments on commit 8f3d5ea

Please sign in to comment.