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

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

Closed
shamoon opened this issue Dec 18, 2023 · 7 comments

Comments

@shamoon
Copy link

shamoon commented Dec 18, 2023

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: squidfunk/mkdocs-material#6520 (reply in thread) . 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

@shamoon shamoon changed the title mkdocs-material deployment with Groups plugin fails with Error: 'GroupPlugin' object has no attribute 'is_serve' when deploying with mike mkdocs-material deployment with Groups plugin fails with Error: 'GroupPlugin' object has no attribute 'is_serve' Dec 18, 2023
@kamilkrzyskow
Copy link

For continuity, since squidfunk/mkdocs-material@55fe1cc the Group plugin in mkdocs-material won't crash mike. However, running on_config without first running on_startup should still be addressed here.

def load_config(config_file=None, **kwargs):
with _open_config(config_file) as f:
cfg = mkdocs.config.load_config(f, **kwargs)
return cfg['plugins'].run_event('config', cfg)

jimporter added a commit that referenced this issue Dec 28, 2023
…#193

I'm not totally convinced this is the right thing to do, since mike doesn't have
the same lifecycle as MkDocs, but whatever...
jimporter added a commit that referenced this issue Dec 28, 2023
…#193

I'm not totally convinced this is the right thing to do, since mike doesn't have
the same lifecycle as MkDocs, but whatever...
@shamoon
Copy link
Author

shamoon commented Dec 28, 2023

Thanks for your continued dedication to the project!

@kamilkrzyskow
Copy link

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
Copy link

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
Copy link
Owner

@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
Copy link

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
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants