beaker-gantry


Namebeaker-gantry JSON
Version 0.22.2 PyPI version JSON
download
home_page
SummaryGantry streamlines running Python experiments in Beaker by managing containers and boilerplate for you
upload_time2024-03-01 17:47:42
maintainer
docs_urlNone
author
requires_python>3.7
licenseApache License Version 2.0, January 2004 https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
<br>
<img src="https://raw.githubusercontent.com/allenai/beaker-py/main/docs/source/_static/beaker-500px-transparent.png" width="200"/>
<br>
<h1>Beaker Gantry</h1>
<p>Gantry streamlines running Python experiments in <a href="https://beaker.org">Beaker</a> by managing containers and boilerplate for you</p>
<hr/>
<!-- TODO: Add badges once this is open source -->
<a href="https://github.com/allenai/beaker-gantry/actions">
    <img alt="CI" src="https://github.com/allenai/beaker-gantry/workflows/Main/badge.svg?event=push&branch=main">
</a>
<a href="https://pypi.org/project/beaker-gantry/">
    <img alt="PyPI" src="https://img.shields.io/pypi/v/beaker-gantry">
</a>
<a href="https://github.com/allenai/beaker-gantry/blob/main/LICENSE">
    <img alt="License" src="https://img.shields.io/github/license/allenai/beaker-gantry.svg?color=blue&cachedrop">
</a>
<br/>
</div>

⚑️*Easy to use*

- **No Docker required!** 🚫 🐳
- No writing YAML experiment specs.
- Easy setup.
- Simple CLI.

🏎  *Fast*

- Fire off Beaker experiments from your local computer instantly!
- No local image build or upload.

πŸͺΆ *Lightweight*

- Pure Python (built on top of [beaker-py](https://github.com/allenai/beaker-py)).
- Minimal dependencies.

### Who is this for?

Gantry is for both new and seasoned Beaker users who need to run Python batch jobs (as opposed to interactive sessions) from a rapidly changing repository.
Without Gantry, this workflow usually looks like this:

1. Add a Dockerfile to your repository.
2. Build the Docker image locally.
3. Push the Docker image to Beaker.
4. Write a YAML Beaker experiment spec that points to the image you just uploaded.
5. Submit the experiment spec.
6. Make changes and repeat from step 2.

This requires experience with Docker, experience writing Beaker experiment specs, and a fast and reliable internet connection (a luxury that some of us don't have, especially in the WFH era πŸ™ƒ).

With Gantry, on the other hand, that same workflow simplifies down to this:

1. Write a conda `environment.yml` file, or simply a PIP `requirements.txt` and/or `setup.py` file.
2. Commit and push your changes.
3. Submit and track a Beaker experiment with the `gantry run` command.
4. Make changes and repeat from step 2.

## In this README

- πŸ’Ύ **[Installing](#installing)**
- πŸš€ **[Quick start](#quick-start)**
- πŸ‘“ **[Best practices](#best-practices)**
- ❓ **[FAQ](#faq)**

### Additional info

#### πŸ‘‹ *Examples*

- [Savings results / metrics from an experiment](./examples/metrics)

#### πŸ’» *For developers*

- [CHANGELOG](https://github.com/allenai/beaker-gantry/blob/main/CHANGELOG.md)
- [CONTRIBUTING](https://github.com/allenai/beaker-gantry/blob/main/CONTRIBUTING.md)

## Installing

### Installing with `pip`

Gantry is available [on PyPI](https://pypi.org/project/gantry/). Just run

```bash
pip install beaker-gantry
```

### Installing from source

To install Gantry from source, first clone [the repository](https://github.com/allenai/beaker-gantry):

```bash
git clone https://github.com/allenai/beaker-gantry.git
cd beaker-gantry
```

Then run

```bash
pip install -e .
```

## Quick start

### One-time setup

1. **Create and clone your repository.**

    If you haven't already done so, create a GitHub repository for your project and clone it locally.
    **Every `gantry` command you run must be invoked from the root directory of your repository.**

2. **Configure Gantry.**

    If you've already configured the [Beaker command-line client](https://github.com/allenai/beaker/), Gantry will 
    find and use the existing configuration file (usually located at `$HOME/.beaker/config.yml`).
    Otherwise just set the environment variable `BEAKER_TOKEN` to your Beaker [user token](https://beaker.org/user).

    The first time you call `gantry run ...` you'll also be prompted to provide a [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the `repo` scope if your repository is not public. This allows Gantry to clone your private repository when it runs in Beaker. You don't have to do this just yet (Gantry will prompt you for it), but if you need to update this token later you can use the `gantry config set-gh-token` command.

3. **Specify your Python environment.**

    Lastly - and this is the most important part - you'll have to create one of several different files that specify your Python environment. There are three options:

    1. A conda [`environment.yml`](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually) file.
    2. A [`setup.py`](https://docs.python.org/3/distutils/introduction.html#a-simple-example) file.
    3. A PIP [`requirements.txt`](https://pip.pypa.io/en/stable/user_guide/#requirements-files) file.

    The first method is [the recommended approach](#use-conda), especially if you're already using conda.
    But it's perfectly okay to use a combination of these different approaches as well.
    This can be useful when, for example, you need to [use a CUDA-enabled version of PyTorch on Beaker but a CPU-only version locally](#how-do-i-use-a-cuda-enabled-version-of-pytorch-on-beaker-when-im-using-a-cpu-only-version-locally).

### Submit your first experiment with Gantry

Let's spin up a Beaker experiment that just prints "Hello, World!" from Python.

First make sure you've committed *and* pushed all changes so far in your repository.
Then (from the root of your repository) run:

```bash
gantry run --workspace {WORKSPACE} --cluster {CLUSTER} -- python -c 'print("Hello, World!")'
```

Just replace `{WORKSPACE}` with the name of your own Beaker [*private*](#use-your-own-private-beaker-workspace) workspace and `{CLUSTER}` with the name of the Beaker cluster you want to run on.

*❗Note: Everything after the `--` is the command + arguments you want to run on Beaker. It's necessary to include the `--` if any of your arguments look like options themselves (like `-c` in this example) so gantry can differentiate them from its own options.*

Try `gantry run --help` to see all of the available options.

## Best practices

### Use your own private Beaker workspace

Any authorized contributors to your workspace will have access to the secrets in your workspace, and Gantry needs to store your GitHub personal access token (PAT) as a secret in the workspace (for non-public repos).
That's also why it's important to [limit the scope and lifetime of your GitHub token](#limit-the-scope-and-lifetime-of-your-github-token).

### Limit the scope and lifetime of your GitHub token

Your PAT only needs to have the `repo` scope and should have a short expiration time (e.g. 30 days).
This limits the harm a bad actor could cause if they were able to read your PAT from your Beaker workspace somehow.

### Use conda

Adding a [conda environment file](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually) will generally make your exact Python environment easier to reproduce, especially when you have platform-dependent requirements like PyTorch.
You don't necessarily need to write the `environment.yml` file manually either.
If you've already initialized a conda environment locally, you can just run:

```bash
conda env export --from-history
```

See [Exporting an Environment File Across Platforms](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms) for more details.

It's also okay to [use a combination of conda environment and PIP requirements files](#can-i-use-both-conda-environment-and-pip-requirements-files).

## FAQ

### Can I use my own Docker/Beaker image?

You sure can! Just set the `--beaker-image` or `--docker-image` flag.

Gantry can use any image that has bash installed. This can be useful when you have dependencies that take a long time to download and build (like PyTorch).

In this case it works best if you build your image with a conda environment that already has your big dependencies installed. Then when you call `gantry run`, use the `--venv` option to tell Gantry to use that environment instead of creating a new conda environment in the container. You may also want to add a `requirements.txt` file to your repository that lists all of your dependencies (including PyTorch and anything else already installed in your image's conda environment) so Gantry can make sure the environment on the image is up-to-date when it runs.

For example, you could use one of our [pre-built PyTorch images](https://beaker.org/ws/ai2/fab/images?text=pytorch&sort=created:descending), such as [`ai2/pytorch1.11.0-cuda11.3-python3.9`](https://beaker.org/im/01G3S1CBQ0K832MCFDA77XQXFJ/details), like this:

```bash
gantry run \
    --beaker-image 'ai2/pytorch1.11.0-cuda11.3-python3.9' \
    --venv 'base' \
    --pip requirements.txt \
    -- python -c 'print("Hello, World!")'
```

### Will Gantry work for GPU experiments?

Absolutely! This was the main use-case Gantry was developed for. Just set the `--gpus` option for `gantry run` to the number of GPUs you need.
You should also ensure that the way in which you specify your Python environment (e.g. conda `environment.yml`, `setup.py`, or PIP `requirements.txt` file) will lead to your dependencies being properly installed to support
the GPU hardware specific to the cluster you're running on.

For example, if one of your dependencies is [PyTorch](https://pytorch.org/), you're probably best off writing a conda `environment.yml` file since conda is the preferred way to install PyTorch.
You'll generally want to use the latest supported CUDA version, so in this case your `environment.yml` file could look like this:

```yaml
name: torch-env
channels:
- pytorch
dependencies:
- python=3.9
- cudatoolkit=11.3
- numpy
- pytorch
- ...
```

### Can I use both conda environment and PIP requirements files?

Yes you can. Gantry will initialize your environment using your conda environment file (if you have one)
and then will also check for a PIP requirements file.


### How do I use a CUDA-enabled version of PyTorch on Beaker when I'm using a CPU-only version locally?

One way to handle this would be to start with a `requirements.txt` that lists the `torch` version you need along with any other dependencies, e.g.

```
# requirements.txt
torch==1.11.0
...
```

Then add a conda `environment.yml` somewhere in your repository that specifies exactly how to install PyTorch (and a CUDA toolkit) on Beaker, e.g.:

```yaml
# beaker/environment.yml
name: torch-env
channels:
- pytorch
dependencies:
- python=3.9
- cudatoolkit=11.3
- pytorch==1.11.0  # make sure this matches the version in requirements.txt
```

When you call `gantry run`, use the `--conda` flag to specify the path to your conda env file (e.g. `--conda beaker/environment.yml`).
Gantry will use that env file to initialize the environment, and then will install the rest of your dependencies from the `requirements.txt` file.

### How can I save results or metrics from an experiment?

By default Gantry uses the `/results` directory on the image as the location of the results dataset.
That means that everything your experiment writes to this directory will be persisted as a Beaker dataset when the experiment finalizes.
And you can also create Beaker metrics for your experiment by writing a JSON file called `metrics.json` in the `/results` directory.

### Can I access data on NFS?

Yes. When you choose an on-premise cluster managed by the Beaker team that supports the NFS drive it will be automatically attached to the experiment's container.

### How can I just see the Beaker experiment spec that Gantry uses?

You can use the `--dry-run` option with `gantry run` to see what Gantry will submit without actually submitting an experiment.
You can also use `--save-spec PATH` in combination with `--dry-run` to save the actual experiment spec to a YAML file.

### How can I update Gantry's GitHub token?

Just use the command `gantry config set-gh-token`.

### How can I attach Beaker datasets to an experiment?

Just use the `--dataset` option for `gantry run`. For example:

```bash
gantry run --dataset 'petew/squad-train:/input-data' -- ls /input-data
```

### How can I run distributed batch jobs with Gantry?

The three options `--replicas` (int), `--leader-selection` (flag), and `--host-networking` (flag) used together give you the ability to run distributed batch jobs. See the [Beaker docs](https://beaker-docs.apps.allenai.org/distributed-training.html#batch-jobs) for more information.

### Why "Gantry"?

A gantry is a structure that's used, among other things, to lift containers off of ships. Analogously Beaker Gantry's purpose is to lift Docker containers (or at least the *management* of Docker containers) away from users.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "beaker-gantry",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Allen Institute for Artificial Intelligence <contact@allenai.org>, Pete Walsh <petew@allenai.org>",
    "download_url": "https://files.pythonhosted.org/packages/3e/69/5754b17655b8ecd5ccfa5f8fef1d17d51709db665725aab724b979ad7c0a/beaker-gantry-0.22.2.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n<br>\n<img src=\"https://raw.githubusercontent.com/allenai/beaker-py/main/docs/source/_static/beaker-500px-transparent.png\" width=\"200\"/>\n<br>\n<h1>Beaker Gantry</h1>\n<p>Gantry streamlines running Python experiments in <a href=\"https://beaker.org\">Beaker</a> by managing containers and boilerplate for you</p>\n<hr/>\n<!-- TODO: Add badges once this is open source -->\n<a href=\"https://github.com/allenai/beaker-gantry/actions\">\n    <img alt=\"CI\" src=\"https://github.com/allenai/beaker-gantry/workflows/Main/badge.svg?event=push&branch=main\">\n</a>\n<a href=\"https://pypi.org/project/beaker-gantry/\">\n    <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/beaker-gantry\">\n</a>\n<a href=\"https://github.com/allenai/beaker-gantry/blob/main/LICENSE\">\n    <img alt=\"License\" src=\"https://img.shields.io/github/license/allenai/beaker-gantry.svg?color=blue&cachedrop\">\n</a>\n<br/>\n</div>\n\n\u26a1\ufe0f*Easy to use*\n\n- **No Docker required!** \ud83d\udeab \ud83d\udc33\n- No writing YAML experiment specs.\n- Easy setup.\n- Simple CLI.\n\n\ud83c\udfce  *Fast*\n\n- Fire off Beaker experiments from your local computer instantly!\n- No local image build or upload.\n\n\ud83e\udeb6 *Lightweight*\n\n- Pure Python (built on top of [beaker-py](https://github.com/allenai/beaker-py)).\n- Minimal dependencies.\n\n### Who is this for?\n\nGantry is for both new and seasoned Beaker users who need to run Python batch jobs (as opposed to interactive sessions) from a rapidly changing repository.\nWithout Gantry, this workflow usually looks like this:\n\n1. Add a Dockerfile to your repository.\n2. Build the Docker image locally.\n3. Push the Docker image to Beaker.\n4. Write a YAML Beaker experiment spec that points to the image you just uploaded.\n5. Submit the experiment spec.\n6. Make changes and repeat from step 2.\n\nThis requires experience with Docker, experience writing Beaker experiment specs, and a fast and reliable internet connection (a luxury that some of us don't have, especially in the WFH era \ud83d\ude43).\n\nWith Gantry, on the other hand, that same workflow simplifies down to this:\n\n1. Write a conda `environment.yml` file, or simply a PIP `requirements.txt` and/or `setup.py` file.\n2. Commit and push your changes.\n3. Submit and track a Beaker experiment with the `gantry run` command.\n4. Make changes and repeat from step 2.\n\n## In this README\n\n- \ud83d\udcbe **[Installing](#installing)**\n- \ud83d\ude80 **[Quick start](#quick-start)**\n- \ud83d\udc53 **[Best practices](#best-practices)**\n- \u2753 **[FAQ](#faq)**\n\n### Additional info\n\n#### \ud83d\udc4b *Examples*\n\n- [Savings results / metrics from an experiment](./examples/metrics)\n\n#### \ud83d\udcbb *For developers*\n\n- [CHANGELOG](https://github.com/allenai/beaker-gantry/blob/main/CHANGELOG.md)\n- [CONTRIBUTING](https://github.com/allenai/beaker-gantry/blob/main/CONTRIBUTING.md)\n\n## Installing\n\n### Installing with `pip`\n\nGantry is available [on PyPI](https://pypi.org/project/gantry/). Just run\n\n```bash\npip install beaker-gantry\n```\n\n### Installing from source\n\nTo install Gantry from source, first clone [the repository](https://github.com/allenai/beaker-gantry):\n\n```bash\ngit clone https://github.com/allenai/beaker-gantry.git\ncd beaker-gantry\n```\n\nThen run\n\n```bash\npip install -e .\n```\n\n## Quick start\n\n### One-time setup\n\n1. **Create and clone your repository.**\n\n    If you haven't already done so, create a GitHub repository for your project and clone it locally.\n    **Every `gantry` command you run must be invoked from the root directory of your repository.**\n\n2. **Configure Gantry.**\n\n    If you've already configured the [Beaker command-line client](https://github.com/allenai/beaker/), Gantry will \n    find and use the existing configuration file (usually located at `$HOME/.beaker/config.yml`).\n    Otherwise just set the environment variable `BEAKER_TOKEN` to your Beaker [user token](https://beaker.org/user).\n\n    The first time you call `gantry run ...` you'll also be prompted to provide a [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the `repo` scope if your repository is not public. This allows Gantry to clone your private repository when it runs in Beaker. You don't have to do this just yet (Gantry will prompt you for it), but if you need to update this token later you can use the `gantry config set-gh-token` command.\n\n3. **Specify your Python environment.**\n\n    Lastly - and this is the most important part - you'll have to create one of several different files that specify your Python environment. There are three options:\n\n    1. A conda [`environment.yml`](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually) file.\n    2. A [`setup.py`](https://docs.python.org/3/distutils/introduction.html#a-simple-example) file.\n    3. A PIP [`requirements.txt`](https://pip.pypa.io/en/stable/user_guide/#requirements-files) file.\n\n    The first method is [the recommended approach](#use-conda), especially if you're already using conda.\n    But it's perfectly okay to use a combination of these different approaches as well.\n    This can be useful when, for example, you need to [use a CUDA-enabled version of PyTorch on Beaker but a CPU-only version locally](#how-do-i-use-a-cuda-enabled-version-of-pytorch-on-beaker-when-im-using-a-cpu-only-version-locally).\n\n### Submit your first experiment with Gantry\n\nLet's spin up a Beaker experiment that just prints \"Hello, World!\" from Python.\n\nFirst make sure you've committed *and* pushed all changes so far in your repository.\nThen (from the root of your repository) run:\n\n```bash\ngantry run --workspace {WORKSPACE} --cluster {CLUSTER} -- python -c 'print(\"Hello, World!\")'\n```\n\nJust replace `{WORKSPACE}` with the name of your own Beaker [*private*](#use-your-own-private-beaker-workspace) workspace and `{CLUSTER}` with the name of the Beaker cluster you want to run on.\n\n*\u2757Note: Everything after the `--` is the command + arguments you want to run on Beaker. It's necessary to include the `--` if any of your arguments look like options themselves (like `-c` in this example) so gantry can differentiate them from its own options.*\n\nTry `gantry run --help` to see all of the available options.\n\n## Best practices\n\n### Use your own private Beaker workspace\n\nAny authorized contributors to your workspace will have access to the secrets in your workspace, and Gantry needs to store your GitHub personal access token (PAT) as a secret in the workspace (for non-public repos).\nThat's also why it's important to [limit the scope and lifetime of your GitHub token](#limit-the-scope-and-lifetime-of-your-github-token).\n\n### Limit the scope and lifetime of your GitHub token\n\nYour PAT only needs to have the `repo` scope and should have a short expiration time (e.g. 30 days).\nThis limits the harm a bad actor could cause if they were able to read your PAT from your Beaker workspace somehow.\n\n### Use conda\n\nAdding a [conda environment file](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually) will generally make your exact Python environment easier to reproduce, especially when you have platform-dependent requirements like PyTorch.\nYou don't necessarily need to write the `environment.yml` file manually either.\nIf you've already initialized a conda environment locally, you can just run:\n\n```bash\nconda env export --from-history\n```\n\nSee [Exporting an Environment File Across Platforms](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#exporting-an-environment-file-across-platforms) for more details.\n\nIt's also okay to [use a combination of conda environment and PIP requirements files](#can-i-use-both-conda-environment-and-pip-requirements-files).\n\n## FAQ\n\n### Can I use my own Docker/Beaker image?\n\nYou sure can! Just set the `--beaker-image` or `--docker-image` flag.\n\nGantry can use any image that has bash installed. This can be useful when you have dependencies that take a long time to download and build (like PyTorch).\n\nIn this case it works best if you build your image with a conda environment that already has your big dependencies installed. Then when you call `gantry run`, use the `--venv` option to tell Gantry to use that environment instead of creating a new conda environment in the container. You may also want to add a `requirements.txt` file to your repository that lists all of your dependencies (including PyTorch and anything else already installed in your image's conda environment) so Gantry can make sure the environment on the image is up-to-date when it runs.\n\nFor example, you could use one of our [pre-built PyTorch images](https://beaker.org/ws/ai2/fab/images?text=pytorch&sort=created:descending), such as [`ai2/pytorch1.11.0-cuda11.3-python3.9`](https://beaker.org/im/01G3S1CBQ0K832MCFDA77XQXFJ/details), like this:\n\n```bash\ngantry run \\\n    --beaker-image 'ai2/pytorch1.11.0-cuda11.3-python3.9' \\\n    --venv 'base' \\\n    --pip requirements.txt \\\n    -- python -c 'print(\"Hello, World!\")'\n```\n\n### Will Gantry work for GPU experiments?\n\nAbsolutely! This was the main use-case Gantry was developed for. Just set the `--gpus` option for `gantry run` to the number of GPUs you need.\nYou should also ensure that the way in which you specify your Python environment (e.g. conda `environment.yml`, `setup.py`, or PIP `requirements.txt` file) will lead to your dependencies being properly installed to support\nthe GPU hardware specific to the cluster you're running on.\n\nFor example, if one of your dependencies is [PyTorch](https://pytorch.org/), you're probably best off writing a conda `environment.yml` file since conda is the preferred way to install PyTorch.\nYou'll generally want to use the latest supported CUDA version, so in this case your `environment.yml` file could look like this:\n\n```yaml\nname: torch-env\nchannels:\n- pytorch\ndependencies:\n- python=3.9\n- cudatoolkit=11.3\n- numpy\n- pytorch\n- ...\n```\n\n### Can I use both conda environment and PIP requirements files?\n\nYes you can. Gantry will initialize your environment using your conda environment file (if you have one)\nand then will also check for a PIP requirements file.\n\n\n### How do I use a CUDA-enabled version of PyTorch on Beaker when I'm using a CPU-only version locally?\n\nOne way to handle this would be to start with a `requirements.txt` that lists the `torch` version you need along with any other dependencies, e.g.\n\n```\n# requirements.txt\ntorch==1.11.0\n...\n```\n\nThen add a conda `environment.yml` somewhere in your repository that specifies exactly how to install PyTorch (and a CUDA toolkit) on Beaker, e.g.:\n\n```yaml\n# beaker/environment.yml\nname: torch-env\nchannels:\n- pytorch\ndependencies:\n- python=3.9\n- cudatoolkit=11.3\n- pytorch==1.11.0  # make sure this matches the version in requirements.txt\n```\n\nWhen you call `gantry run`, use the `--conda` flag to specify the path to your conda env file (e.g. `--conda beaker/environment.yml`).\nGantry will use that env file to initialize the environment, and then will install the rest of your dependencies from the `requirements.txt` file.\n\n### How can I save results or metrics from an experiment?\n\nBy default Gantry uses the `/results` directory on the image as the location of the results dataset.\nThat means that everything your experiment writes to this directory will be persisted as a Beaker dataset when the experiment finalizes.\nAnd you can also create Beaker metrics for your experiment by writing a JSON file called `metrics.json` in the `/results` directory.\n\n### Can I access data on NFS?\n\nYes. When you choose an on-premise cluster managed by the Beaker team that supports the NFS drive it will be automatically attached to the experiment's container.\n\n### How can I just see the Beaker experiment spec that Gantry uses?\n\nYou can use the `--dry-run` option with `gantry run` to see what Gantry will submit without actually submitting an experiment.\nYou can also use `--save-spec PATH` in combination with `--dry-run` to save the actual experiment spec to a YAML file.\n\n### How can I update Gantry's GitHub token?\n\nJust use the command `gantry config set-gh-token`.\n\n### How can I attach Beaker datasets to an experiment?\n\nJust use the `--dataset` option for `gantry run`. For example:\n\n```bash\ngantry run --dataset 'petew/squad-train:/input-data' -- ls /input-data\n```\n\n### How can I run distributed batch jobs with Gantry?\n\nThe three options `--replicas` (int), `--leader-selection` (flag), and `--host-networking` (flag) used together give you the ability to run distributed batch jobs. See the [Beaker docs](https://beaker-docs.apps.allenai.org/distributed-training.html#batch-jobs) for more information.\n\n### Why \"Gantry\"?\n\nA gantry is a structure that's used, among other things, to lift containers off of ships. Analogously Beaker Gantry's purpose is to lift Docker containers (or at least the *management* of Docker containers) away from users.\n",
    "bugtrack_url": null,
    "license": "Apache License Version 2.0, January 2004 https://www.apache.org/licenses/  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION  1. Definitions.  \"License\" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.  \"Licensor\" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.  \"Legal Entity\" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.  \"You\" (or \"Your\") shall mean an individual or Legal Entity exercising permissions granted by this License.  \"Source\" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.  \"Object\" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.  \"Work\" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).  \"Derivative Works\" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.  \"Contribution\" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, \"submitted\" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as \"Not a Contribution.\"  \"Contributor\" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.  2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.  3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.  4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:  (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and  (b) You must cause any modified files to carry prominent notices stating that You changed the files; and  (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and  (d) If the Work includes a \"NOTICE\" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.  You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.  5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.  6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.  7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.  8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.  9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.  END OF TERMS AND CONDITIONS  APPENDIX: How to apply the Apache License to your work.  To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets \"{}\" replaced with your own identifying information. (Don't include the brackets!)  The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same \"printed page\" as the copyright notice for easier identification within third-party archives.  Copyright {yyyy} {name of copyright owner}  Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at  https://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ",
    "summary": "Gantry streamlines running Python experiments in Beaker by managing containers and boilerplate for you",
    "version": "0.22.2",
    "project_urls": {
        "homepage": "https://github.com/allenai/beaker-gantry",
        "repository": "https://github.com/allenai/beaker-gantry"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "859043159b568111f0bc0352fed27c076d515ca4411fb579b760bd50a83530d9",
                "md5": "38d18e7bdcb13be8786fcf1f1bf36ebb",
                "sha256": "fd3077ad51ac12a3aef4dab2a46978d649ba33926600f648483e2332e040b6ce"
            },
            "downloads": -1,
            "filename": "beaker_gantry-0.22.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "38d18e7bdcb13be8786fcf1f1bf36ebb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3.7",
            "size": 30273,
            "upload_time": "2024-03-01T17:47:40",
            "upload_time_iso_8601": "2024-03-01T17:47:40.200259Z",
            "url": "https://files.pythonhosted.org/packages/85/90/43159b568111f0bc0352fed27c076d515ca4411fb579b760bd50a83530d9/beaker_gantry-0.22.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e695754b17655b8ecd5ccfa5f8fef1d17d51709db665725aab724b979ad7c0a",
                "md5": "2e1b5e5bd75a93b65b6362ff1e7a1c66",
                "sha256": "7d3de3a69abd17fd7a5452222460b548809eeb6257e767ae59e5befcc191245a"
            },
            "downloads": -1,
            "filename": "beaker-gantry-0.22.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2e1b5e5bd75a93b65b6362ff1e7a1c66",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">3.7",
            "size": 30069,
            "upload_time": "2024-03-01T17:47:42",
            "upload_time_iso_8601": "2024-03-01T17:47:42.164970Z",
            "url": "https://files.pythonhosted.org/packages/3e/69/5754b17655b8ecd5ccfa5f8fef1d17d51709db665725aab724b979ad7c0a/beaker-gantry-0.22.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-01 17:47:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "allenai",
    "github_project": "beaker-gantry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "beaker-gantry"
}
        
Elapsed time: 0.20985s