Skip to content

Latest commit

 

History

History
461 lines (411 loc) · 28.6 KB

README.md

File metadata and controls

461 lines (411 loc) · 28.6 KB

slurm-rest

API to access and control Slurm.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 0.0.37
  • Package version: 0.0.37.1
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://www.schedmd.com/

Requirements.

Python >= 3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/ccmbioinfo/slurm-rest-py.git

(you may need to run pip with root permission to install globally: sudo pip install git+https://github.com/ccmbioinfo/slurm-rest-py.git)

Then import the package:

import slurm_rest

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import slurm_rest

Getting Started

Please follow the installation procedure and then run the following:

#!/usr/bin/env python3

from slurm_rest import Configuration, ApiClient, ApiException
from slurm_rest.apis import SlurmApi


# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = slurm_rest.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: token
configuration.api_key['token'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['token'] = 'Bearer'

# Configure API key authorization: user
configuration.api_key['user'] = 'YOUR_API_KEY'

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['user'] = 'Bearer'


# Enter a context with an instance of the API client
with ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = SlurmApi(api_client)
    
    try:
        # get diagnostics
        print(api_instance.slurmctld_diag())
    except slurm_rest.ApiException as e:
        print("Exception when calling SlurmApi->slurmctld_diag: %s\n" % e)

Documentation for API Endpoints

Class Method HTTP request Description
DefaultApi slurm_v0035_diag_get GET /slurm/v0.0.35/diag get diagnostics
DefaultApi slurm_v0035_job_job_id_delete DELETE /slurm/v0.0.35/job/{job_id} cancel or signal job
DefaultApi slurm_v0035_job_job_id_get GET /slurm/v0.0.35/job/{job_id} get job info
DefaultApi slurm_v0035_job_job_id_post POST /slurm/v0.0.35/job/{job_id} update job
DefaultApi slurm_v0035_job_submit_post POST /slurm/v0.0.35/job/submit submit new job
DefaultApi slurm_v0035_jobs_get GET /slurm/v0.0.35/jobs get list of jobs
DefaultApi slurm_v0035_node_node_name_get GET /slurm/v0.0.35/node/{node_name} get node info
DefaultApi slurm_v0035_nodes_get GET /slurm/v0.0.35/nodes get all node info
DefaultApi slurm_v0035_partition_partition_name_get GET /slurm/v0.0.35/partition/{partition_name} get partition info
DefaultApi slurm_v0035_partitions_get GET /slurm/v0.0.35/partitions get all partition info
DefaultApi slurm_v0035_ping_get GET /slurm/v0.0.35/ping ping test
OpenapiApi openapi_get GET /openapi Retrieve OpenAPI Specification
OpenapiApi openapi_json_get GET /openapi.json Retrieve OpenAPI Specification
OpenapiApi openapi_v3_get GET /openapi/v3 Retrieve OpenAPI Specification
OpenapiApi openapi_yaml_get GET /openapi.yaml Retrieve OpenAPI Specification
SlurmApi slurmctld_cancel_job DELETE /slurm/v0.0.37/job/{job_id} cancel or signal job
SlurmApi slurmctld_cancel_job_0 DELETE /slurm/v0.0.36/job/{job_id} cancel or signal job
SlurmApi slurmctld_diag GET /slurm/v0.0.37/diag get diagnostics
SlurmApi slurmctld_diag_0 GET /slurm/v0.0.36/diag get diagnostics
SlurmApi slurmctld_get_job GET /slurm/v0.0.37/job/{job_id} get job info
SlurmApi slurmctld_get_job_0 GET /slurm/v0.0.36/job/{job_id} get job info
SlurmApi slurmctld_get_jobs GET /slurm/v0.0.37/jobs get list of jobs
SlurmApi slurmctld_get_jobs_0 GET /slurm/v0.0.36/jobs get list of jobs
SlurmApi slurmctld_get_node GET /slurm/v0.0.37/node/{node_name} get node info
SlurmApi slurmctld_get_node_0 GET /slurm/v0.0.36/node/{node_name} get node info
SlurmApi slurmctld_get_nodes GET /slurm/v0.0.37/nodes get all node info
SlurmApi slurmctld_get_nodes_0 GET /slurm/v0.0.36/nodes get all node info
SlurmApi slurmctld_get_partition GET /slurm/v0.0.37/partition/{partition_name} get partition info
SlurmApi slurmctld_get_partition_0 GET /slurm/v0.0.36/partition/{partition_name} get partition info
SlurmApi slurmctld_get_partitions GET /slurm/v0.0.37/partitions get all partition info
SlurmApi slurmctld_get_partitions_0 GET /slurm/v0.0.36/partitions get all partition info
SlurmApi slurmctld_get_reservation GET /slurm/v0.0.37/reservation/{reservation_name} get reservation info
SlurmApi slurmctld_get_reservations GET /slurm/v0.0.37/reservations get all reservation info
SlurmApi slurmctld_ping GET /slurm/v0.0.37/ping ping test
SlurmApi slurmctld_ping_0 GET /slurm/v0.0.36/ping ping test
SlurmApi slurmctld_submit_job POST /slurm/v0.0.37/job/submit submit new job
SlurmApi slurmctld_submit_job_0 POST /slurm/v0.0.36/job/submit submit new job
SlurmApi slurmctld_update_job POST /slurm/v0.0.37/job/{job_id} update job
SlurmApi slurmctld_update_job_0 POST /slurm/v0.0.36/job/{job_id} update job
SlurmApi slurmdbd_add_clusters POST /slurmdb/v0.0.36/clusters Add clusters
SlurmApi slurmdbd_add_clusters_0 POST /slurmdb/v0.0.37/clusters Add clusters
SlurmApi slurmdbd_add_wckeys POST /slurmdb/v0.0.36/wckeys Add wckeys
SlurmApi slurmdbd_add_wckeys_0 POST /slurmdb/v0.0.37/wckeys Add wckeys
SlurmApi slurmdbd_delete_account DELETE /slurmdb/v0.0.36/account/{account_name} Delete account
SlurmApi slurmdbd_delete_account_0 DELETE /slurmdb/v0.0.37/account/{account_name} Delete account
SlurmApi slurmdbd_delete_association DELETE /slurmdb/v0.0.36/association Delete association
SlurmApi slurmdbd_delete_association_0 DELETE /slurmdb/v0.0.37/association Delete association
SlurmApi slurmdbd_delete_cluster DELETE /slurmdb/v0.0.36/cluster/{cluster_name} Delete cluster
SlurmApi slurmdbd_delete_cluster_0 DELETE /slurmdb/v0.0.37/cluster/{cluster_name} Delete cluster
SlurmApi slurmdbd_delete_qos DELETE /slurmdb/v0.0.36/qos/{qos_name} Delete QOS
SlurmApi slurmdbd_delete_qos_0 DELETE /slurmdb/v0.0.37/qos/{qos_name} Delete QOS
SlurmApi slurmdbd_delete_user DELETE /slurmdb/v0.0.36/user/{user_name} Delete user
SlurmApi slurmdbd_delete_user_0 DELETE /slurmdb/v0.0.37/user/{user_name} Delete user
SlurmApi slurmdbd_delete_wckey DELETE /slurmdb/v0.0.36/wckey/{wckey} Delete wckey
SlurmApi slurmdbd_delete_wckey_0 DELETE /slurmdb/v0.0.37/wckey/{wckey} Delete wckey
SlurmApi slurmdbd_diag GET /slurmdb/v0.0.36/diag Get slurmdb diagnostics
SlurmApi slurmdbd_diag_0 GET /slurmdb/v0.0.37/diag Get slurmdb diagnostics
SlurmApi slurmdbd_get_account GET /slurmdb/v0.0.36/account/{account_name} Get account info
SlurmApi slurmdbd_get_account_0 GET /slurmdb/v0.0.37/account/{account_name} Get account info
SlurmApi slurmdbd_get_accounts GET /slurmdb/v0.0.36/accounts Get account list
SlurmApi slurmdbd_get_accounts_0 GET /slurmdb/v0.0.37/accounts Get account list
SlurmApi slurmdbd_get_association GET /slurmdb/v0.0.36/association Get association info
SlurmApi slurmdbd_get_association_0 GET /slurmdb/v0.0.37/association Get association info
SlurmApi slurmdbd_get_associations GET /slurmdb/v0.0.36/associations Get association list
SlurmApi slurmdbd_get_associations_0 GET /slurmdb/v0.0.37/associations Get association list
SlurmApi slurmdbd_get_cluster GET /slurmdb/v0.0.36/cluster/{cluster_name} Get cluster info
SlurmApi slurmdbd_get_cluster_0 GET /slurmdb/v0.0.37/cluster/{cluster_name} Get cluster info
SlurmApi slurmdbd_get_clusters GET /slurmdb/v0.0.36/clusters Get cluster list
SlurmApi slurmdbd_get_clusters_0 GET /slurmdb/v0.0.37/clusters Get cluster list
SlurmApi slurmdbd_get_db_config GET /slurmdb/v0.0.36/config Dump all configuration information
SlurmApi slurmdbd_get_db_config_0 GET /slurmdb/v0.0.37/config Dump all configuration information
SlurmApi slurmdbd_get_job GET /slurmdb/v0.0.36/job/{job_id} Get job info
SlurmApi slurmdbd_get_job_0 GET /slurmdb/v0.0.37/job/{job_id} Get job info
SlurmApi slurmdbd_get_jobs GET /slurmdb/v0.0.36/jobs Get job list
SlurmApi slurmdbd_get_jobs_0 GET /slurmdb/v0.0.37/jobs Get job list
SlurmApi slurmdbd_get_qos GET /slurmdb/v0.0.36/qos Get QOS list
SlurmApi slurmdbd_get_qos_0 GET /slurmdb/v0.0.37/qos Get QOS list
SlurmApi slurmdbd_get_single_qos GET /slurmdb/v0.0.36/qos/{qos_name} Get QOS info
SlurmApi slurmdbd_get_single_qos_0 GET /slurmdb/v0.0.37/qos/{qos_name} Get QOS info
SlurmApi slurmdbd_get_tres GET /slurmdb/v0.0.36/tres Get TRES info
SlurmApi slurmdbd_get_tres_0 GET /slurmdb/v0.0.37/tres Get TRES info
SlurmApi slurmdbd_get_user GET /slurmdb/v0.0.36/user/{user_name} Get user info
SlurmApi slurmdbd_get_user_0 GET /slurmdb/v0.0.37/user/{user_name} Get user info
SlurmApi slurmdbd_get_users GET /slurmdb/v0.0.36/users Get user list
SlurmApi slurmdbd_get_users_0 GET /slurmdb/v0.0.37/users Get user list
SlurmApi slurmdbd_get_wckey GET /slurmdb/v0.0.36/wckey/{wckey} Get wckey info
SlurmApi slurmdbd_get_wckey_0 GET /slurmdb/v0.0.37/wckey/{wckey} Get wckey info
SlurmApi slurmdbd_get_wckeys GET /slurmdb/v0.0.36/wckeys Get wckey list
SlurmApi slurmdbd_get_wckeys_0 GET /slurmdb/v0.0.37/wckeys Get wckey list
SlurmApi slurmdbd_set_db_config POST /slurmdb/v0.0.36/config Load all configuration information
SlurmApi slurmdbd_set_db_config_0 POST /slurmdb/v0.0.37/config Load all configuration information
SlurmApi slurmdbd_update_account POST /slurmdb/v0.0.36/accounts Update accounts
SlurmApi slurmdbd_update_account_0 POST /slurmdb/v0.0.37/accounts Update accounts
SlurmApi slurmdbd_update_tres POST /slurmdb/v0.0.36/tres Set TRES info
SlurmApi slurmdbd_update_tres_0 POST /slurmdb/v0.0.37/tres Set TRES info
SlurmApi slurmdbd_update_users POST /slurmdb/v0.0.36/users Update user
SlurmApi slurmdbd_update_users_0 POST /slurmdb/v0.0.37/users Update user

Documentation For Models

Documentation For Authorization

token

  • Type: API key
  • API key parameter name: X-SLURM-USER-TOKEN
  • Location: HTTP header

user

  • Type: API key
  • API key parameter name: X-SLURM-USER-NAME
  • Location: HTTP header

Author

sales@schedmd.com

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in slurm_rest.apis and slurm_rest.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from slurm_rest.api.default_api import DefaultApi
  • from slurm_rest.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import slurm_rest
from slurm_rest.apis import *
from slurm_rest.models import *

Generating and updating documentation

Download Slurm's OpenAPI schema at /openapi.json (all forms of this endpoint return the exact same document) to openapi-slurm.json, then run the generator:

docker run --rm \
    --user $(id -u):$(id -g) \
    -v $PWD:/srv \
    openapitools/openapi-generator-cli:v5.3.0 \
    generate \
    -i /srv/openapi-slurm.json \
    -g python \
    --skip-validate-spec \
    -o /srv/SUBDIRECTORY_OF_PWD_IF_NEEDED \
    --package-name slurm_rest \
    --git-user-id ccmbioinfo \
    --git-repo-id slurm-rest-py \
    --additional-properties packageVersion=0.0.37.0

I used Docker to run the CLI for convenience, but it can be run in other ways. The Slurm schema has some validation errors with repeated attributes, so we have to skip that step to generate the client, which seems to work regardless. We use a bind mount for the container to write local files, and additionally use our current UID and GID with the container so the files aren't written out as root. This can be run in the repository root or its parent directory, as long as the -o output path is adjusted accordingly.