Skip to content

Benchmarks generate_data.stock.realistic_4d_w_everything laziness not working #6137

@trexfeathers

Description

@trexfeathers

🐛 Bug Report

Reported here: #5926 (comment)

How To Reproduce

Steps to reproduce the behaviour:

  1. Call the function: my_cube = realistic_4d_w_everything(lazy=False)
  2. Check laziness: print(my_cube.has_lazy_data())

Expected behaviour

Step 2 should print False, but currently prints True.

Environment

  • OS & Version: [e.g., Ubuntu 20.04 LTS]
  • Iris Version: [e.g., From the command line run python -c "import iris; print(iris.__version__)"]

Observed during GHA CI, and locally by @bouweandela

Additional context

def realistic_4d_w_everything(w_mesh=False, lazy=False) -> iris.cube.Cube:
"""Run :func:`iris.tests.stock.realistic_4d_w_everything` in ``DATA_GEN_PYTHON``.
Parameters
----------
w_mesh : bool
See :func:`iris.tests.stock.realistic_4d_w_everything` for details.
lazy : bool
If True, the Cube will be returned with all arrays as they would
normally be loaded from file (i.e. most will still be lazy Dask
arrays). If False, all arrays will be realised NumPy arrays.
"""
def _external(w_mesh_: str, save_path_: str):
import iris
from iris.tests.stock import realistic_4d_w_everything
cube = realistic_4d_w_everything(w_mesh=bool(w_mesh_))
iris.save(cube, save_path_)
save_path = (BENCHMARK_DATA / f"realistic_4d_w_everything_{w_mesh}").with_suffix(
".nc"
)
if not REUSE_DATA or not save_path.is_file():
_ = run_function_elsewhere(_external, w_mesh_=w_mesh, save_path_=str(save_path))
context = nullcontext() if lazy else load_realised()
with context:
return iris.load_cube(save_path, "air_potential_temperature")

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions