Skip to content

Commit

Permalink
chore: deflake tmpdir cleanup in tests (#3573)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayka authored Jan 25, 2025
1 parent 420e110 commit 0da9c25
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
12 changes: 8 additions & 4 deletions docs/guides/editor_features/watching.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ Guide](module_autoreloading.md)
!!! note
Support for watching data files and automatically refreshing cells that depend on them is coming soon. Follow along at <https://github.com/marimo-team/marimo/issues/3258>

## Developing in WASM mode
## Hot-reloading WebAssembly notebooks

Follow these steps to develop a notebook using your own editor while
previewing it as a [WebAssembly notebook](../wasm.md) in the browser. This lets
you take advantage of local development tools while seeing the notebook as it
appears when deployed as a WebAssembly notebook.

Follow these steps to develop a notebook using your own editor, while previewing it as a WebAssembly notebook in the browser. This lets you take advantage of local development tools while seeing the notebook as it appears when deployed as a [WebAssembly notebook](../wasm.md).
```bash
# in one terminal, start a watched edit session
# in one terminal, start a watched edit (or run) session
marimo edit notebook.py --watch

# in another terminal
Expand All @@ -58,4 +62,4 @@ marimo export html-wasm notebook.py -o output_dir --watch
# in a third terminal, serve the WASM application
cd path/to/output_dir
python -m http.server # or a server that watches for changes
```
```
26 changes: 18 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ def executing_kernel() -> Generator[Kernel, None, None]:
mocked.teardown()


def _cleanup_tmp_dir(tmp_dir: TemporaryDirectory) -> None:
try:
# Tests shouldn't care whether temporary directory cleanup
# fails. Python 3.10+ has an ignore_cleanup_error argument,
# but we still support 3.9.
tmp_dir.cleanup()
except Exception:
pass


@pytest.fixture
def temp_marimo_file() -> Generator[str, None, None]:
tmp_dir = TemporaryDirectory()
Expand Down Expand Up @@ -258,7 +268,7 @@ def __(mo):
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -301,7 +311,7 @@ def __(mo):
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -330,7 +340,7 @@ async def __():
f.flush()
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -372,7 +382,7 @@ def __():
f.flush()
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -416,7 +426,7 @@ def __():
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -449,7 +459,7 @@ def temp_md_marimo_file() -> Generator[str, None, None]:
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -486,7 +496,7 @@ def __():
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


@pytest.fixture
Expand Down Expand Up @@ -518,7 +528,7 @@ def __():
f.write(content)
yield tmp_file
finally:
tmp_dir.cleanup()
_cleanup_tmp_dir(tmp_dir)


# Factory to create ExecutionRequests and abstract away cell ID
Expand Down

0 comments on commit 0da9c25

Please sign in to comment.