Skip to content

fix: correct length on artifact.files#10796

Merged
matthoare117-wandb merged 24 commits intomainfrom
hoare/len-bug-fix
Oct 30, 2025
Merged

fix: correct length on artifact.files#10796
matthoare117-wandb merged 24 commits intomainfrom
hoare/len-bug-fix

Conversation

@matthoare117-wandb
Copy link
Copy Markdown
Contributor

@matthoare117-wandb matthoare117-wandb commented Oct 29, 2025

Description

What does the PR do? Include a concise description of the PR contents.

Fixes a bug where len(artifact.files(names=[...])) incorrectly returns the total number of files in the artifact instead of respecting the names filter.

Problem: When calling artifact.files() with a names parameter, the len() function ignores the filter and returns the total artifact file count.

Example:

artifact = wandb.Api().artifact(name="my-artifact:v0")

# If artifact has 100 files total, but only 1 file named "file0.txt"
print(len(artifact.files(names=["file0.txt"])))
# Expected: 1
# Actual (before fix): 100

Fix: Updated the ArtifactFiles class to correctly respect the names filter when calculating length. Now len() returns the count of files matching the provided filter.

  • I updated CHANGELOG.unreleased.md, or it's not applicable

Testing

How was this PR tested?

Added the test test_artifacts_files_name

@matthoare117-wandb matthoare117-wandb requested review from a team as code owners October 29, 2025 05:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthoare117-wandb matthoare117-wandb changed the title Len Bug Fix Fix: Len Bug Fix Oct 29, 2025
@matthoare117-wandb matthoare117-wandb changed the title Fix: Len Bug Fix fix: correct length on artifact.files Oct 29, 2025
Comment thread wandb/apis/public/artifacts.py Outdated
Comment thread wandb/apis/public/artifacts.py Outdated
Comment thread wandb/apis/public/artifacts.py
Comment thread tests/system_tests/test_artifacts/test_artifact_public_api.py Outdated
Comment thread tests/system_tests/test_artifacts/test_artifact_public_api.py Outdated
Copy link
Copy Markdown
Contributor

@tonyyli-wandb tonyyli-wandb left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix! Also thanks for navigating + rolling with what definitely turned out to be a more involved / complicated set of changes than expected 🙂

Comment thread tests/system_tests/test_artifacts/test_artifact_public_api.py Outdated
Comment thread CHANGELOG.unreleased.md Outdated
Comment thread wandb/apis/public/artifacts.py
Comment thread tools/graphql_codegen/artifacts/artifact_files.graphql
@matthoare117-wandb matthoare117-wandb enabled auto-merge (squash) October 30, 2025 19:54
@matthoare117-wandb matthoare117-wandb merged commit bd309a4 into main Oct 30, 2025
34 checks passed
@matthoare117-wandb matthoare117-wandb deleted the hoare/len-bug-fix branch October 30, 2025 19:55
tonyyli-wandb added a commit that referenced this pull request Jan 2, 2026
…11123)

Description
-----------
- Fixes https://wandb.atlassian.net/browse/WB-30038

Removes the legacy server compatibility check for the `File.storagePath` field. These server versions are long past EOL (current EOL at the time of writing is 0.63.0).  As we no longer officially support the affected server versions, it's reasonable for newer SDK releases to drop the outdated workaround logic.

- Remove the check for server support for the `storagePath` field (i.e. the `if client.version_supported("0.12.21")...` guard from `ArtifactFiles.__init__()`)
- Simplify `omit_fields` logic to only handle `totalCount` (which was added more recently, see #10796)
- Remove system test (`test_artifact_files_on_legacy_local_install`) which explicitly mocked and tested against said legacy server behavior

- [x] I updated CHANGELOG.unreleased.md, or it's not applicable

Testing
-------
Existing tests. No behavior changes for supported server versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants