-
Notifications
You must be signed in to change notification settings - Fork 63
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
744 default api key #752
744 default api key #752
Changes from 5 commits
92ebecb
aab511d
234ced5
64e9cf2
f0dba45
241c398
e4ef706
c2e73b2
2e8d187
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
_default_context = None | ||
|
||
|
||
def set_default_context(context=None, base_url=None, api_key=None, creds=None, session=None): | ||
def set_default_context(context=None, base_url=None, api_key='default_public', creds=None, session=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels a little strange to me that Some ideas to get around this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. The first param can be a context or a base_url. Renaming it to be more generic is a good approach to me. |
||
"""set_default_context | ||
|
||
From a pair base_url, api_key. | ||
|
@@ -20,6 +20,14 @@ def set_default_context(context=None, base_url=None, api_key=None, creds=None, s | |
api_key='your api key' | ||
) | ||
|
||
From a base_url (for public datasets) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the idea of educating the user about what's happening. How about saying something about how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
.. code:: | ||
|
||
from cartoframes.auth import set_default_context | ||
|
||
set_default_context('https://your_user_name.carto.com') | ||
|
||
From context. | ||
|
||
.. code:: | ||
|
@@ -47,8 +55,8 @@ def set_default_context(context=None, base_url=None, api_key=None, creds=None, s | |
global _default_context | ||
if isinstance(context, Context): | ||
_default_context = context | ||
elif isinstance(base_url, str) and isinstance(api_key, str): | ||
_default_context = Context(base_url=base_url, api_key=api_key, session=session) | ||
elif isinstance(base_url or context, str) and isinstance(api_key, str): | ||
_default_context = Context(base_url=(base_url or context), api_key=api_key, session=session) | ||
elif isinstance(creds, Credentials): | ||
_default_context = Context(creds=creds, session=session) | ||
else: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing the
Args
section of the docs here. Is that going to happen package-wide in another PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll add it in this PR