code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def to_list(self):
"""Convert tuple to a list where None is always first."""
output = []
if self.none:
output.append(None)
if self.nan:
output.append(np.nan)
return output | Convert tuple to a list where None is always first. | to_list | python | mars-project/mars | mars/learn/utils/_encode.py | https://github.com/mars-project/mars/blob/master/mars/learn/utils/_encode.py | Apache-2.0 |
def _extract_missing(values): # pragma: no cover
"""Extract missing values from `values`.
Parameters
----------
values: set
Set of values to extract missing from.
Returns
-------
output: set
Set with missing values extracted.
missing_values: MissingValues
Obje... | Extract missing values from `values`.
Parameters
----------
values: set
Set of values to extract missing from.
Returns
-------
output: set
Set with missing values extracted.
missing_values: MissingValues
Object with missing value information.
| _extract_missing | python | mars-project/mars | mars/learn/utils/_encode.py | https://github.com/mars-project/mars/blob/master/mars/learn/utils/_encode.py | Apache-2.0 |
def _map_to_integer(values, uniques, check_unknown=True):
"""Map values based on its position in uniques."""
def mapper(values_data, uniques_data):
if values_data.dtype.kind in "OUS":
try:
table = _nandict({val: i for i, val in enumerate(uniques_data)})
retur... | Map values based on its position in uniques. | _map_to_integer | python | mars-project/mars | mars/learn/utils/_encode.py | https://github.com/mars-project/mars/blob/master/mars/learn/utils/_encode.py | Apache-2.0 |
def _check_unknown(values, known_values, return_mask=False): # pragma: no cover
"""
Helper function to check for unknowns in values to be encoded.
Uses pure python method for object dtype, and numpy method for
all other dtypes.
Parameters
----------
values : array
Values to check ... |
Helper function to check for unknowns in values to be encoded.
Uses pure python method for object dtype, and numpy method for
all other dtypes.
Parameters
----------
values : array
Values to check for unknowns.
known_values : array
Known values. Must be unique.
return_... | _check_unknown | python | mars-project/mars | mars/learn/utils/_encode.py | https://github.com/mars-project/mars/blob/master/mars/learn/utils/_encode.py | Apache-2.0 |
def is_set(self, bitno):
"""Return true iff bit number bitno is set"""
byteno, bit_within_wordno = divmod(bitno, 8)
mask = 1 << bit_within_wordno
byte = self.mmap[byteno]
return byte & mask | Return true iff bit number bitno is set | is_set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def set(self, bitno):
"""set bit number bitno to true"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
byte = self.mmap[byteno]
byte |= mask
self.mmap[byteno] = byte | set bit number bitno to true | set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def clear(self, bitno):
"""clear bit number bitno - set it to false"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
byte = self.mmap[byteno]
byte &= Mmap_backend.effs - mask
self.mmap[byteno] = byte | clear bit number bitno - set it to false | clear | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def is_set(self, bitno):
"""Return true iff bit number bitno is set"""
byteno, bit_within_wordno = divmod(bitno, 8)
mask = 1 << bit_within_wordno
os.lseek(self.file_, byteno, os.SEEK_SET)
byte = os.read(self.file_, 1)[0]
return byte & mask | Return true iff bit number bitno is set | is_set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def set(self, bitno):
"""set bit number bitno to true"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
os.lseek(self.file_, byteno, os.SEEK_SET)
byte = os.read(self.file_, 1)[0]
byte |= mask
os.lseek(self.file_, byteno, os.SEEK_SET)
... | set bit number bitno to true | set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def clear(self, bitno):
"""clear bit number bitno - set it to false"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
os.lseek(self.file_, byteno, os.SEEK_SET)
byte = os.read(self.file_, 1)[0]
byte &= File_seek_backend.effs - mask
os.l... | clear bit number bitno - set it to false | clear | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def is_set(self, bitno):
"""Return true iff bit number bitno is set"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
if byteno < self.bytes_in_memory:
return self.array_[byteno] & mask
else:
os.lseek(self.file_, byteno, os.SEEK... | Return true iff bit number bitno is set | is_set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def set(self, bitno):
"""set bit number bitno to true"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = 1 << bit_within_byteno
if byteno < self.bytes_in_memory:
self.array_[byteno] |= mask
else:
os.lseek(self.file_, byteno, os.SEEK_SET)
by... | set bit number bitno to true | set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def clear(self, bitno):
"""clear bit number bitno - set it to false"""
byteno, bit_within_byteno = divmod(bitno, 8)
mask = Array_backend.effs - (1 << bit_within_byteno)
if byteno < self.bytes_in_memory:
self.array_[byteno] &= mask
else:
os.lseek(self.file_... | clear bit number bitno - set it to false | clear | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def close(self):
"""
Write the in-memory portion to disk, leave the already-on-disk portion
unchanged
"""
os.lseek(self.file_, 0, os.SEEK_SET)
os.write(self.file_, bytes(self.array_[0 : self.bytes_in_memory]))
os.close(self.file_) |
Write the in-memory portion to disk, leave the already-on-disk portion
unchanged
| close | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def is_set(self, bitno):
"""Return true iff bit number bitno is set"""
wordno, bit_within_wordno = divmod(bitno, 32)
mask = 1 << bit_within_wordno
return self.array_[wordno] & mask | Return true iff bit number bitno is set | is_set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def set(self, bitno):
"""set bit number bitno to true"""
wordno, bit_within_wordno = divmod(bitno, 32)
mask = 1 << bit_within_wordno
self.array_[wordno] |= mask | set bit number bitno to true | set | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def clear(self, bitno):
"""clear bit number bitno - set it to false"""
wordno, bit_within_wordno = divmod(bitno, 32)
mask = Array_backend.effs - (1 << bit_within_wordno)
self.array_[wordno] &= mask | clear bit number bitno - set it to false | clear | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def get_bitno_seed_rnd(bloom_filter, key):
"""
Apply num_probes_k hash functions to key.
Generate the array index and bitmask corresponding to each result.
"""
# We're using key as a seed to a pseudorandom number generator
hasher = random.Random(key).randrange
for dummy in range(bloom_filte... |
Apply num_probes_k hash functions to key.
Generate the array index and bitmask corresponding to each result.
| get_bitno_seed_rnd | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def simple_hash(int_list, prime1, prime2, prime3):
"""Compute a hash value from a list of integers and 3 primes"""
result = 0
for integer in int_list:
result += ((result + integer + prime1) * prime2) % prime3
return result | Compute a hash value from a list of integers and 3 primes | simple_hash | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def get_filter_bitno_probes(bloom_filter, key):
"""
Apply num_probes_k hash functions to key.
Generate the array index and bitmask corresponding to each result
"""
# This one assumes key is either bytes or str (or other list of integers)
if hasattr(key, "__divmod__"):
int_list = []
... |
Apply num_probes_k hash functions to key.
Generate the array index and bitmask corresponding to each result
| get_filter_bitno_probes | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def try_unlink(filename):
"""unlink a file. Don't complain if it's not there"""
try:
os.unlink(filename)
except OSError:
pass
return | unlink a file. Don't complain if it's not there | try_unlink | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def _match_template(self, bloom_filter):
"""
Compare a sort of signature for two bloom filters.
Used in preparation for binary operations
"""
return (
self.num_bits_m == bloom_filter.num_bits_m
and self.num_probes_k == bloom_filter.num_probes_k
... |
Compare a sort of signature for two bloom filters.
Used in preparation for binary operations
| _match_template | python | mars-project/mars | mars/lib/bloom_filter.py | https://github.com/mars-project/mars/blob/master/mars/lib/bloom_filter.py | Apache-2.0 |
def compress(file: BinaryIO, compress_type: str) -> BinaryIO:
"""
Return a compressed file object.
Parameters
----------
file:
file object.
compress_type: str
compression type.
Returns
-------
compressed_file:
compressed file object.
"""
try:
... |
Return a compressed file object.
Parameters
----------
file:
file object.
compress_type: str
compression type.
Returns
-------
compressed_file:
compressed file object.
| compress | python | mars-project/mars | mars/lib/compression.py | https://github.com/mars-project/mars/blob/master/mars/lib/compression.py | Apache-2.0 |
def get_cuda_context() -> CudaContext:
"""Check whether the current process already has a CUDA context created."""
_init()
if _init_pid is None:
return CudaContext(has_context=False)
for index in range(_get_all_device_count()):
handle = get_handle_by_index(index)
try:
... | Check whether the current process already has a CUDA context created. | get_cuda_context | python | mars-project/mars | mars/lib/nvutils.py | https://github.com/mars-project/mars/blob/master/mars/lib/nvutils.py | Apache-2.0 |
def dump_traceback_code(tb: types.TracebackType, number_of_lines_of_context: int = 5):
"""
Dump codes before and after lines of tracebacks.
Parameters
----------
tb: types.TracebackType
Traceback object
number_of_lines_of_context: int
Total number of lines around the code
Re... |
Dump codes before and after lines of tracebacks.
Parameters
----------
tb: types.TracebackType
Traceback object
number_of_lines_of_context: int
Total number of lines around the code
Returns
-------
result: dict
Dumped code lines of traceback
| dump_traceback_code | python | mars-project/mars | mars/lib/tbcode.py | https://github.com/mars-project/mars/blob/master/mars/lib/tbcode.py | Apache-2.0 |
def load_traceback_code(code_frags: dict, cache: dict = None):
"""
Load dumped codes for remote tracebacks.
Parameters
----------
code_frags: dict
Dumped codes for remote traceback.
cache: dict
Target for codes to be dumped, for test purpose only.
Production code should ... |
Load dumped codes for remote tracebacks.
Parameters
----------
code_frags: dict
Dumped codes for remote traceback.
cache: dict
Target for codes to be dumped, for test purpose only.
Production code should keep this field as None.
| load_traceback_code | python | mars-project/mars | mars/lib/tbcode.py | https://github.com/mars-project/mars/blob/master/mars/lib/tbcode.py | Apache-2.0 |
def parse(version: str) -> Union["LegacyVersion", "Version"]:
"""
Parse the given version string and return either a :class:`Version` object
or a :class:`LegacyVersion` object depending on if the given version is
a valid PEP 440 version or a legacy version.
"""
try:
return Version(versio... |
Parse the given version string and return either a :class:`Version` object
or a :class:`LegacyVersion` object depending on if the given version is
a valid PEP 440 version or a legacy version.
| parse | python | mars-project/mars | mars/lib/version.py | https://github.com/mars-project/mars/blob/master/mars/lib/version.py | Apache-2.0 |
def _parse_local_version(local: str) -> Optional[LocalType]:
"""
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
"""
if local is not None:
return tuple(
part.lower() if not part.isdigit() else int(part)
for part in _local_version_separators.split(... |
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
| _parse_local_version | python | mars-project/mars | mars/lib/version.py | https://github.com/mars-project/mars/blob/master/mars/lib/version.py | Apache-2.0 |
def _patch_loop(loop):
"""
This function is designed to work around https://bugs.python.org/issue36607
It's job is to keep a thread safe variable tasks up to date with any tasks that
are created for the given loop. This then lets you cancel them as _all_tasks
was intended for.
We also need to ... |
This function is designed to work around https://bugs.python.org/issue36607
It's job is to keep a thread safe variable tasks up to date with any tasks that
are created for the given loop. This then lets you cancel them as _all_tasks
was intended for.
We also need to patch the {get,set}_task_facto... | _patch_loop | python | mars-project/mars | mars/lib/aio/_runners.py | https://github.com/mars-project/mars/blob/master/mars/lib/aio/_runners.py | Apache-2.0 |
def run(
main: Union[Coroutine[Any, None, _T], Awaitable[_T]], *, debug: bool = False
) -> _T:
"""Run a coroutine.
This function runs the passed coroutine, taking care of
managing the asyncio event loop and finalizing asynchronous
generators.
This function cannot be called when another asyncio... | Run a coroutine.
This function runs the passed coroutine, taking care of
managing the asyncio event loop and finalizing asynchronous
generators.
This function cannot be called when another asyncio event loop is
running in the same thread.
If debug is True, the event loop will be run in debug ... | run | python | mars-project/mars | mars/lib/aio/_runners.py | https://github.com/mars-project/mars/blob/master/mars/lib/aio/_runners.py | Apache-2.0 |
async def to_thread(func, *args, **kwargs):
"""Asynchronously run function *func* in a separate thread.
Any *args and **kwargs supplied for this function are directly passed
to *func*. Also, the current :class:`contextvars.Context` is propagated,
allowing context variables from the main thread to be ac... | Asynchronously run function *func* in a separate thread.
Any *args and **kwargs supplied for this function are directly passed
to *func*. Also, the current :class:`contextvars.Context` is propagated,
allowing context variables from the main thread to be accessed in the
separate thread.
Return a co... | to_thread | python | mars-project/mars | mars/lib/aio/_threads.py | https://github.com/mars-project/mars/blob/master/mars/lib/aio/_threads.py | Apache-2.0 |
def cat(self, path: path_type) -> bytes:
"""
Return contents of file as a bytes object
Parameters
----------
path : str or path-like
File path to read content from.
Returns
-------
contents : bytes
""" |
Return contents of file as a bytes object
Parameters
----------
path : str or path-like
File path to read content from.
Returns
-------
contents : bytes
| cat | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def ls(self, path: path_type) -> List[path_type]:
"""
Return list of file paths
Returns
-------
paths : list
""" |
Return list of file paths
Returns
-------
paths : list
| ls | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def delete(self, path: path_type, recursive: bool = False):
"""
Delete the indicated file or directory
Parameters
----------
path : str
recursive : bool, default False
If True, also delete child paths for directories
""" |
Delete the indicated file or directory
Parameters
----------
path : str
recursive : bool, default False
If True, also delete child paths for directories
| delete | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def disk_usage(self, path: path_type) -> int:
"""
Compute bytes used by all contents under indicated path in file tree
Parameters
----------
path : string
Can be a file path or directory
Returns
-------
usage : int
"""
path = ... |
Compute bytes used by all contents under indicated path in file tree
Parameters
----------
path : string
Can be a file path or directory
Returns
-------
usage : int
| disk_usage | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def path_split(self, path):
"""
Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part
may be empty.
Parameters
----------
path : string
Can be a file path or directory
Returns
-------
... |
Split a pathname. Returns tuple "(head, tail)" where "tail" is everything after the final slash. Either part
may be empty.
Parameters
----------
path : string
Can be a file path or directory
Returns
-------
usage : int
| path_split | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def stat(self, path: path_type) -> Dict:
"""
Information about a filesystem entry.
Returns
-------
stat : dict
""" |
Information about a filesystem entry.
Returns
-------
stat : dict
| stat | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def rename(self, path: path_type, new_path: path_type):
"""
Rename file, like UNIX mv command
Parameters
----------
path : string
Path to alter
new_path : string
Path to move to
""" |
Rename file, like UNIX mv command
Parameters
----------
path : string
Path to alter
new_path : string
Path to move to
| rename | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def mkdir(self, path: path_type, create_parents: bool = True):
"""
Create a directory.
Parameters
----------
path : str
Path to the directory.
create_parents : bool, default True
If the parent directories don't exists create them as well.
... |
Create a directory.
Parameters
----------
path : str
Path to the directory.
create_parents : bool, default True
If the parent directories don't exists create them as well.
| mkdir | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def exists(self, path: path_type):
"""
Return True if path exists.
Parameters
----------
path : str
Path to check.
""" |
Return True if path exists.
Parameters
----------
path : str
Path to check.
| exists | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def isdir(self, path: path_type) -> bool:
"""
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
""" |
Return True if path is a directory.
Parameters
----------
path : str
Path to check.
| isdir | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def isfile(self, path: path_type) -> bool:
"""
Return True if path is a file.
Parameters
----------
path : str
Path to check.
""" |
Return True if path is a file.
Parameters
----------
path : str
Path to check.
| isfile | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def _isfilestore(self) -> bool:
"""
Returns True if this FileSystem is a unix-style file store with
directories.
""" |
Returns True if this FileSystem is a unix-style file store with
directories.
| _isfilestore | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def open(self, path: path_type, mode: str = "rb") -> Union[BinaryIO, TextIO]:
"""
Open file for reading or writing.
""" |
Open file for reading or writing.
| open | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def walk(self, path: path_type) -> Iterator[Tuple[str, List[str], List[str]]]:
"""
Directory tree generator.
Parameters
----------
path : str
Returns
-------
generator
""" |
Directory tree generator.
Parameters
----------
path : str
Returns
-------
generator
| walk | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def glob(self, path: path_type, recursive: bool = False) -> List[path_type]:
"""
Return a list of paths matching a pathname pattern.
Parameters
----------
path : str
Pattern may contain simple shell-style wildcards
recursive : bool
If recursive is... |
Return a list of paths matching a pathname pattern.
Parameters
----------
path : str
Pattern may contain simple shell-style wildcards
recursive : bool
If recursive is true, the pattern '**' will match any files and
zero or more directories an... | glob | python | mars-project/mars | mars/lib/filesystem/base.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/base.py | Apache-2.0 |
def clear(self):
"""Remove all keys below root - empties out mapping"""
try:
self.fs.rm(self.root, True)
self.fs.mkdir(self.root)
except: # noqa: E722 # pragma: no cover
pass | Remove all keys below root - empties out mapping | clear | python | mars-project/mars | mars/lib/filesystem/fsmap.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/fsmap.py | Apache-2.0 |
def _key_to_str(self, key):
"""Generate full path for the key"""
if isinstance(key, (tuple, list)):
key = str(tuple(key))
else:
key = str(key)
return self._join_path(self.fs, [self.root, key]) if self.root else key | Generate full path for the key | _key_to_str | python | mars-project/mars | mars/lib/filesystem/fsmap.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/fsmap.py | Apache-2.0 |
def _str_to_key(self, s):
"""Strip path of to leave key name"""
key = self._normalize_path(self.fs, s[len(self.root) :], lstrip=True)
if self.fs.pathsep != "/": # pragma: no cover
key = key.replace(self.fs.pathsep, "/")
return key | Strip path of to leave key name | _str_to_key | python | mars-project/mars | mars/lib/filesystem/fsmap.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/fsmap.py | Apache-2.0 |
def build_oss_path(path: path_type, access_key_id, access_key_secret, end_point):
"""
Returns a path with oss info.
Used to register the access_key_id, access_key_secret and
endpoint of OSS. The access_key_id and endpoint are put
into the url with url-safe-base64 encoding.
Parameters
------... |
Returns a path with oss info.
Used to register the access_key_id, access_key_secret and
endpoint of OSS. The access_key_id and endpoint are put
into the url with url-safe-base64 encoding.
Parameters
----------
path : path_type
The original oss url.
access_key_id : str
... | build_oss_path | python | mars-project/mars | mars/lib/filesystem/oss.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/oss.py | Apache-2.0 |
def iglob(self, pathname, recursive=False):
"""Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' a... | Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la
fnmatch. However, unlike fnmatch, filenames starting with a
dot are special cases that are not matched by '*' and '?'
patterns.
If recursive is true,... | iglob | python | mars-project/mars | mars/lib/filesystem/_glob.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/_glob.py | Apache-2.0 |
def oss_isdir(path: path_type):
"""
OSS has no concept of directories, but we define
a ossurl is dir, When there is at least one object
at the ossurl that is the prefix(end with char "/"),
it is considered as a directory.
"""
dirname = stringify_path(path)
if not dirname.endswith("/"):
... |
OSS has no concept of directories, but we define
a ossurl is dir, When there is at least one object
at the ossurl that is the prefix(end with char "/"),
it is considered as a directory.
| oss_isdir | python | mars-project/mars | mars/lib/filesystem/_oss_lib/common.py | https://github.com/mars-project/mars/blob/master/mars/lib/filesystem/_oss_lib/common.py | Apache-2.0 |
def _init_ugly_crap():
"""This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object. Do not attempt to use this on non cpython
interpreters
"""
import ctypes
from types import Trace... | This function implements a few ugly things so that we can patch the
traceback objects. The function returned allows resetting `tb_next` on
any python traceback object. Do not attempt to use this on non cpython
interpreters
| _init_ugly_crap | python | mars-project/mars | mars/lib/tblib/cpython.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/cpython.py | Apache-2.0 |
def tb_set_next(tb, next):
"""Set the tb_next attribute of a traceback object."""
if not (
isinstance(tb, TracebackType)
and (next is None or isinstance(next, TracebackType))
):
raise TypeError("tb_set_next arguments must be traceback objects")
obj = _... | Set the tb_next attribute of a traceback object. | tb_set_next | python | mars-project/mars | mars/lib/tblib/cpython.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/cpython.py | Apache-2.0 |
def clear(self):
"""
For compatibility with PyPy 3.5;
clear() was added to frame in Python 3.4
and is called by traceback.clear_frames(), which
in turn is called by unittest.TestCase.assertRaises
""" |
For compatibility with PyPy 3.5;
clear() was added to frame in Python 3.4
and is called by traceback.clear_frames(), which
in turn is called by unittest.TestCase.assertRaises
| clear | python | mars-project/mars | mars/lib/tblib/__init__.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/__init__.py | Apache-2.0 |
def as_traceback(self):
"""
Convert to a builtin Traceback object that is usable for raising or rendering a stacktrace.
"""
if tproxy:
return tproxy(TracebackType, self.__tproxy__)
if not tb_set_next:
raise RuntimeError("Unsupported Python interpreter!")
... |
Convert to a builtin Traceback object that is usable for raising or rendering a stacktrace.
| as_traceback | python | mars-project/mars | mars/lib/tblib/__init__.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/__init__.py | Apache-2.0 |
def as_dict(self):
"""
Converts to a dictionary representation. You can serialize the result to JSON as it only has
builtin objects like dicts, lists, ints or strings.
"""
if self.tb_next is None:
tb_next = None
else:
tb_next = self.tb_next.to_dict... |
Converts to a dictionary representation. You can serialize the result to JSON as it only has
builtin objects like dicts, lists, ints or strings.
| as_dict | python | mars-project/mars | mars/lib/tblib/__init__.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/__init__.py | Apache-2.0 |
def from_dict(cls, dct):
"""
Creates an instance from a dictionary with the same structure as ``.as_dict()`` returns.
"""
if dct['tb_next']:
tb_next = cls.from_dict(dct['tb_next'])
else:
tb_next = None
code = _AttrDict(
co_filename=dct... |
Creates an instance from a dictionary with the same structure as ``.as_dict()`` returns.
| from_dict | python | mars-project/mars | mars/lib/tblib/__init__.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/__init__.py | Apache-2.0 |
def from_string(cls, string, strict=True):
"""
Creates an instance by parsing a stacktrace. Strict means that parsing stops when lines are not indented by at least two spaces
anymore.
"""
frames = []
header = strict
for line in string.splitlines():
li... |
Creates an instance by parsing a stacktrace. Strict means that parsing stops when lines are not indented by at least two spaces
anymore.
| from_string | python | mars-project/mars | mars/lib/tblib/__init__.py | https://github.com/mars-project/mars/blob/master/mars/lib/tblib/__init__.py | Apache-2.0 |
def patch_memcache():
"""Monkey patch python-memcached to implement our consistent hashring
in its node selection and operations.
"""
def _init(self, servers, *k, **kw):
self._old_init(servers, *k, **kw)
nodes = {}
for server in self.servers:
conf = {
... | Monkey patch python-memcached to implement our consistent hashring
in its node selection and operations.
| patch_memcache | python | mars-project/mars | mars/lib/uhashring/monkey.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/monkey.py | Apache-2.0 |
def __init__(self, nodes=[], **kwargs):
"""Create a new HashRing given the implementation.
:param nodes: nodes used to create the continuum (see doc for format).
:param hash_fn: use this callable function to hash keys, can be set to
'ketama' to use the ketama compatible ... | Create a new HashRing given the implementation.
:param nodes: nodes used to create the continuum (see doc for format).
:param hash_fn: use this callable function to hash keys, can be set to
'ketama' to use the ketama compatible implementation.
:param vnodes: default numb... | __init__ | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def _configure_nodes(self, nodes):
"""Parse and set up the given nodes.
:param nodes: nodes used to create the continuum (see doc for format).
"""
if isinstance(nodes, str):
nodes = [nodes]
elif not isinstance(nodes, (dict, list)):
raise ValueError(
... | Parse and set up the given nodes.
:param nodes: nodes used to create the continuum (see doc for format).
| _configure_nodes | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def _get_pos(self, key):
"""Get the index of the given key in the sorted key list.
We return the position with the nearest hash based on
the provided key unless we reach the end of the continuum/ring
in which case we return the 0 (beginning) index position.
:param key: the key ... | Get the index of the given key in the sorted key list.
We return the position with the nearest hash based on
the provided key unless we reach the end of the continuum/ring
in which case we return the 0 (beginning) index position.
:param key: the key to hash and look for.
| _get_pos | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def _get(self, key, what):
"""Generic getter magic method.
The node with the nearest but not less hash value is returned.
:param key: the key to look for.
:param what: the information to look for in, allowed values:
- instance (default): associated node instance
... | Generic getter magic method.
The node with the nearest but not less hash value is returned.
:param key: the key to look for.
:param what: the information to look for in, allowed values:
- instance (default): associated node instance
- nodename: node name
- p... | _get | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def get_instances(self):
"""Returns a list of the instances of all the configured nodes."""
return [
c.get("instance") for c in self.runtime._nodes.values() if c.get("instance")
] | Returns a list of the instances of all the configured nodes. | get_instances | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def iterate_nodes(self, key, distinct=True):
"""hash_ring compatibility implementation.
Given a string key it returns the nodes as a generator that
can hold the key.
The generator iterates one time through the ring
starting at the correct position.
if `distinct` is set, ... | hash_ring compatibility implementation.
Given a string key it returns the nodes as a generator that
can hold the key.
The generator iterates one time through the ring
starting at the correct position.
if `distinct` is set, then the nodes returned will be unique,
i.e. no ... | iterate_nodes | python | mars-project/mars | mars/lib/uhashring/ring.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring.py | Apache-2.0 |
def hashi(self, key, replica=0):
"""Returns a ketama compatible hash from the given key."""
dh = self._listbytes(md5(str(key).encode("utf-8")).digest())
rd = replica * 4
return (dh[3 + rd] << 24) | (dh[2 + rd] << 16) | (dh[1 + rd] << 8) | dh[0 + rd] | Returns a ketama compatible hash from the given key. | hashi | python | mars-project/mars | mars/lib/uhashring/ring_ketama.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring_ketama.py | Apache-2.0 |
def _hashi_weight_generator(self, node_name, node_conf):
"""Calculate the weight factor of the given node and
yield its hash key for every configured replica.
:param node_name: the node name.
"""
ks = (
node_conf["vnodes"] * len(self._nodes) * node_conf["weight"]
... | Calculate the weight factor of the given node and
yield its hash key for every configured replica.
:param node_name: the node name.
| _hashi_weight_generator | python | mars-project/mars | mars/lib/uhashring/ring_ketama.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring_ketama.py | Apache-2.0 |
def _remove_node(self, node_name):
"""Remove the given node from the continuum/ring.
:param node_name: the node name.
"""
try:
self._nodes.pop(node_name)
except Exception:
raise KeyError(
f"node '{node_name}' not found, "
f... | Remove the given node from the continuum/ring.
:param node_name: the node name.
| _remove_node | python | mars-project/mars | mars/lib/uhashring/ring_ketama.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring_ketama.py | Apache-2.0 |
def __init__(self, hash_fn):
"""Create a new HashRing.
:param hash_fn: use this callable function to hash keys.
"""
self._distribution = Counter()
self._keys = []
self._nodes = {}
self._ring = {}
if hash_fn and not hasattr(hash_fn, "__call__"):
... | Create a new HashRing.
:param hash_fn: use this callable function to hash keys.
| __init__ | python | mars-project/mars | mars/lib/uhashring/ring_meta.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring_meta.py | Apache-2.0 |
def _remove_node(self, node_name):
"""Remove the given node from the continuum/ring.
:param node_name: the node name.
"""
try:
node_conf = self._nodes.pop(node_name)
except Exception:
raise KeyError(
f"node '{node_name}' not found, "
... | Remove the given node from the continuum/ring.
:param node_name: the node name.
| _remove_node | python | mars-project/mars | mars/lib/uhashring/ring_meta.py | https://github.com/mars-project/mars/blob/master/mars/lib/uhashring/ring_meta.py | Apache-2.0 |
def _reload_ray_gauge_set_available():
"""
Note: Gauge `record` method is deprecated in ray 1.3.0 version, so here
make it compatible with the old and new ray versions.
"""
global _ray_gauge_set_available
if _ray_gauge_set_available is not None:
return _ray_gauge_set_available
_ray_... |
Note: Gauge `record` method is deprecated in ray 1.3.0 version, so here
make it compatible with the old and new ray versions.
| _reload_ray_gauge_set_available | python | mars-project/mars | mars/metrics/backends/ray/ray_metric.py | https://github.com/mars-project/mars/blob/master/mars/metrics/backends/ray/ray_metric.py | Apache-2.0 |
def optimize(cls, graph: EntityGraph) -> OptimizationRecords:
"""
Optimize a graph.
Parameters
----------
graph : EntityGraph
Tileable or chunk graph.
Returns
-------
optimization_records : OptimizationRecords
Optimization records... |
Optimize a graph.
Parameters
----------
graph : EntityGraph
Tileable or chunk graph.
Returns
-------
optimization_records : OptimizationRecords
Optimization records.
| optimize | python | mars-project/mars | mars/optimization/logical/core.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/core.py | Apache-2.0 |
def _need_prune(self, op: OperandType) -> bool:
"""
Check if this operand can prune
Returns
-------
need_prune : bool
""" |
Check if this operand can prune
Returns
-------
need_prune : bool
| _need_prune | python | mars-project/mars | mars/optimization/logical/common/column_pruning.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/common/column_pruning.py | Apache-2.0 |
def _get_selected_columns(self, op: OperandType) -> List[Any]:
"""
Get selected columns to prune data source.
Parameters
----------
op : OperandType
Operand.
Returns
-------
columns : list
Columns selected.
""" |
Get selected columns to prune data source.
Parameters
----------
op : OperandType
Operand.
Returns
-------
columns : list
Columns selected.
| _get_selected_columns | python | mars-project/mars | mars/optimization/logical/common/column_pruning.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/common/column_pruning.py | Apache-2.0 |
def _get_successor_required_columns(self, data: TileableData) -> Set[Any]:
"""
Get columns required by the successors of the given tileable data.
"""
successors = self._get_successors(data)
if successors:
return set().union(
*[self._context[successor][... |
Get columns required by the successors of the given tileable data.
| _get_successor_required_columns | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | Apache-2.0 |
def _get_all_columns(data: TileableData) -> Union[Set[Any], None]:
"""
Return all the columns of given tileable data. If the given tileable data is neither
BaseDataFrameData nor BaseSeriesData, None will be returned, indicating that column pruning
is not available for the given tileable ... |
Return all the columns of given tileable data. If the given tileable data is neither
BaseDataFrameData nor BaseSeriesData, None will be returned, indicating that column pruning
is not available for the given tileable data.
| _get_all_columns | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | Apache-2.0 |
def _get_successors(self, data: TileableData) -> List[TileableData]:
"""
Get successors of the given tileable data.
Column pruning is available only when every successor is available for column pruning
(i.e. appears in the context).
"""
successors = list(self._graph.succ... |
Get successors of the given tileable data.
Column pruning is available only when every successor is available for column pruning
(i.e. appears in the context).
| _get_successors | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | Apache-2.0 |
def _build_context(self) -> None:
"""
Select required columns for each tileable data in the graph.
"""
for data in self._graph.topological_iter(reverse=True):
if self._is_skipped_type(data):
continue
self._context[data] = InputColumnSelector.select... |
Select required columns for each tileable data in the graph.
| _build_context | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/column_pruning_rule.py | Apache-2.0 |
def select(
cls, tileable_data: TileableData, required_cols: Set[Any]
) -> Dict[TileableData, Set[Any]]:
"""
Get the column pruning results of given tileable data.
Parameters
----------
tileable_data : TileableData
The tileable data to be processed.
... |
Get the column pruning results of given tileable data.
Parameters
----------
tileable_data : TileableData
The tileable data to be processed.
required_cols: List[Any]
Names of columns required by the successors of the given tileable data. If required_cols... | select | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/input_column_selector.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/input_column_selector.py | Apache-2.0 |
def df_groupby_agg_select_function(tileable_data: TileableData) -> Set[Any]:
"""
Make sure the "group by columns" are preserved.
"""
op: DataFrameGroupByAgg = tileable_data.op
by = op.groupby_params["by"]
if isinstance(tileable_data, BaseDataFrameData):
return get_cols_exclude_index(ti... |
Make sure the "group by columns" are preserved.
| df_groupby_agg_select_function | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/self_column_selector.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/self_column_selector.py | Apache-2.0 |
def df_merge_select_function(tileable_data: TileableData) -> Set[Any]:
"""
Make sure the merge keys are preserved.
"""
op: DataFrameMerge = tileable_data.op
on = op.on
if on is not None:
return get_cols_exclude_index(tileable_data, on)
ret = set()
left_data: BaseDataFrameData =... |
Make sure the merge keys are preserved.
| df_merge_select_function | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/self_column_selector.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/self_column_selector.py | Apache-2.0 |
def test_getitem_with_mask(setup, gen_data1):
"""
Getitem with mask shouldn't prune any column.
"""
file_path, file_path2 = gen_data1
df = md.read_csv(file_path)
df2 = md.read_csv(file_path2)
df = df[df2["c1"] > 3]
r = df.groupby(by="c1", as_index=False).sum()["c2"]
graph = r.build... |
Getitem with mask shouldn't prune any column.
| test_getitem_with_mask | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/tests/test_column_pruning.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/tests/test_column_pruning.py | Apache-2.0 |
def test_setitem(setup, gen_data1):
"""
The output of DataFrameSetitem should preserve the column being set so that tile can work
correctly.
"""
file_path, file_path2 = gen_data1
df = md.read_csv(file_path)
df2 = md.read_csv(file_path2)
df["c5"] = df2["c1"]
r = df.groupby(by="c1", a... |
The output of DataFrameSetitem should preserve the column being set so that tile can work
correctly.
| test_setitem | python | mars-project/mars | mars/optimization/logical/tileable/column_pruning/tests/test_column_pruning.py | https://github.com/mars-project/mars/blob/master/mars/optimization/logical/tileable/column_pruning/tests/test_column_pruning.py | Apache-2.0 |
def is_available(cls) -> bool:
"""
Check this optimizer is available.
Returns
-------
is_available : bool
Available.
""" |
Check this optimizer is available.
Returns
-------
is_available : bool
Available.
| is_available | python | mars-project/mars | mars/optimization/physical/core.py | https://github.com/mars-project/mars/blob/master/mars/optimization/physical/core.py | Apache-2.0 |
def test_numexpr():
r"""
graph(@: node, S: Slice Chunk, #: fused_node):
@ @ @
\ / /
@ --> @ --> S ========> # --> S
/ \ \
@ ... |
graph(@: node, S: Slice Chunk, #: fused_node):
@ @ @
\ / /
@ --> @ --> S ========> # --> S
/ \ \
@ @ ... | test_numexpr | python | mars-project/mars | mars/optimization/physical/tests/test_numexpr.py | https://github.com/mars-project/mars/blob/master/mars/optimization/physical/tests/test_numexpr.py | Apache-2.0 |
async def __on_receive__(self, message: Tuple[Any]):
"""
Handle message from other actors and dispatch them to user methods
Parameters
----------
message : tuple
Message shall be (method_name,) + args + (kwargs,)
"""
return await super().__on_receive_... |
Handle message from other actors and dispatch them to user methods
Parameters
----------
message : tuple
Message shall be (method_name,) + args + (kwargs,)
| __on_receive__ | python | mars-project/mars | mars/oscar/api.py | https://github.com/mars-project/mars/blob/master/mars/oscar/api.py | Apache-2.0 |
def get_allocated_address(
self, config: ActorPoolConfig, allocated: allocated_type
) -> str:
"""
Get external address where the actor allocated to.
Parameters
----------
config: ActorPoolConfig
Actor pool config.
allocated:
Already al... |
Get external address where the actor allocated to.
Parameters
----------
config: ActorPoolConfig
Actor pool config.
allocated:
Already allocated of actor and its strategy.
Returns
-------
allocated_address: str
Extern... | get_allocated_address | python | mars-project/mars | mars/oscar/backends/allocate_strategy.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/allocate_strategy.py | Apache-2.0 |
async def create_actor(self, message: CreateActorMessage) -> ResultMessageType:
"""
Create an actor.
Parameters
----------
message: CreateActorMessage
message to create an actor.
Returns
-------
result_message
result or error mess... |
Create an actor.
Parameters
----------
message: CreateActorMessage
message to create an actor.
Returns
-------
result_message
result or error message.
| create_actor | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def has_actor(self, message: HasActorMessage) -> ResultMessage:
"""
Check if an actor exists or not.
Parameters
----------
message: HasActorMessage
message
Returns
-------
result_message
result message contains if an actor e... |
Check if an actor exists or not.
Parameters
----------
message: HasActorMessage
message
Returns
-------
result_message
result message contains if an actor exists or not.
| has_actor | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def destroy_actor(self, message: DestroyActorMessage) -> ResultMessageType:
"""
Destroy an actor.
Parameters
----------
message: DestroyActorMessage
message to destroy an actor.
Returns
-------
result_message
result or error... |
Destroy an actor.
Parameters
----------
message: DestroyActorMessage
message to destroy an actor.
Returns
-------
result_message
result or error message.
| destroy_actor | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def actor_ref(self, message: ActorRefMessage) -> ResultMessageType:
"""
Get an actor's ref.
Parameters
----------
message: ActorRefMessage
message to get an actor's ref.
Returns
-------
result_message
result or error message... |
Get an actor's ref.
Parameters
----------
message: ActorRefMessage
message to get an actor's ref.
Returns
-------
result_message
result or error message.
| actor_ref | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def send(self, message: SendMessage) -> ResultMessageType:
"""
Send a message to some actor.
Parameters
----------
message: SendMessage
Message to send.
Returns
-------
result_message
result or error message.
""" |
Send a message to some actor.
Parameters
----------
message: SendMessage
Message to send.
Returns
-------
result_message
result or error message.
| send | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def tell(self, message: TellMessage) -> ResultMessageType:
"""
Tell message to some actor.
Parameters
----------
message: TellMessage
Message to tell.
Returns
-------
result_message
result or error message.
""" |
Tell message to some actor.
Parameters
----------
message: TellMessage
Message to tell.
Returns
-------
result_message
result or error message.
| tell | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def cancel(self, message: CancelMessage) -> ResultMessageType:
"""
Cancel message that sent
Parameters
----------
message: CancelMessage
Cancel message.
Returns
-------
result_message
result or error message
""" |
Cancel message that sent
Parameters
----------
message: CancelMessage
Cancel message.
Returns
-------
result_message
result or error message
| cancel | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def handle_control_command(
self, message: ControlMessage
) -> ResultMessageType:
"""
Handle control command.
Parameters
----------
message: ControlMessage
Control message.
Returns
-------
result_message
result o... |
Handle control command.
Parameters
----------
message: ControlMessage
Control message.
Returns
-------
result_message
result or error message.
| handle_control_command | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def create(cls, config: Dict) -> "AbstractActorPool":
"""
Create an actor pool.
Parameters
----------
config: Dict
configurations.
Returns
-------
actor_pool:
Actor pool.
""" |
Create an actor pool.
Parameters
----------
config: Dict
configurations.
Returns
-------
actor_pool:
Actor pool.
| create | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
async def is_sub_pool_alive(self, process: SubProcessHandle):
"""
Check whether sub pool process is alive
Parameters
----------
process : SubProcessHandle
sub pool process handle
Returns
-------
bool
""" |
Check whether sub pool process is alive
Parameters
----------
process : SubProcessHandle
sub pool process handle
Returns
-------
bool
| is_sub_pool_alive | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
def get_external_addresses(
cls, address: str, n_process: int = None, ports: List[int] = None
):
"""Returns external addresses for n pool processes""" | Returns external addresses for n pool processes | get_external_addresses | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
def gen_internal_address(
cls, process_index: int, external_address: str = None
) -> str:
"""Returns internal address for pool of specified process index""" | Returns internal address for pool of specified process index | gen_internal_address | python | mars-project/mars | mars/oscar/backends/pool.py | https://github.com/mars-project/mars/blob/master/mars/oscar/backends/pool.py | Apache-2.0 |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.