generated from AgnostiqHQ/covalent-executor-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added docker test with Slurm cluster (#89)
* Added docker test with Slurm cluster * updated changelog * ignoring docker_tests directory from pytest * added workflow dispatch trigger to the docker test
- Loading branch information
1 parent
35bde23
commit 98e835f
Showing
4 changed files
with
112 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright 2024 Agnostiq Inc. | ||
# | ||
# This file is part of Covalent. | ||
# | ||
# Licensed under the Apache License 2.0 (the "License"). A copy of the | ||
# License may be obtained with this software package or at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Use of this file is prohibited except in compliance with the License. | ||
# 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. | ||
|
||
name: docker_test | ||
|
||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build_container: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create the ssh keypair | ||
run: | | ||
cd tests/docker_tests | ||
ssh-keygen -t ed25519 -f slurm_test -N '' | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and export to Docker | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./tests/docker_tests | ||
load: true | ||
tags: slurm_test:latest | ||
|
||
- name: Start the SLURM cluster container | ||
run: | | ||
docker run -d -p 22:22 --name slurm-container slurm-image | ||
docker exec slurm-container chmod +r /etc/slurm/slurm.conf | ||
- name: Run a basic covalent test | ||
run: | | ||
cd tests/docker_tests | ||
python basic_test.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
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,45 @@ | ||
# Copyright 2024 Agnostiq Inc. | ||
# | ||
# This file is part of Covalent. | ||
# | ||
# Licensed under the Apache License 2.0 (the "License"). A copy of the | ||
# License may be obtained with this software package or at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Use of this file is prohibited except in compliance with the License. | ||
# 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. | ||
|
||
|
||
import covalent as ct | ||
|
||
from covalent_slurm_plugin import SlurmExecutor | ||
|
||
slurm_executor = SlurmExecutor( | ||
username="slurmuser", | ||
address="localhost", | ||
ssh_key_file="./slurm_test", | ||
conda_env="covalent", | ||
ignore_versions=True, | ||
) | ||
|
||
|
||
@ct.lattice | ||
@ct.electron(executor=slurm_executor) | ||
def task(): | ||
print("Hello World!") | ||
return 42 | ||
|
||
|
||
did = ct.dispatch(task)() | ||
print(did) | ||
|
||
res = ct.get_result(did, wait=True) | ||
print(res) | ||
|
||
if __name__ == "__main__": | ||
assert res.result == 42 |