imas-python 0.1.dev1648__py3-none-any.whl → 0.1.dev1651__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of imas-python might be problematic. Click here for more details.

imas/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '0.1.dev1648'
16
- __version_tuple__ = version_tuple = (0, 1, 'dev1648')
15
+ __version__ = version = '0.1.dev1651'
16
+ __version_tuple__ = version_tuple = (0, 1, 'dev1651')
imas/assets/IDSDef.zip CHANGED
Binary file
@@ -13,6 +13,7 @@ import tempfile
13
13
  import time
14
14
  import uuid
15
15
  from pathlib import Path
16
+ from saxonche import PySaxonProcessor
16
17
  from subprocess import CalledProcessError, check_output
17
18
  from zlib import crc32
18
19
 
@@ -22,7 +23,6 @@ except ImportError: # Python 3.8 support
22
23
  from importlib_resources import as_file, files
23
24
 
24
25
  import imas
25
- from imas.dd_helpers import get_saxon
26
26
  from imas.dd_zip import get_dd_xml, get_dd_xml_crc
27
27
  from imas.exception import MDSPlusModelError
28
28
  from imas.ids_factory import IDSFactory
@@ -241,35 +241,84 @@ def model_exists(path: Path) -> bool:
241
241
  )
242
242
 
243
243
 
244
- def create_model_ids_xml(cache_dir_path, fname, version):
245
- """Use saxon to compile an ids.xml suitable for creating an mdsplus model."""
244
+ # def create_model_ids_xml(cache_dir_path, fname, version):
245
+ # """Use saxon to compile an ids.xml suitable for creating an mdsplus model."""
246
+
247
+ # try:
248
+ # # we have to be careful to have the same version of this file as in the access
249
+ # # layer:
250
+ # with as_file(files(imas) / "assets" / "IDSDef2MDSpreTree.xsl") as xslfile:
251
+ # check_output(
252
+ # [
253
+ # "java",
254
+ # "net.sf.saxon.Transform",
255
+ # "-s:" + str(fname),
256
+ # "-o:" + str(Path(cache_dir_path) / "ids.xml"),
257
+ # "DD_GIT_DESCRIBE=" + str(version or fname),
258
+ # # if this is expected as git describe it might break
259
+ # # if we just pass a filename
260
+ # "AL_GIT_DESCRIBE=" + os.environ.get("AL_VERSION", "0.0.0"),
261
+ # "-xsl:" + str(xslfile),
262
+ # ],
263
+ # input=get_dd_xml(version) if version else None,
264
+ # env={"CLASSPATH": get_saxon(), "PATH": os.environ.get("PATH", "")},
265
+ # )
266
+ # except CalledProcessError as e:
267
+ # if fname:
268
+ # logger.error("Error making MDSPlus model IDS.xml for %s", fname)
269
+ # else:
270
+ # logger.error("Error making MDSplus model IDS.xml for %s", version)
271
+ # raise e
272
+
246
273
 
274
+ def create_model_ids_xml(cache_dir_path, fname, version):
275
+ """Use Saxon/C to compile an ids.xml suitable for creating an MDSplus model."""
247
276
  try:
248
- # we have to be careful to have the same version of this file as in the access
249
- # layer:
250
- with as_file(files(imas) / "assets" / "IDSDef2MDSpreTree.xsl") as xslfile:
251
- check_output(
252
- [
253
- "java",
254
- "net.sf.saxon.Transform",
255
- "-s:" + str(fname),
256
- "-o:" + str(Path(cache_dir_path) / "ids.xml"),
257
- "DD_GIT_DESCRIBE=" + str(version or fname),
258
- # if this is expected as git describe it might break
259
- # if we just pass a filename
260
- "AL_GIT_DESCRIBE=" + os.environ.get("AL_VERSION", "0.0.0"),
261
- "-xsl:" + str(xslfile),
262
- ],
263
- input=get_dd_xml(version) if version else None,
264
- env={"CLASSPATH": get_saxon(), "PATH": os.environ.get("PATH", "")},
265
- )
266
- except CalledProcessError as e:
277
+ # Locate the XSL file within the package
278
+ with as_file(files("imas") / "assets" / "IDSDef2MDSpreTree.xsl") as xslfile:
279
+ output_file = Path(cache_dir_path) / "ids.xml"
280
+
281
+ # Initialize Saxon/C processor
282
+ with PySaxonProcessor(license=False) as proc:
283
+ xslt_processor = proc.new_xslt30_processor()
284
+
285
+ # Set the XSLT stylesheet
286
+ xslt_processor.compile_stylesheet(stylesheet_file=str(xslfile))
287
+
288
+ # Prepare the input XML source
289
+ input_xml = get_dd_xml(version) if version else None
290
+ if fname:
291
+ source_file = str(fname)
292
+ elif input_xml:
293
+ source_file = "-" # Use standard input for the XML string
294
+ else:
295
+ raise ValueError("Either 'fname' or 'version' must be provided to generate XML.")
296
+
297
+ # xdm_ddgit = proc.make_string_value(str(version or fname))
298
+ # xsltproc.set_parameter("DD_GIT_DESCRIBE", xdm_ddgit)
299
+ # xdm_algit = proc.make_string_value(os.environ.get("AL_VERSION", "0.0.0"))
300
+ # xsltproc.set_parameter("AL_GIT_DESCRIBE", xdm_algit)
301
+ # Transform XML
302
+ result = xslt_processor.transform_to_file(
303
+ source_file=source_file,
304
+ output_file=str(output_file),
305
+ initial_template_params={
306
+ "DD_GIT_DESCRIBE": str(version or fname),
307
+ "AL_GIT_DESCRIBE": os.environ.get("AL_VERSION", "0.0.0"),
308
+ },
309
+ )
310
+
311
+ if result is False:
312
+ logger.error("Transformation failed: Check Saxon/C logs for details.")
313
+ raise RuntimeError("Saxon/C XSLT transformation failed.")
314
+
315
+ except Exception as e:
267
316
  if fname:
268
- logger.error("Error making MDSPlus model IDS.xml for %s", fname)
317
+ logger.error("Error making MDSplus model IDS.xml for %s", fname)
269
318
  else:
270
319
  logger.error("Error making MDSplus model IDS.xml for %s", version)
271
320
  raise e
272
-
321
+
273
322
 
274
323
  def create_mdsplus_model(cache_dir_path: Path) -> None:
275
324
  """Use jtraverser to compile a valid MDS model file."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: imas-python
3
- Version: 0.1.dev1648
3
+ Version: 0.1.dev1651
4
4
  Summary: Pythonic wrappers for the IMAS Access Layer
5
5
  Author: ITER Organization
6
6
  Author-email: Karel Lucas van de Plassche <karelvandeplassche@gmail.com>, Daan van Vugt <dvanvugt@ignitioncomputing.com>, Maarten Sebregts <msebregts@ignitioncomputing.com>, imas-support@iter.org
@@ -1,7 +1,7 @@
1
1
  imas/__init__.py,sha256=9OHpTf8gCl7BJVU7U2bf9kWatBNNAhFZdgoFPcHeNQU,878
2
2
  imas/__main__.py,sha256=2qXoC0HzV4xkPQAvdubHC4rnK3G6f_2PT9TkkCHYXk8,418
3
3
  imas/_util.py,sha256=FXX13glhmgSiw-0LtjH0xv3YlM3Pa9X4jl9yz9Uv7Vs,9484
4
- imas/_version.py,sha256=XXs7cQDnAk8OFDnF4Rrmyxr2_X5OCidm8hPEAxt02hM,425
4
+ imas/_version.py,sha256=fSc98cUXRjUwffuOpTh7lfHV2cigveu6PnuuiBQ8mq8,425
5
5
  imas/db_entry.py,sha256=OnAgz0c97gbEizrDcuO909VFUzOzeU1OIwWe50PCCxw,31755
6
6
  imas/dd_helpers.py,sha256=IFRmOWw0VyLuR9Xpe9VeVy1ANq5XpFF4m1rj9RtETKI,6275
7
7
  imas/dd_zip.py,sha256=6gQ91rlVsDaU1U6XXaEnaGyvI3ZgQ659GOgIYJLZH6M,10322
@@ -22,7 +22,7 @@ imas/ids_toplevel.py,sha256=YHWZewK8JYf34pYzF_oooMILZAHgnuWCFtr0_JFjmzI,14915
22
22
  imas/setup_logging.py,sha256=McfIYupRQDxtL-lasTjH5F8BxBvncuZhcpzSDEwKtJQ,1872
23
23
  imas/training.py,sha256=JGYjpCubUJDb_Rg0QaaDhNkBHc4Qc376U9fRq24NVXc,1576
24
24
  imas/util.py,sha256=dG282-l7m2U_VhjZ0VnQ-BpsWrzgKSxUZ1AZf-_wDOY,17822
25
- imas/assets/IDSDef.zip,sha256=spXujog-c2Fi2VsFHKvQYo9HrAFryd56si1xeLqOyYg,27383258
25
+ imas/assets/IDSDef.zip,sha256=9t6K2hD_cWqt_HIcEJ7YPBqf1DIjbPH3oh89e-CByf8,27383258
26
26
  imas/assets/IDSDef2MDSpreTree.xsl,sha256=V9eDmDnxe6oYhDP81gmdYip8cF2yST9dGxmZBaATLdA,7296
27
27
  imas/assets/IDS_fake_toplevel.xml,sha256=TJhukQuDHHVTW2U7fK_-KmTQiYOFZMY-ECZXBHQE2mk,18683
28
28
  imas/assets/IDS_minimal.xml,sha256=5B6c0J-WPzSChHWwpLPRkNawx9m6v8BM5nC0OQFnWcQ,1740
@@ -41,7 +41,7 @@ imas/backends/imas_core/al_context.py,sha256=D5PUg6o487kR9diRK9ZclkCpzbn-Brzhkf-
41
41
  imas/backends/imas_core/db_entry_al.py,sha256=7HeXVm2HCNh8f3Ob81GQIRyeWZ-qu6kORWI5OOtyOjQ,14893
42
42
  imas/backends/imas_core/db_entry_helpers.py,sha256=HwWTyY-IF5gEGBuL6BsPnHFL3EZtaLIxr-ctC-3u_A0,8047
43
43
  imas/backends/imas_core/imas_interface.py,sha256=c4OHvhw-aCO4O9sDSmYdcZcgeeBwu0-BcozYpVhsCuQ,7978
44
- imas/backends/imas_core/mdsplus_model.py,sha256=IWmRCsH_fbRWsxV-bE8NFXu_Nh-vUnP5PfwmmTEg5XE,14110
44
+ imas/backends/imas_core/mdsplus_model.py,sha256=Y33BqScO3EiN1Rgj9ia6oLKe02tTSi-x-Nx7h23Hcdc,16405
45
45
  imas/backends/imas_core/uda_support.py,sha256=lxHzby6Fkkpn5j6yWpQrlqlwng-gA9O_hVK03Wf_Ij8,1770
46
46
  imas/backends/netcdf/__init__.py,sha256=pyETe19IpVVezOS7mNzF_Zbt_eGoK8IWnQfG8P7V4CA,191
47
47
  imas/backends/netcdf/db_entry_nc.py,sha256=xx3GDeRbTpbsi2GW2wyaUFmrUKXjFJ0q4sSbMI_-WrQ,6828
@@ -101,9 +101,9 @@ imas/test/test_str_1d.py,sha256=d6GrmV4OYG9f4ludjZBmuqyKOM9XIExTqMh8aQ1UJcQ,3453
101
101
  imas/test/test_time_slicing.py,sha256=FwbdggRJ75Suc268-89daCSaVXhzl8pZZm3Od13EiR4,6959
102
102
  imas/test/test_uda_support.py,sha256=AmakuexebZfJ2-vk_DHfNRPwHmNM2RnwzXqT0eWwWJ0,338
103
103
  imas/test/test_util.py,sha256=BW5EbL-QDIrJNH7tjBgqOacJY0TXvMidXVKpIVZlv1I,6775
104
- imas_python-0.1.dev1648.dist-info/LICENSE.txt,sha256=RzxtV7MG0zbF6dDvQsaZ1OKsHZ7CRyeILenjUIol5rs,7651
105
- imas_python-0.1.dev1648.dist-info/METADATA,sha256=stbhrI6KQ8RMsOK4q_yjOejWusUuXpkAPKe3zZix1XY,13630
106
- imas_python-0.1.dev1648.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
107
- imas_python-0.1.dev1648.dist-info/entry_points.txt,sha256=e8oXj2SLwyFEiBeJRaAXRc9EYQ8eHWWn7NWdjixjeDM,99
108
- imas_python-0.1.dev1648.dist-info/top_level.txt,sha256=_WFOlA1rmpYm0T73sNo5Ntvs7S3x4cR7UE8Oy5I5eJA,5
109
- imas_python-0.1.dev1648.dist-info/RECORD,,
104
+ imas_python-0.1.dev1651.dist-info/LICENSE.txt,sha256=RzxtV7MG0zbF6dDvQsaZ1OKsHZ7CRyeILenjUIol5rs,7651
105
+ imas_python-0.1.dev1651.dist-info/METADATA,sha256=hlboOUl0tPYJDpMpZG3espwHaQFQ7dFNJOsOhc6fRFE,13630
106
+ imas_python-0.1.dev1651.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
107
+ imas_python-0.1.dev1651.dist-info/entry_points.txt,sha256=e8oXj2SLwyFEiBeJRaAXRc9EYQ8eHWWn7NWdjixjeDM,99
108
+ imas_python-0.1.dev1651.dist-info/top_level.txt,sha256=_WFOlA1rmpYm0T73sNo5Ntvs7S3x4cR7UE8Oy5I5eJA,5
109
+ imas_python-0.1.dev1651.dist-info/RECORD,,