Skip to content

Commit

Permalink
perf(tutorials): skip some writes in export_vtk_tutorial.py
Browse files Browse the repository at this point in the history
This brings the runtime from >2 minutes down to ~30 seconds.
  • Loading branch information
wpbonelli committed Feb 3, 2025
1 parent 816ff81 commit efbd104
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
18 changes: 7 additions & 11 deletions .docs/Notebooks/export_vtk_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,6 @@
model_bottom_dir = output_dir / "BOTM"
ml.dis.botm.export(model_bottom_dir, fmt="vtk")

# ### Export transient array recharge

# transient 2d array
# export recharge
model_recharge_dir = output_dir / "RECH"
ml.rch.rech.export(model_recharge_dir, fmt="vtk", pvd=True)

# ### Export HK with point scalars
#

Expand Down Expand Up @@ -245,7 +238,8 @@
vtkobj = vtk.Vtk(ml, xml=True, pvd=True, vertical_exageration=10)

## add recharge to the VTK object
recharge = ml.rch.rech.transient_2ds
subset = list(range(10))
recharge = {k: v for k, v in ml.rch.rech.transient_2ds.items() if k in subset}
vtkobj.add_transient_array(recharge, "recharge", masked_values=[0])

## write vtk files
Expand All @@ -268,8 +262,8 @@
spd = ml.wel.stress_period_data
vtkobj.add_transient_list(spd, masked_values=[0])

## write vtk files
vtkobj.write(output_dir / "tr_list_example" / "wel_flux.vtu")
## write vtk files (skipped, slow)
# vtkobj.write(output_dir / "tr_list_example" / "wel_flux.vtu")
# -

# ### Adding packages to the `Vtk` object
Expand Down Expand Up @@ -320,7 +314,9 @@
# create the vtk object and export heads
vtkobj = vtk.Vtk(ml, xml=True, pvd=True, vertical_exageration=10)
vtkobj.add_heads(hds)
vtkobj.write(workspace / "heads_output_test" / "freyberg_head.vtu")

# skipped, slow
# vtkobj.write(workspace / "heads_output_test" / "freyberg_head.vtu")
# -

# ### Export heads as point scalar arrays
Expand Down
3 changes: 1 addition & 2 deletions autotest/test_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ def get_notebooks(pattern=None, exclude=None):
+ get_notebooks(pattern="example"),
)
def test_notebooks(notebook):
in_ci = is_in_ci()
args = ["jupytext", "--from", "py", "--to", "ipynb", "--execute", notebook]
stdout, stderr, returncode = run_cmd(*args, verbose=True)

# allow notebooks to fail for lack of optional dependencies in local runs,
# expect all dependencies to be present and notebooks to pass in ci tests.
if returncode != 0 and not in_ci:
if returncode != 0 and not is_in_ci():
if "Missing optional dependency" in stderr:
pkg = re.findall("Missing optional dependency '(.*)'", stderr)[0]
pytest.skip(f"notebook requires optional dependency {pkg!r}")
Expand Down

0 comments on commit efbd104

Please sign in to comment.