Skip to main content

slurmic is a package designed to provide seamless Python function execution on Slurm.

Project description

🌩️ slurmic

Pytest Documentation

slurmic is a package designed to provide seamless Python function execution on Slurm.

Features

Execute Python functions on Slurm just like local functions

   from slurmic import SlurmConfig, slurm_fn

   @slurm_fn
   def run_on_slurm(a, b):
      return a + b

   slurm_config = SlurmConfig(
      mode="slurm",
      partition="PARTITION",
      job_name="EXAMPLE",
      tasks_per_node=1,
      cpus_per_task=8,
      mem="1GB",
   )

   job = run_on_slurm[slurm_config](1, b=2) # job is submitted to slurm
   result = job.result() # block and get the result => 3

Easily manage job dependencies

   jobs = []

   # job1 is submitted to slurm directly
   job1 = run_on_slurm[slurm_config](10, 2)
   jobs.append(job1)

   # fn2 must be executed after job1 is finished
   fn2 = run_on_slurm[slurm_config].on_condition(job1)
   job2 = fn2(7, 12)
   jobs.append(job2)

   # This will block until all jobs are finished
   results = [job.result() for job in jobs]
   assert results == [12, 19]

Mapping sequential jobs

   jobs = run_on_slurm[slurm_config].map_array([1, 2, 8, 9], [3, 4, 8, 9])
   results = [job.result() for job in jobs]
   assert results == [4, 6, 16, 18]

Distributed jobs

   # distributed launch command by accelerate as an example
   slurm_config = SlurmConfig(
         mode="slurm",
         cpus_per_task=8,
         gpus_per_node=4,
         use_distributed_env=True,
         # main.py is the entry of the distributed job
         distributed_launch_command="accelerate launch \
            --config_file CONFIG_FILE --num_processes {num_processes} \
               --num_machines {num_machines} --machine_rank {machine_rank} \
                  --main_process_ip {main_process_ip} --main_process_port {main_process_port} \
                     main.py",
   )

   main[slurm_config](config)

Installation

slurmic supports Python 3.10-3.13 and is tested on Linux systems with Slurm installed.

Install slurmic via pip

   pip install slurmic

Development

Development Installation

pip install -e ".[dev]"

Testing

pytest

Build Wheel

uv build

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slurmic-0.2.0.tar.gz (21.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

slurmic-0.2.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file slurmic-0.2.0.tar.gz.

File metadata

  • Download URL: slurmic-0.2.0.tar.gz
  • Upload date:
  • Size: 21.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for slurmic-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c016ef16afec91f50bfb7a90c222f07ab188eaf89f2a5d3d5bc055bef56d559d
MD5 ef11ab9c607d4c27e65d9fc50517d91b
BLAKE2b-256 6d707778698a9c8673e7a26b1c5b8bb331fc5bd5fdf355814ea4bf1f86bce323

See more details on using hashes here.

File details

Details for the file slurmic-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: slurmic-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for slurmic-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df6a6b509ab913f0ada1859c25f6afa21a7c87054fe7d7ddff2388271711a16f
MD5 27ecb7d8de26898879e1a9a03d0a22a7
BLAKE2b-256 55000964a3c358aa9602be086ca0cb03ed859058d3b9878ccc4983554a20d37e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page