-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from aperijake/material_interface
- Loading branch information
Showing
27 changed files
with
1,225 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
|
||
import paramiko | ||
|
||
|
||
def str_to_bool(value): | ||
return value.lower() in ("true", "1", "t", "y", "yes") | ||
|
||
|
||
def run_build(vm_ip, vm_username, gpu, build_type, code_coverage, with_protego): | ||
ssh = paramiko.SSHClient() | ||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | ||
|
||
# Establish the SSH connection with increased timeout and keepalive options | ||
ssh.connect(vm_ip, username=vm_username, timeout=60) | ||
transport = ssh.get_transport() | ||
transport.set_keepalive(30) # Send keepalive messages every 30 seconds | ||
|
||
# Construct the compose file and service name | ||
compose_file = "docker-compose.yml" | ||
service_name = "aperi-mech-development" | ||
if gpu and not code_coverage: | ||
compose_file = "docker-compose_nvidia_t4_gpu.yml" | ||
service_name = "aperi-mech-gpu-development" | ||
|
||
# Construct the configure flag and build path | ||
configure_flag = "" | ||
build_root = "build" | ||
if with_protego: | ||
build_root = "protego-mech/build" | ||
configure_flag += " --protego-mech" | ||
build_path = f"{build_root}/{build_type}" | ||
if gpu: | ||
configure_flag += " --gpu" | ||
build_path += "_gpu" | ||
|
||
run_coverage = "" | ||
if code_coverage: | ||
configure_flag += " --code-coverage" | ||
build_path += "_cov" | ||
run_coverage = "make coverage" | ||
|
||
# Construct the command to run on the VM | ||
commands = f""" | ||
set -e | ||
cd ~/aperi-mech | ||
docker-compose -f {compose_file} run --rm {service_name} /bin/bash -c ' | ||
cd ~/aperi-mech | ||
. ~/spack/share/spack/setup-env.sh | ||
spack env activate aperi-mech | ||
./do_configure --build-type {build_type} {configure_flag} | ||
cd {build_path} | ||
make -j 4 | ||
{run_coverage} | ||
' || {{ echo "Build project step failed"; exit 1; }} | ||
""" | ||
|
||
print("Executing the following commands on the VM:") | ||
print(commands) | ||
|
||
stdin, stdout, stderr = ssh.exec_command(commands, get_pty=True) | ||
for line in stdout: | ||
print(line.strip()) | ||
for line in stderr: | ||
print(line.strip()) | ||
|
||
ssh.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Run build on remote VM") | ||
parser.add_argument("--ip", default="127.0.0.1", help="IP address of the VM") | ||
parser.add_argument("--username", default="azureuser", help="Username for the VM") | ||
parser.add_argument("--gpu", default="false", help="GPU flag (true/false)") | ||
parser.add_argument( | ||
"--build_type", | ||
"--build-type", | ||
dest="build_type", | ||
default="Release", | ||
help="Build type", | ||
) | ||
parser.add_argument( | ||
"--code_coverage", | ||
"--code-coverage", | ||
dest="code_coverage", | ||
default="false", | ||
help="Code coverage flag (true/false)", | ||
) | ||
parser.add_argument( | ||
"--protego", default="false", help="With Protego flag (true/false)" | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
run_build( | ||
args.ip, | ||
args.username, | ||
str_to_bool(args.gpu), | ||
args.build_type, | ||
str_to_bool(args.code_coverage), | ||
str_to_bool(args.protego), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Common Runner Config Steps | ||
description: Setup python on the runner and install dependencies | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install Dependencies | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install paramiko |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
.github/actions/run-aperi-mech-performance-tests/run_aperi-mech_performance_tests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import argparse | ||
|
||
import paramiko | ||
|
||
|
||
def str_to_bool(value): | ||
return value.lower() in ("true", "1", "t", "y", "yes") | ||
|
||
|
||
def run_aperi_mech_performance_tests(vm_ip, vm_username, gpu, parallel): | ||
ssh = paramiko.SSHClient() | ||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | ||
ssh.connect(vm_ip, username=vm_username) | ||
|
||
# Convert string inputs to boolean | ||
gpu = str_to_bool(gpu) | ||
parallel = str_to_bool(parallel) | ||
|
||
# Construct the compose file and service name | ||
compose_file = "docker-compose.yml" | ||
service_name = "aperi-mech-development" | ||
if gpu: | ||
compose_file = "docker-compose_nvidia_t4_gpu.yml" | ||
service_name = "aperi-mech-gpu-development" | ||
|
||
# Construct the test flags | ||
test_flags = "--release" | ||
if gpu: | ||
test_flags += " --gpu" | ||
else: | ||
test_flags += " --cpu" | ||
if parallel: | ||
test_flags += " --parallel" | ||
else: | ||
test_flags += " --serial" | ||
|
||
# Construct the command to run on the VM | ||
commands = f""" | ||
set -e | ||
cd ~/aperi-mech | ||
docker-compose -f {compose_file} run --rm {service_name} /bin/bash -c ' | ||
echo "Setting up Spack environment..." | ||
. ~/spack/share/spack/setup-env.sh | ||
spack env activate aperi-mech | ||
echo "Running aperi-mech performance tests..." | ||
cd ~/aperi-mech/test/ | ||
./run_regression_tests.py --directory ./performance_tests/aperi-mech --build-dir ~/aperi-mech/build/ {test_flags} --write-json --no-preclean | ||
./run_regression_tests.py --directory ./performance_tests/aperi-mech --build-dir ~/aperi-mech/build/ {test_flags} --clean-logs | ||
./run_regression_tests.py --directory ./performance_tests/aperi-mech --build-dir ~/aperi-mech/build/ {test_flags} --clean-results | ||
' || {{ echo "Performance test step failed"; exit 1; }} | ||
""" | ||
|
||
print("Executing the following commands on the VM:") | ||
print(commands) | ||
|
||
stdin, stdout, stderr = ssh.exec_command(commands) | ||
for line in stdout: | ||
print(line.strip()) | ||
for line in stderr: | ||
print(line.strip()) | ||
|
||
ssh.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Run performance tests on remote VM") | ||
parser.add_argument("--ip", default="127.0.0.1", help="IP address of the VM") | ||
parser.add_argument("--username", default="azureuser", help="Username for the VM") | ||
parser.add_argument("--gpu", default="false", help="GPU flag (true/false)") | ||
parser.add_argument( | ||
"--parallel", default="false", help="Parallel flag (true/false)" | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
run_aperi_mech_performance_tests(args.ip, args.username, args.gpu, args.parallel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.