cuddly-jelly-27016
03/06/2025, 3:37 AMsbatch to run a batch script on Slurm cluster
2. `get`: Check the Slurm job state
3. delete (haven't been tested): Cancel the Slurm job
How was this patch tested?
We test create and get in the development environment described as follows:
• Local: MacBook with flytekit installed
• Test slurm agent locally following this guide
• Remote: Single Ubuntu server with slurmctld and slurmd running
• We plan to write a single-host setup tutorial and organize useful resources here
• Communication is done with asyncssh
Suppose we have a batch script to run on Slurm cluster:
#!/bin/bash
echo "Working!" >> ./remote_touch.txt
We use the following python script to test Slurm agent on the client side:
import os
from flytekit import workflow
from flytekitplugins.slurm import Slurm, SlurmTask
echo_job = SlurmTask(
name="echo-job-name",
task_config=Slurm(
slurm_host="<host_alias>",
batch_script_path="<path_to_batch_script_within_slurm_cluster>",
sbatch_conf={
"partition": "debug",
"job-name": "tiny-slurm",
}
)
)
@workflow
def wf() -> None:
echo_job()
if name == "__main__":
from flytekit.clis.sdk_in_container import pyflyte
from click.testing import CliRunner
runner = CliRunner()
path = os.path.realpath(file)
# Local run
print(f">>> LOCAL EXEC <<<")
result = runner.invoke(pyflyte.main, ["run", path, "wf"])
print(result.output)
The test result is shown as follows:
slurm_basic_result
Setup process
As stated above
Check all the applicable boxes
• I updated the documentation accordingly.
• All new and existing tests passed.
• All commits are signed-off.
Related PRs
Docs link
Summary by Bito
Implementation of a Slurm agent for Flytekit with enhanced SSH connection handling, featuring connection pooling, caching, and auto-reconnection. The agent implements robust authentication and shared memory support through asyncssh, with improved thread safety and SSH configuration validation. The changes introduce proper error handling, interactive bash script execution, and a SlurmCluster dataclass with centralized connection management. Enhanced logging system replaces print statements with proper logger calls.
Unit tests added: True
Estimated effort to review (1-5, lower is better): 5
flyteorg/flytekitcuddly-jelly-27016
03/06/2025, 3:37 AM