diff --git a/src/pynxtools_apm/config/eln_cfg.py b/src/pynxtools_apm/config/eln_cfg.py index 2566051..1328113 100644 --- a/src/pynxtools_apm/config/eln_cfg.py +++ b/src/pynxtools_apm/config/eln_cfg.py @@ -48,7 +48,7 @@ "map_to_str": [ "alias", "description", - "method", + ("type", "method"), ("grain_diameter/@units", "grain_diameter/unit"), ("grain_diameter_error/@units", "grain_diameter/unit"), ("heat_treatment_temperature/@units", "heat_treatment_temperature/unit"), @@ -77,7 +77,7 @@ "alias", "preparation_date", "description", - "method", + ("type", "method"), ("initial_radius/@units", "initial_radius/unit"), ("shank_angle/@units", "shank_angle/unit"), ], diff --git a/tests/run_tests.ipynb b/tests/run_tests.ipynb new file mode 100644 index 0000000..4b665d3 --- /dev/null +++ b/tests/run_tests.ipynb @@ -0,0 +1,126 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "fc9345cb-46bf-4df3-9dac-1bde062d9020", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "print(os.getcwd())" + ] + }, + { + "cell_type": "markdown", + "id": "e69ad935-80fd-4e70-af69-ac98e0bf2e34", + "metadata": {}, + "source": [ + "## Define tests" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "48f6e922-52d3-412f-8345-0641d33e676e", + "metadata": {}, + "outputs": [], + "source": [ + "tests = {\n", + " # \"eln\": [(\"eln_data.yaml\", \"apm.oasis.specific.yaml\")],\n", + " \"apt\": [\"Si.apt\"],\n", + " \"csv\": [\"Annealed_CoCrNi_100.csv\"],\n", + " \"env\": [\"ErMnO.env\"],\n", + " \"epos\": [\"R45_04472-v03.epos\"],\n", + " \"fig\": [\"Superalloy_MassSpec_ranged.fig.txt\"],\n", + " \"imago\": [\"default.analysis\"],\n", + " \"pos\": [\"ErMnO_pole.pos\"],\n", + " # \"pyccapt\": [(\"1748_Al_range_.h5\", \"1748_Al.h5\")],\n", + " \"rng\": [\"87D_1.rng\"],\n", + " \"rrng\": [\"VAlN_film_plan-view_700C.rrng\"]\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ae5057c-2101-4792-9804-3af046003db7", + "metadata": {}, + "outputs": [], + "source": [ + "! mkdir -p log\n", + "! mkdir -p prod" + ] + }, + { + "cell_type": "markdown", + "id": "36a351a5-940d-4891-bb7e-1f4ba4100f6d", + "metadata": {}, + "source": [ + "## Run tests" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "809a88fe-5e4f-4429-b668-8a7956210606", + "metadata": {}, + "outputs": [], + "source": [ + "for parser_type, list_of_tests in tests.items():\n", + " for entry in list_of_tests:\n", + " if isinstance(entry, str): # no sidecar file \n", + " print(f\"Running test {parser_type}/{entry}\")\n", + " curr_dir = f\"{os.getcwd()}/data/{parser_type}\"\n", + " in_one = f\"{curr_dir}/{entry}\"\n", + " out = f\"prod/data.{parser_type}.{entry}.nxs\"\n", + " stdout = f\"log/stdout.{parser_type}.{entry}.txt\"\n", + " stderr = f\"log/stderr.{parser_type}.{entry}.txt\"\n", + " ! dataconverter $in_one --reader apm --nxdl NXapm --output $out 1>$stdout 2>$stderr \n", + " continue\n", + " elif isinstance(entry, tuple): # with sidecar file\n", + " if len(entry) == 2 and all(isinstance(val, str) for val in entry):\n", + " print(f\"Running test {parser_type}/{entry}\")\n", + " curr_dir = f\"{os.getcwd()}/data/{parser_type}\"\n", + " in_one = f\"{curr_dir}/{entry[0]}\"\n", + " in_two = f\"{curr_dir}/{entry[1]}\"\n", + " out = f\"prod/data.{parser_type}.{entry[0]}.nxs\"\n", + " stdout = f\"log/stdout.{parser_type}.{entry[0]}.txt\"\n", + " stderr = f\"log/stderr.{parser_type}.{entry[0]}.txt\"\n", + " ! dataconverter $in_one $in_two --reader apm --nxdl NXapm --output $out 1>$stdout 2>$stderr\n", + " continue\n", + " print(f\"Skipping test {parser_type}/{entry}\")\n", + "print(\"Ran all tests\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "213077cb-6c43-42d0-8f0a-213c0f82696d", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.4" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}