-
Notifications
You must be signed in to change notification settings - Fork 135
feat/making global context accessible for users #1060
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
Changes from 7 commits
72a6b5f
b7fea47
597ef33
3751cf5
14ee8b3
9e90b81
a9c5b35
f716fb8
b2bbf33
8534f51
ae9b6a2
069c4a3
d124275
5433f01
2baf728
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 |
|---|---|---|
|
|
@@ -468,6 +468,8 @@ class SessionContext: | |
| See :ref:`user_guide_concepts` in the online documentation for more information. | ||
| """ | ||
|
|
||
| _global_instance = None | ||
|
|
||
| def __init__( | ||
| self, | ||
| config: SessionConfig | None = None, | ||
|
|
@@ -498,6 +500,18 @@ def __init__( | |
|
|
||
| self.ctx = SessionContextInternal(config, runtime) | ||
|
|
||
| @classmethod | ||
| def global_ctx(cls) -> "SessionContextInternal": | ||
|
||
| """Retrieve the global context. | ||
|
|
||
| Returns: | ||
| A `SessionContextInternal` object that corresponds to the global context | ||
| """ | ||
| if cls._global_instance is None: | ||
| internal_ctx = SessionContextInternal.global_ctx() | ||
| cls._global_instance = internal_ctx | ||
| return cls._global_instance | ||
|
|
||
| def enable_url_table(self) -> "SessionContext": | ||
| """Control if local files can be queried as tables. | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,7 +308,7 @@ impl PySessionContext { | |
|
|
||
| #[classmethod] | ||
| #[pyo3(signature = ())] | ||
| fn _global_ctx(_cls: &Bound<'_, PyType>) -> PyResult<Self> { | ||
| fn global_ctx(_cls: &Bound<'_, PyType>) -> PyResult<Self> { | ||
|
Member
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. As you have it here where you moved the single entry over to the python side, this method goes unused. I would recommend you leave this line as is, but up in the python code you call this method instead of creating
Contributor
Author
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. Thanks for your comments, just to summarize whats needed here:
Am I interpreting this correctly? Sorry if I'm overthinking this 😅. I've updated the PR, currently the
Member
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, this description looks correct. |
||
| Ok(Self { | ||
| ctx: get_global_ctx().clone(), | ||
| }) | ||
|
|
||
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.
Why move this from the rust code to the python code?