Skip to content

Treat infer_artifact=False as the documented default in add_tags/remove_tags#5097

Open
chuenchen309 wants to merge 2 commits into
zenml-io:developfrom
chuenchen309:fix/add-tags-infer-artifact-false
Open

Treat infer_artifact=False as the documented default in add_tags/remove_tags#5097
chuenchen309 wants to merge 2 commits into
zenml-io:developfrom
chuenchen309:fix/add-tags-infer-artifact-false

Conversation

@chuenchen309

Copy link
Copy Markdown

Describe changes

The public overloads of add_tags and remove_tags type infer_artifact
as bool = False (src/zenml/utils/tag_utils.py), so passing False
explicitly is documented and valid. But the implementations default the
parameter to Optional[bool] = None, and every dispatch branch tests
infer_artifact is None. An explicit False therefore matches no branch
and falls through to ValueError: Unsupported way to call ..., even when a
valid identifier such as run=... is supplied:

from zenml import add_tags
add_tags(tags=["t"], run=run_id, infer_artifact=False)  # ValueError today

False semantically means "don't infer" — the same as omitting the argument.
This normalizes False to None at the top of both functions so it dispatches
identically to the default. The infer_artifact is True inference path is
untouched, and calls that omit the argument (or pass None/True) are
completely unaffected — the new lines are a no-op unless the value is exactly
False.

Pre-requisites

  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop.
  • IMPORTANT: reflected in other resources:
    • Not applicable — this is an internal dispatch bugfix that restores the
      already-documented behavior of a public overload; no docs, dashboard,
      template, or project changes are needed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Tests

Added test_add_and_remove_tags_with_infer_artifact_false in
tests/integration/functional/utils/test_tag_utils.py, which tags and untags a
pipeline run via run=... with infer_artifact=False. It fails on develop
(the ValueError above) and passes with this change. The full
test_tag_utils.py file passes (4 tests); ruff, ruff format, mypy
(single-file), and typos are clean on both changed files.

Notes

  • I couldn't self-apply a release-notes / no-release-notes label (external
    contributors lack label permissions). Could a maintainer add the appropriate
    one? This is a small user-facing bug fix, so release-notes seems right.

Disclosure: this change was drafted with AI assistance (Claude). The diagnosis,
the fix, and every verification step above were reviewed and run before opening.

…ve_tags

The public overloads of `add_tags` and `remove_tags` type `infer_artifact`
as `bool = False`, so passing `False` explicitly is documented and valid.
But the implementations default it to `None` and every dispatch branch tests
`infer_artifact is None`, so an explicit `False` matches no branch and falls
through to a `ValueError: Unsupported way to call ...` — even when other
valid identifiers (e.g. `run=...`) are supplied.

Normalize `False` to `None` at the top of both functions so it dispatches
identically to omitting the argument (both mean "don't infer"). The
`infer_artifact is True` inference path is unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bcdurak

bcdurak commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Hey @chuenchen309, thank you for your contribution. We'll take a look right away.

Comment on lines +256 to +259
# `infer_artifact=False` is the documented default of the public overload
# and means "don't infer" — same as omitting it. The dispatch below tests
# `infer_artifact is None`, so normalize False to None to avoid falling
# through to the "unsupported call" error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be a bit stricter here.

infer_artifact is only meaningful for the artifact versions with:

add_tags(tags=[...], infer_artifact=True)
add_tags(tags=[...], artifact_name=..., infer_artifact=True)

For manual resource like run, pipeline, artifact, infer_artifact=False is not really part of the API shape. Silently normalizing it to None at the top makes irrelevant argument combinations succeed which would go against the validation.

Could we instead only handle False in the call shapes where this overload/default is meaningful, and keep the unsupported call error for combinations like add_tags(run=..., infer_artifact=False)?

In other words, I agree that False means “do not infer", but I don’t think that should automatically make it valid for every path.

@bcdurak bcdurak added backend Issues that require changes on the backend no-release-notes Release notes will NOT be attached and used publicly for this PR. labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Issues that require changes on the backend no-release-notes Release notes will NOT be attached and used publicly for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants