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

Fixing docker test #90

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from
Draft
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
20 changes: 17 additions & 3 deletions .github/workflows/docker_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ jobs:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"

- 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

Expand All @@ -41,15 +45,25 @@ jobs:
with:
context: ./tests/docker_tests
load: true
tags: slurm_test:latest
tags: slurm-image

- name: Start the SLURM cluster container
run: |
docker run -d -p 22:22 --name slurm-container slurm-image
docker run -d -p 2222:22 --name slurm-container slurm-image
docker exec slurm-container ls -l /etc/slurm/slurm.conf
docker exec slurm-container chown slurmuser:slurmgroup /etc/slurm/slurm.conf
docker exec slurm-container chmod +r /etc/slurm/slurm.conf
docker exec slurm-container ls -l /etc/slurm/slurm.conf
docker exec slurm-container less /etc/passwd
docker exec slurm-container chmod 777 /etc/slurm/slurm.conf
docker exec slurm-container ls -l /etc/slurm/slurm.conf

- name: Run a basic covalent test
run: |
pip install -e .
covalent start
cd tests/docker_tests
python basic_test.py
covalent logs
covalent stop

5 changes: 5 additions & 0 deletions covalent_slurm_plugin/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class ExecutorPluginDefaults(BaseModel):
Path.home() / ".config/covalent/executor_plugins/covalent-slurm-cache"
)
ignore_versions: bool = False
ssh_port: Optional[int] = 22


_EXECUTOR_PLUGIN_DEFAULTS = ExecutorPluginDefaults().model_dump()
Expand Down Expand Up @@ -112,6 +113,7 @@ class SlurmExecutor(AsyncBaseExecutor):
time_limit: time limit for the task
retries: Number of times to retry execution upon failure
ignore_versions: Whether to ignore the Python, Covalent, and Cloudpickle version mismatch on the remote machine and try running the task anyway. Default is False.
ssh_port: Port number to use for SSH connection. Default is 22.
"""

def __init__(
Expand Down Expand Up @@ -141,6 +143,7 @@ def __init__(
time_limit: int = -1,
retries: int = 0,
ignore_versions: bool = None,
ssh_port: int = 22,
):
super().__init__(
log_stdout=log_stdout, log_stderr=log_stderr, time_limit=time_limit, retries=retries
Expand All @@ -164,6 +167,7 @@ def __init__(
if ignore_versions is not None
else get_config("executors.slurm.ignore_versions")
)
self.ssh_port = ssh_port or get_config("executors.slurm.ssh_port")

# Resolve ssh_key_file and cert_file to absolute paths.
if self.ssh_key_file:
Expand Down Expand Up @@ -235,6 +239,7 @@ async def _client_connect(self) -> asyncssh.SSHClientConnection:
try:
conn = await asyncssh.connect(
self.address,
self.ssh_port,
username=self.username,
client_keys=client_keys,
known_hosts=None,
Expand Down
3 changes: 3 additions & 0 deletions tests/docker_tests/basic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ssh_key_file="./slurm_test",
conda_env="covalent",
ignore_versions=True,
ssh_port=2222,
)


Expand All @@ -41,5 +42,7 @@ def task():
res = ct.get_result(did, wait=True)
print(res)

print("Node 0 error:", res._get_node_error(0))

if __name__ == "__main__":
assert res.result == 42
Loading