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

Fix #8: Incremental building not working #14

Closed

Conversation

kujiu
Copy link

@kujiu kujiu commented Jun 4, 2020

Changing config parameters after config provokes regenerating all files. This PR update config parameters during config-inited event.

@jonascj
Copy link
Collaborator

jonascj commented Jun 8, 2020

Thank you, at first glance it looks good. I have however not dealt with the module configuration before so I will need some time to replicate your findings from Issue #8 and review the changes proposed in this PR.

I plan on having it done this week. Do you think we should make a new release with this fix?

@kujiu
Copy link
Author

kujiu commented Jun 8, 2020

I think it could be a good idea. I have no plan to code during next weeks for this project (I need more time...).

Copy link

@terencehonles terencehonles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonascj this PR looks like it fixes the issue for me too. Looking at Sphinx itself, it checks if the project needs to be rebuilt when it creates the env specifically in BuildEnvironment._update_config which is called by BuildEnvironment.setup which happens between the events "config-inited" and "builder-inited" and is why any config needs to happen earlier than it is already.

Comment on lines +268 to 273
def configure_backend(app, main_config):
global DEFAULT_CONFIG

config = copy.deepcopy(DEFAULT_CONFIG)
config.update(app.config.images_config)
app.config.images_config = config

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably use the main_config directly since it's provided, but I'm not sure if there is a good reason why the hook has both app and the config though.

Suggested change
def configure_backend(app, main_config):
global DEFAULT_CONFIG
config = copy.deepcopy(DEFAULT_CONFIG)
config.update(app.config.images_config)
app.config.images_config = config
def check_config(app, config):
'''Ensure all config values are defined'''
merged = copy.deepcopy(DEFAULT_CONFIG)
merged.update(config.images_config)
config.images_config = merged

global DEFAULT_CONFIG

config = copy.deepcopy(DEFAULT_CONFIG)
config.update(app.config.images_config)
app.config.images_config = config

def builder_init(app):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still configuring the backend and probably shouldn't be renamed

Suggested change
def builder_init(app):
def configure_backend(app):

Comment on lines +351 to +352
app.connect('config-inited', configure_backend)
app.connect('builder-inited', builder_init)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the suggestions above:

Suggested change
app.connect('config-inited', configure_backend)
app.connect('builder-inited', builder_init)
app.connect('config-inited', check_config)
app.connect('builder-inited', configure_backend)

@@ -346,7 +348,8 @@ def setup(app):
global DEFAULT_CONFIG

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This global declaration isn't needed, and it might be good to remove it while you're editing this file

@@ -346,7 +348,8 @@ def setup(app):
global DEFAULT_CONFIG
app.require_sphinx('1.0')
app.add_config_value('images_config', DEFAULT_CONFIG, 'env')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this isn't actually needed because the configuration will be merged anyways, it might make sense to just pass a dict which also wouldn't break when copying it.

Suggested change
app.add_config_value('images_config', DEFAULT_CONFIG, 'env')
app.add_config_value('images_config', {}, 'env')

@jonascj
Copy link
Collaborator

jonascj commented Aug 20, 2020

How time flies when you have a baby and a 3-year-old! Please accept my apologies for not attending to the PRs and issues in a timely fashion. I'll attend to them at the latest on August 29th and 30th (I have another project with deadline on August 28th).

@terencehonles
Copy link

terencehonles commented Aug 20, 2020

How time flies when you have a baby and a 3-year-old! Please accept my apologies for not attending to the PRs and issues in a timely fashion. I'll attend to them at the latest on August 29th and 30th (I have another project with deadline on August 28th).

@jonascj not sure @kujiu has had a chance to review my suggestions, but if you'd like me to add my suggestions to another branch and create a PR off of that I can do so. I'd leave attribution for @kujiu so they'll get credit for their work.

@kujiu
Copy link
Author

kujiu commented Aug 20, 2020

Sorry, I didn't see the notification for comments. I don't have time this week and perhaps the next too, but I don't care about credits. You can do the stuff and erase my contribution if you want. Sorry, I have really big projects.

@jonascj
Copy link
Collaborator

jonascj commented Aug 20, 2020

@terencehonles I just meant I'll go over the PR/issue discussions, start reviewing contributions etc. I have no desire to redo good work already done. So if @kujiu has found a good, viable solution we'll use it and credit him one way or another, don't worry.

@terencehonles
Copy link

Sorry, I didn't see the notification for comments. I don't have time this week and perhaps the next too, but I don't care about credits. You can do the stuff and erase my contribution if you want. Sorry, I have really big projects.

No worries @kujiu , I wasn't sure if you were checking your github notifications often. I updated the commit here: terencehonles@f1184cd

You can quickly update this PR with the following commands:

# fetch from my repo without adding another remote
git fetch [email protected]:terencehonles/sphinx-contrib-images.git master-fix-incremental-build

# take what you just fetched and push it to the branch this PR is tracking
git push origin +FETCH_HEAD:master-fix-incremental-build

@terencehonles I just meant I'll go over the PR/issue discussions, start reviewing contributions etc. I have no desire to redo good work already done. So if @kujiu has found a good, viable solution we'll use it and credit him one way or another, don't worry.

@jonascj the suggestions are not re-doing anything, just clarifying what the plugin is doing with respect to the changes in the PR

@SilverRainZ
Copy link

Any progress?

@terencehonles
Copy link

Any progress?

I opened a PR (#18) with my suggestions, but either way we'll need a little time from @jonascj to test and merge them.

@jonascj
Copy link
Collaborator

jonascj commented Jan 6, 2021

@terencehonles Thank you for moving it forward, I'll try to look at it this coming weekend (9th, 10th January).

@SilverRainZ When you asked there was no new progress, no, but now there is a little progress.

See also #20 :-)

@jonascj
Copy link
Collaborator

jonascj commented Apr 27, 2021

Merged #18 which was based on this #14.

@jonascj jonascj closed this Apr 27, 2021
@terencehonles
Copy link

sorry I had too many tabs open and looks like I put it on the wrong one 🤦 it's fixed now

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

Successfully merging this pull request may close these issues.

4 participants