Skip to content

Commit

Permalink
Run Integration tests on AWS runners (#565)
Browse files Browse the repository at this point in the history
* try making AWS hello world yaml

* update aws action to trigger on pull requests

* fix type in yaml and get all these other jobs out of the way

* cosmetic commit to kick ci

* Run integration tests

* Try fixing default path

* Remove CI workflow while working on GPU action

* Fix path typo

* Install package locally

* Remove YANK-based protocols from integration tests

* Revert "Updates for `pint >=0.21` (#562)"

This reverts commit c8c476a.

* Skip CI

* Bump runner version

* Use "local" Dask cluster

https://docs.openforcefield.org/projects/evaluator/en/stable/backends/daskbackends.html#dask-local-cluster

* Set CUDA device

* Fix

* Add CI back

* Undo obsolete Pint changes

* Fix micromamba version

* Bump runner stopper

---------

Co-authored-by: Jeff Wagner <jwagnerjpl@gmail.com>
  • Loading branch information
mattwthompson and j-wags authored Oct 2, 2024
1 parent c8658d8 commit 42256d4
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 109 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Test Self-Hosted Runner
on:
workflow_dispatch:
pull_request:
branches:
- "main"

defaults:
run:
shell: bash -l {0}

jobs:
start-aws-runner:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
mapping: ${{ steps.aws-start.outputs.mapping }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::649715411074:role/gh-actions-runner-role
aws-region: us-east-1
- name: Create cloud runner
id: aws-start
uses: omsf-eco-infra/gha-runner@v0.3.0
with:
provider: "aws"
action: "start"
aws_image_id: ami-0d5079d9be06933e5
aws_instance_type: g4dn.xlarge
aws_region_name: us-east-1
aws_home_dir: /home/ubuntu
env:
GH_PAT: ${{ secrets.GH_PAT }}
self-hosted-test:
runs-on: self-hosted
needs:
- start-aws-runner
steps:
- uses: actions/checkout@v4

- name: Print disk usage
run: "df -h"

- name: Print Docker details
run: "docker version || true"

- name: Setup Conda Environment
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.5.10-0'
environment-file: devtools/conda-envs/test_env.yaml

- name: Install Package and test plugins
run: python -m pip install . utilities/test_plugins/

- name: Double-check local installation
run: python -c "from openff.evaluator import __version__; print(__version__)"
- name: Run integration tests
run: |
cd integration-tests/default-workflows/
python run.py
stop-aws-runner:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
needs:
- start-aws-runner
- self-hosted-test
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::649715411074:role/gh-actions-runner-role
aws-region: us-east-1
- name: Stop instances
uses: omsf-eco-infra/gha-runner@v0.3.0
with:
provider: "aws"
action: "stop"
instance_mapping: ${{ needs.start-aws-runner.outputs.mapping }}
aws_region_name: us-east-1
env:
GH_PAT: ${{ secrets.GH_PAT }}
122 changes: 13 additions & 109 deletions integration-tests/default-workflows/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@
from openff.units import unit

from openff import evaluator
from openff.evaluator.backends import QueueWorkerResources
from openff.evaluator.backends.dask import DaskLSFBackend
from openff.evaluator.backends.backends import ComputeResources
from openff.evaluator.backends.dask import DaskLocalCluster
from openff.evaluator.client import EvaluatorClient, RequestOptions
from openff.evaluator.datasets import PhysicalPropertyDataSet, PropertyPhase
from openff.evaluator.datasets.curation.components.filtering import (
FilterBySubstancesSchema,
)
from openff.evaluator.datasets.curation.components.freesolv import ImportFreeSolvSchema
from openff.evaluator.datasets.curation.workflow import (
CurationWorkflow,
CurationWorkflowSchema,
)
from openff.evaluator.forcefield import ParameterGradientKey
from openff.evaluator.layers.simulation import SimulationSchema
from openff.evaluator.properties import (
Density,
DielectricConstant,
EnthalpyOfMixing,
EnthalpyOfVaporization,
ExcessMolarVolume,
SolvationFreeEnergy,
)
from openff.evaluator.server import EvaluatorServer
from openff.evaluator.storage import LocalFileStorage
Expand All @@ -33,6 +30,8 @@
from openff.evaluator.utils import setup_timestamp_logging
from openff.evaluator.utils.utils import temporarily_change_directory

os.environ["CUDA_VISIBLE_DEVICES"] = "0"


def define_data_set(reweighting: bool) -> PhysicalPropertyDataSet:
# Define a common state to compute estimates at
Expand Down Expand Up @@ -62,23 +61,10 @@ def define_data_set(reweighting: bool) -> PhysicalPropertyDataSet:
)

data_set.add_properties(
SolvationFreeEnergy(
thermodynamic_state=states[1],
phase=PropertyPhase.Liquid,
substance=ethanol_substance,
value=0.0 * SolvationFreeEnergy.default_unit(),
),
SolvationFreeEnergy(
thermodynamic_state=states[1],
phase=PropertyPhase.Liquid,
substance=ethanal_substance,
value=0.0 * SolvationFreeEnergy.default_unit(),
),
*CurationWorkflow.apply(
PhysicalPropertyDataSet(),
CurationWorkflowSchema(
component_schemas=[
ImportFreeSolvSchema(),
FilterBySubstancesSchema(substances_to_include=[("O", "CO")]),
]
),
Expand Down Expand Up @@ -126,75 +112,6 @@ def define_data_set(reweighting: bool) -> PhysicalPropertyDataSet:
return data_set


def solvation_free_energy_schema() -> SimulationSchema:
"""Override trailblazing to use the lambda values of used in the previous OFF study
https://github.com/MobleyLab/SMIRNOFF_paper_code/tree/master/FreeSolv
"""

default_schema = SolvationFreeEnergy.default_simulation_schema()
workflow_schema = default_schema.workflow_schema

conditional_group_schema = next(
x for x in workflow_schema.protocol_schemas if x.id == "conditional_group"
)
conditional_group = conditional_group_schema.to_protocol()

yank_protocol = conditional_group.protocols["run_solvation_yank"]

yank_protocol.electrostatic_lambdas_1 = [
1.00,
0.75,
0.50,
0.25,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
0.00,
]
yank_protocol.steric_lambdas_1 = [
1.00,
1.00,
1.00,
1.00,
1.00,
0.95,
0.90,
0.80,
0.70,
0.60,
0.50,
0.40,
0.35,
0.30,
0.25,
0.20,
0.15,
0.10,
0.05,
0.00,
]

yank_protocol.electrostatic_lambdas_2 = [1.00, 0.75, 0.50, 0.25, 0.00]
yank_protocol.steric_lambdas_2 = [1.00, 1.00, 1.00, 1.00, 1.00]

workflow_schema.protocol_schemas.remove(conditional_group_schema)
workflow_schema.protocol_schemas.append(conditional_group.schema)

return default_schema


def main():
setup_timestamp_logging()

Expand All @@ -208,29 +125,23 @@ def main():
os.makedirs(os.path.join(version, "results"))

with temporarily_change_directory(version):
with DaskLSFBackend(
minimum_number_of_workers=1,
maximum_number_of_workers=12,
resources_per_worker=QueueWorkerResources(
with DaskLocalCluster(
number_of_workers=1,
resources_per_worker=ComputeResources(
number_of_threads=1,
number_of_gpus=1,
preferred_gpu_toolkit=QueueWorkerResources.GPUToolkit.CUDA,
per_thread_memory_limit=5 * unit.gigabyte,
wallclock_time_limit="05:59",
preferred_gpu_toolkit=ComputeResources.GPUToolkit.CUDA,
),
setup_script_commands=[
f"conda activate openff-evaluator-{version}",
"module load cuda/10.0",
],
queue_name="gpuqueue",
) as calculation_backend:
) as local_backend:

with EvaluatorServer(
calculation_backend,
local_backend,
working_directory="outputs",
storage_backend=LocalFileStorage("cached-data"),
):
client = EvaluatorClient()

for allowed_layer in ["SimulationLayer", "ReweightingLayer"]:
for allowed_layer in ["ReweightingLayer"]:
data_set = define_data_set(allowed_layer == "ReweightingLayer")

options = RequestOptions()
Expand All @@ -239,13 +150,6 @@ def main():
property_type: {} for property_type in data_set.property_types
}

if allowed_layer == "SimulationLayer":
options.add_schema(
"SimulationLayer",
"SolvationFreeEnergy",
solvation_free_energy_schema(),
)

request, _ = client.request_estimate(
data_set,
ForceField("openff-1.2.0.offxml"),
Expand Down

0 comments on commit 42256d4

Please sign in to comment.