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

ENH: Fix config for xorbits and xorbits.pandas #818

Merged
merged 14 commits into from
Oct 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
config
luweizheng committed Oct 5, 2024
commit 6ac1d68b7f1008f7fc3a55a340037aa87f52f555
4 changes: 2 additions & 2 deletions python/xorbits/__init__.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
from . import _version
from .core import run
from .deploy import init, shutdown

from .config import option_context, options

def _install():
from .datasets import _install as _install_datasets
@@ -44,4 +44,4 @@ def _install():

__version__ = _version.get_versions()["version"]

__all__ = ["init", "shutdown", "run"]
__all__ = ["init", "shutdown", "run", "options", "option_context"]
1 change: 1 addition & 0 deletions python/xorbits/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from ._mars.config import option_context, options # noqa: F401
24 changes: 16 additions & 8 deletions python/xorbits/pandas/_config/config.py
Original file line number Diff line number Diff line change
@@ -66,18 +66,26 @@ def __init__(self, *args):
except:
mars_dict[key] = value

self.option_contexts = mars_option_context(mars_dict)
self.pandas_option_context = pd.option_context(
*tuple(item for sublist in pd_dict.items() for item in sublist)
)
self.option_contexts = None
self.pandas_option_context = None
if mars_dict:
self.option_contexts = mars_option_context(mars_dict)
if pd_dict:
self.pandas_option_context = pd.option_context(
*tuple(item for sublist in pd_dict.items() for item in sublist)
)

def __enter__(self):
self.option_contexts.__enter__()
self.pandas_option_context.__enter__()
if self.option_contexts:
self.option_contexts.__enter__()
if self.pandas_option_context:
self.pandas_option_context.__enter__()

def __exit__(self, type, value, traceback):
self.option_contexts.__exit__(type, value, traceback)
self.pandas_option_context.__exit__(type, value, traceback)
if self.option_contexts:
self.option_contexts.__exit__(type, value, traceback)
if self.pandas_option_context:
self.pandas_option_context.__exit__(type, value, traceback)


def set_eng_float_format(accuracy: int = 3, use_eng_prefix: bool = False) -> None: