jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
511 stars 45 forks source link

mkdocs-material deployment with Groups plugin fails with Error: 'GroupPlugin' object has no attribute 'is_serve' #193

Closed shamoon closed 6 months ago

shamoon commented 7 months ago

Summary

Thanks for the awesome project. I recently upgraded to mike v2 and started hitting the error above when trying to deploy on ci (example run). I raised a discussion over at the mkdocs-material repo and one of the maintainers recommended I open an issue here, as it sounds like they think there could be a fix here in addition to a fix on their side.

They stated this issue occurs with the use of the Group plugin, apparently because on_config runs before on_startup was ever called. I think this comment is most relevant: https://github.com/squidfunk/mkdocs-material/discussions/6520#discussioncomment-7881006 . I'm not familiar-enough with either codebase to have much to add in terms of e.g. a PR

Of course, I defer to you guys about whether this is something to be changed in your project.

Configuration and Logs

Additional Context

relevant portion of our mkdocs.yml:

...
plugins:
  - group:
      enabled: !ENV MKINSIDERS
      plugins:
        - optimize
        - typeset
        - social

Thanks for your time

kamilkrzyskow commented 7 months ago

For continuity, since https://github.com/squidfunk/mkdocs-material/commit/55fe1ccc539098b71f15795f1d6ab8297cb41142 the Group plugin in mkdocs-material won't crash mike. However, running on_config without first running on_startup should still be addressed here. https://github.com/jimporter/mike/blob/533e996066579124a8c406c4d70e54fb78ac8dd6/mike/mkdocs_utils.py#L30-L33

shamoon commented 6 months ago

Thanks for your continued dedication to the project!

kamilkrzyskow commented 6 months ago

But why are both startup and shutdown being run during load of the config @jimporter? I feel like this will completely break the lifecycle of plugins that open a resource in startup then use it later in post_build and close the resource in shutdown. I think any event triggers should be outside of the load_config utils function and should be exported into the driver itself to mimic the proper event lifecycle, but I'm just guessing.

kamilkrzyskow commented 6 months ago

Unless this is a patch just for the load function, and later on it runs the full lifecycle again. I didn't check how the driver works in it's entirety.

jimporter commented 6 months ago

@kamilkrzyskow mike's loading of the config is totally separate from the mkdocs build action that happens later (mike can't really control MkDoc's internal plugin lifecycle anyway). This way avoids any possible strangeness with nested startup events, and gives plugins a chance to clean themselves up during the mike "pre-build" phase.

kamilkrzyskow commented 6 months ago

OK, if the mkdocs build happens later then it's all good, and sorry for jumping the gun. I'm still unsure whether or not running the on_config event for all plugins is really necessary during load, as it seems to me you only need to run the mike's plugin on_config event to get what you need. 🤔

jimporter commented 6 months ago

OK, if the mkdocs build happens later then it's all good, and sorry for jumping the gun. I'm still unsure whether or not running the on_config event for all plugins is really necessary during load, as it seems to me you only need to run the mike's plugin on_config event to get what you need. 🤔

Plugins can do arbitrary things to transform the config during on_config, so we probably want to do that. For example, someone could write a plugin that automatically fills in values for remote_branch and remote_name (or even fill in some special values for the mike plugin).