Skip to content

Commit 0043080

Browse files
authored
Big rework (#283)
* Rework the Job-API * Rework the Node-API * Add valgrind suppression file * Rework slurmdbd Job API * rework tests directory structure, split into "unit" and "integration"
1 parent 3dc607a commit 0043080

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+12620
-41
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pyslurm/*.pxi~
1616
pyslurm/*.pxd~
1717
pyslurm/*.so
1818
pyslurm/*.c
19+
pyslurm/**/*.c
20+
pyslurm/**/*.so
21+
pyslurm/**/__pycache__
1922

2023
# Ignore vim swap files
2124
*.swp
@@ -25,6 +28,7 @@ tests/*.pyc
2528

2629
# Ignore pycache (Python 3)
2730
*/__pycache__
31+
*/**/__pycache__
2832

2933
# Ignore job output files
3034
*.out

pyslurm/__init__.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,51 @@
1616
from .pyslurm import *
1717
from .__version__ import __version__
1818

19+
from pyslurm.core.job import (
20+
Job,
21+
Jobs,
22+
JobStep,
23+
JobSteps,
24+
JobSubmitDescription,
25+
)
26+
27+
from pyslurm.core import db
28+
from pyslurm.core.node import Node, Nodes
29+
30+
import pyslurm.core.error
31+
from pyslurm.core.error import (
32+
RPCError,
33+
)
34+
35+
# Utility time functions
36+
from pyslurm.core.common.ctime import (
37+
timestr_to_secs,
38+
timestr_to_mins,
39+
secs_to_timestr,
40+
mins_to_timestr,
41+
date_to_timestamp,
42+
timestamp_to_date,
43+
)
44+
45+
# General utility functions
46+
from pyslurm.core.common import (
47+
uid_to_name,
48+
gid_to_name,
49+
user_to_uid,
50+
group_to_gid,
51+
expand_range_str,
52+
humanize,
53+
dehumanize,
54+
nodelist_from_range_str,
55+
nodelist_to_range_str,
56+
)
57+
58+
from pyslurm.core import slurmctld
59+
60+
# Initialize slurm api
61+
from pyslurm.api import slurm_init, slurm_fini
62+
slurm_init()
63+
1964

2065
def version():
2166
return __version__

pyslurm/api.pxd

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#########################################################################
2+
# api.pxd - pyslurm core API
3+
#########################################################################
4+
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
5+
#
6+
# This file is part of PySlurm
7+
#
8+
# PySlurm is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 2 of the License, or
11+
# (at your option) any later version.
12+
13+
# PySlurm is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License along
19+
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
20+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
# cython: c_string_type=unicode, c_string_encoding=default
23+
# cython: language_level=3
24+
25+
from pyslurm cimport slurm
26+
from pyslurm.core.common cimport cstr

pyslurm/api.pyx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#########################################################################
2+
# api.pyx - pyslurm core API
3+
#########################################################################
4+
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
5+
#
6+
# This file is part of PySlurm
7+
#
8+
# PySlurm is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 2 of the License, or
11+
# (at your option) any later version.
12+
13+
# PySlurm is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License along
19+
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
20+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
# cython: c_string_type=unicode, c_string_encoding=default
23+
# cython: language_level=3
24+
25+
26+
def slurm_init(config_path=None):
27+
"""Initialize the Slurm API.
28+
29+
This function must be called first before certain RPC functions can be
30+
executed. slurm_init is automatically called when the pyslurm module is
31+
loaded.
32+
33+
Args:
34+
config_path (str, optional):
35+
An absolute path to the slurm config file to use. The default is
36+
None, so libslurm will automatically detect its config.
37+
"""
38+
slurm.slurm_init(cstr.from_unicode(config_path))
39+
40+
41+
def slurm_fini():
42+
"""Clean up data structures previously allocated through slurm_init."""
43+
slurm.slurm_fini()

pyslurm/core/__init__.pxd

Whitespace-only changes.

pyslurm/core/__init__.py

Whitespace-only changes.

pyslurm/core/common/__init__.pxd

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#########################################################################
2+
# common/__init__.pxd - common/utility functions
3+
#########################################################################
4+
# Copyright (C) 2023 Toni Harzendorf <toni.harzendorf@gmail.com>
5+
#
6+
# This file is part of PySlurm
7+
#
8+
# PySlurm is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 2 of the License, or
11+
# (at your option) any later version.
12+
13+
# PySlurm is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License along
19+
# with PySlurm; if not, write to the Free Software Foundation, Inc.,
20+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
# cython: c_string_type=unicode, c_string_encoding=default
23+
# cython: language_level=3
24+
25+
from pyslurm cimport slurm
26+
from pyslurm.slurm cimport xfree, try_xmalloc, xmalloc
27+
from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t
28+
from pyslurm.core.common cimport cstr
29+
from libc.stdlib cimport free
30+
31+
cpdef uid_to_name(uint32_t uid, err_on_invalid=*, dict lookup=*)
32+
cpdef gid_to_name(uint32_t gid, err_on_invalid=*, dict lookup=*)

0 commit comments

Comments
 (0)