Skip to content

Expose constants which were read from MPI Standard DSL #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: develop
Choose a base branch
from
Draft
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
22 changes: 18 additions & 4 deletions src/pympistandard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


__all__ = ["PROCEDURES", "KINDS", "CALLBACKS", "PREDEFINED_FUNCTIONS"]
__all__ = ["PROCEDURES", "KINDS", "CALLBACKS", "PREDEFINED_FUNCTIONS", "CONSTANTS"]
__author__ = "Martin Ruefenacht"
__version__ = "0.1"

Expand All @@ -19,13 +19,21 @@
import sys


MPI_DATABASE_FILE: str = "apis.json"
MPI_DATABASE_FILE: str = "mpidb.json"


from .storage import KINDS, PROCEDURES, CALLBACKS, PREDEFINED_FUNCTIONS, clear_storage
from .storage import (
KINDS,
PROCEDURES,
CALLBACKS,
PREDEFINED_FUNCTIONS,
CONSTANTS,
clear_storage,
)
from .parameter import Direction
from .procedure import Procedure
from .callback import Callback
from .constant import Constant
from .predefined_function import PredefinedFunction
from .kind import Kind, PolyKind
from . import _kinds
Expand Down Expand Up @@ -181,6 +189,8 @@ def _load_database_v1(path: Path) -> None:
Find and register all procedures found in the 'apis.json' file with Procedure instances.
"""

# TODO discover which files of our database are in path, apis.json, constants.json

with path.open("r") as datafile:
if path.suffix == ".json":
dataset = json.load(datafile)
Expand All @@ -199,7 +209,7 @@ def _load_database_v1(path: Path) -> None:
raise RuntimeError(f"Unrecognized suffix of data file {path}")

# read in datafile
for name, desc in dataset.items():
for name, desc in dataset["procedures"].items():
if desc["attributes"]["predefined_function"]:
predef = PredefinedFunction(name, desc)
PREDEFINED_FUNCTIONS[predef.name] = predef
Expand All @@ -211,3 +221,7 @@ def _load_database_v1(path: Path) -> None:
else:
procedure = Procedure(name, desc)
PROCEDURES[procedure.name] = procedure

for name, desc in dataset["constants"].items():
const = Constant(name, desc)
CONSTANTS[name] = const
Loading