Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added docker test with Slurm cluster #89

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/docker_test.yml
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

9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
shell: python

- name: Run tests
run: PYTHONPATH=$PWD/tests pytest -vv tests/ --cov=covalent_slurm_plugin
run: PYTHONPATH=$PWD/tests pytest -vv tests/ --cov=covalent_slurm_plugin --ignore=tests/docker_tests

- name: Generate coverage report
run: coverage xml -o coverage.xml
Expand Down Expand Up @@ -136,9 +136,14 @@ jobs:
fi
echo "RELEASE=$release" >> $GITHUB_ENV
echo "::set-output name=release::$release"

docker_test:
needs: tests
if: github.ref == 'refs/heads/develop' && needs.tests.outputs.release == 'true'
uses: ./.github/workflows/docker_test.yml

release:
needs: tests
needs: docker_test
if: github.ref == 'refs/heads/develop' && needs.tests.outputs.release == 'true'
uses: AgnostiqHQ/covalent-slurm-plugin/.github/workflows/release.yml@develop
secrets: inherit
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [UNRELEASED]

### Operations

- Added a docker based SLURM cluster in the CI pipeline for testing the plugin.
- Ignoring `tests/docker_tests` directory from pytest.

## [0.18.0] - 2024-01-26

### Added
Expand Down
45 changes: 45 additions & 0 deletions tests/docker_tests/basic_test.py
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
Loading