MCPcopy
hub / github.com/ray-project/ray / get_current

Method get_current

python/ray/data/context.py:956–990  ·  view source on GitHub ↗

Get or create the current DataContext. When a Dataset is created, the current DataContext will be sealed. Changes to `DataContext.get_current()` will not impact existing Datasets. Examples: .. testcode:: import ray context = ray

()

Source from the content-addressed store, hash-verified

954
955 @staticmethod
956 def get_current() -> "DataContext":
957 """Get or create the current DataContext.
958
959 When a Dataset is created, the current DataContext will be sealed.
960 Changes to `DataContext.get_current()` will not impact existing Datasets.
961
962 Examples:
963
964 .. testcode::
965 import ray
966
967 context = ray.data.DataContext.get_current()
968
969 context.target_max_block_size = 100 * 1024 ** 2
970 ds1 = ray.data.range(1)
971 context.target_max_block_size = 1 * 1024 ** 2
972 ds2 = ray.data.range(1)
973
974 # ds1's target_max_block_size will be 100MB
975 ds1.take_all()
976 # ds2's target_max_block_size will be 1MB
977 ds2.take_all()
978
979 Developer notes: Avoid using `DataContext.get_current()` in data
980 internal components, use the DataContext object captured in the
981 Dataset and pass it around as arguments.
982 """
983
984 global _default_context
985
986 with _context_lock:
987 if _default_context is None:
988 _default_context = DataContext()
989
990 return _default_context
991
992 @staticmethod
993 @contextlib.contextmanager

Callers 15

batch_to_blockMethod · 0.45
__init__Method · 0.45
handle_traceFunction · 0.45
random_sampleMethod · 0.45
random_splitMethod · 0.45
__init__Method · 0.45
from_blocksFunction · 0.45
from_itemsFunction · 0.45
_read_datasource_v2Function · 0.45
read_datasourceFunction · 0.45
read_parquetFunction · 0.45
read_jsonFunction · 0.45

Calls 1

DataContextClass · 0.85

Tested by

no test coverage detected