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

Don't call render_targets() from get_targets() when all requested targets are cached #1141

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

simu
Copy link
Contributor

@simu simu commented Feb 16, 2024

Proposed Changes

Only render Reclass inventory if render_targets() is called with either targets=None or a non-empty list of targets to render. Without this, the whole Reclass inventory is rendered for pretty much every call to get_targets() since that method calls render_targets() with targets=[] if it already has parameters for all targets.

Docs and Tests

  • Tests added
  • Updated documentation

@simu simu mentioned this pull request Feb 20, 2024
2 tasks
Copy link
Contributor

@MatteoVoges MatteoVoges left a comment

Choose a reason for hiding this comment

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

The idea of the targets list was to give the backend control about the strategy for rendering specified targets. As reclass has no such concept ( afaik it has single target and everything) I thought we would render everything regardless, which targets are specified or even if any targets are specified.

Maybe we should remove the default value None for targets, so that the logic of not rendering with empty targets can live at a higher level.

I just wanted to move away from the behavior empty list = all targets, to make it more explicit.

@simu
Copy link
Contributor Author

simu commented Feb 20, 2024

I just wanted to move away from the behavior empty list = all targets, to make it more explicit.

That's fine, but the ReclassInventory backend doesn't actually respect empty list == no targets without this PR

@simu
Copy link
Contributor Author

simu commented Feb 20, 2024

As reclass has no such concept ( afaik it has single target and everything) I thought we would render everything regardless, which targets are specified or even if any targets are specified.

If you want to selectively render targets ("nodes" in reclass terminology), you could use nodeinfo()

@MatteoVoges
Copy link
Contributor

MatteoVoges commented Feb 21, 2024

That's fine, but the ReclassInventory backend doesn't actually respect empty list == no targets without this PR

I see, what about just adding an if targets_to_render: inside the get_targets() method?
Because I still think, this should be a general and not backend specific thing.

@simu
Copy link
Contributor Author

simu commented Feb 21, 2024

That's fine, but the ReclassInventory backend doesn't actually respect empty list == no targets without this PR

I see, what about just adding an if targets_to_render: inside the get_targets() method? Because I still think, this should be a general and not backend specific thing.

I assumed that render_targets(targets=[]) probably works as expected (i.e. doesn't render anything) with OmegaConf, so I thought I'd just fix it in the Reclass backend. I'm happy to adjust get_targets() to not even call render_targets() if it decides that nothing needs to be rendered.

@simu simu changed the title Don't re-render Reclass inventory if render_targets() is called with an empty list of targets to render Don't call render_targets() from get_targets() when all requested targets are cached Feb 21, 2024
Copy link
Contributor

@MatteoVoges MatteoVoges left a comment

Choose a reason for hiding this comment

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

Thanks for the update!

@MatteoVoges MatteoVoges merged commit 6b4a02c into kapicorp:master Feb 21, 2024
7 checks passed
@simu simu deleted the fix/inventory-caching branch February 21, 2024 15:58
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.

2 participants