repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.flat_map | def flat_map(self, flatmap_fn):
"""Applies a flatmap operator to the stream.
Attributes:
flatmap_fn (function): The user-defined logic of the flatmap
(e.g. split()).
"""
op = Operator(
_generate_uuid(),
OpType.FlatMap,
"FlatM... | python | def flat_map(self, flatmap_fn):
"""Applies a flatmap operator to the stream.
Attributes:
flatmap_fn (function): The user-defined logic of the flatmap
(e.g. split()).
"""
op = Operator(
_generate_uuid(),
OpType.FlatMap,
"FlatM... | [
"def",
"flat_map",
"(",
"self",
",",
"flatmap_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"FlatMap",
",",
"\"FlatMap\"",
",",
"flatmap_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
... | Applies a flatmap operator to the stream.
Attributes:
flatmap_fn (function): The user-defined logic of the flatmap
(e.g. split()). | [
"Applies",
"a",
"flatmap",
"operator",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L536-L549 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.key_by | def key_by(self, key_selector):
"""Applies a key_by operator to the stream.
Attributes:
key_attribute_index (int): The index of the key attributed
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
OpType.KeyBy,
"... | python | def key_by(self, key_selector):
"""Applies a key_by operator to the stream.
Attributes:
key_attribute_index (int): The index of the key attributed
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
OpType.KeyBy,
"... | [
"def",
"key_by",
"(",
"self",
",",
"key_selector",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"KeyBy",
",",
"\"KeyBy\"",
",",
"other",
"=",
"key_selector",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"... | Applies a key_by operator to the stream.
Attributes:
key_attribute_index (int): The index of the key attributed
(assuming tuple records). | [
"Applies",
"a",
"key_by",
"operator",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L553-L566 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.reduce | def reduce(self, reduce_fn):
"""Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
OpType.Reduce,
... | python | def reduce(self, reduce_fn):
"""Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
OpType.Reduce,
... | [
"def",
"reduce",
"(",
"self",
",",
"reduce_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Reduce",
",",
"\"Sum\"",
",",
"reduce_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parall... | Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records). | [
"Applies",
"a",
"rolling",
"sum",
"operator",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L569-L582 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.sum | def sum(self, attribute_selector, state_keeper=None):
"""Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
... | python | def sum(self, attribute_selector, state_keeper=None):
"""Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records).
"""
op = Operator(
_generate_uuid(),
... | [
"def",
"sum",
"(",
"self",
",",
"attribute_selector",
",",
"state_keeper",
"=",
"None",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Sum",
",",
"\"Sum\"",
",",
"_sum",
",",
"other",
"=",
"attribute_selector",
","... | Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records). | [
"Applies",
"a",
"rolling",
"sum",
"operator",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L585-L600 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.time_window | def time_window(self, window_width_ms):
"""Applies a system time window to the stream.
Attributes:
window_width_ms (int): The length of the window in ms.
"""
op = Operator(
_generate_uuid(),
OpType.TimeWindow,
"TimeWindow",
nu... | python | def time_window(self, window_width_ms):
"""Applies a system time window to the stream.
Attributes:
window_width_ms (int): The length of the window in ms.
"""
op = Operator(
_generate_uuid(),
OpType.TimeWindow,
"TimeWindow",
nu... | [
"def",
"time_window",
"(",
"self",
",",
"window_width_ms",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"TimeWindow",
",",
"\"TimeWindow\"",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parall... | Applies a system time window to the stream.
Attributes:
window_width_ms (int): The length of the window in ms. | [
"Applies",
"a",
"system",
"time",
"window",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L605-L617 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.filter | def filter(self, filter_fn):
"""Applies a filter to the stream.
Attributes:
filter_fn (function): The user-defined filter function.
"""
op = Operator(
_generate_uuid(),
OpType.Filter,
"Filter",
filter_fn,
num_insta... | python | def filter(self, filter_fn):
"""Applies a filter to the stream.
Attributes:
filter_fn (function): The user-defined filter function.
"""
op = Operator(
_generate_uuid(),
OpType.Filter,
"Filter",
filter_fn,
num_insta... | [
"def",
"filter",
"(",
"self",
",",
"filter_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Filter",
",",
"\"Filter\"",
",",
"filter_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"par... | Applies a filter to the stream.
Attributes:
filter_fn (function): The user-defined filter function. | [
"Applies",
"a",
"filter",
"to",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L620-L632 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.inspect | def inspect(self, inspect_logic):
"""Inspects the content of the stream.
Attributes:
inspect_logic (function): The user-defined inspect function.
"""
op = Operator(
_generate_uuid(),
OpType.Inspect,
"Inspect",
inspect_logic,
... | python | def inspect(self, inspect_logic):
"""Inspects the content of the stream.
Attributes:
inspect_logic (function): The user-defined inspect function.
"""
op = Operator(
_generate_uuid(),
OpType.Inspect,
"Inspect",
inspect_logic,
... | [
"def",
"inspect",
"(",
"self",
",",
"inspect_logic",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Inspect",
",",
"\"Inspect\"",
",",
"inspect_logic",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
... | Inspects the content of the stream.
Attributes:
inspect_logic (function): The user-defined inspect function. | [
"Inspects",
"the",
"content",
"of",
"the",
"stream",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L644-L656 | train |
ray-project/ray | python/ray/experimental/streaming/streaming.py | DataStream.sink | def sink(self):
"""Closes the stream with a sink operator."""
op = Operator(
_generate_uuid(),
OpType.Sink,
"Sink",
num_instances=self.env.config.parallelism)
return self.__register(op) | python | def sink(self):
"""Closes the stream with a sink operator."""
op = Operator(
_generate_uuid(),
OpType.Sink,
"Sink",
num_instances=self.env.config.parallelism)
return self.__register(op) | [
"def",
"sink",
"(",
"self",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Sink",
",",
"\"Sink\"",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parallelism",
")",
"return",
"self",
".",
"... | Closes the stream with a sink operator. | [
"Closes",
"the",
"stream",
"with",
"a",
"sink",
"operator",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L661-L668 | train |
ray-project/ray | python/ray/log_monitor.py | LogMonitor.close_all_files | def close_all_files(self):
"""Close all open files (so that we can open more)."""
while len(self.open_file_infos) > 0:
file_info = self.open_file_infos.pop(0)
file_info.file_handle.close()
file_info.file_handle = None
self.closed_file_infos.append(file_inf... | python | def close_all_files(self):
"""Close all open files (so that we can open more)."""
while len(self.open_file_infos) > 0:
file_info = self.open_file_infos.pop(0)
file_info.file_handle.close()
file_info.file_handle = None
self.closed_file_infos.append(file_inf... | [
"def",
"close_all_files",
"(",
"self",
")",
":",
"while",
"len",
"(",
"self",
".",
"open_file_infos",
")",
">",
"0",
":",
"file_info",
"=",
"self",
".",
"open_file_infos",
".",
"pop",
"(",
"0",
")",
"file_info",
".",
"file_handle",
".",
"close",
"(",
"... | Close all open files (so that we can open more). | [
"Close",
"all",
"open",
"files",
"(",
"so",
"that",
"we",
"can",
"open",
"more",
")",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L81-L88 | train |
ray-project/ray | python/ray/log_monitor.py | LogMonitor.update_log_filenames | def update_log_filenames(self):
"""Update the list of log files to monitor."""
log_filenames = os.listdir(self.logs_dir)
for log_filename in log_filenames:
full_path = os.path.join(self.logs_dir, log_filename)
if full_path not in self.log_filenames:
self.... | python | def update_log_filenames(self):
"""Update the list of log files to monitor."""
log_filenames = os.listdir(self.logs_dir)
for log_filename in log_filenames:
full_path = os.path.join(self.logs_dir, log_filename)
if full_path not in self.log_filenames:
self.... | [
"def",
"update_log_filenames",
"(",
"self",
")",
":",
"log_filenames",
"=",
"os",
".",
"listdir",
"(",
"self",
".",
"logs_dir",
")",
"for",
"log_filename",
"in",
"log_filenames",
":",
"full_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"l... | Update the list of log files to monitor. | [
"Update",
"the",
"list",
"of",
"log",
"files",
"to",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L90-L104 | train |
ray-project/ray | python/ray/log_monitor.py | LogMonitor.open_closed_files | def open_closed_files(self):
"""Open some closed files if they may have new lines.
Opening more files may require us to close some of the already open
files.
"""
if not self.can_open_more_files:
# If we can't open any more files. Close all of the files.
s... | python | def open_closed_files(self):
"""Open some closed files if they may have new lines.
Opening more files may require us to close some of the already open
files.
"""
if not self.can_open_more_files:
# If we can't open any more files. Close all of the files.
s... | [
"def",
"open_closed_files",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"can_open_more_files",
":",
"# If we can't open any more files. Close all of the files.",
"self",
".",
"close_all_files",
"(",
")",
"files_with_no_updates",
"=",
"[",
"]",
"while",
"len",
"("... | Open some closed files if they may have new lines.
Opening more files may require us to close some of the already open
files. | [
"Open",
"some",
"closed",
"files",
"if",
"they",
"may",
"have",
"new",
"lines",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L106-L160 | train |
ray-project/ray | python/ray/log_monitor.py | LogMonitor.check_log_files_and_publish_updates | def check_log_files_and_publish_updates(self):
"""Get any changes to the log files and push updates to Redis.
Returns:
True if anything was published and false otherwise.
"""
anything_published = False
for file_info in self.open_file_infos:
assert not fil... | python | def check_log_files_and_publish_updates(self):
"""Get any changes to the log files and push updates to Redis.
Returns:
True if anything was published and false otherwise.
"""
anything_published = False
for file_info in self.open_file_infos:
assert not fil... | [
"def",
"check_log_files_and_publish_updates",
"(",
"self",
")",
":",
"anything_published",
"=",
"False",
"for",
"file_info",
"in",
"self",
".",
"open_file_infos",
":",
"assert",
"not",
"file_info",
".",
"file_handle",
".",
"closed",
"lines_to_publish",
"=",
"[",
"... | Get any changes to the log files and push updates to Redis.
Returns:
True if anything was published and false otherwise. | [
"Get",
"any",
"changes",
"to",
"the",
"log",
"files",
"and",
"push",
"updates",
"to",
"Redis",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L162-L208 | train |
ray-project/ray | python/ray/log_monitor.py | LogMonitor.run | def run(self):
"""Run the log monitor.
This will query Redis once every second to check if there are new log
files to monitor. It will also store those log files in Redis.
"""
while True:
self.update_log_filenames()
self.open_closed_files()
an... | python | def run(self):
"""Run the log monitor.
This will query Redis once every second to check if there are new log
files to monitor. It will also store those log files in Redis.
"""
while True:
self.update_log_filenames()
self.open_closed_files()
an... | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"update_log_filenames",
"(",
")",
"self",
".",
"open_closed_files",
"(",
")",
"anything_published",
"=",
"self",
".",
"check_log_files_and_publish_updates",
"(",
")",
"# If nothing was publish... | Run the log monitor.
This will query Redis once every second to check if there are new log
files to monitor. It will also store those log files in Redis. | [
"Run",
"the",
"log",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L210-L223 | train |
ray-project/ray | python/ray/tune/suggest/suggestion.py | SuggestionAlgorithm.add_configurations | def add_configurations(self, experiments):
"""Chains generator given experiment specifications.
Arguments:
experiments (Experiment | list | dict): Experiments to run.
"""
experiment_list = convert_to_experiment_list(experiments)
for experiment in experiment_list:
... | python | def add_configurations(self, experiments):
"""Chains generator given experiment specifications.
Arguments:
experiments (Experiment | list | dict): Experiments to run.
"""
experiment_list = convert_to_experiment_list(experiments)
for experiment in experiment_list:
... | [
"def",
"add_configurations",
"(",
"self",
",",
"experiments",
")",
":",
"experiment_list",
"=",
"convert_to_experiment_list",
"(",
"experiments",
")",
"for",
"experiment",
"in",
"experiment_list",
":",
"self",
".",
"_trial_generator",
"=",
"itertools",
".",
"chain",... | Chains generator given experiment specifications.
Arguments:
experiments (Experiment | list | dict): Experiments to run. | [
"Chains",
"generator",
"given",
"experiment",
"specifications",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L43-L53 | train |
ray-project/ray | python/ray/tune/suggest/suggestion.py | SuggestionAlgorithm.next_trials | def next_trials(self):
"""Provides a batch of Trial objects to be queued into the TrialRunner.
A batch ends when self._trial_generator returns None.
Returns:
trials (list): Returns a list of trials.
"""
trials = []
for trial in self._trial_generator:
... | python | def next_trials(self):
"""Provides a batch of Trial objects to be queued into the TrialRunner.
A batch ends when self._trial_generator returns None.
Returns:
trials (list): Returns a list of trials.
"""
trials = []
for trial in self._trial_generator:
... | [
"def",
"next_trials",
"(",
"self",
")",
":",
"trials",
"=",
"[",
"]",
"for",
"trial",
"in",
"self",
".",
"_trial_generator",
":",
"if",
"trial",
"is",
"None",
":",
"return",
"trials",
"trials",
"+=",
"[",
"trial",
"]",
"self",
".",
"_finished",
"=",
... | Provides a batch of Trial objects to be queued into the TrialRunner.
A batch ends when self._trial_generator returns None.
Returns:
trials (list): Returns a list of trials. | [
"Provides",
"a",
"batch",
"of",
"Trial",
"objects",
"to",
"be",
"queued",
"into",
"the",
"TrialRunner",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L55-L71 | train |
ray-project/ray | python/ray/tune/suggest/suggestion.py | SuggestionAlgorithm._generate_trials | def _generate_trials(self, experiment_spec, output_path=""):
"""Generates trials with configurations from `_suggest`.
Creates a trial_id that is passed into `_suggest`.
Yields:
Trial objects constructed according to `spec`
"""
if "run" not in experiment_spec:
... | python | def _generate_trials(self, experiment_spec, output_path=""):
"""Generates trials with configurations from `_suggest`.
Creates a trial_id that is passed into `_suggest`.
Yields:
Trial objects constructed according to `spec`
"""
if "run" not in experiment_spec:
... | [
"def",
"_generate_trials",
"(",
"self",
",",
"experiment_spec",
",",
"output_path",
"=",
"\"\"",
")",
":",
"if",
"\"run\"",
"not",
"in",
"experiment_spec",
":",
"raise",
"TuneError",
"(",
"\"Must specify `run` in {}\"",
".",
"format",
"(",
"experiment_spec",
")",
... | Generates trials with configurations from `_suggest`.
Creates a trial_id that is passed into `_suggest`.
Yields:
Trial objects constructed according to `spec` | [
"Generates",
"trials",
"with",
"configurations",
"from",
"_suggest",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L73-L102 | train |
ray-project/ray | python/ray/tune/suggest/variant_generator.py | generate_variants | def generate_variants(unresolved_spec):
"""Generates variants from a spec (dict) with unresolved values.
There are two types of unresolved values:
Grid search: These define a grid search over values. For example, the
following grid search values in a spec will produce six distinct
vari... | python | def generate_variants(unresolved_spec):
"""Generates variants from a spec (dict) with unresolved values.
There are two types of unresolved values:
Grid search: These define a grid search over values. For example, the
following grid search values in a spec will produce six distinct
vari... | [
"def",
"generate_variants",
"(",
"unresolved_spec",
")",
":",
"for",
"resolved_vars",
",",
"spec",
"in",
"_generate_variants",
"(",
"unresolved_spec",
")",
":",
"assert",
"not",
"_unresolved_values",
"(",
"spec",
")",
"yield",
"format_vars",
"(",
"resolved_vars",
... | Generates variants from a spec (dict) with unresolved values.
There are two types of unresolved values:
Grid search: These define a grid search over values. For example, the
following grid search values in a spec will produce six distinct
variants in combination:
"activation":... | [
"Generates",
"variants",
"from",
"a",
"spec",
"(",
"dict",
")",
"with",
"unresolved",
"values",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/variant_generator.py#L16-L44 | train |
ray-project/ray | python/ray/tune/suggest/variant_generator.py | resolve_nested_dict | def resolve_nested_dict(nested_dict):
"""Flattens a nested dict by joining keys into tuple of paths.
Can then be passed into `format_vars`.
"""
res = {}
for k, v in nested_dict.items():
if isinstance(v, dict):
for k_, v_ in resolve_nested_dict(v).items():
res[(k,... | python | def resolve_nested_dict(nested_dict):
"""Flattens a nested dict by joining keys into tuple of paths.
Can then be passed into `format_vars`.
"""
res = {}
for k, v in nested_dict.items():
if isinstance(v, dict):
for k_, v_ in resolve_nested_dict(v).items():
res[(k,... | [
"def",
"resolve_nested_dict",
"(",
"nested_dict",
")",
":",
"res",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"nested_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"for",
"k_",
",",
"v_",
"in",
"resolve_ne... | Flattens a nested dict by joining keys into tuple of paths.
Can then be passed into `format_vars`. | [
"Flattens",
"a",
"nested",
"dict",
"by",
"joining",
"keys",
"into",
"tuple",
"of",
"paths",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/variant_generator.py#L108-L120 | train |
ray-project/ray | python/ray/tune/automlboard/run.py | run_board | def run_board(args):
"""
Run main entry for AutoMLBoard.
Args:
args: args parsed from command line
"""
init_config(args)
# backend service, should import after django settings initialized
from backend.collector import CollectorService
service = CollectorService(
args.l... | python | def run_board(args):
"""
Run main entry for AutoMLBoard.
Args:
args: args parsed from command line
"""
init_config(args)
# backend service, should import after django settings initialized
from backend.collector import CollectorService
service = CollectorService(
args.l... | [
"def",
"run_board",
"(",
"args",
")",
":",
"init_config",
"(",
"args",
")",
"# backend service, should import after django settings initialized",
"from",
"backend",
".",
"collector",
"import",
"CollectorService",
"service",
"=",
"CollectorService",
"(",
"args",
".",
"lo... | Run main entry for AutoMLBoard.
Args:
args: args parsed from command line | [
"Run",
"main",
"entry",
"for",
"AutoMLBoard",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L18-L43 | train |
ray-project/ray | python/ray/tune/automlboard/run.py | init_config | def init_config(args):
"""
Initialize configs of the service.
Do the following things:
1. automl board settings
2. database settings
3. django settings
"""
os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir
os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level
os.environ["AUTOMLBOARD_... | python | def init_config(args):
"""
Initialize configs of the service.
Do the following things:
1. automl board settings
2. database settings
3. django settings
"""
os.environ["AUTOMLBOARD_LOGDIR"] = args.logdir
os.environ["AUTOMLBOARD_LOGLEVEL"] = args.log_level
os.environ["AUTOMLBOARD_... | [
"def",
"init_config",
"(",
"args",
")",
":",
"os",
".",
"environ",
"[",
"\"AUTOMLBOARD_LOGDIR\"",
"]",
"=",
"args",
".",
"logdir",
"os",
".",
"environ",
"[",
"\"AUTOMLBOARD_LOGLEVEL\"",
"]",
"=",
"args",
".",
"log_level",
"os",
".",
"environ",
"[",
"\"AUTO... | Initialize configs of the service.
Do the following things:
1. automl board settings
2. database settings
3. django settings | [
"Initialize",
"configs",
"of",
"the",
"service",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L46-L80 | train |
ray-project/ray | python/ray/worker.py | get_gpu_ids | def get_gpu_ids():
"""Get the IDs of the GPUs that are available to the worker.
If the CUDA_VISIBLE_DEVICES environment variable was set when the worker
started up, then the IDs returned by this method will be a subset of the
IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range
[0, N... | python | def get_gpu_ids():
"""Get the IDs of the GPUs that are available to the worker.
If the CUDA_VISIBLE_DEVICES environment variable was set when the worker
started up, then the IDs returned by this method will be a subset of the
IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range
[0, N... | [
"def",
"get_gpu_ids",
"(",
")",
":",
"if",
"_mode",
"(",
")",
"==",
"LOCAL_MODE",
":",
"raise",
"Exception",
"(",
"\"ray.get_gpu_ids() currently does not work in PYTHON \"",
"\"MODE.\"",
")",
"all_resource_ids",
"=",
"global_worker",
".",
"raylet_client",
".",
"resour... | Get the IDs of the GPUs that are available to the worker.
If the CUDA_VISIBLE_DEVICES environment variable was set when the worker
started up, then the IDs returned by this method will be a subset of the
IDs in CUDA_VISIBLE_DEVICES. If not, the IDs will fall in the range
[0, NUM_GPUS - 1], where NUM_GP... | [
"Get",
"the",
"IDs",
"of",
"the",
"GPUs",
"that",
"are",
"available",
"to",
"the",
"worker",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1042-L1069 | train |
ray-project/ray | python/ray/worker.py | error_info | def error_info():
"""Return information about failed tasks."""
worker = global_worker
worker.check_connected()
return (global_state.error_messages(driver_id=worker.task_driver_id) +
global_state.error_messages(driver_id=DriverID.nil())) | python | def error_info():
"""Return information about failed tasks."""
worker = global_worker
worker.check_connected()
return (global_state.error_messages(driver_id=worker.task_driver_id) +
global_state.error_messages(driver_id=DriverID.nil())) | [
"def",
"error_info",
"(",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"return",
"(",
"global_state",
".",
"error_messages",
"(",
"driver_id",
"=",
"worker",
".",
"task_driver_id",
")",
"+",
"global_state",
".",
"error_... | Return information about failed tasks. | [
"Return",
"information",
"about",
"failed",
"tasks",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1134-L1139 | train |
ray-project/ray | python/ray/worker.py | _initialize_serialization | def _initialize_serialization(driver_id, worker=global_worker):
"""Initialize the serialization library.
This defines a custom serializer for object IDs and also tells ray to
serialize several exception classes that we define for error handling.
"""
serialization_context = pyarrow.default_serializa... | python | def _initialize_serialization(driver_id, worker=global_worker):
"""Initialize the serialization library.
This defines a custom serializer for object IDs and also tells ray to
serialize several exception classes that we define for error handling.
"""
serialization_context = pyarrow.default_serializa... | [
"def",
"_initialize_serialization",
"(",
"driver_id",
",",
"worker",
"=",
"global_worker",
")",
":",
"serialization_context",
"=",
"pyarrow",
".",
"default_serialization_context",
"(",
")",
"# Tell the serialization context to use the cloudpickle version that we",
"# ship with Ra... | Initialize the serialization library.
This defines a custom serializer for object IDs and also tells ray to
serialize several exception classes that we define for error handling. | [
"Initialize",
"the",
"serialization",
"library",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1142-L1210 | train |
ray-project/ray | python/ray/worker.py | init | def init(redis_address=None,
num_cpus=None,
num_gpus=None,
resources=None,
object_store_memory=None,
redis_max_memory=None,
log_to_driver=True,
node_ip_address=None,
object_id_seed=None,
local_mode=False,
redirect_worker_output=No... | python | def init(redis_address=None,
num_cpus=None,
num_gpus=None,
resources=None,
object_store_memory=None,
redis_max_memory=None,
log_to_driver=True,
node_ip_address=None,
object_id_seed=None,
local_mode=False,
redirect_worker_output=No... | [
"def",
"init",
"(",
"redis_address",
"=",
"None",
",",
"num_cpus",
"=",
"None",
",",
"num_gpus",
"=",
"None",
",",
"resources",
"=",
"None",
",",
"object_store_memory",
"=",
"None",
",",
"redis_max_memory",
"=",
"None",
",",
"log_to_driver",
"=",
"True",
"... | Connect to an existing Ray cluster or start one and connect to it.
This method handles two cases. Either a Ray cluster already exists and we
just attach this driver to it, or we start all of the processes associated
with a Ray cluster and attach to the newly started cluster.
To start Ray and all of th... | [
"Connect",
"to",
"an",
"existing",
"Ray",
"cluster",
"or",
"start",
"one",
"and",
"connect",
"to",
"it",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1213-L1455 | train |
ray-project/ray | python/ray/worker.py | shutdown | def shutdown(exiting_interpreter=False):
"""Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tes... | python | def shutdown(exiting_interpreter=False):
"""Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tes... | [
"def",
"shutdown",
"(",
"exiting_interpreter",
"=",
"False",
")",
":",
"if",
"exiting_interpreter",
"and",
"global_worker",
".",
"mode",
"==",
"SCRIPT_MODE",
":",
"# This is a duration to sleep before shutting down everything in order",
"# to make sure that log messages finish pr... | Disconnect the worker, and terminate processes started by ray.init().
This will automatically run at the end when a Python process that uses Ray
exits. It is ok to run this twice in a row. The primary use case for this
function is to cleanup state between tests.
Note that this will clear any remote fu... | [
"Disconnect",
"the",
"worker",
"and",
"terminate",
"processes",
"started",
"by",
"ray",
".",
"init",
"()",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1462-L1496 | train |
ray-project/ray | python/ray/worker.py | print_logs | def print_logs(redis_client, threads_stopped):
"""Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit.
"""
pubsub_... | python | def print_logs(redis_client, threads_stopped):
"""Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit.
"""
pubsub_... | [
"def",
"print_logs",
"(",
"redis_client",
",",
"threads_stopped",
")",
":",
"pubsub_client",
"=",
"redis_client",
".",
"pubsub",
"(",
"ignore_subscribe_messages",
"=",
"True",
")",
"pubsub_client",
".",
"subscribe",
"(",
"ray",
".",
"gcs_utils",
".",
"LOG_FILE_CHA... | Prints log messages from workers on all of the nodes.
Args:
redis_client: A client to the primary Redis shard.
threads_stopped (threading.Event): A threading event used to signal to
the thread that it should exit. | [
"Prints",
"log",
"messages",
"from",
"workers",
"on",
"all",
"of",
"the",
"nodes",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1526-L1575 | train |
ray-project/ray | python/ray/worker.py | print_error_messages_raylet | def print_error_messages_raylet(task_error_queue, threads_stopped):
"""Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread tha... | python | def print_error_messages_raylet(task_error_queue, threads_stopped):
"""Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread tha... | [
"def",
"print_error_messages_raylet",
"(",
"task_error_queue",
",",
"threads_stopped",
")",
":",
"while",
"True",
":",
"# Exit if we received a signal that we should stop.",
"if",
"threads_stopped",
".",
"is_set",
"(",
")",
":",
"return",
"try",
":",
"error",
",",
"t"... | Prints message received in the given output queue.
This checks periodically if any un-raised errors occured in the background.
Args:
task_error_queue (queue.Queue): A queue used to receive errors from the
thread that listens to Redis.
threads_stopped (threading.Event): A threading ... | [
"Prints",
"message",
"received",
"in",
"the",
"given",
"output",
"queue",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1578-L1610 | train |
ray-project/ray | python/ray/worker.py | listen_error_messages_raylet | def listen_error_messages_raylet(worker, task_error_queue, threads_stopped):
"""Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to... | python | def listen_error_messages_raylet(worker, task_error_queue, threads_stopped):
"""Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to... | [
"def",
"listen_error_messages_raylet",
"(",
"worker",
",",
"task_error_queue",
",",
"threads_stopped",
")",
":",
"worker",
".",
"error_message_pubsub_client",
"=",
"worker",
".",
"redis_client",
".",
"pubsub",
"(",
"ignore_subscribe_messages",
"=",
"True",
")",
"# Exp... | Listen to error messages in the background on the driver.
This runs in a separate thread on the driver and pushes (error, time)
tuples to the output queue.
Args:
worker: The worker class that this thread belongs to.
task_error_queue (queue.Queue): A queue used to communicate with the
... | [
"Listen",
"to",
"error",
"messages",
"in",
"the",
"background",
"on",
"the",
"driver",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1613-L1675 | train |
ray-project/ray | python/ray/worker.py | connect | def connect(node,
mode=WORKER_MODE,
log_to_driver=False,
worker=global_worker,
driver_id=None,
load_code_from_local=False):
"""Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
... | python | def connect(node,
mode=WORKER_MODE,
log_to_driver=False,
worker=global_worker,
driver_id=None,
load_code_from_local=False):
"""Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
... | [
"def",
"connect",
"(",
"node",
",",
"mode",
"=",
"WORKER_MODE",
",",
"log_to_driver",
"=",
"False",
",",
"worker",
"=",
"global_worker",
",",
"driver_id",
"=",
"None",
",",
"load_code_from_local",
"=",
"False",
")",
":",
"# Do some basic checking to make sure we d... | Connect this worker to the raylet, to Plasma, and to Redis.
Args:
node (ray.node.Node): The node to connect.
mode: The mode of the worker. One of SCRIPT_MODE, WORKER_MODE, and
LOCAL_MODE.
log_to_driver (bool): If true, then output from all of the worker
processes on ... | [
"Connect",
"this",
"worker",
"to",
"the",
"raylet",
"to",
"Plasma",
"and",
"to",
"Redis",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1687-L1958 | train |
ray-project/ray | python/ray/worker.py | disconnect | def disconnect():
"""Disconnect this worker from the raylet and object store."""
# Reset the list of cached remote functions and actors so that if more
# remote functions or actors are defined and then connect is called again,
# the remote functions will be exported. This is mostly relevant for the
... | python | def disconnect():
"""Disconnect this worker from the raylet and object store."""
# Reset the list of cached remote functions and actors so that if more
# remote functions or actors are defined and then connect is called again,
# the remote functions will be exported. This is mostly relevant for the
... | [
"def",
"disconnect",
"(",
")",
":",
"# Reset the list of cached remote functions and actors so that if more",
"# remote functions or actors are defined and then connect is called again,",
"# the remote functions will be exported. This is mostly relevant for the",
"# tests.",
"worker",
"=",
"gl... | Disconnect this worker from the raylet and object store. | [
"Disconnect",
"this",
"worker",
"from",
"the",
"raylet",
"and",
"object",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1961-L1994 | train |
ray-project/ray | python/ray/worker.py | _try_to_compute_deterministic_class_id | def _try_to_compute_deterministic_class_id(cls, depth=5):
"""Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results tha... | python | def _try_to_compute_deterministic_class_id(cls, depth=5):
"""Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results tha... | [
"def",
"_try_to_compute_deterministic_class_id",
"(",
"cls",
",",
"depth",
"=",
"5",
")",
":",
"# Pickling, loading, and pickling again seems to produce more consistent",
"# results than simply pickling. This is a bit",
"class_id",
"=",
"pickle",
".",
"dumps",
"(",
"cls",
")",
... | Attempt to produce a deterministic class ID for a given class.
The goal here is for the class ID to be the same when this is run on
different worker processes. Pickling, loading, and pickling again seems to
produce more consistent results than simply pickling. This is a bit crazy
and could cause proble... | [
"Attempt",
"to",
"produce",
"a",
"deterministic",
"class",
"ID",
"for",
"a",
"given",
"class",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2006-L2045 | train |
ray-project/ray | python/ray/worker.py | register_custom_serializer | def register_custom_serializer(cls,
use_pickle=False,
use_dict=False,
serializer=None,
deserializer=None,
local=False,
driver_id=None,... | python | def register_custom_serializer(cls,
use_pickle=False,
use_dict=False,
serializer=None,
deserializer=None,
local=False,
driver_id=None,... | [
"def",
"register_custom_serializer",
"(",
"cls",
",",
"use_pickle",
"=",
"False",
",",
"use_dict",
"=",
"False",
",",
"serializer",
"=",
"None",
",",
"deserializer",
"=",
"None",
",",
"local",
"=",
"False",
",",
"driver_id",
"=",
"None",
",",
"class_id",
"... | Enable serialization and deserialization for a particular class.
This method runs the register_class function defined below on every worker,
which will enable ray to properly serialize and deserialize objects of
this class.
Args:
cls (type): The class that ray should use this custom serializer... | [
"Enable",
"serialization",
"and",
"deserialization",
"for",
"a",
"particular",
"class",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2048-L2148 | train |
ray-project/ray | python/ray/worker.py | get | def get(object_ids):
"""Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it ... | python | def get(object_ids):
"""Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it ... | [
"def",
"get",
"(",
"object_ids",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"with",
"profiling",
".",
"profile",
"(",
"\"ray.get\"",
")",
":",
"if",
"worker",
".",
"mode",
"==",
"LOCAL_MODE",
":",
"# In LOCAL_MODE, ... | Get a remote object or a list of remote objects from the object store.
This method blocks until the object corresponding to the object ID is
available in the local object store. If this object is not in the local
object store, it will be shipped from an object store that has it (once the
object has bee... | [
"Get",
"a",
"remote",
"object",
"or",
"a",
"list",
"of",
"remote",
"objects",
"from",
"the",
"object",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2151-L2194 | train |
ray-project/ray | python/ray/worker.py | put | def put(value):
"""Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value.
"""
worker = global_worker
worker.check_connected()
with profiling.profile("ray.put"):
if worker.mode == LOCAL_MODE:
... | python | def put(value):
"""Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value.
"""
worker = global_worker
worker.check_connected()
with profiling.profile("ray.put"):
if worker.mode == LOCAL_MODE:
... | [
"def",
"put",
"(",
"value",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"with",
"profiling",
".",
"profile",
"(",
"\"ray.put\"",
")",
":",
"if",
"worker",
".",
"mode",
"==",
"LOCAL_MODE",
":",
"# In LOCAL_MODE, ray.p... | Store an object in the object store.
Args:
value: The Python object to be stored.
Returns:
The object ID assigned to this value. | [
"Store",
"an",
"object",
"in",
"the",
"object",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2197-L2218 | train |
ray-project/ray | python/ray/worker.py | wait | def wait(object_ids, num_returns=1, timeout=None):
"""Return a list of IDs that are ready and a list of IDs that are not.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns ... | python | def wait(object_ids, num_returns=1, timeout=None):
"""Return a list of IDs that are ready and a list of IDs that are not.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns ... | [
"def",
"wait",
"(",
"object_ids",
",",
"num_returns",
"=",
"1",
",",
"timeout",
"=",
"None",
")",
":",
"worker",
"=",
"global_worker",
"if",
"isinstance",
"(",
"object_ids",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"wait() expected a list of ray... | Return a list of IDs that are ready and a list of IDs that are not.
.. warning::
The **timeout** argument used to be in **milliseconds** (up through
``ray==0.6.1``) and now it is in **seconds**.
If timeout is set, the function returns either when the requested number of
IDs are ready or w... | [
"Return",
"a",
"list",
"of",
"IDs",
"that",
"are",
"ready",
"and",
"a",
"list",
"of",
"IDs",
"that",
"are",
"not",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2221-L2315 | train |
ray-project/ray | python/ray/worker.py | remote | def remote(*args, **kwargs):
"""Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
... | python | def remote(*args, **kwargs):
"""Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
... | [
"def",
"remote",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"worker",
"=",
"get_global_worker",
"(",
")",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"len",
"(",
"kwargs",
")",
"==",
"0",
"and",
"callable",
"(",
"args",
"[",
"0",
... | Define a remote function or an actor class.
This can be used with no arguments to define a remote function or actor as
follows:
.. code-block:: python
@ray.remote
def f():
return 1
@ray.remote
class Foo(object):
def method(self):
re... | [
"Define",
"a",
"remote",
"function",
"or",
"an",
"actor",
"class",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L2369-L2467 | train |
ray-project/ray | python/ray/worker.py | Worker.task_context | def task_context(self):
"""A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that hav... | python | def task_context(self):
"""A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that hav... | [
"def",
"task_context",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
".",
"_task_context",
",",
"\"initialized\"",
")",
":",
"# Initialize task_context for the current thread.",
"if",
"ray",
".",
"utils",
".",
"is_main_thread",
"(",
")",
":",
"# If... | A thread-local that contains the following attributes.
current_task_id: For the main thread, this field is the ID of this
worker's current running task; for other threads, this field is a
fake random ID.
task_index: The number of tasks that have been submitted from the
... | [
"A",
"thread",
"-",
"local",
"that",
"contains",
"the",
"following",
"attributes",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L175-L210 | train |
ray-project/ray | python/ray/worker.py | Worker.get_serialization_context | def get_serialization_context(self, driver_id):
"""Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serializati... | python | def get_serialization_context(self, driver_id):
"""Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serializati... | [
"def",
"get_serialization_context",
"(",
"self",
",",
"driver_id",
")",
":",
"# This function needs to be proctected by a lock, because it will be",
"# called by`register_class_for_serialization`, as well as the import",
"# thread, from different threads. Also, this function will recursively",
... | Get the SerializationContext of the driver that this worker is processing.
Args:
driver_id: The ID of the driver that indicates which driver to get
the serialization context for.
Returns:
The serialization context of the given driver. | [
"Get",
"the",
"SerializationContext",
"of",
"the",
"driver",
"that",
"this",
"worker",
"is",
"processing",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L227-L244 | train |
ray-project/ray | python/ray/worker.py | Worker.store_and_register | def store_and_register(self, object_id, value, depth=100):
"""Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively... | python | def store_and_register(self, object_id, value, depth=100):
"""Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively... | [
"def",
"store_and_register",
"(",
"self",
",",
"object_id",
",",
"value",
",",
"depth",
"=",
"100",
")",
":",
"counter",
"=",
"0",
"while",
"True",
":",
"if",
"counter",
"==",
"depth",
":",
"raise",
"Exception",
"(",
"\"Ray exceeded the maximum number of class... | Store an object and attempt to register its class if needed.
Args:
object_id: The ID of the object to store.
value: The value to put in the object store.
depth: The maximum number of classes to recursively register.
Raises:
Exception: An exception is rai... | [
"Store",
"an",
"object",
"and",
"attempt",
"to",
"register",
"its",
"class",
"if",
"needed",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L276-L350 | train |
ray-project/ray | python/ray/worker.py | Worker.put_object | def put_object(self, object_id, value):
"""Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
... | python | def put_object(self, object_id, value):
"""Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
... | [
"def",
"put_object",
"(",
"self",
",",
"object_id",
",",
"value",
")",
":",
"# Make sure that the value is not an object ID.",
"if",
"isinstance",
"(",
"value",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"Calling 'put' on an ray.ObjectID is not allowed \"",
... | Put value in the local object store with object id objectid.
This assumes that the value for objectid has not yet been placed in the
local object store.
Args:
object_id (object_id.ObjectID): The object ID of the value to be
put.
value: The value to put i... | [
"Put",
"value",
"in",
"the",
"local",
"object",
"store",
"with",
"object",
"id",
"objectid",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L352-L400 | train |
ray-project/ray | python/ray/worker.py | Worker.get_object | def get_object(self, object_ids):
"""Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
... | python | def get_object(self, object_ids):
"""Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
... | [
"def",
"get_object",
"(",
"self",
",",
"object_ids",
")",
":",
"# Make sure that the values are object IDs.",
"for",
"object_id",
"in",
"object_ids",
":",
"if",
"not",
"isinstance",
"(",
"object_id",
",",
"ObjectID",
")",
":",
"raise",
"TypeError",
"(",
"\"Attempt... | Get the value or values in the object store associated with the IDs.
Return the values from the local object store for object_ids. This will
block until all the values for object_ids have been written to the
local object store.
Args:
object_ids (List[object_id.ObjectID]): A... | [
"Get",
"the",
"value",
"or",
"values",
"in",
"the",
"object",
"store",
"associated",
"with",
"the",
"IDs",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L479-L559 | train |
ray-project/ray | python/ray/worker.py | Worker.submit_task | def submit_task(self,
function_descriptor,
args,
actor_id=None,
actor_handle_id=None,
actor_counter=0,
actor_creation_id=None,
actor_creation_dummy_object_id=None,
... | python | def submit_task(self,
function_descriptor,
args,
actor_id=None,
actor_handle_id=None,
actor_counter=0,
actor_creation_id=None,
actor_creation_dummy_object_id=None,
... | [
"def",
"submit_task",
"(",
"self",
",",
"function_descriptor",
",",
"args",
",",
"actor_id",
"=",
"None",
",",
"actor_handle_id",
"=",
"None",
",",
"actor_counter",
"=",
"0",
",",
"actor_creation_id",
"=",
"None",
",",
"actor_creation_dummy_object_id",
"=",
"Non... | Submit a remote task to the scheduler.
Tell the scheduler to schedule the execution of the function with
function_descriptor with arguments args. Retrieve object IDs for the
outputs of the function from the scheduler and immediately return them.
Args:
function_descriptor: T... | [
"Submit",
"a",
"remote",
"task",
"to",
"the",
"scheduler",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L561-L699 | train |
ray-project/ray | python/ray/worker.py | Worker.run_function_on_all_workers | def run_function_on_all_workers(self, function,
run_on_other_drivers=False):
"""Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
... | python | def run_function_on_all_workers(self, function,
run_on_other_drivers=False):
"""Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
... | [
"def",
"run_function_on_all_workers",
"(",
"self",
",",
"function",
",",
"run_on_other_drivers",
"=",
"False",
")",
":",
"# If ray.init has not been called yet, then cache the function and",
"# export it when connect is called. Otherwise, run the function on all",
"# workers.",
"if",
... | Run arbitrary code on all of the workers.
This function will first be run on the driver, and then it will be
exported to all of the workers to be run. It will also be run on any
new workers that register later. If ray.init has not been called yet,
then cache the function and export it l... | [
"Run",
"arbitrary",
"code",
"on",
"all",
"of",
"the",
"workers",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L701-L752 | train |
ray-project/ray | python/ray/worker.py | Worker._get_arguments_for_execution | def _get_arguments_for_execution(self, function_name, serialized_args):
"""Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is c... | python | def _get_arguments_for_execution(self, function_name, serialized_args):
"""Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is c... | [
"def",
"_get_arguments_for_execution",
"(",
"self",
",",
"function_name",
",",
"serialized_args",
")",
":",
"arguments",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"arg",
")",
"in",
"enumerate",
"(",
"serialized_args",
")",
":",
"if",
"isinstance",
"(",
"arg",
"... | Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is called by the worker that is executing the remote
function.
Args:
... | [
"Retrieve",
"the",
"arguments",
"for",
"the",
"remote",
"function",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L759-L794 | train |
ray-project/ray | python/ray/worker.py | Worker._store_outputs_in_object_store | def _store_outputs_in_object_store(self, object_ids, outputs):
"""Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs... | python | def _store_outputs_in_object_store(self, object_ids, outputs):
"""Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs... | [
"def",
"_store_outputs_in_object_store",
"(",
"self",
",",
"object_ids",
",",
"outputs",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"object_ids",
")",
")",
":",
"if",
"isinstance",
"(",
"outputs",
"[",
"i",
"]",
",",
"ray",
".",
"actor",
"."... | Store the outputs of a remote function in the local object store.
This stores the values that were returned by a remote function in the
local object store. If any of the return values are object IDs, then
these object IDs are aliased with the object IDs that the scheduler
assigned for t... | [
"Store",
"the",
"outputs",
"of",
"a",
"remote",
"function",
"in",
"the",
"local",
"object",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L796-L828 | train |
ray-project/ray | python/ray/worker.py | Worker._process_task | def _process_task(self, task, function_execution_info):
"""Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exceptio... | python | def _process_task(self, task, function_execution_info):
"""Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exceptio... | [
"def",
"_process_task",
"(",
"self",
",",
"task",
",",
"function_execution_info",
")",
":",
"assert",
"self",
".",
"current_task_id",
".",
"is_nil",
"(",
")",
"assert",
"self",
".",
"task_context",
".",
"task_index",
"==",
"0",
"assert",
"self",
".",
"task_c... | Execute a task assigned to this worker.
This method deserializes a task from the scheduler, and attempts to
execute the task. If the task succeeds, the outputs are stored in the
local object store. If the task throws an exception, RayTaskError
objects are stored in the object store to r... | [
"Execute",
"a",
"task",
"assigned",
"to",
"this",
"worker",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L830-L921 | train |
ray-project/ray | python/ray/worker.py | Worker._wait_for_and_process_task | def _wait_for_and_process_task(self, task):
"""Wait for a task to be ready and process the task.
Args:
task: The task to execute.
"""
function_descriptor = FunctionDescriptor.from_bytes_list(
task.function_descriptor_list())
driver_id = task.driver_id()
... | python | def _wait_for_and_process_task(self, task):
"""Wait for a task to be ready and process the task.
Args:
task: The task to execute.
"""
function_descriptor = FunctionDescriptor.from_bytes_list(
task.function_descriptor_list())
driver_id = task.driver_id()
... | [
"def",
"_wait_for_and_process_task",
"(",
"self",
",",
"task",
")",
":",
"function_descriptor",
"=",
"FunctionDescriptor",
".",
"from_bytes_list",
"(",
"task",
".",
"function_descriptor_list",
"(",
")",
")",
"driver_id",
"=",
"task",
".",
"driver_id",
"(",
")",
... | Wait for a task to be ready and process the task.
Args:
task: The task to execute. | [
"Wait",
"for",
"a",
"task",
"to",
"be",
"ready",
"and",
"process",
"the",
"task",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L943-L1012 | train |
ray-project/ray | python/ray/worker.py | Worker._get_next_task_from_raylet | def _get_next_task_from_raylet(self):
"""Get the next task from the raylet.
Returns:
A task from the raylet.
"""
with profiling.profile("worker_idle"):
task = self.raylet_client.get_task()
# Automatically restrict the GPUs available to this task.
... | python | def _get_next_task_from_raylet(self):
"""Get the next task from the raylet.
Returns:
A task from the raylet.
"""
with profiling.profile("worker_idle"):
task = self.raylet_client.get_task()
# Automatically restrict the GPUs available to this task.
... | [
"def",
"_get_next_task_from_raylet",
"(",
"self",
")",
":",
"with",
"profiling",
".",
"profile",
"(",
"\"worker_idle\"",
")",
":",
"task",
"=",
"self",
".",
"raylet_client",
".",
"get_task",
"(",
")",
"# Automatically restrict the GPUs available to this task.",
"ray",... | Get the next task from the raylet.
Returns:
A task from the raylet. | [
"Get",
"the",
"next",
"task",
"from",
"the",
"raylet",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1014-L1026 | train |
ray-project/ray | python/ray/worker.py | Worker.main_loop | def main_loop(self):
"""The main loop a worker runs to receive and execute tasks."""
def exit(signum, frame):
shutdown()
sys.exit(0)
signal.signal(signal.SIGTERM, exit)
while True:
task = self._get_next_task_from_raylet()
self._wait_for_... | python | def main_loop(self):
"""The main loop a worker runs to receive and execute tasks."""
def exit(signum, frame):
shutdown()
sys.exit(0)
signal.signal(signal.SIGTERM, exit)
while True:
task = self._get_next_task_from_raylet()
self._wait_for_... | [
"def",
"main_loop",
"(",
"self",
")",
":",
"def",
"exit",
"(",
"signum",
",",
"frame",
")",
":",
"shutdown",
"(",
")",
"sys",
".",
"exit",
"(",
"0",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"exit",
")",
"while",
"True",
"... | The main loop a worker runs to receive and execute tasks. | [
"The",
"main",
"loop",
"a",
"worker",
"runs",
"to",
"receive",
"and",
"execute",
"tasks",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1028-L1039 | train |
ray-project/ray | python/ray/rllib/agents/ppo/utils.py | flatten | def flatten(weights, start=0, stop=2):
"""This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index.
"""
... | python | def flatten(weights, start=0, stop=2):
"""This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index.
"""
... | [
"def",
"flatten",
"(",
"weights",
",",
"start",
"=",
"0",
",",
"stop",
"=",
"2",
")",
":",
"for",
"key",
",",
"val",
"in",
"weights",
".",
"items",
"(",
")",
":",
"new_shape",
"=",
"val",
".",
"shape",
"[",
"0",
":",
"start",
"]",
"+",
"(",
"... | This methods reshapes all values in a dictionary.
The indices from start to stop will be flattened into a single index.
Args:
weights: A dictionary mapping keys to numpy arrays.
start: The starting index.
stop: The ending index. | [
"This",
"methods",
"reshapes",
"all",
"values",
"in",
"a",
"dictionary",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ppo/utils.py#L8-L21 | train |
ray-project/ray | python/ray/node.py | Node.address_info | def address_info(self):
"""Get a dictionary of addresses."""
return {
"node_ip_address": self._node_ip_address,
"redis_address": self._redis_address,
"object_store_address": self._plasma_store_socket_name,
"raylet_socket_name": self._raylet_socket_name,
... | python | def address_info(self):
"""Get a dictionary of addresses."""
return {
"node_ip_address": self._node_ip_address,
"redis_address": self._redis_address,
"object_store_address": self._plasma_store_socket_name,
"raylet_socket_name": self._raylet_socket_name,
... | [
"def",
"address_info",
"(",
"self",
")",
":",
"return",
"{",
"\"node_ip_address\"",
":",
"self",
".",
"_node_ip_address",
",",
"\"redis_address\"",
":",
"self",
".",
"_redis_address",
",",
"\"object_store_address\"",
":",
"self",
".",
"_plasma_store_socket_name",
",... | Get a dictionary of addresses. | [
"Get",
"a",
"dictionary",
"of",
"addresses",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L199-L207 | train |
ray-project/ray | python/ray/node.py | Node.create_redis_client | def create_redis_client(self):
"""Create a redis client."""
return ray.services.create_redis_client(
self._redis_address, self._ray_params.redis_password) | python | def create_redis_client(self):
"""Create a redis client."""
return ray.services.create_redis_client(
self._redis_address, self._ray_params.redis_password) | [
"def",
"create_redis_client",
"(",
"self",
")",
":",
"return",
"ray",
".",
"services",
".",
"create_redis_client",
"(",
"self",
".",
"_redis_address",
",",
"self",
".",
"_ray_params",
".",
"redis_password",
")"
] | Create a redis client. | [
"Create",
"a",
"redis",
"client",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L209-L212 | train |
ray-project/ray | python/ray/node.py | Node._make_inc_temp | def _make_inc_temp(self, suffix="", prefix="", directory_name="/tmp/ray"):
"""Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The bas... | python | def _make_inc_temp(self, suffix="", prefix="", directory_name="/tmp/ray"):
"""Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The bas... | [
"def",
"_make_inc_temp",
"(",
"self",
",",
"suffix",
"=",
"\"\"",
",",
"prefix",
"=",
"\"\"",
",",
"directory_name",
"=",
"\"/tmp/ray\"",
")",
":",
"directory_name",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"directory_name",
")",
"index",
"=",
"self... | Return a incremental temporary file name. The file is not created.
Args:
suffix (str): The suffix of the temp file.
prefix (str): The prefix of the temp file.
directory_name (str) : The base directory of the temp file.
Returns:
A string of file name. If ... | [
"Return",
"a",
"incremental",
"temporary",
"file",
"name",
".",
"The",
"file",
"is",
"not",
"created",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L226-L256 | train |
ray-project/ray | python/ray/node.py | Node.new_log_files | def new_log_files(self, name, redirect_output=True):
"""Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and fals... | python | def new_log_files(self, name, redirect_output=True):
"""Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and fals... | [
"def",
"new_log_files",
"(",
"self",
",",
"name",
",",
"redirect_output",
"=",
"True",
")",
":",
"if",
"redirect_output",
"is",
"None",
":",
"redirect_output",
"=",
"self",
".",
"_ray_params",
".",
"redirect_output",
"if",
"not",
"redirect_output",
":",
"retur... | Generate partially randomized filenames for log files.
Args:
name (str): descriptive string for this log file.
redirect_output (bool): True if files should be generated for
logging stdout and stderr and false if stdout and stderr
should not be redirected.... | [
"Generate",
"partially",
"randomized",
"filenames",
"for",
"log",
"files",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L258-L287 | train |
ray-project/ray | python/ray/node.py | Node._prepare_socket_file | def _prepare_socket_file(self, socket_path, default_prefix):
"""Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
soc... | python | def _prepare_socket_file(self, socket_path, default_prefix):
"""Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
soc... | [
"def",
"_prepare_socket_file",
"(",
"self",
",",
"socket_path",
",",
"default_prefix",
")",
":",
"if",
"socket_path",
"is",
"not",
"None",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"socket_path",
")",
":",
"raise",
"Exception",
"(",
"\"Socket file {}... | Prepare the socket file for raylet and plasma.
This method helps to prepare a socket file.
1. Make the directory if the directory does not exist.
2. If the socket file exists, raise exception.
Args:
socket_path (string): the socket file to prepare. | [
"Prepare",
"the",
"socket",
"file",
"for",
"raylet",
"and",
"plasma",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L289-L306 | train |
ray-project/ray | python/ray/node.py | Node.start_redis | def start_redis(self):
"""Start the Redis servers."""
assert self._redis_address is None
redis_log_files = [self.new_log_files("redis")]
for i in range(self._ray_params.num_redis_shards):
redis_log_files.append(self.new_log_files("redis-shard_" + str(i)))
(self._redi... | python | def start_redis(self):
"""Start the Redis servers."""
assert self._redis_address is None
redis_log_files = [self.new_log_files("redis")]
for i in range(self._ray_params.num_redis_shards):
redis_log_files.append(self.new_log_files("redis-shard_" + str(i)))
(self._redi... | [
"def",
"start_redis",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_redis_address",
"is",
"None",
"redis_log_files",
"=",
"[",
"self",
".",
"new_log_files",
"(",
"\"redis\"",
")",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"_ray_params",
".",
"n... | Start the Redis servers. | [
"Start",
"the",
"Redis",
"servers",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L308-L330 | train |
ray-project/ray | python/ray/node.py | Node.start_log_monitor | def start_log_monitor(self):
"""Start the log monitor."""
stdout_file, stderr_file = self.new_log_files("log_monitor")
process_info = ray.services.start_log_monitor(
self.redis_address,
self._logs_dir,
stdout_file=stdout_file,
stderr_file=stderr_fi... | python | def start_log_monitor(self):
"""Start the log monitor."""
stdout_file, stderr_file = self.new_log_files("log_monitor")
process_info = ray.services.start_log_monitor(
self.redis_address,
self._logs_dir,
stdout_file=stdout_file,
stderr_file=stderr_fi... | [
"def",
"start_log_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"log_monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_log_monitor",
"(",
"self",
".",
"redis_address",
",",
... | Start the log monitor. | [
"Start",
"the",
"log",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L332-L344 | train |
ray-project/ray | python/ray/node.py | Node.start_reporter | def start_reporter(self):
"""Start the reporter."""
stdout_file, stderr_file = self.new_log_files("reporter", True)
process_info = ray.services.start_reporter(
self.redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
redis_password=sel... | python | def start_reporter(self):
"""Start the reporter."""
stdout_file, stderr_file = self.new_log_files("reporter", True)
process_info = ray.services.start_reporter(
self.redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
redis_password=sel... | [
"def",
"start_reporter",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"reporter\"",
",",
"True",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_reporter",
"(",
"self",
".",
"redis_address",
... | Start the reporter. | [
"Start",
"the",
"reporter",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L346-L358 | train |
ray-project/ray | python/ray/node.py | Node.start_dashboard | def start_dashboard(self):
"""Start the dashboard."""
stdout_file, stderr_file = self.new_log_files("dashboard", True)
self._webui_url, process_info = ray.services.start_dashboard(
self.redis_address,
self._temp_dir,
stdout_file=stdout_file,
stderr... | python | def start_dashboard(self):
"""Start the dashboard."""
stdout_file, stderr_file = self.new_log_files("dashboard", True)
self._webui_url, process_info = ray.services.start_dashboard(
self.redis_address,
self._temp_dir,
stdout_file=stdout_file,
stderr... | [
"def",
"start_dashboard",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"dashboard\"",
",",
"True",
")",
"self",
".",
"_webui_url",
",",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_dashboard",
... | Start the dashboard. | [
"Start",
"the",
"dashboard",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L360-L375 | train |
ray-project/ray | python/ray/node.py | Node.start_plasma_store | def start_plasma_store(self):
"""Start the plasma store."""
stdout_file, stderr_file = self.new_log_files("plasma_store")
process_info = ray.services.start_plasma_store(
stdout_file=stdout_file,
stderr_file=stderr_file,
object_store_memory=self._ray_params.obj... | python | def start_plasma_store(self):
"""Start the plasma store."""
stdout_file, stderr_file = self.new_log_files("plasma_store")
process_info = ray.services.start_plasma_store(
stdout_file=stdout_file,
stderr_file=stderr_file,
object_store_memory=self._ray_params.obj... | [
"def",
"start_plasma_store",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"plasma_store\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_plasma_store",
"(",
"stdout_file",
"=",
"stdout_file",
... | Start the plasma store. | [
"Start",
"the",
"plasma",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L377-L391 | train |
ray-project/ray | python/ray/node.py | Node.start_raylet | def start_raylet(self, use_valgrind=False, use_profiler=False):
"""Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler.
... | python | def start_raylet(self, use_valgrind=False, use_profiler=False):
"""Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler.
... | [
"def",
"start_raylet",
"(",
"self",
",",
"use_valgrind",
"=",
"False",
",",
"use_profiler",
"=",
"False",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"raylet\"",
")",
"process_info",
"=",
"ray",
".",
"services",
"."... | Start the raylet.
Args:
use_valgrind (bool): True if we should start the process in
valgrind.
use_profiler (bool): True if we should start the process in the
valgrind profiler. | [
"Start",
"the",
"raylet",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L393-L426 | train |
ray-project/ray | python/ray/node.py | Node.new_worker_redirected_log_file | def new_worker_redirected_log_file(self, worker_id):
"""Create new logging files for workers to redirect its output."""
worker_stdout_file, worker_stderr_file = (self.new_log_files(
"worker-" + ray.utils.binary_to_hex(worker_id), True))
return worker_stdout_file, worker_stderr_file | python | def new_worker_redirected_log_file(self, worker_id):
"""Create new logging files for workers to redirect its output."""
worker_stdout_file, worker_stderr_file = (self.new_log_files(
"worker-" + ray.utils.binary_to_hex(worker_id), True))
return worker_stdout_file, worker_stderr_file | [
"def",
"new_worker_redirected_log_file",
"(",
"self",
",",
"worker_id",
")",
":",
"worker_stdout_file",
",",
"worker_stderr_file",
"=",
"(",
"self",
".",
"new_log_files",
"(",
"\"worker-\"",
"+",
"ray",
".",
"utils",
".",
"binary_to_hex",
"(",
"worker_id",
")",
... | Create new logging files for workers to redirect its output. | [
"Create",
"new",
"logging",
"files",
"for",
"workers",
"to",
"redirect",
"its",
"output",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L428-L432 | train |
ray-project/ray | python/ray/node.py | Node.start_monitor | def start_monitor(self):
"""Start the monitor."""
stdout_file, stderr_file = self.new_log_files("monitor")
process_info = ray.services.start_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
autoscaling_config=self._ra... | python | def start_monitor(self):
"""Start the monitor."""
stdout_file, stderr_file = self.new_log_files("monitor")
process_info = ray.services.start_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
autoscaling_config=self._ra... | [
"def",
"start_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_monitor",
"(",
"self",
".",
"_redis_address",
",",
"stdout_fi... | Start the monitor. | [
"Start",
"the",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L438-L448 | train |
ray-project/ray | python/ray/node.py | Node.start_raylet_monitor | def start_raylet_monitor(self):
"""Start the raylet monitor."""
stdout_file, stderr_file = self.new_log_files("raylet_monitor")
process_info = ray.services.start_raylet_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
... | python | def start_raylet_monitor(self):
"""Start the raylet monitor."""
stdout_file, stderr_file = self.new_log_files("raylet_monitor")
process_info = ray.services.start_raylet_monitor(
self._redis_address,
stdout_file=stdout_file,
stderr_file=stderr_file,
... | [
"def",
"start_raylet_monitor",
"(",
"self",
")",
":",
"stdout_file",
",",
"stderr_file",
"=",
"self",
".",
"new_log_files",
"(",
"\"raylet_monitor\"",
")",
"process_info",
"=",
"ray",
".",
"services",
".",
"start_raylet_monitor",
"(",
"self",
".",
"_redis_address"... | Start the raylet monitor. | [
"Start",
"the",
"raylet",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L450-L463 | train |
ray-project/ray | python/ray/node.py | Node.start_head_processes | def start_head_processes(self):
"""Start head processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
assert self._redis_address is None
# If this is the head node, start the relevant head node pro... | python | def start_head_processes(self):
"""Start head processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
assert self._redis_address is None
# If this is the head node, start the relevant head node pro... | [
"def",
"start_head_processes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Process STDOUT and STDERR is being redirected to {}.\"",
".",
"format",
"(",
"self",
".",
"_logs_dir",
")",
")",
"assert",
"self",
".",
"_redis_address",
"is",
"None",
"# If this is... | Start head processes on the node. | [
"Start",
"head",
"processes",
"on",
"the",
"node",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L465-L477 | train |
ray-project/ray | python/ray/node.py | Node.start_ray_processes | def start_ray_processes(self):
"""Start all of the processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
self.start_plasma_store()
self.start_raylet()
if PY3:
self.start_repo... | python | def start_ray_processes(self):
"""Start all of the processes on the node."""
logger.info(
"Process STDOUT and STDERR is being redirected to {}.".format(
self._logs_dir))
self.start_plasma_store()
self.start_raylet()
if PY3:
self.start_repo... | [
"def",
"start_ray_processes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Process STDOUT and STDERR is being redirected to {}.\"",
".",
"format",
"(",
"self",
".",
"_logs_dir",
")",
")",
"self",
".",
"start_plasma_store",
"(",
")",
"self",
".",
"start_ra... | Start all of the processes on the node. | [
"Start",
"all",
"of",
"the",
"processes",
"on",
"the",
"node",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L479-L491 | train |
ray-project/ray | python/ray/node.py | Node._kill_process_type | def _kill_process_type(self,
process_type,
allow_graceful=False,
check_alive=True,
wait=False):
"""Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will k... | python | def _kill_process_type(self,
process_type,
allow_graceful=False,
check_alive=True,
wait=False):
"""Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will k... | [
"def",
"_kill_process_type",
"(",
"self",
",",
"process_type",
",",
"allow_graceful",
"=",
"False",
",",
"check_alive",
"=",
"True",
",",
"wait",
"=",
"False",
")",
":",
"process_infos",
"=",
"self",
".",
"all_processes",
"[",
"process_type",
"]",
"if",
"pro... | Kill a process of a given type.
If the process type is PROCESS_TYPE_REDIS_SERVER, then we will kill all
of the Redis servers.
If the process was started in valgrind, then we will raise an exception
if the process has a non-zero exit code.
Args:
process_type: The ty... | [
"Kill",
"a",
"process",
"of",
"a",
"given",
"type",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L493-L579 | train |
ray-project/ray | python/ray/node.py | Node.kill_redis | def kill_redis(self, check_alive=True):
"""Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_aliv... | python | def kill_redis(self, check_alive=True):
"""Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_aliv... | [
"def",
"kill_redis",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_REDIS_SERVER",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the Redis servers.
Args:
check_alive (bool): Raise an exception if any of the processes
were already dead. | [
"Kill",
"the",
"Redis",
"servers",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L581-L589 | train |
ray-project/ray | python/ray/node.py | Node.kill_plasma_store | def kill_plasma_store(self, check_alive=True):
"""Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_PLASMA_STORE, check_alive=check_alive) | python | def kill_plasma_store(self, check_alive=True):
"""Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_PLASMA_STORE, check_alive=check_alive) | [
"def",
"kill_plasma_store",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_PLASMA_STORE",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the plasma store.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"plasma",
"store",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L591-L599 | train |
ray-project/ray | python/ray/node.py | Node.kill_raylet | def kill_raylet(self, check_alive=True):
"""Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET, check_alive=check_alive) | python | def kill_raylet(self, check_alive=True):
"""Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET, check_alive=check_alive) | [
"def",
"kill_raylet",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_RAYLET",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the raylet.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"raylet",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L601-L609 | train |
ray-project/ray | python/ray/node.py | Node.kill_log_monitor | def kill_log_monitor(self, check_alive=True):
"""Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_LOG_MONITOR, check_alive=check_alive) | python | def kill_log_monitor(self, check_alive=True):
"""Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_LOG_MONITOR, check_alive=check_alive) | [
"def",
"kill_log_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_LOG_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the log monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"log",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L611-L619 | train |
ray-project/ray | python/ray/node.py | Node.kill_reporter | def kill_reporter(self, check_alive=True):
"""Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
# reporter is started only in PY3.
if PY3:
self._kill_process_type(
ray_cons... | python | def kill_reporter(self, check_alive=True):
"""Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
# reporter is started only in PY3.
if PY3:
self._kill_process_type(
ray_cons... | [
"def",
"kill_reporter",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"# reporter is started only in PY3.",
"if",
"PY3",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_REPORTER",
",",
"check_alive",
"=",
"check_alive",
")"... | Kill the reporter.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"reporter",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L621-L631 | train |
ray-project/ray | python/ray/node.py | Node.kill_dashboard | def kill_dashboard(self, check_alive=True):
"""Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_DASHBOARD, check_alive=check_alive) | python | def kill_dashboard(self, check_alive=True):
"""Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_DASHBOARD, check_alive=check_alive) | [
"def",
"kill_dashboard",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_DASHBOARD",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the dashboard.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"dashboard",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L633-L641 | train |
ray-project/ray | python/ray/node.py | Node.kill_monitor | def kill_monitor(self, check_alive=True):
"""Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_MONITOR, check_alive=check_alive) | python | def kill_monitor(self, check_alive=True):
"""Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_MONITOR, check_alive=check_alive) | [
"def",
"kill_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L643-L651 | train |
ray-project/ray | python/ray/node.py | Node.kill_raylet_monitor | def kill_raylet_monitor(self, check_alive=True):
"""Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET_MONITOR, check_alive=check_al... | python | def kill_raylet_monitor(self, check_alive=True):
"""Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead.
"""
self._kill_process_type(
ray_constants.PROCESS_TYPE_RAYLET_MONITOR, check_alive=check_al... | [
"def",
"kill_raylet_monitor",
"(",
"self",
",",
"check_alive",
"=",
"True",
")",
":",
"self",
".",
"_kill_process_type",
"(",
"ray_constants",
".",
"PROCESS_TYPE_RAYLET_MONITOR",
",",
"check_alive",
"=",
"check_alive",
")"
] | Kill the raylet monitor.
Args:
check_alive (bool): Raise an exception if the process was already
dead. | [
"Kill",
"the",
"raylet",
"monitor",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L653-L661 | train |
ray-project/ray | python/ray/node.py | Node.kill_all_processes | def kill_all_processes(self, check_alive=True, allow_graceful=False):
"""Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception ... | python | def kill_all_processes(self, check_alive=True, allow_graceful=False):
"""Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception ... | [
"def",
"kill_all_processes",
"(",
"self",
",",
"check_alive",
"=",
"True",
",",
"allow_graceful",
"=",
"False",
")",
":",
"# Kill the raylet first. This is important for suppressing errors at",
"# shutdown because we give the raylet a chance to exit gracefully and",
"# clean up its c... | Kill all of the processes.
Note that This is slower than necessary because it calls kill, wait,
kill, wait, ... instead of kill, kill, ..., wait, wait, ...
Args:
check_alive (bool): Raise an exception if any of the processes were
already dead. | [
"Kill",
"all",
"of",
"the",
"processes",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L663-L690 | train |
ray-project/ray | python/ray/node.py | Node.live_processes | def live_processes(self):
"""Return a list of the live processes.
Returns:
A list of the live processes.
"""
result = []
for process_type, process_infos in self.all_processes.items():
for process_info in process_infos:
if process_info.proc... | python | def live_processes(self):
"""Return a list of the live processes.
Returns:
A list of the live processes.
"""
result = []
for process_type, process_infos in self.all_processes.items():
for process_info in process_infos:
if process_info.proc... | [
"def",
"live_processes",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"process_type",
",",
"process_infos",
"in",
"self",
".",
"all_processes",
".",
"items",
"(",
")",
":",
"for",
"process_info",
"in",
"process_infos",
":",
"if",
"process_info",
... | Return a list of the live processes.
Returns:
A list of the live processes. | [
"Return",
"a",
"list",
"of",
"the",
"live",
"processes",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/node.py#L692-L703 | train |
ray-project/ray | python/ray/rllib/agents/es/es.py | create_shared_noise | def create_shared_noise(count):
"""Create a large array of noise to be shared by all workers."""
seed = 123
noise = np.random.RandomState(seed).randn(count).astype(np.float32)
return noise | python | def create_shared_noise(count):
"""Create a large array of noise to be shared by all workers."""
seed = 123
noise = np.random.RandomState(seed).randn(count).astype(np.float32)
return noise | [
"def",
"create_shared_noise",
"(",
"count",
")",
":",
"seed",
"=",
"123",
"noise",
"=",
"np",
".",
"random",
".",
"RandomState",
"(",
"seed",
")",
".",
"randn",
"(",
"count",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"return",
"noise"
] | Create a large array of noise to be shared by all workers. | [
"Create",
"a",
"large",
"array",
"of",
"noise",
"to",
"be",
"shared",
"by",
"all",
"workers",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/es/es.py#L51-L55 | train |
ray-project/ray | python/ray/experimental/sgd/tfbench/model_config.py | get_model_config | def get_model_config(model_name, dataset):
"""Map model name to model network configuration."""
model_map = _get_model_map(dataset.name)
if model_name not in model_map:
raise ValueError("Invalid model name \"%s\" for dataset \"%s\"" %
(model_name, dataset.name))
else:
... | python | def get_model_config(model_name, dataset):
"""Map model name to model network configuration."""
model_map = _get_model_map(dataset.name)
if model_name not in model_map:
raise ValueError("Invalid model name \"%s\" for dataset \"%s\"" %
(model_name, dataset.name))
else:
... | [
"def",
"get_model_config",
"(",
"model_name",
",",
"dataset",
")",
":",
"model_map",
"=",
"_get_model_map",
"(",
"dataset",
".",
"name",
")",
"if",
"model_name",
"not",
"in",
"model_map",
":",
"raise",
"ValueError",
"(",
"\"Invalid model name \\\"%s\\\" for dataset ... | Map model name to model network configuration. | [
"Map",
"model",
"name",
"to",
"model",
"network",
"configuration",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L41-L48 | train |
ray-project/ray | python/ray/experimental/sgd/tfbench/model_config.py | register_model | def register_model(model_name, dataset_name, model_func):
"""Register a new model that can be obtained with `get_model_config`."""
model_map = _get_model_map(dataset_name)
if model_name in model_map:
raise ValueError("Model \"%s\" is already registered for dataset"
"\"%s\"" ... | python | def register_model(model_name, dataset_name, model_func):
"""Register a new model that can be obtained with `get_model_config`."""
model_map = _get_model_map(dataset_name)
if model_name in model_map:
raise ValueError("Model \"%s\" is already registered for dataset"
"\"%s\"" ... | [
"def",
"register_model",
"(",
"model_name",
",",
"dataset_name",
",",
"model_func",
")",
":",
"model_map",
"=",
"_get_model_map",
"(",
"dataset_name",
")",
"if",
"model_name",
"in",
"model_map",
":",
"raise",
"ValueError",
"(",
"\"Model \\\"%s\\\" is already registere... | Register a new model that can be obtained with `get_model_config`. | [
"Register",
"a",
"new",
"model",
"that",
"can",
"be",
"obtained",
"with",
"get_model_config",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/model_config.py#L51-L57 | train |
ray-project/ray | python/ray/rllib/agents/ars/policies.py | rollout | def rollout(policy, env, timestep_limit=None, add_noise=False, offset=0):
"""Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to... | python | def rollout(policy, env, timestep_limit=None, add_noise=False, offset=0):
"""Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to... | [
"def",
"rollout",
"(",
"policy",
",",
"env",
",",
"timestep_limit",
"=",
"None",
",",
"add_noise",
"=",
"False",
",",
"offset",
"=",
"0",
")",
":",
"env_timestep_limit",
"=",
"env",
".",
"spec",
".",
"max_episode_steps",
"timestep_limit",
"=",
"(",
"env_ti... | Do a rollout.
If add_noise is True, the rollout will take noisy actions with
noise drawn from that stream. Otherwise, no action noise will be added.
Parameters
----------
policy: tf object
policy from which to draw actions
env: GymEnv
environment from which to draw rewards, don... | [
"Do",
"a",
"rollout",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/ars/policies.py#L19-L54 | train |
ray-project/ray | python/ray/tune/suggest/basic_variant.py | BasicVariantGenerator.next_trials | def next_trials(self):
"""Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials.
"""
trials = list(self._trial_generator)
if self._shuffle:
random.shuffle(trials)
self._finished = True
r... | python | def next_trials(self):
"""Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials.
"""
trials = list(self._trial_generator)
if self._shuffle:
random.shuffle(trials)
self._finished = True
r... | [
"def",
"next_trials",
"(",
"self",
")",
":",
"trials",
"=",
"list",
"(",
"self",
".",
"_trial_generator",
")",
"if",
"self",
".",
"_shuffle",
":",
"random",
".",
"shuffle",
"(",
"trials",
")",
"self",
".",
"_finished",
"=",
"True",
"return",
"trials"
] | Provides Trial objects to be queued into the TrialRunner.
Returns:
trials (list): Returns a list of trials. | [
"Provides",
"Trial",
"objects",
"to",
"be",
"queued",
"into",
"the",
"TrialRunner",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L51-L61 | train |
ray-project/ray | python/ray/tune/suggest/basic_variant.py | BasicVariantGenerator._generate_trials | def _generate_trials(self, unresolved_spec, output_path=""):
"""Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yie... | python | def _generate_trials(self, unresolved_spec, output_path=""):
"""Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yie... | [
"def",
"_generate_trials",
"(",
"self",
",",
"unresolved_spec",
",",
"output_path",
"=",
"\"\"",
")",
":",
"if",
"\"run\"",
"not",
"in",
"unresolved_spec",
":",
"raise",
"TuneError",
"(",
"\"Must specify `run` in {}\"",
".",
"format",
"(",
"unresolved_spec",
")",
... | Generates Trial objects with the variant generation process.
Uses a fixed point iteration to resolve variants. All trials
should be able to be generated at once.
See also: `ray.tune.suggest.variant_generator`.
Yields:
Trial object | [
"Generates",
"Trial",
"objects",
"with",
"the",
"variant",
"generation",
"process",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/basic_variant.py#L63-L87 | train |
ray-project/ray | python/ray/rllib/optimizers/segment_tree.py | SegmentTree.reduce | def reduce(self, start=0, end=None):
"""Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginni... | python | def reduce(self, start=0, end=None):
"""Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginni... | [
"def",
"reduce",
"(",
"self",
",",
"start",
"=",
"0",
",",
"end",
"=",
"None",
")",
":",
"if",
"end",
"is",
"None",
":",
"end",
"=",
"self",
".",
"_capacity",
"-",
"1",
"if",
"end",
"<",
"0",
":",
"end",
"+=",
"self",
".",
"_capacity",
"return"... | Returns result of applying `self.operation`
to a contiguous subsequence of the array.
self.operation(
arr[start], operation(arr[start+1], operation(... arr[end])))
Parameters
----------
start: int
beginning of the subsequence
end: int
... | [
"Returns",
"result",
"of",
"applying",
"self",
".",
"operation",
"to",
"a",
"contiguous",
"subsequence",
"of",
"the",
"array",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/segment_tree.py#L59-L83 | train |
ray-project/ray | python/ray/experimental/gcs_flush_policy.py | set_flushing_policy | def set_flushing_policy(flushing_policy):
"""Serialize this policy for Monitor to pick up."""
if "RAY_USE_NEW_GCS" not in os.environ:
raise Exception(
"set_flushing_policy() is only available when environment "
"variable RAY_USE_NEW_GCS is present at both compile and run time."
... | python | def set_flushing_policy(flushing_policy):
"""Serialize this policy for Monitor to pick up."""
if "RAY_USE_NEW_GCS" not in os.environ:
raise Exception(
"set_flushing_policy() is only available when environment "
"variable RAY_USE_NEW_GCS is present at both compile and run time."
... | [
"def",
"set_flushing_policy",
"(",
"flushing_policy",
")",
":",
"if",
"\"RAY_USE_NEW_GCS\"",
"not",
"in",
"os",
".",
"environ",
":",
"raise",
"Exception",
"(",
"\"set_flushing_policy() is only available when environment \"",
"\"variable RAY_USE_NEW_GCS is present at both compile ... | Serialize this policy for Monitor to pick up. | [
"Serialize",
"this",
"policy",
"for",
"Monitor",
"to",
"pick",
"up",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/gcs_flush_policy.py#L80-L91 | train |
ray-project/ray | python/ray/tune/cluster_info.py | get_ssh_key | def get_ssh_key():
"""Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes.
"""
path = os.environ.get("TUNE_CLUSTER_SSH_KEY",
os.path.expanduser("~/ray_bootstrap_key... | python | def get_ssh_key():
"""Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes.
"""
path = os.environ.get("TUNE_CLUSTER_SSH_KEY",
os.path.expanduser("~/ray_bootstrap_key... | [
"def",
"get_ssh_key",
"(",
")",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"TUNE_CLUSTER_SSH_KEY\"",
",",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/ray_bootstrap_key.pem\"",
")",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"pa... | Returns ssh key to connecting to cluster workers.
If the env var TUNE_CLUSTER_SSH_KEY is provided, then this key
will be used for syncing across different nodes. | [
"Returns",
"ssh",
"key",
"to",
"connecting",
"to",
"cluster",
"workers",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/cluster_info.py#L15-L25 | train |
ray-project/ray | python/ray/tune/suggest/hyperopt.py | HyperOptSearch.on_trial_complete | def on_trial_complete(self,
trial_id,
result=None,
error=False,
early_terminated=False):
"""Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when int... | python | def on_trial_complete(self,
trial_id,
result=None,
error=False,
early_terminated=False):
"""Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when int... | [
"def",
"on_trial_complete",
"(",
"self",
",",
"trial_id",
",",
"result",
"=",
"None",
",",
"error",
"=",
"False",
",",
"early_terminated",
"=",
"False",
")",
":",
"ho_trial",
"=",
"self",
".",
"_get_hyperopt_trial",
"(",
"trial_id",
")",
"if",
"ho_trial",
... | Passes the result to HyperOpt unless early terminated or errored.
The result is internally negated when interacting with HyperOpt
so that HyperOpt can "maximize" this value, as it minimizes on default. | [
"Passes",
"the",
"result",
"to",
"HyperOpt",
"unless",
"early",
"terminated",
"or",
"errored",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/hyperopt.py#L126-L151 | train |
ray-project/ray | python/ray/experimental/streaming/batched_queue.py | plasma_prefetch | def plasma_prefetch(object_id):
"""Tells plasma to prefetch the given object_id."""
local_sched_client = ray.worker.global_worker.raylet_client
ray_obj_id = ray.ObjectID(object_id)
local_sched_client.fetch_or_reconstruct([ray_obj_id], True) | python | def plasma_prefetch(object_id):
"""Tells plasma to prefetch the given object_id."""
local_sched_client = ray.worker.global_worker.raylet_client
ray_obj_id = ray.ObjectID(object_id)
local_sched_client.fetch_or_reconstruct([ray_obj_id], True) | [
"def",
"plasma_prefetch",
"(",
"object_id",
")",
":",
"local_sched_client",
"=",
"ray",
".",
"worker",
".",
"global_worker",
".",
"raylet_client",
"ray_obj_id",
"=",
"ray",
".",
"ObjectID",
"(",
"object_id",
")",
"local_sched_client",
".",
"fetch_or_reconstruct",
... | Tells plasma to prefetch the given object_id. | [
"Tells",
"plasma",
"to",
"prefetch",
"the",
"given",
"object_id",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L17-L21 | train |
ray-project/ray | python/ray/experimental/streaming/batched_queue.py | plasma_get | def plasma_get(object_id):
"""Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before.
"""
client = ray.worker.global_worker.plasma_client
plasma_id = ray.pyarrow.plasma.ObjectID(object_id)
while not client.contains(... | python | def plasma_get(object_id):
"""Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before.
"""
client = ray.worker.global_worker.plasma_client
plasma_id = ray.pyarrow.plasma.ObjectID(object_id)
while not client.contains(... | [
"def",
"plasma_get",
"(",
"object_id",
")",
":",
"client",
"=",
"ray",
".",
"worker",
".",
"global_worker",
".",
"plasma_client",
"plasma_id",
"=",
"ray",
".",
"pyarrow",
".",
"plasma",
".",
"ObjectID",
"(",
"object_id",
")",
"while",
"not",
"client",
".",... | Get an object directly from plasma without going through object table.
Precondition: plasma_prefetch(object_id) has been called before. | [
"Get",
"an",
"object",
"directly",
"from",
"plasma",
"without",
"going",
"through",
"object",
"table",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L24-L33 | train |
ray-project/ray | python/ray/experimental/streaming/batched_queue.py | BatchedQueue.enable_writes | def enable_writes(self):
"""Restores the state of the batched queue for writing."""
self.write_buffer = []
self.flush_lock = threading.RLock()
self.flush_thread = FlushThread(self.max_batch_time,
self._flush_writes) | python | def enable_writes(self):
"""Restores the state of the batched queue for writing."""
self.write_buffer = []
self.flush_lock = threading.RLock()
self.flush_thread = FlushThread(self.max_batch_time,
self._flush_writes) | [
"def",
"enable_writes",
"(",
"self",
")",
":",
"self",
".",
"write_buffer",
"=",
"[",
"]",
"self",
".",
"flush_lock",
"=",
"threading",
".",
"RLock",
"(",
")",
"self",
".",
"flush_thread",
"=",
"FlushThread",
"(",
"self",
".",
"max_batch_time",
",",
"sel... | Restores the state of the batched queue for writing. | [
"Restores",
"the",
"state",
"of",
"the",
"batched",
"queue",
"for",
"writing",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L136-L141 | train |
ray-project/ray | python/ray/experimental/streaming/batched_queue.py | BatchedQueue._wait_for_reader | def _wait_for_reader(self):
"""Checks for backpressure by the downstream reader."""
if self.max_size <= 0: # Unlimited queue
return
if self.write_item_offset - self.cached_remote_offset <= self.max_size:
return # Hasn't reached max size
remote_offset = internal_... | python | def _wait_for_reader(self):
"""Checks for backpressure by the downstream reader."""
if self.max_size <= 0: # Unlimited queue
return
if self.write_item_offset - self.cached_remote_offset <= self.max_size:
return # Hasn't reached max size
remote_offset = internal_... | [
"def",
"_wait_for_reader",
"(",
"self",
")",
":",
"if",
"self",
".",
"max_size",
"<=",
"0",
":",
"# Unlimited queue",
"return",
"if",
"self",
".",
"write_item_offset",
"-",
"self",
".",
"cached_remote_offset",
"<=",
"self",
".",
"max_size",
":",
"return",
"#... | Checks for backpressure by the downstream reader. | [
"Checks",
"for",
"backpressure",
"by",
"the",
"downstream",
"reader",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/batched_queue.py#L166-L187 | train |
ray-project/ray | python/ray/rllib/optimizers/rollout.py | collect_samples | def collect_samples(agents, sample_batch_size, num_envs_per_worker,
train_batch_size):
"""Collects at least train_batch_size samples, never discarding any."""
num_timesteps_so_far = 0
trajectories = []
agent_dict = {}
for agent in agents:
fut_sample = agent.sample.remot... | python | def collect_samples(agents, sample_batch_size, num_envs_per_worker,
train_batch_size):
"""Collects at least train_batch_size samples, never discarding any."""
num_timesteps_so_far = 0
trajectories = []
agent_dict = {}
for agent in agents:
fut_sample = agent.sample.remot... | [
"def",
"collect_samples",
"(",
"agents",
",",
"sample_batch_size",
",",
"num_envs_per_worker",
",",
"train_batch_size",
")",
":",
"num_timesteps_so_far",
"=",
"0",
"trajectories",
"=",
"[",
"]",
"agent_dict",
"=",
"{",
"}",
"for",
"agent",
"in",
"agents",
":",
... | Collects at least train_batch_size samples, never discarding any. | [
"Collects",
"at",
"least",
"train_batch_size",
"samples",
"never",
"discarding",
"any",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L14-L40 | train |
ray-project/ray | python/ray/rllib/optimizers/rollout.py | collect_samples_straggler_mitigation | def collect_samples_straggler_mitigation(agents, train_batch_size):
"""Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples.
"""
num_timesteps_so_far = 0
traje... | python | def collect_samples_straggler_mitigation(agents, train_batch_size):
"""Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples.
"""
num_timesteps_so_far = 0
traje... | [
"def",
"collect_samples_straggler_mitigation",
"(",
"agents",
",",
"train_batch_size",
")",
":",
"num_timesteps_so_far",
"=",
"0",
"trajectories",
"=",
"[",
"]",
"agent_dict",
"=",
"{",
"}",
"for",
"agent",
"in",
"agents",
":",
"fut_sample",
"=",
"agent",
".",
... | Collects at least train_batch_size samples.
This is the legacy behavior as of 0.6, and launches extra sample tasks to
potentially improve performance but can result in many wasted samples. | [
"Collects",
"at",
"least",
"train_batch_size",
"samples",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/rollout.py#L43-L72 | train |
ray-project/ray | python/ray/utils.py | format_error_message | def format_error_message(exception_message, task_exception=False):
"""Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
... | python | def format_error_message(exception_message, task_exception=False):
"""Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
... | [
"def",
"format_error_message",
"(",
"exception_message",
",",
"task_exception",
"=",
"False",
")",
":",
"lines",
"=",
"exception_message",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"task_exception",
":",
"# For errors that occur inside of tasks, remove lines 1 and 2 which ar... | Improve the formatting of an exception thrown by a remote function.
This method takes a traceback from an exception and makes it nicer by
removing a few uninformative lines and adding some space to indent the
remaining lines nicely.
Args:
exception_message (str): A message generated by traceba... | [
"Improve",
"the",
"formatting",
"of",
"an",
"exception",
"thrown",
"by",
"a",
"remote",
"function",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L32-L51 | train |
ray-project/ray | python/ray/utils.py | push_error_to_driver | def push_error_to_driver(worker, error_type, message, driver_id=None):
"""Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
... | python | def push_error_to_driver(worker, error_type, message, driver_id=None):
"""Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
... | [
"def",
"push_error_to_driver",
"(",
"worker",
",",
"error_type",
",",
"message",
",",
"driver_id",
"=",
"None",
")",
":",
"if",
"driver_id",
"is",
"None",
":",
"driver_id",
"=",
"ray",
".",
"DriverID",
".",
"nil",
"(",
")",
"worker",
".",
"raylet_client",
... | Push an error message to the driver to be printed in the background.
Args:
worker: The worker to use.
error_type (str): The type of the error.
message (str): The message that will be printed in the background
on the driver.
driver_id: The ID of the driver to push the err... | [
"Push",
"an",
"error",
"message",
"to",
"the",
"driver",
"to",
"be",
"printed",
"in",
"the",
"background",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L54-L68 | train |
ray-project/ray | python/ray/utils.py | push_error_to_driver_through_redis | def push_error_to_driver_through_redis(redis_client,
error_type,
message,
driver_id=None):
"""Push an error message to the driver to be printed in the background.
Normally the push_error_to_driv... | python | def push_error_to_driver_through_redis(redis_client,
error_type,
message,
driver_id=None):
"""Push an error message to the driver to be printed in the background.
Normally the push_error_to_driv... | [
"def",
"push_error_to_driver_through_redis",
"(",
"redis_client",
",",
"error_type",
",",
"message",
",",
"driver_id",
"=",
"None",
")",
":",
"if",
"driver_id",
"is",
"None",
":",
"driver_id",
"=",
"ray",
".",
"DriverID",
".",
"nil",
"(",
")",
"# Do everything... | Push an error message to the driver to be printed in the background.
Normally the push_error_to_driver function should be used. However, in some
instances, the raylet client is not available, e.g., because the
error happens in Python before the driver or worker has connected to the
backend processes.
... | [
"Push",
"an",
"error",
"message",
"to",
"the",
"driver",
"to",
"be",
"printed",
"in",
"the",
"background",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L71-L99 | train |
ray-project/ray | python/ray/utils.py | is_cython | def is_cython(obj):
"""Check if an object is a Cython function or method"""
# TODO(suo): We could split these into two functions, one for Cython
# functions and another for Cython methods.
# TODO(suo): There doesn't appear to be a Cython function 'type' we can
# check against via isinstance. Please... | python | def is_cython(obj):
"""Check if an object is a Cython function or method"""
# TODO(suo): We could split these into two functions, one for Cython
# functions and another for Cython methods.
# TODO(suo): There doesn't appear to be a Cython function 'type' we can
# check against via isinstance. Please... | [
"def",
"is_cython",
"(",
"obj",
")",
":",
"# TODO(suo): We could split these into two functions, one for Cython",
"# functions and another for Cython methods.",
"# TODO(suo): There doesn't appear to be a Cython function 'type' we can",
"# check against via isinstance. Please correct me if I'm wron... | Check if an object is a Cython function or method | [
"Check",
"if",
"an",
"object",
"is",
"a",
"Cython",
"function",
"or",
"method"
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L102-L114 | train |
ray-project/ray | python/ray/utils.py | is_function_or_method | def is_function_or_method(obj):
"""Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method.
"""
return inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj) | python | def is_function_or_method(obj):
"""Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method.
"""
return inspect.isfunction(obj) or inspect.ismethod(obj) or is_cython(obj) | [
"def",
"is_function_or_method",
"(",
"obj",
")",
":",
"return",
"inspect",
".",
"isfunction",
"(",
"obj",
")",
"or",
"inspect",
".",
"ismethod",
"(",
"obj",
")",
"or",
"is_cython",
"(",
"obj",
")"
] | Check if an object is a function or method.
Args:
obj: The Python object in question.
Returns:
True if the object is an function or method. | [
"Check",
"if",
"an",
"object",
"is",
"a",
"function",
"or",
"method",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L117-L126 | train |
ray-project/ray | python/ray/utils.py | random_string | def random_string():
"""Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the sta... | python | def random_string():
"""Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the sta... | [
"def",
"random_string",
"(",
")",
":",
"# Get the state of the numpy random number generator.",
"numpy_state",
"=",
"np",
".",
"random",
".",
"get_state",
"(",
")",
"# Try to use true randomness.",
"np",
".",
"random",
".",
"seed",
"(",
"None",
")",
"# Generate the ra... | Generate a random string to use as an ID.
Note that users may seed numpy, which could cause this function to generate
duplicate IDs. Therefore, we need to seed numpy ourselves, but we can't
interfere with the state of the user's random number generator, so we
extract the state of the random number gene... | [
"Generate",
"a",
"random",
"string",
"to",
"use",
"as",
"an",
"ID",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L134-L157 | train |
ray-project/ray | python/ray/utils.py | decode | def decode(byte_str, allow_none=False):
"""Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
... | python | def decode(byte_str, allow_none=False):
"""Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
... | [
"def",
"decode",
"(",
"byte_str",
",",
"allow_none",
"=",
"False",
")",
":",
"if",
"byte_str",
"is",
"None",
"and",
"allow_none",
":",
"return",
"\"\"",
"if",
"not",
"isinstance",
"(",
"byte_str",
",",
"bytes",
")",
":",
"raise",
"ValueError",
"(",
"\"Th... | Make this unicode in Python 3, otherwise leave it as bytes.
Args:
byte_str: The byte string to decode.
allow_none: If true, then we will allow byte_str to be None in which
case we will return an empty string. TODO(rkn): Remove this flag.
This is only here to simplify upgradi... | [
"Make",
"this",
"unicode",
"in",
"Python",
"3",
"otherwise",
"leave",
"it",
"as",
"bytes",
"."
] | 4eade036a0505e244c976f36aaa2d64386b5129b | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L160-L181 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.