Skip to content

Commit 963f75a

Browse files
authored
Merge pull request #31 from openPMD/topic-softwareDeps
Software Deps & Machine
2 parents 1c6e75a + fd06a37 commit 963f75a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

openpmd_validator/check_h5.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ def check_root_attr(f, v):
416416
"^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} [\+|-][0-9]{4}$")
417417

418418
# optional
419+
result_array += test_attr(f, v, "optional", "softwareDependencies", np.string_)
420+
result_array += test_attr(f, v, "optional", "machine", np.string_)
419421
result_array += test_attr(f, v, "optional", "comment", np.string_)
420422

421423
return(result_array)

openpmd_validator/createExamples_h5.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import numpy as np
2020
import datetime
2121
from dateutil.tz import tzlocal
22+
import sys
23+
import socket
2224

2325

2426
def get_basePath(f, iteration):
@@ -60,6 +62,22 @@ def setup_base_path(f, iteration):
6062
bp.attrs["dt"] = 0.5 # Value expressed in femtoseconds
6163
bp.attrs["timeUnitSI"] = np.float64(1.e-15) # Conversion factor
6264

65+
def get_software_dependencies():
66+
"""
67+
Returns the software dependencies of this script as a semicolon
68+
separated string.
69+
"""
70+
return np.string_(
71+
"python@{0}.{1}.{2};".format(
72+
sys.version_info.major,
73+
sys.version_info.minor,
74+
sys.version_info.micro
75+
) +
76+
"numpy@{0};".format( np.__version__ ) +
77+
"hdf5@{0};".format( h5.version.hdf5_version ) +
78+
"h5py@{0}".format( h5.__version__)
79+
)
80+
6381
def setup_root_attr(f):
6482
"""
6583
Write the root metadata for this file
@@ -86,6 +104,8 @@ def setup_root_attr(f):
86104
f.attrs["author"] = np.string_("Axel Huebl <[email protected]>")
87105
f.attrs["software"] = np.string_("openPMD Example Script")
88106
f.attrs["softwareVersion"] = np.string_("1.0.0")
107+
f.attrs["softwareDependencies"] = get_software_dependencies()
108+
f.attrs["machine"] = np.string_(socket.gethostname())
89109
f.attrs["date"] = np.string_(
90110
datetime.datetime.now(tzlocal()).strftime('%Y-%m-%d %H:%M:%S %z'))
91111

0 commit comments

Comments
 (0)