Skip to content

Fix missing sampler argument in xaeronet volume dataloader demo - #1964

Open
Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix/xaeronet-volume-dataloader-sampler
Open

Fix missing sampler argument in xaeronet volume dataloader demo#1964
Anai-Guo wants to merge 1 commit into
NVIDIA:mainfrom
Anai-Guo:fix/xaeronet-volume-dataloader-sampler

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 4, 2026

Copy link
Copy Markdown

Problem

examples/cfd/external_aerodynamics/xaeronet/volume/dataloader.py cannot be run as a
script. create_dataloader takes sampler as a required positional argument:

def create_dataloader(
    file_list, mean, std, sampler, nan_to_0=True, batch_size=1, ...
):

but the __main__ demo block at the bottom of the same file omits it:

dataloader = create_dataloader(
    file_list, mean, std, nan_to_0=True, batch_size=2, num_workers=1
)

so python dataloader.py fails with
TypeError: create_dataloader() missing 1 required positional argument: 'sampler'
before any data is touched.

Two things show sampler was added to the signature after this demo was written and
the demo was never updated:

  • The docstring documents file_list, mean, std, batch_size, num_workers,
    pin_memory and prefetch_factor — but neither sampler nor nan_to_0.
  • The sibling surface/dataloader.py has the same __main__ demo and runs fine,
    because its create_dataloader has no required sampler.

Fix

Pass sampler=None, exactly as the real training code in the same example already
does at volume/train.py:

valid_dataloader = create_dataloader(
    valid_dataset, mean, std, batch_size=1, num_workers=1, sampler=None
)

DataLoader(sampler=None) is the documented default (sequential order), so the demo
behaves as originally intended. Also documented sampler and nan_to_0 in the
docstring.

Verification

No GPU or DriveAer dataset here, so I verified the argument binding rather than
executing the loader — which is exactly where the failure is. Signatures were
extracted from the file's AST and each call shape replayed with Signature.bind:

create_dataloader (file_list, mean, std, sampler, nan_to_0=True, batch_size=1,
                   num_workers=4, pin_memory=True, prefetch_factor=2)
  volume/train.py:118 (real production call)     -> binds OK
  volume/dataloader.py __main__ (as written)     -> TypeError: missing a required argument: 'sampler'
  volume/dataloader.py __main__ (patched)        -> binds OK

Formatting, with the version pinned in .pre-commit-config.yaml (ruff v0.12.5), run
from the repo root:

$ ruff format --check examples/cfd/external_aerodynamics/xaeronet/volume/dataloader.py
1 file already formatted

(ruff check excludes ^examples/ in the pre-commit config; I confirmed the file's
ruff check output is byte-identical before and after this patch either way.)

🤖 Generated with Claude Code

`create_dataloader` takes `sampler` as a required positional argument, but
the `__main__` demo block in the same file omits it, so running the module
directly raises TypeError before any data is loaded.

Pass `sampler=None`, matching `volume/train.py`, and document the two
parameters (`sampler`, `nan_to_0`) that were missing from the docstring.

Signed-off-by: Anai-Guo <antai12232931@outlook.com>
@Anai-Guo
Anai-Guo requested a review from mnabian as a code owner September 4, 2026 07:18
@copy-pr-bot

copy-pr-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS review map

Current for commit 2043b912a960. An approval covers every file listed for that owner; one owner is sufficient for shared files.

@mnabian — 1 file(s)
  • examples/cfd/external_aerodynamics/xaeronet/volume/dataloader.py

Comment /codeowners-info to refresh.

@greptile-apps

greptile-apps Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR fixes the XAeroNet volume dataloader demo by explicitly passing sampler=None, allowing the call to satisfy the required function signature. It also documents the sampler and nan_to_0 parameters.

Important Files Changed

Filename Overview
examples/cfd/external_aerodynamics/xaeronet/volume/dataloader.py Correctly supplies the omitted required sampler argument in the demo and accurately documents both previously undocumented parameters.

Reviews (1): Last reviewed commit: "Fix missing `sampler` argument in xaeron..." | Re-trigger Greptile

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.

1 participant