Skip to content

Allow backend kwargs to be passed via special keywords <backend>_kwargs= - #7297

Open
eriknw wants to merge 19 commits into
networkx:mainfrom
eriknw:backends_kwargs
Open

eriknw wants to merge 19 commits into
networkx:mainfrom
eriknw:backends_kwargs

Conversation

@eriknw

@eriknw eriknw commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

For example, add my_backend_kwargs={"be_awesome": True} to a dispatchable function call, which will add be_awesome=True when using my_backend and will ignore it otherwise. This should only be used for backend-specific keyword arguments.

CC @rlratzel

For example, add `my_backend_kwargs={"be_awesome": True}` to a dispatchable function call,
which will add `be_awesome=True` when using `my_backend` and will ignore it otherwise.
This should only be used for backend-specific keyword arguments.
@eriknw

eriknw commented Feb 15, 2024

Copy link
Copy Markdown
Contributor Author

One potential shortcoming of this is that this only works for backends that are valid identifiers. I think this is fine.

@dschult dschult added type: Enhancements Dispatching Related to dispatching and backend support labels Feb 15, 2024
@dschult dschult changed the title Allow backend kwargs to be passed via special keywords *_kwargs= Allow backend kwargs to be passed via special keywords <backend>_kwargs= Jun 26, 2024
@eriknw

eriknw commented Jul 1, 2024

Copy link
Copy Markdown
Contributor Author

I updated the docs to explain this feature (I was waiting on #7404). This means this is implemented, tested, and documented (and we had discussed and generally liked this spelling a long time ago), so now this is waiting on final review.

@eriknw

eriknw commented Jul 25, 2024

Copy link
Copy Markdown
Contributor Author

This PR should now be much easier to review now that #7494 has been merged (thanks for that!) since both PRs renamed nx-loopback to nx_loopback.

Comment thread networkx/utils/backends.py Resolved

@MridulS MridulS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, maybe we should log the silent dropping of unknown *_kwargs.

@eriknw

eriknw commented Jul 31, 2024

Copy link
Copy Markdown
Contributor Author

Looks good, maybe we should log the silent dropping of unknown *_kwargs.

Thanks for the reviews! I have added a log message for backends that are not installed (or e.g. misspelled).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dispatching Related to dispatching and backend support type: Enhancements

Development

Successfully merging this pull request may close these issues.

4 participants