diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 8305708b10..1d8125765e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -17,106 +17,6 @@ env: SOURCE_DATE_EPOCH: "1668811211" jobs: - pyodide-python-version: - name: Determine Pyodide Python version - runs-on: ubuntu-22.04 - outputs: - python-version: ${{ steps.retrieve-python-version.outputs.python-version }} - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Cache python version - id: cache-pyodide-python-version - uses: actions/cache@v4 - with: - path: pyodide-python-version - key: ${{ runner.os }}-docs-pyodide-python-version-${{ hashFiles('docs/requirements-wasm.txt') }} - - - name: Setup Python - if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true' - uses: actions/setup-python@v5 - with: - python-version: "${{ env.X86_64_PYTHON_VERSION }}" - - - name: Install dependencies - if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true' - run: python3 -m pip install -r docs/requirements-wasm.txt - - - name: Determine Python version - if: steps.cache-pyodide-python-version.outputs.cache-hit != 'true' - id: compute-python-version - run: | - # Save Python version - PYTHON_VERSION=$(pyodide config get python_version) - echo $PYTHON_VERSION > pyodide-python-version - - - name: Retrieve Python version - id: retrieve-python-version - run: | - PYTHON_VERSION=$(cat pyodide-python-version) - echo "python-version=$PYTHON_VERSION" >> "$GITHUB_OUTPUT" - - awkward-cpp-wasm: - name: Build C++ WASM - runs-on: ubuntu-22.04 - needs: [pyodide-python-version] - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "${{ needs.pyodide-python-version.outputs.python-version }}" - - - name: Generate build files - run: pipx run nox -s prepare -- --headers --signatures - - - name: Cache wheel - id: cache-awkward-cpp-wasm-wheel - uses: actions/cache@v4 - with: - path: ./awkward-cpp/dist - key: ${{ runner.os }}-"${{ needs.pyodide-python-version.outputs.python-version }}-awkward-cpp-wasm-${{ hashFiles('awkward-cpp/**') }} - - - name: Install dependencies - if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true' - run: python3 -m pip install -r docs/requirements-wasm.txt - - - name: Determine EMSDK version - if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true' - id: compute-emsdk-version - run: | - # Prepare xbuild environment (side-effect) - pyodide config list - # Save EMSDK version - EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) - echo "emsdk-version=$EMSCRIPTEN_VERSION" >> $GITHUB_OUTPUT - working-directory: awkward-cpp - - - name: Install EMSDK - uses: mymindstorm/setup-emsdk@v14 - if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true' - with: - version: ${{ steps.compute-emsdk-version.outputs.emsdk-version }} - - - name: Build wheel - if: steps.cache-awkward-cpp-wasm-wheel.outputs.cache-hit != 'true' - id: build-awkward-cpp-wasm-wheel - run: | - # pyodide-build doesn't work out of the box with pipx - CFLAGS=-fexceptions LDFLAGS=-fexceptions pyodide build --exports whole_archive - working-directory: awkward-cpp - - - name: Upload wheel - uses: actions/upload-artifact@v4 - with: - name: awkward-cpp-wasm - path: awkward-cpp/dist/awkward*wasm32.whl - awkward-cpp-x86-64: runs-on: ubuntu-22.04 name: Build C++ x86 @@ -241,7 +141,7 @@ jobs: build-docs: runs-on: ubuntu-22.04 - needs: [awkward-cpp-wasm, awkward-cpp-x86-64, awkward, execute-cppyy] + needs: [awkward-cpp-x86-64, awkward, execute-cppyy] name: Build Docs defaults: run: @@ -285,12 +185,6 @@ jobs: mkdir -p docs/lite/pypi/ cp dist/awkward*.whl docs/lite/pypi/ - - name: Download & copy awkward-cpp WASM wheel to JupyterLite - uses: actions/download-artifact@v4 - with: - name: awkward-cpp-wasm - path: docs/lite/pypi - - name: Download awkward-cpp x86_64 wheel uses: actions/download-artifact@v4 with: diff --git a/src/awkward/_errors.py b/src/awkward/_errors.py index a6efa8f04b..2ce5e3a2c7 100644 --- a/src/awkward/_errors.py +++ b/src/awkward/_errors.py @@ -2,8 +2,6 @@ from __future__ import annotations -import builtins -import sys import threading import warnings from collections.abc import Callable, Collection, Iterable, Mapping @@ -51,11 +49,6 @@ def __call__(self): return self.func(*self.args, **self.kwargs) -class KeyError(builtins.KeyError): - def __str__(self): - return super(Exception, self).__str__() - - class ErrorContext: # Any other threads should get a completely independent _slate. _slate = threading.local() @@ -75,50 +68,33 @@ def __enter__(self): self._slate.__dict__["__primary_context__"] = self def __exit__(self, exception_type, exception_value, traceback): - try: + if ( + exception_type is not None + and issubclass(exception_type, Exception) + and self.primary() is self + ): + # Step out of the way so that another ErrorContext can become primary. + # Is this necessary to do here? (We're about to raise an exception anyway) + self._slate.__dict__.clear() # Handle caught exception - if ( - exception_type is not None - and issubclass(exception_type, Exception) - and self.primary() is self - ): - self.handle_exception(exception_type, exception_value) - finally: + raise self.decorate_exception(exception_type, exception_value) + else: # Step out of the way so that another ErrorContext can become primary. if self.primary() is self: self._slate.__dict__.clear() - def handle_exception(self, cls: type[E], exception: E): - if sys.version_info >= (3, 11, 0, "final"): - self.decorate_exception(cls, exception) - else: - raise self.decorate_exception(cls, exception) - def decorate_exception(self, cls: type[E], exception: E) -> Exception: - if sys.version_info >= (3, 11, 0, "final"): - if issubclass(cls, (NotImplementedError, AssertionError)): - exception.add_note( - "\n\nSee if this has been reported at https://github.com/scikit-hep/awkward/issues" - ) + def _add_note(exception: E, note: str) -> E: + if hasattr(exception, "add_note"): + exception.add_note(note) else: - exception.add_note(self.note) + exception.__notes__ = [note] return exception - else: - new_exception: Exception - if issubclass(cls, (NotImplementedError, AssertionError)): - # Raise modified exception - new_exception = cls( - str(exception) - + "\n\nSee if this has been reported at https://github.com/scikit-hep/awkward/issues" - ) - new_exception.__cause__ = exception - elif issubclass(cls, builtins.KeyError): - new_exception = KeyError(self.format_exception(exception)) - new_exception.__cause__ = exception - else: - new_exception = cls(self.format_exception(exception)) - new_exception.__cause__ = exception - return new_exception + + note = self.note + if issubclass(cls, (NotImplementedError, AssertionError)): + note = "\n\nSee if this has been reported at https://github.com/scikit-hep/awkward/issues" + return _add_note(exception, note) def format_argument(self, width, value): from awkward import contents, highlevel, record diff --git a/src/awkward/prettyprint.py b/src/awkward/prettyprint.py index fb2b8199f7..b4075cf0d6 100644 --- a/src/awkward/prettyprint.py +++ b/src/awkward/prettyprint.py @@ -93,6 +93,9 @@ def get_at(data: Content, index: int): def get_field(data: Content, field: str): + if isinstance(data._layout, ak.record.Record): + if data._layout._array.content(field)._is_getitem_at_placeholder(): + return PlaceholderValue() out = data._layout._getitem_field(field) if isinstance(out, ak.contents.NumpyArray): array_param = out.parameter("__array__") diff --git a/tests/test_1447_jax_autodiff_slices_ufuncs.py b/tests/test_1447_jax_autodiff_slices_ufuncs.py index 9d3b049e30..875757c669 100644 --- a/tests/test_1447_jax_autodiff_slices_ufuncs.py +++ b/tests/test_1447_jax_autodiff_slices_ufuncs.py @@ -4,12 +4,15 @@ import numpy as np import pytest +from packaging.version import parse as parse_version import awkward as ak jax = pytest.importorskip("jax") jax.config.update("jax_platform_name", "cpu") jax.config.update("jax_enable_x64", True) +if parse_version(jax.__version__) >= parse_version("0.4.36"): + jax.config.update("jax_data_dependent_tracing_fallback", True) ak.jax.register_and_check()