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

Rename Datasette.__init__(config=) parameter to settings= #1432

Closed
simonw opened this issue Aug 13, 2021 · 9 comments
Closed

Rename Datasette.__init__(config=) parameter to settings= #1432

simonw opened this issue Aug 13, 2021 · 9 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 13, 2021

While I'm doing this I should rename this internal variable to avoid confusion in the future:

config=None,

Originally posted by @simonw in #1431 (comment)

@simonw
Copy link
Owner Author

simonw commented Aug 13, 2021

Also this method:

datasette/datasette/app.py

Lines 422 to 424 in 77f4629

def config_dict(self):
# Returns a fully resolved config dictionary, useful for templates
return {option.name: self.setting(option.name) for option in SETTINGS}

And the places that use it:

"config": self.ds.config_dict(),

"config": self.ds.config_dict(),

Which is used in this template:

{% if next_url and config.allow_csv_stream %}<label><input type="checkbox" name="_stream"> stream all rows</label>{% endif %}

@simonw
Copy link
Owner Author

simonw commented Aug 13, 2021

This is going to break some plugins: https://ripgrep.datasette.io/-/ripgrep?pattern=config%3D&literal=on&glob=%21datasette%2F**

datasette-cluster-map/tests/test_cluster_map.py

@pytest.mark.asyncio

async def test_respects_base_url():
ds = Datasette([], memory=True, config={"base_url": "/foo/"})
response = await ds.client.get("/:memory:?sql=select+1+as+latitude,+2+as+longitude")
assert (

datasette-export-notebook/tests/test_export_notebook.py

@pytest.mark.asyncio

async def test_notebook_no_csv(db_path):
datasette = Datasette([db_path], config={"allow_csv_stream": False})
response = await datasette.client.get("/db/big.Notebook")
assert ".csv" not in response.text

datasette-publish-vercel/tests/test_publish_vercel.py

metadata=metadata,
cors=True,
config={"default_page_size": 10, "sql_time_limit_ms": 2000}
).app()
"""

datasette-publish-vercel/datasette_publish_vercel/init.py

metadata=metadata{extras},
cors=True,
config={settings}

).app()

""".strip()

datasette-search-all/tests/test_search_all.py

async def test_base_url(db_path, path):
sqlite_utils.Database(db_path)["creatures"].enable_fts(["name", "description"])
datasette = Datasette([db_path], config={"base_url": "/foo/"})
response = await datasette.client.get(path)
assert response.status_code == 200

I should fix those as soon as this goes out in a release. I won't close this issue until then.

simonw added a commit that referenced this issue Aug 13, 2021
@simonw
Copy link
Owner Author

simonw commented Aug 13, 2021

It's only datasette-publish-vercel that will break the actual functionality - the others will have broken tests.

@ashishdotme
Copy link

ashishdotme commented Oct 12, 2021

Any workaround for making it work with datasette-publish-vercel. Currently getting below error

module initialization error: init() got an unexpected keyword argument 'config'
module initialization error
init() got an unexpected keyword argument 'config'

@ashishdotme
Copy link

Nevermind, had to remove the branch argument in the workflow to make vercel publish work

@ashishdotme
Copy link

@simonw I am getting the below issue again now, even after removing branch argument from vercel datasette plugin

module initialization error: init() got an unexpected keyword argument 'config'
module initialization error
init() got an unexpected keyword argument 'config'

@mroswell
Copy link
Sponsor Contributor

I am getting this when I visit my live Datasette page:

This Serverless Function has crashed.
Your connection is working correctly.
Vercel is working correctly.
500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
ID: ...

And in the server logs, I'm getting

[GET] /disinfectants/listN
19:53:14:23
module initialization error: __init__() got an unexpected keyword argument 'config'
module initialization error
__init__() got an unexpected keyword argument 'config'

Which is the same error that @ashishdotme reported above.

@mroswell
Copy link
Sponsor Contributor

Resolved, with assistance from @ashishdotme (Thank you!)

Updated requirements.txt to include:

datasette==0.59
datasette-publish-vercel==0.11
sqlite-utils==3.6

Ran:

$ pip3 install -r requirements.txt

The site is back at work! Yay!

@simonw
Copy link
Owner Author

simonw commented Jan 10, 2024

This issue is obsolete thanks to the new metadata v.s. config change in Datasette 1.0.

@simonw simonw closed this as completed Jan 10, 2024
@simonw simonw added the wontfix label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants