Skip to content

Commit 80c231b

Browse files
Merge pull request #1327 from douglasjacobsen/gemini-context
Add Gemini context file to Ramble
2 parents f0958c4 + a285c64 commit 80c231b

File tree

1 file changed

+278
-0
lines changed

1 file changed

+278
-0
lines changed

GEMINI.md

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
# Gemini Context for Ramble
2+
3+
**Objective:** This document guides the Gemini CLI in assisting with questions and tasks related to the Ramble experimentation framework.
4+
5+
## What is Ramble?
6+
7+
Ramble is a multi-platform experimentation framework written in Python, designed to increase exploration productivity and improve reproducibility. It helps automate and manage tasks such as:
8+
9+
* Software installation (often using Spack)
10+
* Acquiring input files
11+
* Configuring experiments (e.g., parameter sweeps, scaling studies)
12+
* Executing experiments
13+
* Extracting and analyzing results
14+
15+
Ramble works on Linux, macOS, and many supercomputers.
16+
17+
## Ramble Command Line Interface (CLI)
18+
19+
Ramble is primarily controlled through the `ramble` command. Key aspects of the CLI include:
20+
21+
* You should always examing the command line interface before you execute any ramble commands, as the arguments might change over time.
22+
* **Getting Help:** Users can get help on any command by using `ramble help` or `ramble help --all` for more detailed information on all commands. Help is also available for subcommands (e.g., `ramble workspace --help`).
23+
* **Discovering Commands and Depth:** To discover the full command hierarchy and determine its maximum depth, start with `ramble help --all`. For any command that shows `...` in its help text (indicating it has subcommands), run that command with `--help` or `-h` to explore its subcommands (e.g., `ramble workspace --help`). This process can be repeated recursively until no more subcommands are found. The longest chain of commands reveals the maximum depth of the CLI.
24+
* **Key Commands:**
25+
* `ramble workspace create`: To set up a new experiment workspace.
26+
* `ramble workspace config`: To manage workspace configurations.
27+
* `ramble run`: To execute the experiments defined in the workspace.
28+
* `ramble list`: To list available applications, modifiers, etc.
29+
* `ramble config`: To manage Ramble's configuration settings.
30+
* `ramble repo`: To manage Ramble repositories.
31+
* **Command Reference:** A full list of commands and their options is available in the [Command Reference](https://ramble.readthedocs.io/en/latest/command_index.html) section of the documentation.
32+
33+
## Ramble Configuration Files
34+
35+
Ramble uses YAML files for configuration, drawing inspiration from Spack's configuration system. Configurations are applied in scopes, with higher precedence scopes overriding lower ones (e.g., user settings override system defaults, workspace settings override user settings).
36+
37+
### Workspace Configuration
38+
39+
* **Main File:** Each workspace has a primary configuration file located at `$workspace/configs/ramble.yaml`. This file defines the experiments, software, and variables for the workspace.
40+
* **Structure:** All content within `ramble.yaml` lives under the top-level `ramble:` dictionary.
41+
* **Detailed Documentation:** [Workspace Configuration File](https://ramble.readthedocs.io/en/latest/workspace_config.html)
42+
43+
### Configuration Sections
44+
45+
Ramble supports various sections within its configuration files. These can exist in the workspace `ramble.yaml`, in separate files within `$workspace/configs/`, or in other configuration scopes (user, site, system). Key sections include:
46+
47+
* `applications`: Defines the experiments to be generated, including application, workload, and experiment scopes, variables, matrices, etc.. See the [Application Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#application-section).
48+
* `config`: Controls internal Ramble behavior, shell settings, Spack command flags, and upload configurations. See the [Config Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#config-section).
49+
* `env_vars`: Manages environment variable modifications (set, append, prepend, unset) for experiments. See the [Environment Variables Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#environment-variables-section).
50+
* `software`: Defines software packages and environments, specifying package manager specs (e.g., Spack specs), compilers, and dependencies. See the [Software Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#software-section).
51+
* `variables`: Defines key-value pairs used for parameterization and expansion within other configuration sections and templates. See the [Variables Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#variables-section).
52+
* `variants`: Customizes variants for experiment creation, such as selecting the `package_manager`. See the [Variants Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#variants-section).
53+
* `modifiers`: Specifies experiment modifiers to be applied to experiments, including mode and target executables. See the [Modifiers Section](https://ramble.readthedocs.io/en/latest/configuration_files.html#modifiers-section).
54+
* `repos`: Lists paths to repositories containing Application definitions.
55+
* `modifier_repos`: Lists paths to repositories containing Modifier definitions.
56+
* **Other Sections:** `formatted_executables`, `internals`, `licenses`, `mirrors`, `success_criteria`.
57+
58+
* **Full Details:** See the [Configuration Files Documentation](https://ramble.readthedocs.io/en/latest/configuration_files.html) for a complete description of all sections and scopes.
59+
60+
## Package Managers
61+
62+
Ramble can leverage various package managers to install the software required for experiments. The configuration of package managers is detailed in the [Package Managers Documentation](https://ramble.readthedocs.io/en/latest/package_managers.html).
63+
64+
### Spack
65+
66+
A key feature of Ramble is its ability to manage software stacks, often using **Spack**.
67+
68+
* **Spack:** Spack is a flexible package manager for supercomputers, Linux, and macOS, supporting multiple versions, configurations, platforms, and compilers.
69+
* **Ramble's Usage:** Ramble can be configured to use an existing Spack instance. Experiment configuration files in Ramble define the software stacks required, which Ramble can then realize using Spack.
70+
* **Spack Documentation:** To understand how to use Spack, specify packages, versions, compilers, and variants, refer to the official Spack Documentation:
71+
* **Spack Homepage:** [https://spack.io/](https://spack.io/)
72+
* **Spack Documentation:** [https://spack.readthedocs.io/en/latest/](https://spack.readthedocs.io/en/latest/)
73+
* [Getting Started](https://spack.readthedocs.io/en/latest/getting_started.html)
74+
* [Spec Syntax](https://spack.readthedocs.io/en/latest/spec_syntax.html)
75+
* [Spack Environments](https://spack.readthedocs.io/en/latest/replace_conda_homebrew.html)
76+
* [Command Reference](https://spack.readthedocs.io/en/latest/command_index.html)
77+
* **Key Concepts:** When assisting with Ramble and Spack, be aware of Spack concepts like `spack.yaml`, environments, compilers, and specs.
78+
79+
## Developing New Object Definitions
80+
81+
Ramble is extensible through user-defined objects. These objects are Python classes that follow specific conventions and structures. Ramble uses a specialized language structure, defined in Python, to parse and manage these definitions.
82+
83+
* **Definition Files:** Each object definition resides in a Python file (e.g., `application.py` for an application) within a directory named after the object inside a repository.
84+
* **Object Types:** The primary object types that users can define include:
85+
* **Applications:** Define the core software and execution logic for an experiment.
86+
* **Modifiers:** Allow for systematic alterations to application configurations or execution parameters.
87+
* **Package Managers:** Interfaces to software installation tools like Spack, EESSI, etc.
88+
* **Workflow Managers:** Interfaces to batch systems or workflow tools (e.g., Slurm, LSF).
89+
These types, and their base classes, are enumerated in `lib/ramble/ramble/repository.py` within the `ObjectTypes` Enum.
90+
* **Ramble Definition Language:** Ramble uses a set of Python classes and decorators to define the structure and attributes of each object type. These are implemented in the `lib/ramble/ramble/language` directory. This includes files like:
91+
* `application_language.py`
92+
* `modifier_language.py`
93+
* `package_manager_language.py`
94+
* `workflow_manager_language.py`
95+
* `shared_language.py`
96+
These modules define the valid keywords, sections, and expected types for the object definition classes.
97+
* **Developer Guides:** Ramble provides guides for creating new definitions:
98+
* [Application Definition Developers Guide](https://ramble.readthedocs.io/en/latest/dev_guides/application_dev_guide.html)
99+
* [Modifier Definition Developers Guide](https://ramble.readthedocs.io/en/latest/dev_guides/modifier_dev_guide.html)
100+
* [Package Manager Definition Developers Guide](https://ramble.readthedocs.io/en/latest/dev_guides/package_manager_dev_guide.html)
101+
* [Advanced Topics for Definition Developers](https://ramble.readthedocs.io/en/latest/dev_guides/advanced_topics.html)
102+
103+
New definitions are typically placed in a user-created repository and added to the Ramble configuration.
104+
105+
### How to Write an Application Definition
106+
107+
This section provides a practical guide for creating a new Ramble application definition by focusing on the key patterns and concepts.
108+
109+
1. **Repository Structure**: To determine the correct directory structure for a custom definition, inspect the `ObjectTypes` Enum in `lib/ramble/ramble/repository.py`. This enum defines the valid object types (e.g., `APPLICATIONS`, `MODIFIERS`). The value of each enum member (e.g., `'applications'`) is the name of the required subdirectory within a repository. Each specific definition should then be placed in its own directory inside that subdirectory. For example, a new application would be located at `my-repo/applications/my-app-name/application.py`.
110+
111+
2. **The Definition File**: The definition file (e.g., `application.py`) contains a Python class that inherits from a base class. There are two categories of base definitions to be aware of:
112+
* **Fundamental Base Classes**: These are the abstract building blocks for new definitions (e.g., `executable-application`, `basic-modifier`). This is the most common starting point for creating a new definition from scratch. You can discover them by running:
113+
```bash
114+
ramble list --type base_classes
115+
```
116+
* **Inheritable Concrete Definitions**: These are fully-formed definitions that are designed to be inherited by other definitions to promote code reuse (e.g., a `base_application` like `hpcg`). This is a more advanced pattern. You can discover them by running `ramble list --type base_<object_type>`, for example:
117+
```bash
118+
ramble list --type base_applications
119+
ramble list --type base_modifiers
120+
ramble list --type base_package_managers
121+
```
122+
123+
3. **Key Concepts and Patterns**:
124+
* **Declarative Directives**: The application's behavior is defined by calling special functions (directives) within the class body. Instead of writing imperative code, you declare the application's properties.
125+
* **Logical Grouping of Directives**: Directives can be understood in logical groups based on their purpose:
126+
* **Metadata**: Directives that set the application's `name`, `maintainers`, and `tags`.
127+
* **Software Dependencies**: Directives for specifying required software packages (`software_spec`) and compilers (`define_compiler`). These often contain package-manager-specific syntax.
128+
* **Execution & Workloads**: Directives for defining `executable` commands, `input_file` data sources, and `workload`s, which are combinations of executables and inputs that represent a specific test case.
129+
* **Parameterization**: The `workload_variable` directive is used to define parameters that can be set in the Ramble configuration, allowing for flexible and reusable workload definitions.
130+
* **Results & Validation**: Directives for defining how to parse results (`figure_of_merit`) and determine a successful run (`success_criteria`) from output files, typically using regular expressions.
131+
* **Templating**: A `register_template` directive exists to generate complex input or configuration files from a template file.
132+
* **Conditional Logic**: A core pattern in Ramble is the use of a `with when(...)` context manager. This allows directives to be applied conditionally, based on factors like the chosen package manager, system architecture, or other variants. This is the standard way to create a single, portable definition that works in multiple environments.
133+
134+
4. **Best Practices**:
135+
* **Study Existing Definitions**: The most effective way to understand the current, concrete syntax is to study the built-in application definitions. These provide real-world examples of the patterns described above. Good starting points are `hostname` (simple), `gromacs` (complex), and `hpcg` (inheritance).
136+
* **Write Informative Docstrings**: The docstring for the application class should clearly describe the application and include links to its official website, documentation, and source code.
137+
* **Check for Software Conflicts**: Before adding a new `software_spec`, check for existing definitions of the same package to ensure consistency.
138+
1. Get a summary of all existing software definitions: `ramble software-definitions --summary`
139+
2. Search the output for the package you intend to add.
140+
3. Use a consistent version and spec to avoid conflicts and encourage software reuse.
141+
4. After adding your `software_spec`, confirm that no conflicts were introduced: `ramble software-definitions --conflicts`
142+
143+
144+
## Key Ramble Resources
145+
146+
* **GitHub Repository:** [https://github.com/GoogleCloudPlatform/ramble](https://github.com/GoogleCloudPlatform/ramble)
147+
* Source code, issue tracker, and discussions.
148+
* The `develop` branch has the latest contributions.
149+
* **Documentation:** [https://ramble.readthedocs.io/en/latest/](https://ramble.readthedocs.io/en/latest/)
150+
* [Getting Started Guide](https://ramble.readthedocs.io/en/latest/getting_started.html)
151+
* [Tutorials](https://ramble.readthedocs.io/en/latest/tutorials.html)
152+
* [Configuration Files](https://ramble.readthedocs.io/en/latest/configuration_files.html)
153+
* [Ramble Workspace](https://ramble.readthedocs.io/en/latest/workspace.html)
154+
* [Package Managers](https://ramble.readthedocs.io/en/latest/package_managers.html)
155+
* [Developer Guides](https://ramble.readthedocs.io/en/latest/dev_guides.html)
156+
* [Command Reference](https://ramble.readthedocs.io/en/latest/command_index.html)
157+
* **Examples:** The [examples directory](https://github.com/GoogleCloudPlatform/ramble/tree/develop/examples) in the GitHub repo contains many example configuration files.
158+
159+
## Common Tasks & Questions
160+
161+
* **Using the CLI:** How to use `ramble` commands to perform tasks.
162+
* **Writing Configs:** Understanding the YAML syntax and available sections for `ramble.yaml` and other config files.
163+
* **Setting up a workspace:** Users often start by creating a Ramble workspace using `ramble workspace create`.
164+
* **Defining software:** Software requirements are specified in YAML configuration files, often leveraging Spack specs.
165+
* **Running experiments:** How to launch, monitor, and manage experiment sets.
166+
* **Creating new Components:** How to write new Application, Modifier, or other object definitions using Ramble's Python-based definition structure.
167+
* **Troubleshooting:** Issues related to software builds with Spack, configuration errors, or execution problems.
168+
169+
### Running a Simple Test Experiment
170+
171+
This workflow details how to create a workspace, configure it for a single experiment with a specific workload, and then run and analyze the experiment. This is a common task for quickly testing the Ramble environment.
172+
173+
1. **Create an empty workspace:**
174+
```bash
175+
ramble workspace create -d <workspace_name>
176+
```
177+
* The `-d` flag is important, as it creates an empty workspace directory.
178+
179+
2. **Add the experiment with a specific workload:**
180+
```bash
181+
ramble -D <workspace_name> workspace manage experiments <application_name> --workload-filter <workload_name>
182+
```
183+
* Replace `<application_name>` with the application you want to test (e.g., `hostname`).
184+
* Replace `<workload_name>` with the specific workload for that application (e.g., `local`).
185+
* The `-D <workspace_name>` flag directs the command to the correct workspace without needing to activate it globally.
186+
187+
3. **Verify the experiment configuration:**
188+
```bash
189+
ramble -D <workspace_name> workspace info
190+
```
191+
* This command should show that only the `<application_name>.<workload_name>.generated` experiment is configured.
192+
193+
4. **Set up the workspace:**
194+
```bash
195+
ramble -D <workspace_name> workspace setup
196+
```
197+
* This step generates the necessary scripts and files for the experiment to run.
198+
199+
5. **Run the experiment:**
200+
```bash
201+
ramble -D <workspace_name> on
202+
```
203+
204+
6. **Analyze the results:**
205+
```bash
206+
ramble -D <workspace_name> workspace analyze
207+
```
208+
209+
7. **View the results:**
210+
```bash
211+
cat <workspace_name>/results.latest.txt
212+
```
213+
214+
215+
## Guidance for Gemini
216+
217+
* When Ramble and software are mentioned together, a package manager like Spack is likely involved in the software installation process.
218+
* Refer to the official Ramble documentation on Read the Docs as the primary source of truth for Ramble-specific questions.
219+
* Refer to the official Spack documentation for questions about Spack usage, syntax, and concepts.
220+
* Direct users to the **Developer Guides** when they ask about creating new object types, and explain that definitions are Python classes using a structure defined in `ramble.language`.
221+
* Point users to the **Command Reference** for CLI usage questions.
222+
* For configuration questions, guide users to the **Configuration Files** and **Workspace Configuration File** sections of the Ramble documentation.
223+
* Use the examples in the GitHub repository to understand common configuration patterns.
224+
* Encourage users to provide their Ramble configuration files and any error messages for debugging.
225+
226+
## Running Unit Tests
227+
228+
Ramble uses `pytest` for its unit tests. The tests can be run using a wrapper command, `ramble unit-test`.
229+
230+
* **Running all tests:**
231+
```bash
232+
ramble unit-test
233+
```
234+
235+
* **Running tests in parallel:** To speed up the test suite, you can run tests in parallel across all available CPU cores:
236+
```bash
237+
ramble unit-test -n auto
238+
```
239+
240+
* **Passing Pytest Arguments:** You can pass any `pytest` arguments to the command. For example, to only run tests with "gromacs" in their name:
241+
```bash
242+
ramble unit-test -k gromacs
243+
```
244+
245+
* **Getting Help:**
246+
* For help with the `ramble unit-test` command itself: `ramble unit-test --help`
247+
* For a full list of all available `pytest` options: `ramble unit-test --pytest-help`
248+
249+
## Running Style Checks
250+
251+
Ramble uses `isort`, `black`, and `flake8` to enforce a consistent code style. You can check and fix style issues using the `ramble style` command.
252+
253+
* **Checking for Style Errors:** To check for any style violations in the files you've changed in your current branch:
254+
```bash
255+
ramble style
256+
```
257+
To check all files in the project, use the `--all` flag:
258+
```bash
259+
ramble style --all
260+
```
261+
262+
* **Fixing Style Errors:** To automatically fix any style errors in your changed files:
263+
```bash
264+
ramble style --fix
265+
```
266+
To fix all files in the project, combine `--all` and `--fix`:
267+
```bash
268+
ramble style --all --fix
269+
```
270+
271+
* **Advanced Usage:** You can also specify which styling tools to run or skip. For example, to only run `isort` and `black`:
272+
```bash
273+
ramble style -t isort -t black
274+
```
275+
To skip `flake8`:
276+
```bash
277+
ramble style -s flake8
278+
```

0 commit comments

Comments
 (0)