|
| 1 | +Agent Contributor Guidelines and Information |
| 2 | +============================================ |
| 3 | + |
| 4 | +Read the ``README.rst`` for an overview of libEnsemble. |
| 5 | + |
| 6 | +- libEnsemble uses a manager-worker architecture. Points are generated by a generator and sent to a worker, which runs a simulator. |
| 7 | +- The manager determines how and when points get passed to workers via an allocation function. |
| 8 | +- See ``libensemble/tests/regression_tests/test_1d_sampling.py`` for a simple example of the libEnsemble interface. |
| 9 | + |
| 10 | +Repository Layout |
| 11 | +----------------- |
| 12 | + |
| 13 | +- ``libensemble/`` - Source code. |
| 14 | +- ``/alloc_funcs`` - Allocation functions. Policies for passing work between the manager and workers. |
| 15 | +- ``/comms`` - Modules and abstractions for communication between the manager and workers. |
| 16 | +- ``/executors`` - An interface for launching executables, often simulations. |
| 17 | +- ``/gen_classes`` - Generators that adhere to the `gest-api` standard. |
| 18 | + Recommended over entries from ``/gen_funcs`` that perform similar functionality. |
| 19 | +- ``/gen_funcs`` - Generator functions. Modules for producing points for simulations. |
| 20 | +- ``/resources`` - Classes and functions for managing compute resources for MPI tasks, libensemble workers. |
| 21 | +- ``/sim_funcs`` - Simulator functions. Modules for running simulations or performing experiments. |
| 22 | +- ``/tests`` - Tests. |
| 23 | + - ``/functionality_tests`` - Primarily tests libEnsemble code only. |
| 24 | + - ``/regression_tests`` - Tests libEnsemble code with external code. Often more closely resembles actual use-cases. |
| 25 | + - ``/unit_tests`` - Tests for individual modules. |
| 26 | +- ``/tools`` - Tools. Misc functions and classes to ease development. |
| 27 | +- ``/utils`` - Utilities. Misc functions and classes used internally by multiple modules. |
| 28 | +- ``ensemble.py`` - The primary interface for parameterizing and running libEnsemble. |
| 29 | +- ``generators.py`` - Base classes for generators that adhere to the `gest-api` standard. |
| 30 | +- ``history.py`` - Module for recording points that have been generated and simulation results. NumPy array. |
| 31 | +- ``libE.py`` - libE main file. Previous primary interface for parameterizing and running libEnsemble. |
| 32 | +- ``logger.py`` - Logging configuration. |
| 33 | +- ``manager.py`` - Module for maintaining the history array and passing points between the workers. |
| 34 | +- ``message_numbers.py`` - Constants that represent states of the ensemble. |
| 35 | +- ``specs.py`` - Dataclasses for parameterizing the ensemble. Most importantly, contains ``LibeSpecs, SimSpecs, GenSpecs``. |
| 36 | +- ``worker.py`` - Module for running generators and simulators. Communicates with the manager. |
| 37 | +- ``version.py`` - Version file. |
| 38 | + |
| 39 | +- ``.github/`` - GitHub actions. See ``.github/workflows/`` for the CI. |
| 40 | +- ``docs/`` - Documentation. Check here first for information before reading the source code. |
| 41 | +- ``examples/`` - The ``*_funcs`` and ``calling_scripts`` directories contain symlinks to examples further in the source code. |
| 42 | +- ``/libE_submission_scripts`` - Example scripts for submitting libEnsemble jobs to HPC systems. |
| 43 | +- ``/tutorials`` - Tutorials on how to use libEnsemble. |
| 44 | +- ``pyproject.toml`` - Project configuration file. Contains information about the project and its dependencies. |
| 45 | + |
| 46 | +Other files in the root directory should be self-documenting. |
| 47 | + |
| 48 | +Information about Generators |
| 49 | +---------------------------- |
| 50 | + |
| 51 | +- Generators are functions or objects that produce points for simulations. |
| 52 | +- The History array is a NumPy structured array that stores points that have been generated and simulation results. |
| 53 | +Its fields match ``sim_specs/gen_specs["out"]`` or ``vocs`` attributes, plus additional reserved fields for metadata. |
| 54 | +- Prior to libEnsemble v1.6.0, generators were plain functions. They often ran in "persistent" mode, meaning they executed in a |
| 55 | +long-running loop, sending and receiving points to and from the manager until the ensemble was complete. |
| 56 | +- A ``gest-api`` or "standardized" generator is a class that at a minimum implements ``suggest`` and ``ingest`` methods, and is parameterized by a ``vocs``. |
| 57 | +- See ``libensemble/generators.py`` for more information about the ``gest-api`` standard. |
| 58 | +- If using a generator that adheres to the ``gest-api`` standard, or a classic persistent generator, use the ``start_only_persistent`` allocation function. |
| 59 | +- Generators are often used for simple sampling, optimization, calibration, uncertainty quantification, and other simulation-based tasks. |
| 60 | + |
| 61 | +General Guidelines |
| 62 | +------------------ |
| 63 | + |
| 64 | +- If using classic ``sim_specs`` and ``gen_specs``, then ensure that ``sim_specs["out"]`` and ``gen_specs["in"]`` field names match, and vice-versa. |
| 65 | +- As-of libEnsemble v1.6.0, ``SimSpecs`` and ``GenSpecs`` can also be parameterized by a ``vocs`` object, imported from ``gest_api.vocs`` (NOT xopt.vocs). |
| 66 | +- ``VOCS`` contains variables, objectives, constraints, and other settings that define the problem. |
| 67 | +See ``libensemble/tests/regression_tests/test_xopt_EI.py`` for an example of how to use it. |
| 68 | +- An MPI distribution is not required for libEnsemble to run, but is required to use the ``MPIExecutor``. ``mpich`` is recommended. |
| 69 | +- New tests are heavily encouraged for new features, bug fixes, or integrations. See ``libensemble/tests/regression_tests`` for examples. |
| 70 | +- Never use destructive git commands unless explicitly requested. |
| 71 | +- Code is in the ``black`` style. This should be enforced by ``pre-commit``. |
| 72 | +- When writing new code, prefer the ``LibeSpecs``, ``SimSpecs``, and ``GenSpecs`` dataclasses over the classic ``sim_specs`` and ``gen_specs`` bare dictionaries. |
| 73 | +- Read ``CONTRIBUTING.md`` for more information. |
| 74 | +- The external ``libE-community-examples`` repository contains past use-cases, generators, and other examples. |
| 75 | + |
| 76 | +Development Environment |
| 77 | +----------------------- |
| 78 | + |
| 79 | +- ``pixi`` is the recommended environment manager for libEnsemble development. See ``pyproject.toml`` for the list |
| 80 | +of dependencies and the available testing environments. |
| 81 | +- Enter the development environment with ``pixi shell -e dev``. This environment contains the most common dependencies for development and testing. |
| 82 | +- For one-off commands, use ``pixi run -e dev``. This will run a single command in the development environment. |
| 83 | +- If ``pixi`` is not available or not preferred by the user, ``pip install -e .`` can be used instead. Other dependencies may need to be installed manually. |
| 84 | +- If committing, use ``pre-commit`` to ensure that code style and formatting are consistent. See ``.pre-commit-config.yaml`` for |
| 85 | +the configuration and ``pyproject.toml`` for other configuration. |
| 86 | + |
| 87 | +Testing |
| 88 | +------- |
| 89 | + |
| 90 | +- Run tests with the ``run-tests.py`` script: ``python libensemble/tests/run-tests.py``. See ``libensemble/tests/run-tests.py`` for usage information. |
| 91 | +- Some tests require third party software to be installed. When developing a feature or fixing a bug, since the entire test suite will be run on Github Actions, |
| 92 | +for local development running individual tests is sufficient. |
| 93 | +- Individual unit tests can be run with ``pixi run -e dev pytest path/to/test_file``. |
| 94 | +- A libEnsemble run typically outputs an ``ensemble.log`` and ``libE_stats.txt`` file in the working directory. Check these files for tracebacks or run statistics. |
| 95 | +- An "ensemble" or "workflow" directory may also be created, often containing per-simulation output directories |
0 commit comments