Skip to content

Commit 4fecccd

Browse files
author
Martin Ruefenacht
committed
Added top-level unloading of currently selected API version, MPI version, and path
1 parent 61a5920 commit 4fecccd

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/pympistandard/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import os
1818

1919

20-
from .storage import KINDS, PROCEDURES, CALLBACKS, PREDEFINED_FUNCTIONS
20+
from .storage import KINDS, PROCEDURES, CALLBACKS, PREDEFINED_FUNCTIONS, clear_storage
2121
from .parameter import Direction
2222
from .procedure import Procedure
2323
from .callback import Callback
@@ -45,13 +45,19 @@
4545
)
4646

4747

48+
@export
49+
def unload() -> None:
50+
"""Unloads currently loaded Python API Interface and MPI Standard."""
51+
52+
clear_storage()
53+
54+
55+
# TODO rename to load(api_version, mpi_version, path)
4856
@export
4957
def use_api_version(version: Union[int, str] = "LATEST", given_path: Union[str, Path] = None) -> None:
5058
"""Sets the Python API interface which the user expects to use."""
5159

52-
# clean from possible prior usage
53-
KINDS.clear()
54-
PROCEDURES.clear()
60+
unload()
5561

5662
# load version of API
5763
if version in (1, "LATEST"):

src/pympistandard/storage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@
2020
CONSTANTS = NamespaceDict()
2121
# to support this the Python DSL in the MPI Standard needs to be extended
2222
# and all the constants need to be encoded (name, type, value if given)
23+
24+
def clear_storage():
25+
KINDS.clear()
26+
PROCEDURES.clear()
27+
CALLBACKS.clear()
28+
PREDEFINED_FUNCTIONS.clear()
29+
CONSTANTS.clear()

0 commit comments

Comments
 (0)