diff --git a/.gitignore b/.gitignore index 6bea6e8b..f79b3369 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Ignore Build Directory # build/ +site # Ignore Docs Directory # #doc/ diff --git a/doc/Makefile b/doc/Makefile deleted file mode 100644 index eb9f6570..00000000 --- a/doc/Makefile +++ /dev/null @@ -1,130 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - -rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PySLURM.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PySLURM.qhc" - -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/PySLURM" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/PySLURM" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - make -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." diff --git a/doc/doctrees/environment.pickle b/doc/doctrees/environment.pickle deleted file mode 100644 index 3b329421..00000000 Binary files a/doc/doctrees/environment.pickle and /dev/null differ diff --git a/doc/doctrees/index.doctree b/doc/doctrees/index.doctree deleted file mode 100644 index 063112f0..00000000 Binary files a/doc/doctrees/index.doctree and /dev/null differ diff --git a/doc/source/conf.py b/doc/source/conf.py deleted file mode 100644 index 96f93a6e..00000000 --- a/doc/source/conf.py +++ /dev/null @@ -1,233 +0,0 @@ -# -*- coding: utf-:8 -*- -# -# PySlurm documentation build configuration file, created by -# sphinx-quickstart on Thu Sep 8 18:50:27 2011. -# -# This file is execfile()d with the current directory set to its containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -from datetime import datetime - -from pyslurm import __version__ - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) -arch = os.uname()[-1] -pyver = str(sys.version_info.major) + "." + str(sys.version_info.minor) -sys.path.insert(0, os.path.abspath('../../build/lib.linux-' + arch + '-' + pyver)) - -# -- General configuration ----------------------------------------------------- - -# If your documentation needs a minimal Sphinx version, state it here. -needs_sphinx = '1.1' - -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'sphinx.ext.intersphinx' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = 'PySlurm' -copyright = '%s, PySlurm Developers' % datetime.now().year - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = __version__ -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -#language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -#today = '' -# Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = [] - -# The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -#add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -#show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] - - -# -- Options for HTML output --------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'default' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -#html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -#html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -html_logo = "_static/pyslurm-docs.png" - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -#html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -#html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -#html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -#html_additional_pages = {} - -# If false, no module index is generated. -#html_domain_indices = True - -# If false, no index is generated. -#html_use_index = True - -# If true, the index is split into individual pages for each letter. -#html_split_index = False - -# If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -#html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None - -# Output file base name for HTML help builder. -htmlhelp_basename = 'PySlurmDoc' - - -# -- Options for LaTeX output -------------------------------------------------- - -# The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' - -# The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). -latex_documents = [ - ('index', 'PySlurm.tex', 'PySlurm Documentation', - 'Mark Roberts, Giovanni Torres', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -#latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -#latex_use_parts = False - -# If true, show page references after internal links. -#latex_show_pagerefs = False - -# If true, show URL addresses after external links. -#latex_show_urls = False - -# Additional stuff for the LaTeX preamble. -#latex_preamble = '' - -# Documents to append as an appendix to all manuals. -#latex_appendices = [] - -# If false, no module index is generated. -#latex_domain_indices = True - - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'pyslurm', 'PySlurm Documentation', - ['Mark Roberts, Giovanni Torres'], 1) -] - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/index.rst b/doc/source/index.rst deleted file mode 100644 index b76e46c6..00000000 --- a/doc/source/index.rst +++ /dev/null @@ -1,118 +0,0 @@ -.. PySlurm documentation master file, created by - sphinx-quickstart on Thu Sep 8 18:50:27 2011. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -PySlurm: Slurm Interface to python -=================================== - -:Authors: Mark Roberts, Giovanni Torres -:Date: |today| -:Version: |version| - -This module provides a low-level Python wrapper around the Slurm C-API using Cython. - -Contents -======== - -.. toctree:: - :maxdepth: 2 - :numbered: - -Config Class -************ - -.. autoclass:: pyslurm.config - :members: - -FrontEnd Class -************** - -.. autoclass:: pyslurm.front_end - :members: - -HostList Class -************** - -.. autoclass:: pyslurm.hostlist - :members: - -Job Class -********* - -.. autoclass:: pyslurm.job - :members: - -JobStep Class -************* - -.. autoclass:: pyslurm.jobstep - :members: - -Node Class -********** - -.. autoclass:: pyslurm.node - :members: - -Partition Class -*************** - -.. autoclass:: pyslurm.partition - :members: - -Reservation Class -***************** - -.. autoclass:: pyslurm.reservation - :members: - -Slurmdb Events Class -******************** - -.. autoclass:: pyslurm.slurmdb_events - :members: - -Slurmdb Reservations Class -************************** - -.. autoclass:: pyslurm.slurmdb_reservations - :members: - -Slurmdb Clusters Class -********************** - -.. autoclass:: pyslurm.slurmdb_clusters - :members: - -Slurmdb Jobs Class -****************** - -.. autoclass:: pyslurm.slurmdb_jobs - :members: - -Statistics Class -**************** - -.. autoclass:: pyslurm.statistics - :members: - -Topology Class -************** - -.. autoclass:: pyslurm.topology - :members: - -Trigger Class -************* - -.. autoclass:: pyslurm.trigger - :members: - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/doc_requirements.txt b/doc_requirements.txt new file mode 100644 index 00000000..7497dfa3 --- /dev/null +++ b/doc_requirements.txt @@ -0,0 +1,6 @@ +cython>=3.0.0b1 +wheel +setuptools +mkdocstrings[python] +mike +mkdocs-material diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..a3097617 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,52 @@ +--- +hide: + - navigation +--- +# PySlurm: Slurm Interface to python + +This module provides a low-level Python wrapper around the Slurm C-API using Cython. + +::: pyslurm.config + handler: python + +::: pyslurm.front_end + handler: python + +::: pyslurm.hostlist + handler: python + +::: pyslurm.job + handler: python + +::: pyslurm.jobstep + handler: python + +::: pyslurm.node + handler: python + +::: pyslurm.partition + handler: python + +::: pyslurm.reservation + handler: python + +::: pyslurm.slurmdb_events + handler: python + +::: pyslurm.slurmdb_reservations + handler: python + +::: pyslurm.slurmdb_clusters + handler: python + +::: pyslurm.slurmdb_jobs + handler: python + +::: pyslurm.statistics + handler: python + +::: pyslurm.topology + handler: python + +::: pyslurm.trigger + handler: python \ No newline at end of file diff --git a/doc/source/_static/pyslurm-docs.png b/docs/pyslurm-docs.png similarity index 100% rename from doc/source/_static/pyslurm-docs.png rename to docs/pyslurm-docs.png diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 00000000..18fe35d6 --- /dev/null +++ b/docs/stylesheets/extra.css @@ -0,0 +1,4 @@ +/* Maximum space for text block */ +.md-grid { + max-width: 70%; +} diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 00000000..8e18475a --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,19 @@ +site_name: pyslurm +theme: + name: "material" + logo: pyslurm-docs.png +plugins: +- search +- mkdocstrings: + handlers: + python: + options: + filters: ["!^_"] + docstring_style: sphinx + show_signature: true + show_root_heading: true +extra: + version: + provider: mike +extra_css: + - stylesheets/extra.css diff --git a/pyslurm/pyslurm.pyx b/pyslurm/pyslurm.pyx index 58e5e951..84869d05 100644 --- a/pyslurm/pyslurm.pyx +++ b/pyslurm/pyslurm.pyx @@ -1,4 +1,3 @@ -# cython: embedsignature=True # cython: profile=False # cython: language_level=3 # cython: auto_pickle=False @@ -274,10 +273,11 @@ ctypedef struct config_key_pair_t: def get_controllers(): - """Get information about slurm controllers. + """ + Get information about slurm controllers. :return: Name of primary controller, Name of backup controllers - :rtype: `tuple` + :rtype: tuple """ cdef: slurm.slurm_conf_t *slurm_ctl_conf_ptr = NULL @@ -305,12 +305,13 @@ def get_controllers(): def is_controller(Host=None): - """Return slurm controller status for host. + """ + Return slurm controller status for host. :param string Host: Name of host to check :returns: None, primary or backup - :rtype: `string` + :rtype: string """ control_machs = get_controllers() if not Host: @@ -326,10 +327,11 @@ def is_controller(Host=None): def slurm_api_version(): - """Return the slurm API version number. + """ + Return the slurm API version number. :returns: version_major, version_minor, version_micro - :rtype: `tuple` + :rtype: tuple """ cdef long version = slurm.SLURM_VERSION_NUMBER @@ -339,10 +341,11 @@ def slurm_api_version(): def slurm_load_slurmd_status(): - """Issue RPC to get and load the status of Slurmd daemon. + """ + Issue RPC to get and load the status of Slurmd daemon. :returns: Slurmd information - :rtype: `dict` + :rtype: dict """ cdef: dict Status = {}, Status_dict = {} @@ -391,7 +394,8 @@ def slurm_init(conf_file=None): slurm.slurm_init(NULL) def slurm_fini(): - """Call at process termination to cleanup internal configuration + """ + Call at process termination to cleanup internal configuration structures. :returns: None @@ -404,7 +408,9 @@ def slurm_fini(): # def get_private_data_list(data): - """Return the list of enciphered Private Data configuration.""" + """ + Return the list of enciphered Private Data configuration. + """ result = [] exponent = 7 @@ -420,7 +426,9 @@ def get_private_data_list(data): return result cdef class config: - """Class to access slurm config Information.""" + """ + Class to access slurm config Information. + """ cdef: slurm.slurm_conf_t *slurm_ctl_conf_ptr @@ -439,32 +447,36 @@ cdef class config: self.__free() def lastUpdate(self): - """Get the time (epoch seconds) the retrieved data was updated. + """ + Get the time (epoch seconds) the retrieved data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return the config IDs from retrieved data. + """ + Return the config IDs from retrieved data. :returns: Dictionary of config key IDs - :rtype: `dict` + :rtype: dict """ return self.__ConfigDict.keys() def find_id(self, char *keyID=''): - """Retrieve config ID data. - + """ + Retrieve config ID data. :param str keyID: Config key string to search :returns: Dictionary of values for given config key - :rtype: `dict` + :rtype: dict """ return self.__ConfigDict.get(keyID, {}) cdef void __free(self): - """Free memory allocated by slurm_load_ctl_conf.""" + """ + Free memory allocated by slurm_load_ctl_conf. + """ if self.__Config_ptr is not NULL: slurm.slurm_free_ctl_conf(self.__Config_ptr) self.__Config_ptr = NULL @@ -472,14 +484,17 @@ cdef class config: self.__lastUpdate = 0 def display_all(self): - """Print slurm control configuration information.""" + """ + Print slurm control configuration information. + """ slurm.slurm_print_ctl_conf(slurm.stdout, self.__Config_ptr) cdef int __load(self) except? -1: - """Load the slurm control configuration information. + """ + Load the slurm control configuration information. :returns: slurm error code - :rtype: `integer` + :rtype: integer """ cdef: slurm.slurm_conf_t *slurm_ctl_conf_ptr = NULL @@ -495,10 +510,11 @@ cdef class config: return errCode def key_pairs(self): - """Return a dict of the slurm control data as key pairs. + """ + Return a dict of the slurm control data as key pairs. :returns: Dictionary of slurm key-pair values - :rtype: `dict` + :rtype: dict """ cdef: void *ret_list = NULL @@ -534,10 +550,11 @@ cdef class config: return keyDict def get(self): - """Return the slurm control configuration information. + """ + Return the slurm control configuration information. :returns: Configuration data - :rtype: `dict` + :rtype: dict """ self.__load() self.__get() @@ -545,10 +562,11 @@ cdef class config: return self.__ConfigDict cpdef dict __get(self): - """Get the slurm control configuration information. + """ + Get the slurm control configuration information. :returns: Configuration data - :rtype: `dict` + :rtype: dict """ cdef: void *ret_list = NULL @@ -819,7 +837,9 @@ cdef class config: cdef class partition: - """Class to access/modify Slurm Partition Information.""" + """ + Class to access/modify Slurm Partition Information. + """ cdef: slurm.partition_info_msg_t *_Partition_ptr @@ -836,18 +856,20 @@ cdef class partition: pass def lastUpdate(self): - """Return time (epoch seconds) the partition data was updated. + """ + Return time (epoch seconds) the partition data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return the partition IDs from retrieved data. + """ + Return the partition IDs from retrieved data. :returns: Dictionary of partition IDs - :rtype: `dict` + :rtype: dict """ cdef: int rc @@ -872,21 +894,23 @@ cdef class partition: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) def find_id(self, partID): - """Get partition information for a given partition. + """ + Get partition information for a given partition. :param str partID: Partition key string to search :returns: Dictionary of values for given partition - :rtype: `dict` + :rtype: dict """ return self.get().get(partID) def find(self, name='', val=''): - """Search for a property and associated value in the retrieved partition data. + """ + Search for a property and associated value in the retrieved partition data. :param str name: key string to search :param str value: value string to match :returns: List of IDs that match - :rtype: `list` + :rtype: list """ cdef: list retList = [] @@ -901,7 +925,8 @@ cdef class partition: return retList def print_info_msg(self, int oneLiner=0): - """Display the partition information from previous load partition method. + """ + Display the partition information from previous load partition method. :param int oneLiner: Display on one line (default=0) """ @@ -924,12 +949,13 @@ cdef class partition: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) def delete(self, PartID): - """Delete a give slurm partition. + """ + Delete a give slurm partition. :param string PartID: Name of slurm partition :returns: 0 for success else set the slurm error code as appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.delete_part_msg_t part_msg @@ -948,10 +974,11 @@ cdef class partition: return errCode def get(self): - """Get all slurm partition information + """ + Get all slurm partition information :returns: Dictionary of dictionaries whose key is the partition name. - :rtype: `dict` + :rtype: dict """ cdef: int rc @@ -1126,36 +1153,39 @@ cdef class partition: def update(self, dict Partition_dict): - """Update a slurm partition. + """ + Update a slurm partition. :param dict partition_dict: A populated partition dictionary, an empty one is created by create_partition_dict :returns: 0 for success, -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef int errCode = slurm_update_partition(Partition_dict) return errCode def create(self, dict Partition_dict): - """Create a slurm partition. + """ + Create a slurm partition. :param dict partition_dict: A populated partition dictionary, an empty one can be created by create_partition_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef int errCode = slurm_create_partition(Partition_dict) return errCode def create_partition_dict(): - """Returns a dictionary that can be populated by the user + """ + Returns a dictionary that can be populated by the user and used for the update_partition and create_partition calls. :returns: Empty reservation dictionary - :rtype: `dict` + :rtype: dict """ return { 'Alternate': None, @@ -1177,13 +1207,14 @@ def create_partition_dict(): def slurm_create_partition(dict partition_dict): - """Create a slurm partition. + """ + Create a slurm partition. :param dict partition_dict: A populated partition dictionary, an empty one is created by create_partition_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.update_part_msg_t part_msg_ptr @@ -1208,13 +1239,14 @@ def slurm_create_partition(dict partition_dict): def slurm_update_partition(dict partition_dict): - """Update a slurm partition. + """ + Update a slurm partition. :param dict partition_dict: A populated partition dictionary, an empty one is created by create_partition_dict :returns: 0 for success, -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.update_part_msg_t part_msg_ptr @@ -1273,11 +1305,12 @@ def slurm_update_partition(dict partition_dict): def slurm_delete_partition(PartID): - """Delete a slurm partition. + """ + Delete a slurm partition. :param string PartID: Name of slurm partition :returns: 0 for success else set the slurm error code as appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.delete_part_msg_t part_msg @@ -1301,11 +1334,12 @@ def slurm_delete_partition(PartID): cpdef int slurm_ping(int Controller=0) except? -1: - """Issue RPC to check if slurmctld is responsive. + """ + Issue RPC to check if slurmctld is responsive. :param int Controller: 0 for primary (Default=0), 1 for backup, 2 for backup2, ... :returns: 0 for success or slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_ping(Controller) @@ -1318,10 +1352,11 @@ cpdef int slurm_ping(int Controller=0) except? -1: cpdef int slurm_reconfigure() except? -1: - """Issue RPC to have slurmctld reload its configuration file. + """ + Issue RPC to have slurmctld reload its configuration file. :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_reconfigure() @@ -1334,7 +1369,8 @@ cpdef int slurm_reconfigure() except? -1: cpdef int slurm_shutdown(uint16_t Options=0) except? -1: - """Issue RPC to have slurmctld cease operations. + """ + Issue RPC to have slurmctld cease operations. Both the primary and backup controller are shutdown. @@ -1343,7 +1379,7 @@ cpdef int slurm_shutdown(uint16_t Options=0) except? -1: 1 - slurmctld generates a core file 2 - slurmctld is shutdown (no core file) :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_shutdown(Options) @@ -1356,12 +1392,13 @@ cpdef int slurm_shutdown(uint16_t Options=0) except? -1: cpdef int slurm_takeover(int backup_inx) except? -1: - """Issue a RPC to have slurmctld backup controller take over. + """ + Issue a RPC to have slurmctld backup controller take over. The backup controller takes over the primary controller. :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_takeover(backup_inx) @@ -1370,11 +1407,12 @@ cpdef int slurm_takeover(int backup_inx) except? -1: cpdef int slurm_set_debug_level(uint32_t DebugLevel=0) except? -1: - """Set the slurm controller debug level. + """ + Set the slurm controller debug level. :param int DebugLevel: 0 (default) to 6 :returns: 0 for success, -1 for error and set slurm error number - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_set_debug_level(DebugLevel) @@ -1388,12 +1426,13 @@ cpdef int slurm_set_debug_level(uint32_t DebugLevel=0) except? -1: cpdef int slurm_set_debugflags(uint32_t debug_flags_plus=0, uint32_t debug_flags_minus=0) except? -1: - """Set the slurm controller debug flags. + """ + Set the slurm controller debug flags. :param int debug_flags_plus: debug flags to be added :param int debug_flags_minus: debug flags to be removed :returns: 0 for success, -1 for error and set slurm error number - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_set_debugflags(debug_flags_plus, @@ -1407,11 +1446,12 @@ cpdef int slurm_set_debugflags(uint32_t debug_flags_plus=0, cpdef int slurm_set_schedlog_level(uint32_t Enable=0) except? -1: - """Set the slurm scheduler debug level. + """ + Set the slurm scheduler debug level. :param int Enable: True = 0, False = 1 :returns: 0 for success, -1 for error and set the slurm error number - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_set_schedlog_level(Enable) @@ -1429,11 +1469,12 @@ cpdef int slurm_set_schedlog_level(uint32_t Enable=0) except? -1: cpdef int slurm_suspend(uint32_t JobID=0) except? -1: - """Suspend a running slurm job. + """ + Suspend a running slurm job. :param int JobID: Job identifier :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_suspend(JobID) @@ -1446,11 +1487,12 @@ cpdef int slurm_suspend(uint32_t JobID=0) except? -1: cpdef int slurm_resume(uint32_t JobID=0) except? -1: - """Resume a running slurm job step. + """ + Resume a running slurm job step. :param int JobID: Job identifier :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_resume(JobID) @@ -1463,11 +1505,12 @@ cpdef int slurm_resume(uint32_t JobID=0) except? -1: cpdef int slurm_requeue(uint32_t JobID=0, uint32_t State=0) except? -1: - """Requeue a running slurm job step. + """ + Requeue a running slurm job step. :param int JobID: Job identifier :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_requeue(JobID, State) @@ -1480,11 +1523,12 @@ cpdef int slurm_requeue(uint32_t JobID=0, uint32_t State=0) except? -1: cpdef long slurm_get_rem_time(uint32_t JobID=0) except? -1: - """Get the remaining time in seconds for a slurm job step. + """ + Get the remaining time in seconds for a slurm job step. :param int JobID: Job identifier :returns: Remaining time in seconds or -1 on error - :rtype: `long` + :rtype: long """ cdef int apiError = 0 cdef long errCode = slurm.slurm_get_rem_time(JobID) @@ -1497,11 +1541,12 @@ cpdef long slurm_get_rem_time(uint32_t JobID=0) except? -1: cpdef time_t slurm_get_end_time(uint32_t JobID=0) except? -1: - """Get the end time in seconds for a slurm job step. + """ + Get the end time in seconds for a slurm job step. :param int JobID: Job identifier :returns: Remaining time in seconds or -1 on error - :rtype: `integer` + :rtype: integer """ cdef time_t EndTime = -1 cdef int apiError = 0 @@ -1515,11 +1560,12 @@ cpdef time_t slurm_get_end_time(uint32_t JobID=0) except? -1: cpdef int slurm_job_node_ready(uint32_t JobID=0) except? -1: - """Return if a node could run a slurm job now if dispatched. + """ + Return if a node could run a slurm job now if dispatched. :param int JobID: Job identifier :returns: Node Ready code - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_job_node_ready(JobID) @@ -1528,12 +1574,13 @@ cpdef int slurm_job_node_ready(uint32_t JobID=0) except? -1: cpdef int slurm_signal_job(uint32_t JobID=0, uint16_t Signal=0) except? -1: - """Send a signal to a slurm job step. + """ + Send a signal to a slurm job step. :param int JobID: Job identifier :param int Signal: Signal to send (default=0) :returns: 0 for success or -1 for error and the set Slurm errno - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_signal_job(JobID, Signal) @@ -1552,13 +1599,14 @@ cpdef int slurm_signal_job(uint32_t JobID=0, uint16_t Signal=0) except? -1: cpdef int slurm_signal_job_step(uint32_t JobID=0, uint32_t JobStep=0, uint16_t Signal=0) except? -1: - """Send a signal to a slurm job step. + """ + Send a signal to a slurm job step. :param int JobID: Job identifier :param int JobStep: Job step identifier :param int Signal: Signal to send (default=0) :returns: Error code - 0 for success or -1 for error and set the slurm errno - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_signal_job_step(JobID, JobStep, Signal) @@ -1572,13 +1620,14 @@ cpdef int slurm_signal_job_step(uint32_t JobID=0, uint32_t JobStep=0, cpdef int slurm_kill_job(uint32_t JobID=0, uint16_t Signal=0, uint16_t BatchFlag=0) except? -1: - """Terminate a running slurm job step. + """ + Terminate a running slurm job step. :param int JobID: Job identifier :param int Signal: Signal to send :param int BatchFlag: Job batch flag (default=0) :returns: 0 for success or -1 for error and set slurm errno - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_kill_job(JobID, Signal, BatchFlag) @@ -1592,13 +1641,14 @@ cpdef int slurm_kill_job(uint32_t JobID=0, uint16_t Signal=0, cpdef int slurm_kill_job_step(uint32_t JobID=0, uint32_t JobStep=0, uint16_t Signal=0) except? -1: - """Terminate a running slurm job step. + """ + Terminate a running slurm job step. :param int JobID: Job identifier :param int JobStep: Job step identifier :param int Signal: Signal to send (default=0) :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_kill_job_step(JobID, JobStep, Signal) @@ -1612,14 +1662,15 @@ cpdef int slurm_kill_job_step(uint32_t JobID=0, uint32_t JobStep=0, cpdef int slurm_kill_job2(const char *JobID='', uint16_t Signal=0, uint16_t BatchFlag=0, char* sibling=NULL) except? -1: - """Terminate a running slurm job step. + """ + Terminate a running slurm job step. :param const char * JobID: Job identifier :param int Signal: Signal to send :param int BatchFlag: Job batch flag (default=0) :param string sibling: optional string of sibling cluster to send the message to :returns: 0 for success or -1 for error and set slurm errno - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_kill_job2(JobID, Signal, BatchFlag, sibling) @@ -1632,12 +1683,13 @@ cpdef int slurm_kill_job2(const char *JobID='', uint16_t Signal=0, cpdef int slurm_complete_job(uint32_t JobID=0, uint32_t JobCode=0) except? -1: - """Complete a running slurm job step. + """ + Complete a running slurm job step. :param int JobID: Job identifier :param int JobCode: Return code (default=0) :returns: 0 for success or -1 for error and set slurm errno - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_complete_job(JobID, JobCode) @@ -1650,12 +1702,13 @@ cpdef int slurm_complete_job(uint32_t JobID=0, uint32_t JobCode=0) except? -1: cpdef int slurm_notify_job(uint32_t JobID=0, char* Msg='') except? -1: - """Notify a message to a running slurm job step. + """ + Notify a message to a running slurm job step. :param string JobID: Job identifier (default=0) :param string Msg: Message string to send to job :returns: 0 for success or -1 on error - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 @@ -1669,13 +1722,14 @@ cpdef int slurm_notify_job(uint32_t JobID=0, char* Msg='') except? -1: cpdef int slurm_terminate_job_step(uint32_t JobID=0, uint32_t JobStep=0) except? -1: - """Terminate a running slurm job step. + """ + Terminate a running slurm job step. :param int JobID: Job identifier (default=0) :param int JobStep: Job step identifier (default=0) :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef int apiError = 0 cdef int errCode = slurm.slurm_terminate_job_step(JobID, JobStep) @@ -1692,7 +1746,9 @@ cpdef int slurm_terminate_job_step(uint32_t JobID=0, uint32_t JobStep=0) except? cdef class job: - """Class to access/modify Slurm Job Information.""" + """ + Class to access/modify Slurm Job Information. + """ cdef: slurm.job_info_msg_t *_job_ptr @@ -1712,26 +1768,29 @@ cdef class job: pass def lastUpdate(self): - """Get the time (epoch seconds) the job data was updated. + """ + Get the time (epoch seconds) the job data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def lastBackfill(self): - """Get the time (epoch seconds) of last backfilling run. + """ + Get the time (epoch seconds) of last backfilling run. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastBackfill cpdef ids(self): - """Return the job IDs from retrieved data. + """ + Return the job IDs from retrieved data. :returns: Dictionary of job IDs - :rtype: `dict` + :rtype: dict """ cdef: @@ -1754,12 +1813,13 @@ cdef class job: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) def find(self, name='', val=''): - """Search for a property and associated value in the retrieved job data. + """ + Search for a property and associated value in the retrieved job data. :param str name: key string to search :param str value: value string to match :returns: List of IDs that match - :rtype: `list` + :rtype: list """ cdef: list retList = [] @@ -1809,7 +1869,8 @@ cdef class job: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) def find_id(self, jobid): - """Retrieve job ID data. + """ + Retrieve job ID data. This method accepts both string and integer formats of the jobid. This works for single jobs and job arrays. It uses the internal @@ -1818,20 +1879,21 @@ cdef class job: :param str jobid: Job id key string to search :returns: List of dictionary of values for given job id - :rtype: `list` + :rtype: list """ self._load_single_job(jobid) return list(self.get_job_ptr().values()) def find_user(self, user): - """Retrieve a user's job data. + """ + Retrieve a user's job data. This method calls slurm_load_job_user to get all job_table records associated with a specific user. :param str user: User string to search :returns: Dictionary of values for all user's jobs - :rtype: `dict` + :rtype: dict """ cdef: int apiError @@ -1855,13 +1917,14 @@ cdef class job: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) cpdef get(self): - """Get all slurm jobs information. + """ + Get all slurm jobs information. This method calls slurm_load_jobs to get job_table records for all jobs :returns: Data where key is the job name, each entry contains a dictionary of job attributes - :rtype: `dict` + :rtype: dict """ cdef: int apiError @@ -1876,10 +1939,11 @@ cdef class job: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) cdef dict get_job_ptr(self): - """Convert all job arrays in buffer to dictionary. + """ + Convert all job arrays in buffer to dictionary. :returns: dictionary of job attributes - :rtype: `dict` + :rtype: dict """ cdef: char time_str[32] @@ -2211,11 +2275,12 @@ cdef class job: return self._JobDict cpdef int __cpus_allocated_on_node_id(self, int nodeID=0): - """Get the number of cpus allocated to a job on a node by node name. + """ + Get the number of cpus allocated to a job on a node by node name. :param int nodeID: Numerical node ID :returns: Num of CPUs allocated to job on this node or -1 on error - :rtype: `integer` + :rtype: integer """ cdef: slurm.job_resources_t *job_resrcs_ptr = self._record.job_resrcs @@ -2224,11 +2289,12 @@ cdef class job: return retval cdef int __cpus_allocated_on_node(self, char* nodeName=''): - """Get the number of cpus allocated to a slurm job on a node by node name. + """ + Get the number of cpus allocated to a slurm job on a node by node name. :param string nodeName: Name of node :returns: Num of CPUs allocated to job on this node or -1 on error - :rtype: `integer` + :rtype: integer """ cdef: slurm.job_resources_t *job_resrcs_ptr = self._record.job_resrcs @@ -2237,11 +2303,12 @@ cdef class job: return retval cdef list __cpus_allocated_list_on_node(self, char* nodeName=''): - """Get a list of cpu ids allocated to current slurm job on a node by node name. + """ + Get a list of cpu ids allocated to current slurm job on a node by node name. :param string nodeName: Name of node :returns: list of allocated cpus (empty, if nothing found or error) - :rtype: `list` + :rtype: list """ cdef: int error = 0 @@ -2262,11 +2329,12 @@ cdef class job: return cpus_list def __unrange(self, bit_str): - """converts a string describing a bitmap (from slurm_job_cpus_allocated_str_on_node()) to a list. + """ + converts a string describing a bitmap (from slurm_job_cpus_allocated_str_on_node()) to a list. :param string bit_str: string describing a bitmap (e.g. "0-30,45,50-60") :returns: list referring to bitmap (empty if not succesful) - :rtype: `list` + :rtype: list """ r_list = [] @@ -2284,12 +2352,15 @@ cdef class job: return r_list cpdef __free(self): - """Release the storage generated by the slurm_get_job_steps function.""" + """ + Release the storage generated by the slurm_get_job_steps function. + """ if self._job_ptr is not NULL: slurm.slurm_free_job_info_msg(self._job_ptr) cpdef print_job_info_msg(self, int oneLiner=0): - """Print the data structure describing all job step records. + """ + Print the data structure describing all job step records. The job step records are loaded by the slurm_get_job_steps function. @@ -2314,15 +2385,15 @@ cdef class job: """ Return the contents of the batch-script for a Job. - Note: The string returned also includes all the "\n" characters - (new-line). + Note: The string returned also includes all the "\\n" characters + (new-line). :param jobid: ID of the Job for which the script should be retrieved. :type jobid: Union[str, int] :raises: [ValueError]: When retrieving the Batch-Script for the Job was not successful. :returns: The content of the batch script. - :rtype: `str` + :rtype: str """ # This reimplements the slurm_job_batch_script API call. Otherwise we # would have to parse the FILE* ptr we get from it back into a @@ -2744,7 +2815,9 @@ cdef class job: return 0 cdef int envcount(self, char **env): - """Return the number of elements in the environment `env`.""" + """ + Return the number of elements in the environment `env`. + """ cdef int envc = 0 while (env[envc] != NULL): envc += 1 @@ -2791,7 +2864,8 @@ cdef class job: return rc def submit_batch_job(self, job_opts): - """Submit batch job. + """ + Submit batch job. * make sure options match sbatch command line opts and not struct member names. """ cdef: @@ -2959,7 +3033,7 @@ cdef class job: To reference a job with job array set, use the first/"master" jobid (the same as given by squeue) :returns: The exit code of the slurm job. - :rtype: `int` + :rtype: int """ exit_status = -9999 complete = False @@ -2985,13 +3059,14 @@ cdef class job: def slurm_pid2jobid(uint32_t JobPID=0): - """Get the slurm job id from a process id. + """ + Get the slurm job id from a process id. :param int JobPID: Job process id :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer :returns: Job Identifier - :rtype: `integer` + :rtype: integer """ cdef: uint32_t JobID = 0 @@ -3006,14 +3081,15 @@ def slurm_pid2jobid(uint32_t JobPID=0): cdef secs2time_str(uint32_t time): - """Convert seconds to Slurm string format. + """ + Convert seconds to Slurm string format. This method converts time in seconds (86400) to Slurm's string format (1-00:00:00). :param int time: time in seconds :returns: time string - :rtype: `str` + :rtype: str """ cdef: char *time_str @@ -3037,14 +3113,15 @@ cdef secs2time_str(uint32_t time): cdef mins2time_str(uint32_t time): - """Convert minutes to Slurm string format. + """ + Convert minutes to Slurm string format. This method converts time in minutes (14400) to Slurm's string format (10-00:00:00). :param int time: time in minutes :returns: time string - :rtype: `str` + :rtype: str """ cdef: double days, hours, minutes, seconds @@ -3086,10 +3163,11 @@ class SlurmError(Exception): def slurm_get_errno(): - """Return the slurm error as set by a slurm API call. + """ + Return the slurm error as set by a slurm API call. :returns: slurm error number - :rtype: `integer` + :rtype: integer """ cdef int errNum = slurm.slurm_get_errno() @@ -3097,11 +3175,12 @@ def slurm_get_errno(): def slurm_strerror(int Errno=0): - """Return slurm error message represented by a given slurm error number. + """ + Return slurm error message represented by a given slurm error number. :param int Errno: slurm error number. :returns: slurm error string - :rtype: `string` + :rtype: string """ cdef char* errMsg = slurm.slurm_strerror(Errno) @@ -3109,7 +3188,8 @@ def slurm_strerror(int Errno=0): def slurm_seterrno(int Errno=0): - """Set the slurm error number. + """ + Set the slurm error number. :param int Errno: slurm error number """ @@ -3117,7 +3197,8 @@ def slurm_seterrno(int Errno=0): def slurm_perror(char* Msg=''): - """Print to standard error the supplied header. + """ + Print to standard error the supplied header. Header is followed by a colon, followed by a text description of the last Slurm error code generated. @@ -3134,7 +3215,9 @@ def slurm_perror(char* Msg=''): cdef class node: - """Class to access/modify/update Slurm Node Information.""" + """ + Class to access/modify/update Slurm Node Information. + """ cdef: slurm.node_info_msg_t *_Node_ptr @@ -3153,18 +3236,20 @@ cdef class node: pass def lastUpdate(self): - """Return last time (epoch seconds) the node data was updated. + """ + Return last time (epoch seconds) the node data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate cpdef ids(self): - """Return the node IDs from retrieved data. + """ + Return the node IDs from retrieved data. :returns: Dictionary of node IDs - :rtype: `dict` + :rtype: dict """ cdef: int rc @@ -3186,19 +3271,21 @@ cdef class node: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) def find_id(self, nodeID): - """Get node information for a given node. + """ + Get node information for a given node. :param str nodeID: Node key string to search :returns: Dictionary of values for given node - :rtype: `dict` + :rtype: dict """ return list(self.get_node(nodeID).values())[0] def get(self): - """Get all slurm node information. + """ + Get all slurm node information. :returns: Dictionary of dictionaries whose key is the node name. - :rtype: `dict` + :rtype: dict """ return self.get_node(None) @@ -3207,11 +3294,12 @@ cdef class node: return re.split(r',(?![^(]*\))', gres_str) def get_node(self, nodeID): - """Get single slurm node information. + """ + Get single slurm node information. :param str nodeID: Node key string to search. Default NULL. :returns: Dictionary of give node info data. - :rtype: `dict` + :rtype: dict """ cdef: int rc @@ -3435,18 +3523,20 @@ cdef class node: cpdef update(self, dict node_dict): - """Update slurm node information. + """ + Update slurm node information. :param dict node_dict: A populated node dictionary, an empty one is created by create_node_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ return slurm_update_node(node_dict) cpdef print_node_info_msg(self, int oneLiner=False): - """Output information about all slurm nodes. + """ + Output information about all slurm nodes. :param int oneLiner: Print on one line - False (Default) or True """ @@ -3467,13 +3557,14 @@ cdef class node: def slurm_update_node(dict node_dict): - """Update slurm node information. + """ + Update slurm node information. :param dict node_dict: A populated node dictionary, an empty one is created by create_node_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.update_node_msg_t node_msg @@ -3519,13 +3610,14 @@ def slurm_update_node(dict node_dict): def create_node_dict(): - """Return a an update_node dictionary + """ + Return a an update_node dictionary This dictionary can be populated by the user and used for the update_node call. :returns: Empty node dictionary - :rtype: `dict` + :rtype: dict """ return { 'node_names': None, @@ -3543,7 +3635,9 @@ def create_node_dict(): cdef class jobstep: - """Class to access/modify Slurm Jobstep Information.""" + """ + Class to access/modify Slurm Jobstep Information. + """ cdef: slurm.time_t _lastUpdate @@ -3562,16 +3656,19 @@ cdef class jobstep: self.__destroy() cpdef __destroy(self): - """Free the slurm job memory allocated by load jobstep method.""" + """ + Free the slurm job memory allocated by load jobstep method. + """ self._lastUpdate = 0 self._ShowFlags = 0 self._JobStepDict = {} def lastUpdate(self): - """Get the time (epoch seconds) the jobstep data was updated. + """ + Get the time (epoch seconds) the jobstep data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate @@ -3600,17 +3697,19 @@ cdef class jobstep: return retDict cpdef get(self): - """Get slurm jobstep information. + """ + Get slurm jobstep information. :returns: Data whose key is the jobstep ID. - :rtype: `dict` + :rtype: dict """ self.__get() return self._JobStepDict cpdef __get(self): - """Load details about job steps. + """ + Load details about job steps. This method loads details about job steps that satisfy the job_id and/or step_id specifications provided if the data has been updated @@ -3620,7 +3719,7 @@ cdef class jobstep: :param int StepID: Jobstep Identifier :param int ShowFlags: Display flags (Default=0) :returns: Data whose key is the job and step ID - :rtype: `dict` + :rtype: dict """ cdef: slurm.job_step_info_response_msg_t *job_step_info_ptr = NULL @@ -3738,12 +3837,13 @@ cdef class jobstep: self._JobStepDict = Steps cpdef layout(self, uint32_t JobID=0, uint32_t StepID=0): - """Get the slurm job step layout from a given job and step id. + """ + Get the slurm job step layout from a given job and step id. :param int JobID: slurm job id (Default=0) :param int StepID: slurm step id (Default=0) :returns: List of job step layout. - :rtype: `list` + :rtype: list """ cdef: slurm.slurm_step_id_t step_id @@ -3797,7 +3897,9 @@ cdef class jobstep: cdef class hostlist: - """Wrapper class for Slurm hostlist functions.""" + """ + Wrapper class for Slurm hostlist functions. + """ cdef slurm.hostlist_t hl @@ -3827,7 +3929,8 @@ cdef class hostlist: return slurm.slurm_hostlist_count(self.hl) cpdef get_list(self): - """Get the list of hostnames composing the hostlist. + """ + Get the list of hostnames composing the hostlist. For example with a hostlist created with "tux[1-3]" -> [ 'tux1', tux2', 'tux3' ]. @@ -3919,11 +4022,12 @@ cdef class hostlist: cdef class trigger: def set(self, dict trigger_dict): - """Set or create a slurm trigger. + """ + Set or create a slurm trigger. :param dict trigger_dict: A populated dictionary of trigger information :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.trigger_info_t trigger_set @@ -3995,10 +4099,11 @@ cdef class trigger: return 0 def get(self): - """Get the information on slurm triggers. + """ + Get the information on slurm triggers. :returns: Where key is the trigger ID - :rtype: `dict` + :rtype: dict """ cdef: slurm.trigger_info_msg_t *trigger_get = NULL @@ -4026,13 +4131,14 @@ cdef class trigger: return Triggers def clear(self, TriggerID=0, UserID=slurm.NO_VAL, ID=0): - """Clear or remove a slurm trigger. + """ + Clear or remove a slurm trigger. :param string TriggerID: Trigger Identifier :param string UserID: User Identifier :param string ID: Job Identifier :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ cdef: slurm.trigger_info_t trigger_clear @@ -4063,7 +4169,9 @@ cdef class trigger: cdef class reservation: - """Class to access/update/delete slurm reservation Information.""" + """ + Class to access/update/delete slurm reservation Information. + """ cdef: slurm.reserve_info_msg_t *_Res_ptr @@ -4081,37 +4189,41 @@ cdef class reservation: self.__free() def lastUpdate(self): - """Get the time (epoch seconds) the reservation data was updated. + """ + Get the time (epoch seconds) the reservation data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return a list of reservation IDs from retrieved data. + """ + Return a list of reservation IDs from retrieved data. :returns: Dictionary of reservation IDs - :rtype: `dict` + :rtype: dict """ return self._ResDict.keys() def find_id(self, resID): - """Retrieve reservation ID data. + """ + Retrieve reservation ID data. :param str resID: Reservation key string to search :returns: Dictionary of values for given reservation key - :rtype: `dict` + :rtype: dict """ return self._ResDict.get(resID, {}) def find(self, name='', val=''): - """Search for property and associated value in reservation data. + """ + Search for property and associated value in reservation data. :param str name: key string to search :param str value: value string to match :returns: List of IDs that match - :rtype: `list` + :rtype: list """ # [ key for key, value in self._ResDict.items() if self._ResDict[key]['state'] == 'error'] @@ -4127,7 +4239,9 @@ cdef class reservation: self.__load() cdef int __load(self) except? -1: - """Load slurm reservation information.""" + """ + Load slurm reservation information. + """ cdef: slurm.reserve_info_msg_t *new_reserve_info_ptr = NULL @@ -4157,16 +4271,19 @@ cdef class reservation: return errCode cdef __free(self): - """Free slurm reservation pointer.""" + """ + Free slurm reservation pointer. + """ if self._Res_ptr is not NULL: slurm.slurm_free_reservation_info_msg(self._Res_ptr) def get(self): - """Get slurm reservation information. + """ + Get slurm reservation information. :returns: Data whose key is the Reservation ID - :rtype: `dict` + :rtype: dict """ self.load() self.__get() @@ -4207,27 +4324,32 @@ cdef class reservation: self._ResDict = Reservations def create(self, dict reservation_dict={}): - """Create slurm reservation.""" + """ + Create slurm reservation. + """ return slurm_create_reservation(reservation_dict) def delete(self, ResID): - """Delete slurm reservation. + """ + Delete slurm reservation. :returns: 0 for success or a slurm error code - :rtype: `integer` + :rtype: integer """ return slurm_delete_reservation(ResID) def update(self, dict reservation_dict={}): - """Update a slurm reservation attributes. + """ + Update a slurm reservation attributes. :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ return slurm_update_reservation(reservation_dict) def print_reservation_info_msg(self, int oneLiner=0): - """Output information about all slurm reservations. + """ + Output information about all slurm reservations. :param int Flags: Print on one line - 0 (Default) or 1 """ @@ -4241,13 +4363,14 @@ cdef class reservation: def slurm_create_reservation(dict reservation_dict={}): - """Create a slurm reservation. + """ + Create a slurm reservation. :param dict reservation_dict: A populated reservation dictionary, an empty one is created by create_reservation_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `string` + :rtype: string """ cdef: slurm.resv_desc_msg_t resv_msg @@ -4341,13 +4464,14 @@ def slurm_create_reservation(dict reservation_dict={}): return resID def slurm_update_reservation(dict reservation_dict={}): - """Update a slurm reservation. + """ + Update a slurm reservation. :param dict reservation_dict: A populated reservation dictionary, an empty one is created by create_reservation_dict :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef: slurm.resv_desc_msg_t resv_msg @@ -4435,11 +4559,12 @@ def slurm_update_reservation(dict reservation_dict={}): def slurm_delete_reservation(ResID): - """Delete a slurm reservation. + """ + Delete a slurm reservation. :param string ResID: Reservation Identifier :returns: 0 for success or -1 for error, and the slurm error code is set appropriately. - :rtype: `integer` + :rtype: integer """ cdef slurm.reservation_name_msg_t resv_msg @@ -4460,13 +4585,14 @@ def slurm_delete_reservation(ResID): def create_reservation_dict(): - """Create and empty dict for use with create_reservation method. + """ + Create and empty dict for use with create_reservation method. Returns a dictionary that can be populated by the user an used for the update_reservation and create_reservation calls. :returns: Empty Reservation dictionary - :rtype: `dict` + :rtype: dict """ return { 'start_time': 0, @@ -4490,7 +4616,9 @@ def create_reservation_dict(): cdef class topology: - """Class to access/update slurm topology information.""" + """ + Class to access/update slurm topology information. + """ cdef: slurm.topo_info_response_msg_t *_topo_info_ptr @@ -4504,24 +4632,31 @@ cdef class topology: self.__free() def lastUpdate(self): - """Get the time (epoch seconds) the retrieved data was updated. + """ + Get the time (epoch seconds) the retrieved data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate cpdef __free(self): - """Free the memory returned by load method.""" + """ + Free the memory returned by load method. + """ if self._topo_info_ptr is not NULL: slurm.slurm_free_topo_info_msg(self._topo_info_ptr) def load(self): - """Load slurm topology information.""" + """ + Load slurm topology information. + """ self.__load() cpdef int __load(self) except? -1: - """Load slurm topology.""" + """ + Load slurm topology. + """ cdef int apiError = 0 cdef int errCode = 0 @@ -4537,10 +4672,11 @@ cdef class topology: return errCode def get(self): - """Get slurm topology information. + """ + Get slurm topology information. :returns: Dictionary whose key is the Topology ID - :rtype: `dict` + :rtype: dict """ self.__load() self.__get() @@ -4570,11 +4706,14 @@ cdef class topology: self._TopoDict = Topo def display(self): - """Display topology information to standard output.""" + """ + Display topology information to standard output. + """ self._print_topo_info_msg() cpdef _print_topo_info_msg(self): - """Output information about topology based upon message as loaded using slurm_load_topo. + """ + Output information about topology based upon message as loaded using slurm_load_topo. :param int Flags: Print on one line - False (Default), True """ @@ -4605,9 +4744,10 @@ cdef class statistics: pass cpdef dict get(self): - """Get slurm statistics information. + """ + Get slurm statistics information. - :rtype: `dict` + :rtype: dict """ cdef: int errCode @@ -4704,7 +4844,8 @@ cdef class statistics: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) cpdef int reset(self): - """Reset scheduling statistics + """ + Reset scheduling statistics This method required root privileges. """ @@ -4981,7 +5122,9 @@ cdef class statistics: cdef class front_end: - """Class to access/update slurm front end node information.""" + """ + Class to access/update slurm front end node information. + """ cdef: slurm.time_t Time @@ -5001,16 +5144,22 @@ cdef class front_end: self.__destroy() cpdef __destroy(self): - """Free the memory allocated by load front end node method.""" + """ + Free the memory allocated by load front end node method. + """ if self._FrontEndNode_ptr is not NULL: slurm.slurm_free_front_end_info_msg(self._FrontEndNode_ptr) def load(self): - """Load slurm front end node information.""" + """ + Load slurm front end node information. + """ self.__load() cdef int __load(self) except? -1: - """Load slurm front end node.""" + """ + Load slurm front end node. + """ cdef: # slurm.front_end_info_msg_t *new_FrontEndNode_ptr = NULL time_t last_time = NULL @@ -5031,26 +5180,29 @@ cdef class front_end: return errCode def lastUpdate(self): - """Return last time (sepoch seconds) the node data was updated. + """ + Return last time (sepoch seconds) the node data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return the node IDs from retrieved data. + """ + Return the node IDs from retrieved data. :returns: Dictionary of node IDs - :rtype: `dict` + :rtype: dict """ return list(self._FrontEndDict.keys()) def get(self): - """Get front end node information. + """ + Get front end node information. :returns: Dictionary whose key is the Topology ID - :rtype: `dict` + :rtype: dict """ self.__load() self.__get() @@ -5093,7 +5245,9 @@ cdef class front_end: cdef class qos: - """Class to access/update slurm QOS information.""" + """ + Class to access/update slurm QOS information. + """ cdef: void *dbconn @@ -5108,16 +5262,22 @@ cdef class qos: self.__destroy() cdef __destroy(self): - """QOS Destructor method.""" + """ + QOS Destructor method. + """ self._QOSDict = {} def load(self): - """Load slurm QOS information.""" + """ + Load slurm QOS information. + """ self.__load() cdef int __load(self) except? -1: - """Load slurm QOS list.""" + """ + Load slurm QOS list. + """ cdef: slurm.slurmdb_qos_cond_t *new_qos_cond = NULL int apiError = 0 @@ -5134,26 +5294,29 @@ cdef class qos: return 0 def lastUpdate(self): - """Return last time (sepoch seconds) the QOS data was updated. + """ + Return last time (sepoch seconds) the QOS data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return the QOS IDs from retrieved data. + """ + Return the QOS IDs from retrieved data. :returns: Dictionary of QOS IDs - :rtype: `dict` + :rtype: dict """ return self._QOSDict.keys() def get(self): - """Get slurm QOS information. + """ + Get slurm QOS information. :returns: Dictionary whose key is the QOS ID - :rtype: `dict` + :rtype: dict """ self.__load() self.__get() @@ -5233,7 +5396,9 @@ cdef class qos: # slurmdbd jobs Class # cdef class slurmdb_jobs: - """Class to access Slurmdbd Jobs information.""" + """ + Class to access Slurmdbd Jobs information. + """ cdef: void* db_conn @@ -5248,7 +5413,8 @@ cdef class slurmdb_jobs: slurm.slurmdb_connection_close(&self.db_conn) def get(self, jobids=[], userids=[], starttime=0, endtime=0, flags = None, db_flags = None, clusters = []): - """Get Slurmdb information about some jobs. + """ + Get Slurmdb information about some jobs. Input formats for start and end times: * today or tomorrow @@ -5265,7 +5431,7 @@ cdef class slurmdb_jobs: :param starttime: Select jobs eligible after this timestamp :param endtime: Select jobs eligible before this timestamp :returns: Dictionary whose key is the JOBS ID - :rtype: `dict` + :rtype: dict """ cdef: int i = 0 @@ -5488,7 +5654,9 @@ cdef class slurmdb_jobs: # slurmdbd Reservations Class # cdef class slurmdb_reservations: - """Class to access Slurmdbd reservations information.""" + """ + Class to access Slurmdbd reservations information. + """ cdef: void *dbconn @@ -5501,7 +5669,8 @@ cdef class slurmdb_reservations: slurm.slurmdb_destroy_reservation_cond(self.reservation_cond) def set_reservation_condition(self, start_time, end_time): - """Limit the next get() call to reservations that start after and before a certain time. + """ + Limit the next get() call to reservations that start after and before a certain time. :param start_time: Select reservations that start after this timestamp :param end_time: Select reservations that end before this timestamp @@ -5517,10 +5686,11 @@ cdef class slurmdb_reservations: raise MemoryError() def get(self): - """Get slurm reservations information. + """ + Get slurm reservations information. :returns: Dictionary whose keys are the reservations ids - :rtype: `dict` + :rtype: dict """ cdef: slurm.List reservation_list @@ -5589,7 +5759,9 @@ cdef class slurmdb_reservations: # slurmdbd clusters Class # cdef class slurmdb_clusters: - """Class to access Slurmdbd Clusters information.""" + """ + Class to access Slurmdbd Clusters information. + """ cdef: void *db_conn @@ -5605,7 +5777,8 @@ cdef class slurmdb_clusters: slurm.slurmdb_connection_close(&self.db_conn) def set_cluster_condition(self, start_time, end_time): - """Limit the next get() call to clusters that existed after and before + """ + Limit the next get() call to clusters that existed after and before a certain time. :param start_time: Select clusters that existed after this timestamp @@ -5624,10 +5797,11 @@ cdef class slurmdb_clusters: raise MemoryError() def get(self): - """Get slurm clusters information. + """ + Get slurm clusters information. :returns: Dictionary whose keys are the clusters ids - :rtype: `dict` + :rtype: dict """ cdef: slurm.List clusters_list @@ -5705,7 +5879,9 @@ cdef class slurmdb_clusters: # slurmdbd Events Class # cdef class slurmdb_events: - """Class to access Slurmdbd events information.""" + """ + Class to access Slurmdbd events information. + """ cdef: void *dbconn @@ -5718,7 +5894,8 @@ cdef class slurmdb_events: slurm.slurmdb_destroy_event_cond(self.event_cond) def set_event_condition(self, start_time, end_time): - """Limit the next get() call to conditions that existed after and before a certain time. + """ + Limit the next get() call to conditions that existed after and before a certain time. :param start_time: Select conditions that existed after this timestamp :param end_time: Select conditions that existed before this timestamp @@ -5734,10 +5911,11 @@ cdef class slurmdb_events: raise MemoryError() def get(self): - """Get slurm events information. + """ + Get slurm events information. :returns: Dictionary whose keys are the events ids - :rtype: `dict` + :rtype: dict """ cdef: slurm.List event_list @@ -5783,7 +5961,9 @@ cdef class slurmdb_events: # cdef class slurmdb_reports: - """Class to access Slurmdbd reports.""" + """ + Class to access Slurmdbd reports. + """ cdef: void *db_conn @@ -5888,12 +6068,13 @@ cdef class slurmdb_reports: def get_last_slurm_error(): - """Get and return the last error from a slurm API call. + """ + Get and return the last error from a slurm API call. :returns: Slurm error number and the associated error string - :rtype: `integer` + :rtype: integer :returns: Slurm error string - :rtype: `string` + :rtype: string """ rc = slurm.slurm_get_errno() @@ -5903,11 +6084,12 @@ def get_last_slurm_error(): return (rc, slurm.stringOrNone(slurm.slurm_strerror(rc), '')) cdef inline dict __get_licenses(char *licenses): - """Returns a dict of licenses from the slurm license string. + """ + Returns a dict of licenses from the slurm license string. :param string licenses: String containing license information :returns: Dictionary of licenses and associated value. - :rtype: `dict` + :rtype: dict """ if (licenses is NULL): return {} @@ -5931,17 +6113,19 @@ cdef inline dict __get_licenses(char *licenses): def get_node_use(inx): - """Returns a string that represents the block node mode. + """ + Returns a string that represents the block node mode. :param int ResType: Slurm block node usage :returns: Block node usage string - :rtype: `string` + :rtype: string """ return slurm.slurm_node_state_string(inx) def get_trigger_res_type(uint16_t inx): - """Returns a string that represents the slurm trigger res type. + """ + Returns a string that represents the slurm trigger res type. :param int ResType: Slurm trigger res state - TRIGGER_RES_TYPE_JOB 1 @@ -5952,7 +6136,7 @@ def get_trigger_res_type(uint16_t inx): - TRIGGER_RES_TYPE_FRONT_END 6 - TRIGGER_RES_TYPE_OTHER 7 :returns: Trigger reservation state string - :rtype: `string` + :rtype: string """ return __get_trigger_res_type(inx) @@ -5978,7 +6162,8 @@ cdef inline object __get_trigger_res_type(uint16_t ResType): def get_trigger_type(uint32_t inx): - """Returns a string that represents the state of the slurm trigger. + """ + Returns a string that represents the state of the slurm trigger. :param int TriggerType: Slurm trigger type - TRIGGER_TYPE_UP 0x00000001 @@ -6002,7 +6187,7 @@ def get_trigger_type(uint32_t inx): - TRIGGER_TYPE_PRI_DB_RES_OP 0x00080000 - TRIGGER_TYPE_BURST_BUFFER 0x00100000 :returns: Trigger state string - :rtype: `string` + :rtype: string """ return __get_trigger_type(inx) @@ -6077,7 +6262,7 @@ cdef inline object __get_trigger_type(uint32_t TriggerType): # - RESERVE_FLAG_TIME_FLOAT 0x00020000 # - RESERVE_FLAG_REPLACE 0x00040000 # :returns: Reservation state string -# :rtype: `string` +# :rtype: string # """ # try: # return slurm.slurm_reservation_flags_string(inx) @@ -6090,7 +6275,7 @@ def get_debug_flags(uint64_t inx): :param int flags: Slurm debug flags :returns: Debug flag string - :rtype: `string` + :rtype: string """ return debug_flags2str(inx) @@ -6236,21 +6421,23 @@ cdef inline list debug_flags2str(uint64_t debug_flags): def get_node_state(uint32_t inx): - """Returns a string that represents the state of the slurm node. + """ + Returns a string that represents the state of the slurm node. :param int inx: Slurm node state :returns: Node state string - :rtype: `string` + :rtype: string """ return slurm.slurm_node_state_string(inx) def get_rm_partition_state(int inx): - """Returns a string that represents the partition state. + """ + Returns a string that represents the partition state. :param int inx: Slurm partition state :returns: Partition state string - :rtype: `string` + :rtype: string """ return __get_rm_partition_state(inx) @@ -6276,7 +6463,8 @@ cdef inline object __get_rm_partition_state(int inx): def get_preempt_mode(uint16_t inx): - """Returns a string that represents the preempt mode. + """ + Returns a string that represents the preempt mode. :param int inx: Slurm preempt mode - PREEMPT_MODE_OFF 0x0000 @@ -6285,13 +6473,14 @@ def get_preempt_mode(uint16_t inx): - PREEMPT_MODE_CANCEL 0x0008 - PREEMPT_MODE_GANG 0x8000 :returns: Preempt mode string - :rtype: `string` + :rtype: string """ return slurm.slurm_preempt_mode_string(inx) def get_partition_state(uint16_t inx): - """Returns a string that represents the state of the slurm partition. + """ + Returns a string that represents the state of the slurm partition. :param int inx: Slurm partition state - PARTITION_DOWN 0x01 @@ -6299,7 +6488,7 @@ def get_partition_state(uint16_t inx): - PARTITION_DRAIN 0x02 - PARTITION_INACTIVE 0x00 :returns: Partition state string - :rtype: `string` + :rtype: string """ state = "" if inx: @@ -6317,12 +6506,13 @@ def get_partition_state(uint16_t inx): return state cdef inline object __get_partition_state(int inx, int extended=0): - """Returns a string that represents the state of the partition. + """ + Returns a string that represents the state of the partition. :param int inx: Slurm partition type :param int extended: :returns: Partition state - :rtype: `string` + :rtype: string """ cdef: int drain_flag = (inx & 0x0200) @@ -6374,11 +6564,12 @@ cdef inline object __get_partition_state(int inx, int extended=0): def get_partition_mode(uint16_t flags=0, uint16_t max_share=0): - """Returns a string represents the state of the partition mode. + """ + Returns a string represents the state of the partition mode. :param int inx: Slurm partition mode :returns: Partition mode string - :rtype: `string` + :rtype: string """ return __get_partition_mode(flags, max_share) @@ -6431,7 +6622,8 @@ cdef inline dict __get_partition_mode(uint16_t flags=0, uint16_t max_share=0): def get_job_state(inx): - """Return the state of the slurm job state. + """ + Return the state of the slurm job state. :param int inx: Slurm job state - JOB_PENDING 0 @@ -6448,7 +6640,7 @@ def get_job_state(inx): - JOB_OOM 12 - JOB_END :returns: Job state string - :rtype: `string` + :rtype: string """ try: job_state = slurm.stringOrNone(slurm.slurm_job_state_string(inx), '') @@ -6458,22 +6650,24 @@ def get_job_state(inx): def get_job_state_reason(inx): - """Returns a reason why the slurm job is in a provided state. + """ + Returns a reason why the slurm job is in a provided state. :param int inx: Slurm job state reason :returns: Reason string - :rtype: `string` + :rtype: string """ job_reason = slurm.stringOrNone(slurm.slurm_job_reason_string(inx), '') return job_reason def epoch2date(epochSecs): - """Convert epoch secs to a python time string. + """ + Convert epoch secs to a python time string. :param int epochSecs: Seconds since epoch :returns: Date - :rtype: `string` + :rtype: string """ try: dateTime = p_time.gmtime(epochSecs) @@ -6509,7 +6703,9 @@ class Dict(defaultdict): cdef class licenses: - """Class to access slurm controller license information.""" + """ + Class to access slurm controller license information. + """ cdef: slurm.license_info_msg_t *_msg @@ -6523,26 +6719,30 @@ cdef class licenses: self._lastUpdate = NULL def __dealloc__(self): - """Free the memory allocated by load licenses method.""" + """ + Free the memory allocated by load licenses method. + """ pass def lastUpdate(self): - """Return last time (epoch seconds) license data was updated. + """ + Return last time (epoch seconds) license data was updated. :returns: epoch seconds - :rtype: `integer` + :rtype: integer """ return self._lastUpdate def ids(self): - """Return the current license names from retrieved license data. + """ + Return the current license names from retrieved license data. This method calls slurm_load_licenses to retrieve license information from the controller. slurm_free_license_info_msg is used to free the license message buffer. :returns: Dictionary of licenses - :rtype: `dict` + :rtype: dict """ cdef: int rc @@ -6567,14 +6767,15 @@ cdef class licenses: raise ValueError(slurm.stringOrNone(slurm.slurm_strerror(apiError), ''), apiError) cpdef get(self): - """Get full license information from the slurm controller. + """ + Get full license information from the slurm controller. This method calls slurm_load_licenses to retrieve license information from the controller. slurm_free_license_info_msg is used to free the license message buffer. :returns: Dictionary whose key is the license name - :rtype: `dict` + :rtype: dict """ cdef: int rc diff --git a/pyslurm/slurm/header.pxi b/pyslurm/slurm/header.pxi index 8dc36a95..7de32bf2 100644 --- a/pyslurm/slurm/header.pxi +++ b/pyslurm/slurm/header.pxi @@ -720,7 +720,7 @@ cdef extern from "slurm/slurm.h": unsigned char type unsigned char hash[32] - cpdef enum job_states: + cdef enum job_states: JOB_PENDING JOB_RUNNING JOB_SUSPENDED @@ -735,7 +735,7 @@ cdef extern from "slurm/slurm.h": JOB_OOM JOB_END - cpdef enum job_state_reason: + cdef enum job_state_reason: WAIT_NO_REASON WAIT_PRIORITY WAIT_DEPENDENCY @@ -936,25 +936,25 @@ cdef extern from "slurm/slurm.h": WAIT_QOS_MIN_BILLING WAIT_RESV_DELETED - cpdef enum job_acct_types: + cdef enum job_acct_types: JOB_START JOB_STEP JOB_SUSPEND JOB_TERMINATED - cpdef enum auth_plugin_type: + cdef enum auth_plugin_type: AUTH_PLUGIN_NONE AUTH_PLUGIN_MUNGE AUTH_PLUGIN_JWT - cpdef enum hash_plugin_type: + cdef enum hash_plugin_type: HASH_PLUGIN_DEFAULT HASH_PLUGIN_NONE HASH_PLUGIN_K12 HASH_PLUGIN_SHA256 HASH_PLUGIN_CNT - cpdef enum select_plugin_type: + cdef enum select_plugin_type: SELECT_PLUGIN_CONS_RES SELECT_PLUGIN_LINEAR SELECT_PLUGIN_SERIAL @@ -963,27 +963,27 @@ cdef extern from "slurm/slurm.h": SELECT_PLUGIN_CONS_TRES SELECT_PLUGIN_CRAY_CONS_TRES - cpdef enum switch_plugin_type: + cdef enum switch_plugin_type: SWITCH_PLUGIN_NONE SWITCH_PLUGIN_GENERIC SWITCH_PLUGIN_CRAY SWITCH_PLUGIN_SLINGSHOT - cpdef enum select_jobdata_type: + cdef enum select_jobdata_type: SELECT_JOBDATA_PAGG_ID SELECT_JOBDATA_PTR SELECT_JOBDATA_CLEANING SELECT_JOBDATA_NETWORK SELECT_JOBDATA_RELEASED - cpdef enum select_nodedata_type: + cdef enum select_nodedata_type: SELECT_NODEDATA_SUBCNT SELECT_NODEDATA_PTR SELECT_NODEDATA_MEM_ALLOC SELECT_NODEDATA_TRES_ALLOC_FMT_STR SELECT_NODEDATA_TRES_ALLOC_WEIGHTED - cpdef enum select_print_mode: + cdef enum select_print_mode: SELECT_PRINT_HEAD SELECT_PRINT_DATA SELECT_PRINT_MIXED @@ -1002,7 +1002,7 @@ cdef extern from "slurm/slurm.h": SELECT_PRINT_RESV_ID SELECT_PRINT_START_LOC - cpdef enum select_node_cnt: + cdef enum select_node_cnt: SELECT_GET_NODE_SCALING SELECT_GET_NODE_CPU_CNT SELECT_GET_MP_CPU_CNT @@ -1011,19 +1011,19 @@ cdef extern from "slurm/slurm.h": SELECT_SET_NODE_CNT SELECT_SET_MP_CNT - cpdef enum acct_gather_profile_info: + cdef enum acct_gather_profile_info: ACCT_GATHER_PROFILE_DIR ACCT_GATHER_PROFILE_DEFAULT ACCT_GATHER_PROFILE_RUNNING - cpdef enum jobacct_data_type: + cdef enum jobacct_data_type: JOBACCT_DATA_TOTAL JOBACCT_DATA_PIPE JOBACCT_DATA_RUSAGE JOBACCT_DATA_TOT_VSIZE JOBACCT_DATA_TOT_RSS - cpdef enum acct_energy_type: + cdef enum acct_energy_type: ENERGY_DATA_JOULES_TASK ENERGY_DATA_STRUCT ENERGY_DATA_RECONFIG @@ -1034,7 +1034,7 @@ cdef extern from "slurm/slurm.h": ENERGY_DATA_NODE_ENERGY_UP ENERGY_DATA_STEP_PTR - cpdef enum task_dist_states: + cdef enum task_dist_states: SLURM_DIST_CYCLIC SLURM_DIST_BLOCK SLURM_DIST_ARBITRARY @@ -1075,7 +1075,7 @@ cdef extern from "slurm/slurm.h": ctypedef task_dist_states task_dist_states_t - cpdef enum cpu_bind_type: + cdef enum cpu_bind_type: CPU_BIND_VERBOSE CPU_BIND_TO_THREADS CPU_BIND_TO_CORES @@ -1097,7 +1097,7 @@ cdef extern from "slurm/slurm.h": ctypedef cpu_bind_type cpu_bind_type_t - cpdef enum mem_bind_type: + cdef enum mem_bind_type: MEM_BIND_VERBOSE MEM_BIND_NONE MEM_BIND_RANK @@ -1109,14 +1109,14 @@ cdef extern from "slurm/slurm.h": ctypedef mem_bind_type mem_bind_type_t - cpdef enum accel_bind_type: + cdef enum accel_bind_type: ACCEL_BIND_VERBOSE ACCEL_BIND_CLOSEST_GPU ACCEL_BIND_CLOSEST_NIC ctypedef accel_bind_type accel_bind_type_t - cpdef enum node_states: + cdef enum node_states: NODE_STATE_UNKNOWN NODE_STATE_DOWN NODE_STATE_IDLE @@ -1662,7 +1662,7 @@ cdef extern from "slurm/slurm.h": ctypedef srun_step_missing_msg srun_step_missing_msg_t - cpdef enum suspend_opts: + cdef enum suspend_opts: SUSPEND_JOB RESUME_JOB @@ -3140,7 +3140,7 @@ cdef extern from "slurm/slurmdb.h": SLURMDB_ADD_TRES SLURMDB_UPDATE_FEDS - cpdef enum cluster_fed_states: + cdef enum cluster_fed_states: CLUSTER_FED_STATE_NA CLUSTER_FED_STATE_ACTIVE CLUSTER_FED_STATE_INACTIVE @@ -3231,7 +3231,7 @@ cdef extern from "slurm/slurmdb.h": uint16_t with_coords uint16_t with_deleted - cpdef enum: + cdef enum: SLURMDB_ACCT_FLAG_NONE SLURMDB_ACCT_FLAG_DELETED @@ -3726,7 +3726,7 @@ cdef extern from "slurm/slurmdb.h": uint16_t with_wckeys uint16_t without_defaults - cpdef enum: + cdef enum: SLURMDB_USER_FLAG_NONE SLURMDB_USER_FLAG_DELETED @@ -3759,7 +3759,7 @@ cdef extern from "slurm/slurmdb.h": uint16_t with_usage uint16_t with_deleted - cpdef enum: + cdef enum: SLURMDB_WCKEY_FLAG_NONE SLURMDB_WCKEY_FLAG_DELETED @@ -3827,7 +3827,7 @@ cdef extern from "slurm/slurmdb.h": uint32_t count List tres_list - cpdef enum: + cdef enum: DBD_ROLLUP_HOUR DBD_ROLLUP_DAY DBD_ROLLUP_MONTH diff --git a/scripts/builddocs.sh b/scripts/builddocs.sh index 5e555bfd..cc5625c2 100755 --- a/scripts/builddocs.sh +++ b/scripts/builddocs.sh @@ -1,24 +1,5 @@ #!/bin/bash -#set -e -########################################### -# Build the docs and push to GitHub Pages # -########################################### - -# Build docs for all jobs within build -pip$PYTHON install Sphinx>=1.1 -make BUILDDIR=/root/docs -C /pyslurm/doc/ html - -# Only push to GitHub Pages once per build -if [[ "$PYTHON" == "2.7" && - "$CYTHON" == "0.27.3" && - "$SLURM" == "17.11.8" && - "$BRANCH" == "master" ]] -then - git clone https://github.com/pyslurm/pyslurm.github.io.git - rsync -av --delete --exclude=.git /root/docs/html/ /pyslurm.github.io/ - cd pyslurm.github.io - git add . - git -c user.name="Travis" -c user.email="Travis" commit -m 'Updated docs' - git push -q https://giovtorres:$GITHUB_TOKEN@github.com/pyslurm/pyslurm.github.io &2>/dev/null -fi +pip install -r doc_requirements.txt +pip install --no-build-isolation -e . +mkdocs build diff --git a/setup.cfg b/setup.cfg index af6883db..a7d6399b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,3 @@ -[aliases] -doc=build_sphinx -docs=build_sphinx - [bdist_rpm] release = 1 packager = Giovanni Torres @@ -13,12 +9,6 @@ build_requires = python3-devel >= 3.6 requires = slurm use_bzip2 = 1 -[build_sphinx] -builder = man -source-dir = doc/source -build-dir = doc/build -all_files = 1 - [flake8] max-line-length = 88 extend-ignore = E203 diff --git a/setup.py b/setup.py index c36f279e..17e25bb5 100644 --- a/setup.py +++ b/setup.py @@ -157,7 +157,7 @@ def cleanup_build(): info("Removing build/") remove_tree("build", verbose=1) - files = find_files_with_extension("pyslurm", {".c", ".pyc"}) + files = find_files_with_extension("pyslurm", {".c", ".pyc", ".so"}) for file in files: if file.is_file():