Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projects plugin cache not being updated #6306

Closed
4 tasks done
alexvoss opened this issue Nov 7, 2023 · 15 comments
Closed
4 tasks done

Projects plugin cache not being updated #6306

alexvoss opened this issue Nov 7, 2023 · 15 comments
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open

Comments

@alexvoss
Copy link
Collaborator

alexvoss commented Nov 7, 2023

Context

Using the projects plugin in Insiders, I am having the problem that it seems the cache is never updated.

Bug description

Changes to the mkdocs.yml files in project do not get picked up. I am changing the color scheme as an example, see below. It seems the config.pickle file in .cache is not getting updated when a mkdocs.yml file in a project is changed.

Related links

Reproduction

9.4.8+insiders.4.43.0-projects-plugin-cache.zip

Steps to reproduce

  1. rm -rf .cache
  2. mkdocs serve
  3. Open subproject in a browser and observe that the project has an indigo palette
  4. In another window, edit the project's mkdocs.yml to set the palette to red
  5. Make a change to the docs/index.md to see that the browser updates
  6. You will see that while the change from (5) shows, the palette is still indigo
  7. Restart mkdocs serve
  8. Observe that the color scheme still has not changed.
  9. Stop mkdocs serve
  10. rm -rf .cache
  11. Start mkdocs serve
  12. Observe that the color scheme has changed now.

Btw. I selected a browser below without thinking and it seems this selection cannot be reset?

Browser

Other

Before submitting

@squidfunk
Copy link
Owner

Thanks for reporting! Could you maybe check if data is updated when you disable the cache:

plugins:
  - projects:
      cache: false

@squidfunk squidfunk added the needs investigation Issue must be investigated by the maintainers label Nov 7, 2023
@alexvoss
Copy link
Collaborator Author

alexvoss commented Nov 7, 2023

Will do. As soon as I managed to produce a new zip file - because the info plugin did not include the projects directory?

@alexvoss
Copy link
Collaborator Author

alexvoss commented Nov 7, 2023

Ok, here is the new .zip file.
9.4.8+insiders.4.43.0-projects-plugin-cache.zip

@alexvoss
Copy link
Collaborator Author

alexvoss commented Nov 7, 2023

Ok, with cache: false a cache is still being created, which might be something to change. Also, the palette does not update. In contrast to the version with no setting for cache, it does change on a restart of mkdocs serve. I think this is how I have been rolling with the examples, have cache turned off and restart whenever I made a chance to a mkdocs.ymlfile.

I did try to debug this but the only thing I could find out is that line 108 in plugin.py might need to be and not self.is_root: instead of or not self.is_root:?

Changing this alone did not fix it, though.

@squidfunk
Copy link
Owner

The cache must be created - we need a way to store intermediate results. This is the same for all plugins. What we could do in theory (but I haven't done it, because nobody complained) is to create a temporary directory and use that for intermediate storage, but the plugins definitely need intermediate storage. Thus, cache disables cache usage, not the cache itself.

I'll investigate as soon as possible.

@squidfunk
Copy link
Owner

squidfunk commented Nov 19, 2023

Fixed in f0b2a6e. My testing shows that the editing experience is much smoother now. In fact, we forgot to update the cache that must be used in nested projects when detecting a change and reloading the configuration. That's now sorted.

By the way, I'm very sorry this took so long, but you know: #6307 kind of eats up all my time right now 😅

@squidfunk squidfunk added bug Issue reports a bug resolved Issue is resolved, yet unreleased if open and removed needs investigation Issue must be investigated by the maintainers labels Nov 19, 2023
@squidfunk
Copy link
Owner

Released as part of 9.4.10+insiders-4.43.1.

@squidfunk
Copy link
Owner

@alexvoss does this work better for you now?

@alexvoss
Copy link
Collaborator Author

Did a quick test by modifying the mkdocs.yml files in one of our examples and it did get picked up. Thanks for fixing this. I will try and do some more work with the projects plugin in the coming days and will report any remaining issues I find but this fix and the other one that helped with newly created projects or those that do not use Material fix the two issues I had some across - IIRC.

@squidfunk
Copy link
Owner

That's great to hear! I'm really looking forward making the editing experience as smooth as possible.

@squidfunk
Copy link
Owner

Reopening, there still seem to be some issues.

@squidfunk squidfunk reopened this Dec 3, 2023
@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label Dec 3, 2023
@squidfunk
Copy link
Owner

I've started breaking the projects plugin into discernable parts that will make management of projects simpler, and address the issues with caching as well. This will take some more time, but I'm confident that I'll have a working prototype by the end of the week. I'll also fix #6399 on the way.

@squidfunk
Copy link
Owner

I wanted to wait with the next release until I finished the refactoring, but it's gotten so big, I needed to get it out before it wouldn't fit through the door anymore. I'll continue working on this and I'm close to having a working version fixing the caching issues and improving the overall structure of the plugin.

@squidfunk
Copy link
Owner

squidfunk commented Dec 10, 2023

Fixed in f1cb613. I did a rewrite of the plugin and changed the approach to caching, so the workaround suggested in #6306 (comment) is no longer needed. Also see #6399 (comment) to learn what the rewrite solved as well.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label Dec 10, 2023
@squidfunk
Copy link
Owner

Released as part of 9.5.2+insiders-4.47.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue reports a bug resolved Issue is resolved, yet unreleased if open
Projects
None yet
Development

No branches or pull requests

2 participants