Skip to content

Add tutorial API for example datasets#1502

Merged
rajeeja merged 5 commits intoUXARRAY:mainfrom
alioacar:fix-1496
May 9, 2026
Merged

Add tutorial API for example datasets#1502
rajeeja merged 5 commits intoUXARRAY:mainfrom
alioacar:fix-1496

Conversation

@alioacar
Copy link
Copy Markdown
Contributor

@alioacar alioacar commented Apr 29, 2026

Closes #1496

This is a draft PR for early feedback on the tutorial dataset API. I also went through the notebooks and updated them to use tutorial API.

Overview

  • Add a new ux.tutorial API for loading built-in sample datasets from the existing test/meshfiles directory (following @erogluorhan's suggestion)
  • Add a tutorial dataset registry under uxarray/tutorial/
  • Add tests covering the new tutorial helpers
  • Update the notebooks to use the tutorial API
  • In data-structures.ipynb, show both the usual dataset(and grid) loading pattern and the tutorial API for comparison

Expected Usage

import uxarray as ux

# tutorial dataset usage
uxds = ux.tutorial.open_dataset("quad-hexagon")
uxgrid = ux.tutorial.open_grid("outCSne30")

# tutorial dataset usage with multiple data files
uxds_multi = ux.tutorial.open_mfdataset("quad-hexagon-random")

# regular usage with user-provided files remains unchanged
grid_path = "/path/to/grid.nc"
data_path = "/path/to/data.nc"
data_paths = ["/path/to/data1.nc", "/path/to/data2.nc"]

uxds = ux.open_dataset(grid_path, data_path)
uxds_multi = ux.open_mfdataset(grid_path, data_paths)

PR Checklist

General

  • An issue is linked created and linked
  • Filled out Overview and Expected Usage (if applicable) sections

Testing

  • Adequate tests are created if there is new functionality
  • Tests cover all possible logical paths in your function
  • Tests are not too basic (such as simply calling a function and nothing else)

Documentation

  • Docstrings have been added to all new functions
  • Update api.rst

Examples

  • Clear the output of all cells before committing

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

alioacar added 3 commits May 1, 2026 09:30
Now tutorial api checks both source tree relative paths and
path.cwd which helps docs builds. This needs to support both
cloned repo and root repo.
@alioacar alioacar marked this pull request as ready for review May 1, 2026 09:16
@erogluorhan erogluorhan requested review from erogluorhan and rajeeja May 4, 2026 16:46
@erogluorhan
Copy link
Copy Markdown
Member

Thanks @alioacar ! @rajeeja and I will look into this as soon as we can and will get back to you. In the meantime, I approved the workflow runs, we'll see their results soon.

Copy link
Copy Markdown
Contributor

@rajeeja rajeeja left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, @alioacar _meshfiles_path() resolves to test/meshfiles/ which is not included in the PyPI distribution, so ux.tutorial.open_dataset() will raise FileNotFoundError for any user who did pip install uxarray rather than cloning the repo, please revise uxarray/tutorial/init.py, in the _meshfiles_path() function.. Path.cwd() is not the rightway.

@alioacar
Copy link
Copy Markdown
Contributor Author

alioacar commented May 9, 2026

thanks for the feedback @rajeeja. I updated the tutorial data path resolution.
1- use an env variable for data path. UXARRAY_DATA_DIR (for docs or other configured envs)
2- otherwise use the local test/meshfiles directory (working from a clone)
3- otherwise fall back to download/cache for PyPI.
This removes the reliance on Path.cwd while still keeping the cloned workflow working.

@rajeeja rajeeja self-requested a review May 9, 2026 22:48
Copy link
Copy Markdown
Contributor

@rajeeja rajeeja left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution👍✈️

@rajeeja rajeeja merged commit 49b8e4b into UXARRAY:main May 9, 2026
13 checks passed
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.

Add a tutorial dataset loader

3 participants