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

Improve plugin options #949

Merged
merged 22 commits into from
Oct 11, 2024
Merged

Improve plugin options #949

merged 22 commits into from
Oct 11, 2024

Conversation

jesper-friis
Copy link
Collaborator

@jesper-friis jesper-friis commented Sep 12, 2024

Description

Improve option handling for plugins. This PR tries:

  • Remove the limits on possible option values you can pass to storage plugins, due to the restriction imposed by the allowed characters in the query part of an URL. This currently poses a strong limits what data you can pass as an option.
  • Make it more convenient to pass options to plugins (transparent URL encoding).
  • Allow option values to be any JSON-serialisable Python object.

Tasks:

  • Implement URL-encoding/decoding in C
  • Make URL-encoding/decoding accessele to Python
  • Let dlite_option_parse() transparently URL-decode the option string
  • Let Options Python class transparently URL-decode the option string
  • Add Python API for creating an option string from a dict that transparently URL-encode the values
  • Allow to provide options as dict to the high-level Python API, like Storage, and Instance.save(), ...

Type of change

  • Bug fix & code cleanup
  • New feature
  • Documentation update
  • Test update

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?

@jesper-friis jesper-friis marked this pull request as draft September 12, 2024 06:42
@jesper-friis jesper-friis changed the title WIP: Improve plugin options Improve plugin options Oct 8, 2024
@jesper-friis jesper-friis marked this pull request as ready for review October 8, 2024 07:29

Default values may be provided via the `defaults` argument. It
should either be a dict or a string of the same form as `options`.
Arguments:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Arguments? Instance Variables I suppose? And shouldn't this be in the docstring og the init?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are right, the arguments refer to the arguments passed to the __init__() method. But it is common to document arguments in the class docstring. I like to do it for the following reasons:

  • In case the class has both a __new__() and a __init__() method, we don't need to duplicate the argument documentation if we keep it in the class docstring.
  • The __new__() and __init__() methods starts with an underscore and may be hidden by some documentation systems.

jesper-friis and others added 3 commits October 9, 2024 23:08
Co-authored-by: Francesca L. Bleken <48128015+francescalb@users.noreply.github.com>
Co-authored-by: Francesca L. Bleken <48128015+francescalb@users.noreply.github.com>
Co-authored-by: Francesca L. Bleken <48128015+francescalb@users.noreply.github.com>
@jesper-friis jesper-friis merged commit 6c36dee into master Oct 11, 2024
14 checks passed
@jesper-friis jesper-friis deleted the option_encode branch October 11, 2024 09:04
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.

Document builtin storage plugins
2 participants