Skip to main content

Asynchronous SLURM REST requests with proxy support.

Project description

slurm-requests

PyPI - Version PyPI - Python Version


Asynchronous SLURM REST requests with proxy support.

Installation

pip install slurm-requests

Usage

import asyncio

import slurm_requests as slurm


async def main():

    # set defaults to avoid repetition
    slurm.init_defaults(
        url="https://example.com/sapi",
        api_version="v0.0.40",
        user_name="example_user",
        user_token="example_token",
        partition="example_partition",
        # constraints="GPU",
        environment=["EXAMPLE_VAR=example_value"],
        # headers={"X-Example-Header": "example_value"},
        # proxy_url="socks5://localhost:8080",
    )

    # check connection + credentials
    await slurm.ping()
    await slurm.diagnose()

    # submit
    job_id, _ = await slurm.job_submit(
        name="example_job",
        working_directory="/home/example_user/slurm",
        script="#!/usr/bin/bash\necho Hello, SLURM!",
        # time_limit=60,
        # dependency="afterok:123456",
    )
    assert job_id is not None

    # check state
    response = await slurm.job_current_state_and_reason(job_id=job_id)
    assert response is not None
    state, reason = response
    print(f"Job {job_id} is currently in state '{state}' due to reason '{reason}'.")

    # cancel
    await slurm.job_cancel(job_id=job_id)

    # advanced: overwrite a default (works for all functions)
    await slurm.ping(user_name="dummy", dry_run=True)


if __name__ == "__main__":
    asyncio.run(main())

License

slurm-requests is distributed under the terms of the CC-BY-SA-4.0 license.

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

slurm_requests-0.0.3.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

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

slurm_requests-0.0.3-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file slurm_requests-0.0.3.tar.gz.

File metadata

  • Download URL: slurm_requests-0.0.3.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for slurm_requests-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c4bb824d789e4a70837e9c9a1702f12c38ec908b6fa81d1245c7559bec8e090d
MD5 0de2b3c5dce131bba5da563ee3030540
BLAKE2b-256 e81fc143fc8a69bc1be43fe86a0c4b166a21503c3151cfc282ca818696f5ae65

See more details on using hashes here.

File details

Details for the file slurm_requests-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for slurm_requests-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c200f27ddd38cce047eebaca0c626eb32e42b46916d0831c7035ab1157356bbb
MD5 8f96b4ceaf1601baad518b31fcaa3d9c
BLAKE2b-256 b5d8d3d90c9d201122618a065a03b6d33eff5486f3d905b4f8bc23b1357456d0

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