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

Slurm scheduler #16

Merged
merged 7 commits into from
Jan 24, 2023
Merged

Slurm scheduler #16

merged 7 commits into from
Jan 24, 2023

Conversation

sverhoeven
Copy link
Member

@sverhoeven sverhoeven commented Nov 11, 2022

Adds Slurm scheduler support.

Also adds

To test spin up a Slurm container with

docker run --detach --publish 10022:22 xenonmiddleware/slurm:20

To submit a job in a Python REPL (python -m asyncio or ipython)

from pathlib import Path
from bartender.filesystems.sftp import SftpFileSystem
from bartender.schedulers.abstract import JobDescription
from bartender.schedulers.slurm import SlurmScheduler
from bartender.schedulers.runner import SshCommandRunner

job_dir = Path('/tmp/jobs/myjob')
job_dir.mkdir(parents=True, exist_ok=True)
config = {
            "hostname": 'localhost',
            "port": 10022,
            "username": 'xenon',
            "password": 'javagat',
        }
scheduler = SlurmScheduler(runner=SshCommandRunner(config))
description = JobDescription(command="echo -n hello", job_dir=str(job_dir))
fs = SftpFileSystem(entry='/home/xenon', config=config)
localized_description = fs.localize_description(description, job_dir.parent)

await fs.upload(description, localized_description)

job_id = await scheduler.submit(localized_description)

print(await scheduler.state(job_id))
# Repeat fetching state until it is 'ok' or 'error'

await fs.download(localized_description, description)

After download should have stderr.txt, stdout.txt, returncode files in /tmp/jobs/myjob.

As similar job submission is done at https://github.com/i-VRESSE/bartender/blob/slurm-scheduler/bartender/tests/schedulers/test_slurm.py#L60

Don't forget to docker rm -f <slurm container name or id> when you are done.

@sverhoeven sverhoeven changed the base branch from main to memory-scheduler November 11, 2022 15:40
@sverhoeven sverhoeven marked this pull request as ready for review November 18, 2022 13:23
@sverhoeven sverhoeven requested a review from Peter9192 January 18, 2023 08:37
@Peter9192
Copy link
Contributor

Just a heads up that I successfully managed to execute the instructions in the top post. I'm still trying to grasp more fully how this works, but that also requires looking at #15.

Base automatically changed from memory-scheduler to main January 24, 2023 10:48
Copy link
Contributor

@Peter9192 Peter9192 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and pair-reviewed!

bartender/schedulers/slurm.py Outdated Show resolved Hide resolved
Comment on lines +78 to +81
def close(self) -> None:
"""Close SSH connection."""
if self.conn:
self.conn.close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, once open it stays open. Would it make sense to close the connection after each transfer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Postponed to #35

bartender/filesystems/sftp.py Show resolved Hide resolved
bartender/_ssh_utils.py Outdated Show resolved Hide resolved
bartender/filesystems/abstract.py Show resolved Hide resolved
bartender/filesystems/local.py Show resolved Hide resolved
bartender/schedulers/slurm.py Outdated Show resolved Hide resolved
bartender/tests/schedulers/test_slurm.py Show resolved Hide resolved
sverhoeven and others added 2 commits January 24, 2023 15:08
Co-authored-by: Peter Kalverla <peter@kalversweep.nl>
Co-authored-by: Peter Kalverla <peter@kalversweep.nl>
@sverhoeven sverhoeven merged commit f1b0996 into main Jan 24, 2023
@sverhoeven sverhoeven deleted the slurm-scheduler branch January 24, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use testcontainers
2 participants