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

auto-loading settings #689

Closed
edublancas opened this issue Jun 29, 2023 · 2 comments · Fixed by #726
Closed

auto-loading settings #689

edublancas opened this issue Jun 29, 2023 · 2 comments · Fixed by #726
Assignees
Labels
stash Label used to categorize issues that will be worked on next

Comments

@edublancas
Copy link

we have a bunch of configuration settings that users can tweak. However, to change them, users have to put them in all their notebooks.

A better alternative would be to let them define the config project-wide in a pyproject.toml file (which is becoming standard in the Python ecosystem).

Example, a sample pyproject.toml could look like this:

[tool.jupysql.SqlMagic]
feedback = true
autopandas = true

Note that we should recursively look for the pyproject.toml, you can copy this function.

This behavior should be triggered when loading the extension. e.g., running %load_ext sql should display a message if a pyproject.toml is found and it should print the loaded settings and its values.

Some edge cases:

  • if the option doesn't exist, we should display a message when loading the settings
  • if there's a typo, we should provide a did you mean {x}? hint in the message (e.g., fedback instead of feedback)
  • if assigning the value throws an error, we should show a message and tell the user, the default value will be used

e.g., the user has autopandas="not-a-valid-value"

@edublancas edublancas added stash Label used to categorize issues that will be worked on next med complexity labels Jun 29, 2023
@bbeat2782
Copy link

Acceptance Criteria

  1. Running %load_ext sql triggers pyproject.toml file and displays a message that it found the file, prints out loaded settings, and changes configuration settings
  2. If pyproject.toml does not exist, it displays a message
  3. If there's a typo on one of the settings, it displays a message hinting at what a user might intend
  4. If an invalid value for setting is provided, it displays a message that it is not a valid value and uses the default value instead.
  5. Add documentation for explaining setting up pyproject.toml
  6. Add test functions

@edublancas
Copy link
Author

edublancas commented Jul 11, 2023

A few observations:

Running %load_ext sql triggers pyproject.toml file and displays a message that it found the file, prints out loaded settings, and changes configuration settings

This should trigger loading the file and notify the user if it found it. it should also look up in parent directories (in case the notebook is in project/notebooks/mynotebook.ipynb but the config file is in project/pyproject.toml)

If pyproject.toml does not exist, it displays a message

No need to do anything if the file doesn't exist

If there's a typo on one of the settings, it displays a message hinting at what a user might intend
If an invalid value for setting is provided, it displays a message that it is not a valid value and uses the default value instead.

these two are highly related. you can use difflib if there's something in the config file (under the tool.jupysql.SqlMagic section) that doesn't exist, you check if there are close matches. if so, the error message should suggest the fixed version. if there are no close matches, you simply return the value in the config file and tell the user that those are invalid, and show a link to the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stash Label used to categorize issues that will be worked on next
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants