Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pyslurm/*.pxi~
pyslurm/*.pxd~
pyslurm/*.so
pyslurm/*.c
pyslurm/**/*.c
pyslurm/**/*.so
pyslurm/**/__pycache__

# Ignore vim swap files
*.swp
Expand All @@ -25,6 +28,7 @@ tests/*.pyc

# Ignore pycache (Python 3)
*/__pycache__
*/**/__pycache__

# Ignore job output files
*.out
Expand Down
45 changes: 45 additions & 0 deletions pyslurm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,51 @@
from .pyslurm import *
from .__version__ import __version__

from pyslurm.core.job import (
Job,
Jobs,
JobStep,
JobSteps,
JobSubmitDescription,
)

from pyslurm.core import db
from pyslurm.core.node import Node, Nodes

import pyslurm.core.error
from pyslurm.core.error import (
RPCError,
)

# Utility time functions
from pyslurm.core.common.ctime import (
timestr_to_secs,
timestr_to_mins,
secs_to_timestr,
mins_to_timestr,
date_to_timestamp,
timestamp_to_date,
)

# General utility functions
from pyslurm.core.common import (
uid_to_name,
gid_to_name,
user_to_uid,
group_to_gid,
expand_range_str,
humanize,
dehumanize,
nodelist_from_range_str,
nodelist_to_range_str,
)

from pyslurm.core import slurmctld

# Initialize slurm api
from pyslurm.api import slurm_init, slurm_fini
slurm_init()


def version():
return __version__
26 changes: 26 additions & 0 deletions pyslurm/api.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#########################################################################
# api.pxd - pyslurm core API
#########################################################################
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
#
# This file is part of PySlurm
#
# PySlurm is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# PySlurm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# cython: c_string_type=unicode, c_string_encoding=default
# cython: language_level=3

from pyslurm cimport slurm
from pyslurm.core.common cimport cstr
43 changes: 43 additions & 0 deletions pyslurm/api.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#########################################################################
# api.pyx - pyslurm core API
#########################################################################
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
#
# This file is part of PySlurm
#
# PySlurm is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# PySlurm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# cython: c_string_type=unicode, c_string_encoding=default
# cython: language_level=3


def slurm_init(config_path=None):
"""Initialize the Slurm API.

This function must be called first before certain RPC functions can be
executed. slurm_init is automatically called when the pyslurm module is
loaded.

Args:
config_path (str, optional):
An absolute path to the slurm config file to use. The default is
None, so libslurm will automatically detect its config.
"""
slurm.slurm_init(cstr.from_unicode(config_path))


def slurm_fini():
"""Clean up data structures previously allocated through slurm_init."""
slurm.slurm_fini()
Empty file added pyslurm/core/__init__.pxd
Empty file.
Empty file added pyslurm/core/__init__.py
Empty file.
32 changes: 32 additions & 0 deletions pyslurm/core/common/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#########################################################################
# common/__init__.pxd - common/utility functions
#########################################################################
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
#
# This file is part of PySlurm
#
# PySlurm is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# PySlurm is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# cython: c_string_type=unicode, c_string_encoding=default
# cython: language_level=3

from pyslurm cimport slurm
from pyslurm.slurm cimport xfree, try_xmalloc, xmalloc
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
from pyslurm.core.common cimport cstr
from libc.stdlib cimport free

cpdef uid_to_name(uint32_t uid, err_on_invalid=*, dict lookup=*)
cpdef gid_to_name(uint32_t gid, err_on_invalid=*, dict lookup=*)
Loading