This demo showcases executing simulations at scale using Globus Compute.
As a proxy for a real scientific simulation, this demo simulates dropping golf balls on a green. A golf green is randomly generated using Perlin noise, and the simulation is performed using PyBullet.
- Clone the repository and navigate to the project directory:
git clone https://github.com/globus-labs/globus-compute-golf-demo cd globus-compute-golf-demo
- Create a virtual environment:
This demo requires Python 3.9 or later.
You may use alternate environment managers, such as Conda, provided you have
python -m venv venv . venv/bin/activate
pip
installed. We do not recommend installing the packages into your system Python. - Install the package and dependencies:
pip install .
- Configure a Globus Compute Endpoint:
This step can be performed on your local machine or on a remote machine.
You will need to authenticate with Globus Auth if you have not used Globus Compute on your local device before.
A UUID for your endpoint will be returned; save this for later (you can find it later with
globus-compute-endpoint list
).For more information on configuring Endpoints, check out the docs.globus-compute-endpoint configure golf-demo globus-compute-endpoint start golf-demo
We will start with running a single simulation locally to visualize what the simulation looks like. This will generate a random terrain and drop a ball at a random position.
python run_single.py --num-balls 100
You should see a pop up window that looks like the following.
The parameters of the simulation are fully configurable.
Use python run_single.py --help
to see all of the options.
For example, set --width 50
to increase the size of the terrain.
This will also zoom the camera out so it may be difficult to see the balls; the ball size can be changed with --ball-diameter
.
Next, we can run the same simulation at scale by generating n
random initial ball positions and submitting one simulation per ball to Globus Compute.
Globus Compute will manage the parallel execution of tasks on the Endpoint you configured.
Replace <UUID>
with the UUID of your Endpoint.
python run_globus_compute.py --num-balls 1000 --endpoint <UUID>
Tip
Passing --process-pool 8
instead of --endpoint <UUID>
will run the simulations across a pool of 8 local processes rather than via Globus Compute.
Warning
Increasing the width of the terrain or the resolution of the terrain will increase the size of the mesh map. Globus Compute has a 10MB payload limit which can be exceeded if the terrain is too large.
Because the simulations are executed in parallel on remote processes, the simulations are performed in a "headless" mode (i.e., the simulation is not rendered to the screen).
The script visualizes the results of the simulations via plots that are saved to images/
.
2D Contour Plot (images/contour.png
)
3D Terrain Heatmap (images/terrain.png
)
To contributed to this repository:
- Fork and/or create a branch for your features/changes.
The
main
branch of this repository has branch protection enabled so all changes must be made via a pull request. - Install the package with development dependencies.
pip install -e .[dev]
- Make your changes.
- Run the pre-commit checks and fix any issues.
pre-commit run --all-files
- Commit your changes and open a pull request.