Skip to content

Commit 1346248

Browse files
authored
Skip cache for -g flag on build. (#1040)
1 parent 7312015 commit 1346248

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Instructions: Add a subsection under `[Unreleased]` for additions, fixes, change
1111

1212
### Changed
1313

14+
- NEW BEHAVIOR: the `pretext build -g` command will not use cached versions of assets when regenerating. You can still generate assets and use the cache with `pretext generate`.
1415
- Improve default settings in codespace settings.
1516

1617
## [2.24.0] - 2025-07-21

docs/asset-generation.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,24 @@ However, for select assets (currently `asymptote`, `latex-image`, `prefigure`, a
2626

2727
2. If the software to generate assets is improved (which happens with `prefigure` assets, for example), the user will not get new versions of these assets (assuming no changes are made to source).
2828

29+
3. Sometimes a generated asset will pull in external data, such as a `latex-image` that includes an external `.png`, or a `prefigure` diagram that uses an external data file. The hash only knows about the code in the original asset, so changing the external import will not change the hash.
30+
2931
## User Interface
3032

3133
Assets are generated (sometimes using the cache, sometimes skipping it) depending on what CLI command a user enters.
3234

3335
- `pretext build`. Assets will be generated only if the source has changed inside that asset type, and cached output will be copied if present.
34-
- `pretext build -g` (`pretext build --generate`). For each asset type in source, we will request it be generated by core regardless of whether the source has changed. Will copy cached versions of assets where possible.
35-
- `pretext build -q` (`pretext build --no-generate`). No assets will be generated (or copied from cache), even if source has changed (or hasn't been successfully generated before).
36-
- `pretext generate`. Assets of all, or specified, types will be generated, even if source has changed. Cached versions of individual assets will be copied if possible (CHANGE?). Identical to `pretext build -g` except it allows to limit by asset type and doesn't call build.
36+
- `pretext build -g` (`pretext build --generate`). For each asset type in source, we will request it be generated by core regardless of whether the source has changed. Will also regenerate any assets in the cache. Equivalent to running `pretext generate -f` followed by `pretext build`.
37+
- `pretext build -q` (`pretext build --no-generate`). No assets will be generated (or copied from cache), even if source has changed (or hasn't been successfully generated before). Intended for building quickly and to avoid errors coming from missing executables (if you want to still see the non-asset parts of the document).
38+
- `pretext generate`. Assets of all, or specified, types will be generated, even if source has changed. Cached versions of individual assets will be copied if possible. Allows to limit by asset type and doesn't call build.
3739
- `pretext generate -q` (`pretext generate --only-changed`). Limit generation of assets to only those that have changed since last call to generate. Same as `pretext build` except you don't do a build, just generate assets, and can limit to asset type.
38-
- `pretext generate -f` (`pretext generate --force`). Generates all assets, even if source has not changed, and does NOT copy assets from cache even if available.
40+
- `pretext generate -f` (`pretext generate --force`). Generates all assets, even if source has not changed, and does NOT copy assets from cache even if available (they will be updated). Same behavior as `pretext build -g`, except you don't do a build, just generate assets, and can limit to asset type.
3941

4042
There is also a `pretext generate --clean` that deletes the .cache directory.
4143

4244
### Consequences
4345

44-
To avoid pitfall number 1, run `pretext build -g`.
46+
To avoid pitfall number 1, run `pretext generate`.
4547

46-
To avoid pitfall number 2, run `pretext generate -f`.
48+
To avoid pitfall numbers 2 or 3, run `pretext build -g` or `pretext generate -f`.
4749

pretext/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
VERSION = get_version("pretext", Path(__file__).parent.parent)
2020

2121

22-
CORE_COMMIT = "32262dda4922a4535bcfb10fe1c66b50c51337ac"
22+
CORE_COMMIT = "45be2cfe85fd54a3e5c03743226919eb1a6b2085"
2323

2424

2525
def activate() -> None:

pretext/cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,9 @@ def build(
606606
try:
607607
for t in targets:
608608
log.info(f"Generating assets for {t.name}")
609-
t.generate_assets(only_changed=False, xmlid=xmlid, clean=clean)
609+
t.generate_assets(
610+
only_changed=False, xmlid=xmlid, clean=clean, skip_cache=True
611+
)
610612
no_generate = True
611613
except Exception as e:
612614
log.error(f"Failed to generate assets: {e} \n")

0 commit comments

Comments
 (0)