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

Confusion around setting config values #642

Open
TomAugspurger opened this issue Feb 23, 2025 · 4 comments · May be fixed by #644
Open

Confusion around setting config values #642

TomAugspurger opened this issue Feb 23, 2025 · 4 comments · May be fixed by #644
Assignees
Labels
improvement Improves an existing functionality

Comments

@TomAugspurger
Copy link
Contributor

In #603 (comment), @bdice raised an issue that I also ran into with the kvikio.defaults system. We have three methods per option, typically:

  • kvikio.defaults.<option>
  • kvikio.defaults.set_<option>
  • kvikio.defaults.<option>_reset

It wasn't initially clear to me which of set_<option> and <option>_reset is method that immediately sets the value, and which is the one that must be used as a context manager. And I still mix it up occasionally.

I like the way donfig, which was based on the Dask config system, combines that into a single object that handles both immediately setting the value and is usable as a context manager.

>>> kvikio.defaults.set({option: value})  # set it permenantly

>>> with kvikio.defaults.set({option: value}): ...  # set it for the lifetime of the context manager
@bdice
Copy link
Contributor

bdice commented Feb 23, 2025

Yes, this API feels more Pythonic to me. I would support refactoring in this direction.

@madsbk
Copy link
Member

madsbk commented Feb 24, 2025

Agree, looks like a good idea!

I would be good to include config of cuFile's DriverProperties, which is currently just exposed as a class: https://github.com/rapidsai/kvikio/blob/branch-25.04/python/kvikio/kvikio/cufile_driver.py#L11

@kingcrimsontianyu kingcrimsontianyu self-assigned this Feb 24, 2025
@kingcrimsontianyu kingcrimsontianyu linked a pull request Feb 24, 2025 that will close this issue
@kingcrimsontianyu kingcrimsontianyu added the improvement Improves an existing functionality label Feb 24, 2025
@kingcrimsontianyu
Copy link
Contributor

kingcrimsontianyu commented Feb 25, 2025

I think DriverProperties has already been made pretty Pythonic with the @property decorator. Is this what you have in mind as further improvement? @madsbk

# Only allow non-read-only properties to be set this way
with kvikio.cufile_driver.set({"poll_mode": True, "max_device_cache_size": 4096})

@madsbk
Copy link
Member

madsbk commented Feb 25, 2025

Yes, I think it would be good to use the API style.

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

Successfully merging a pull request may close this issue.

4 participants