#!/usr/bin/env python # coding: utf-8 # In[1]: import ipyparallel as ipp # In[2]: cluster = ipp.Cluster(engine_launcher_class="slurm", controller_ip="0.0.0.0", profile_dir="/data/profile") cluster.config.SlurmEngineSetLauncher.batch_template = """\ #!/bin/sh #SBATCH --ntasks={n} #SBATCH --export=ALL #SBATCH --job-name=ipengine-{cluster_id} #SBATCH --mem=1gb #SBATCH --time=00:05:00 #SBATCH --ntasks-per-node=1 env | sort srun {program_and_args} """ cluster.start_cluster_sync(n=2) rc = cluster.connect_client_sync() rc.wait_for_engines(2) # In[3]: get_ipython().system('squeue') # In[4]: import socket rc[:].apply_async(socket.gethostname).get_dict() # The rendered template: # In[5]: get_ipython().system('cat slurm_engine.sbatch')