You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by GitBox <gi...@apache.org> on 2026/04/20 22:18:51 UTC

[GH] (tvm-ffi/junrushao/2026-04-20/enum-enhance): Workflow run "CI" failed!

The GitHub Actions job "CI" on tvm-ffi.git/junrushao/2026-04-20/enum-enhance has failed.
Run started by GitHub user junrushao (triggered by junrushao).

Head commit for run:
07d84d1dedfe4c4285666a449cc6c19cd74783c4 / Junru Shao <ju...@nvidia.com>
refactor(enum)!: hide identity fields and add IntEnum/StrEnum payload bases

Architecture:
- Rename the intrinsic identity fields on ``ffi::EnumObj`` from
  ``value``/``name`` to ``_value``/``_name`` in the C++ layout, reflection
  schema (``ObjectDef<EnumObj>::def_ro``), repr printer, and
  ``reflection::EnumDef``.  Prefixing with an underscore frees the public
  ``value`` symbol for user-defined payload fields while keeping the
  dense ordinal and declaration-key as the canonical variant identity.
- Introduce ``IntEnum`` / ``StrEnum`` Python base classes that reserve a
  declared ``value: int`` (resp. ``str``) payload field via the new
  ``_prepare_payload_enum_subclass`` helper.  The helper injects or
  validates the ``value`` annotation before ``Enum.__init_subclass__``
  runs, so reflection sees the payload as a first-class declared field
  rather than an extensible attribute.
- Tighten the py_class base-info lookup to fall back to
  ``base.__tvm_ffi_type_info__`` when ``_type_cls_to_type_info`` misses,
  so Python subclasses descending through ``IntEnum``/``StrEnum`` (whose
  ancestry passes through C++-registered ``EnumObj``) can be registered
  without losing their parent type info.

Public Interfaces:
- C++ ABI break: ``EnumObj::value`` and ``EnumObj::name`` no longer
  exist; consumers must read ``EnumObj::_value`` and ``EnumObj::_name``
  (both still declared via reflection, so Python access through the
  property descriptors continues to work under the new names).
- Python API break: ``enum_instance.value`` / ``enum_instance.name``
  are no longer surfaced on plain ``Enum`` subclasses; use
  ``_value`` / ``_name`` for the intrinsic ordinal and key.  Any user
  code relying on the previous public names must either rename to the
  underscore form or migrate to ``IntEnum`` / ``StrEnum`` to obtain a
  user-visible ``value`` field.
- New exports: ``tvm_ffi.dataclasses.IntEnum`` and
  ``tvm_ffi.dataclasses.StrEnum`` (also added to ``__all__``).
- ``entry(...)`` now rejects ``_value=`` / ``_name=`` kwargs (previously
  ``value=`` / ``name=``), matching the renamed fields.

UI/UX:
- none (library-level change).

Behavioral Changes:
- Reading ``instance.value`` / ``instance.name`` on a plain ``Enum``
  subclass now raises ``AttributeError``; only ``IntEnum`` / ``StrEnum``
  expose ``value`` as a user payload.
- Repr formatting still produces ``<type_key>.<_name>`` (wire-identical
  output; only the internal field-access path changed).
- Ordinal- and name-keyed lookups (``get``, ``by_name``, ``by_value``,
  ``entries``, ``attr_dict``, ``EnumAttrMap``) transparently use the
  renamed fields; no semantic change for callers that go through the
  documented accessors.

Docs:
- Doxygen and Python docstrings updated in-place to reference the
  renamed fields (``enum.h``, ``reflection/enum_def.h``,
  ``reflection/accessor.h``, ``dataclasses/enum.py``).
- No doc site page references the old public ``EnumObj::value`` /
  ``EnumObj::name`` names, so no further doc/migration-note changes are
  required in ``docs/``.

Tests:
- Executed: ``uv run pytest -x tests/python/test_dataclass_enum.py``
- Result: pass (44/44), including two new tests
  (``test_int_enum_payload_value``, ``test_str_enum_payload_value``)
  and the hidden-identity assertion
  (``test_public_value_and_name_are_hidden``).  The existing
  ``test_entry_rejects_*`` cases were renamed to match the new kwargs.

Untested Edge Cases:
- C++ unit tests for ``refl::EnumDef`` were not rerun locally in this
  commit cycle; CI (Linux x86_64/aarch64, macOS arm64, Windows) will
  cover the renamed ``EnumObj::_value`` / ``_name`` compile path.
- No coverage for downstream Rust bindings consuming ``EnumObj``
  fields directly; relying on CI's Rust job to catch any fallout.
- ``IntEnum`` / ``StrEnum`` interaction with the cross-language
  (C++-backed) open-registry mode is not exercised here; existing
  single-language payload tests are sufficient for the initial surface.

BREAKING CHANGE: ``ffi::EnumObj::value`` and ``ffi::EnumObj::name`` are
renamed to ``_value`` and ``_name``.  Python code reading ``.value`` /
``.name`` on an ``Enum`` variant must migrate to ``._value`` / ``._name``
for the intrinsic ordinal and key, or switch the base class to
``IntEnum`` / ``StrEnum`` to carry a user-visible ``value`` payload.
``entry(...)`` callers passing ``value=`` / ``name=`` must rename those
kwargs to ``_value`` / ``_name`` (or remove them, since both are
auto-assigned).

Report URL: https://github.com/apache/tvm-ffi/actions/runs/24693063866

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org