partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Trainable.train | Runs one logical iteration of training.
Subclasses should override ``_train()`` instead to return results.
This class automatically fills the following fields in the result:
`done` (bool): training is terminated. Filled only if not provided.
`time_this_iter_s` (float): Time in... | python/ray/tune/trainable.py | def train(self):
"""Runs one logical iteration of training.
Subclasses should override ``_train()`` instead to return results.
This class automatically fills the following fields in the result:
`done` (bool): training is terminated. Filled only if not provided.
`time_t... | def train(self):
"""Runs one logical iteration of training.
Subclasses should override ``_train()`` instead to return results.
This class automatically fills the following fields in the result:
`done` (bool): training is terminated. Filled only if not provided.
`time_t... | [
"Runs",
"one",
"logical",
"iteration",
"of",
"training",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L111-L211 | [
"def",
"train",
"(",
"self",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"result",
"=",
"self",
".",
"_train",
"(",
")",
"assert",
"isinstance",
"(",
"result",
",",
"dict",
")",
",",
"\"_train() needs to return a dict.\"",
"# We do not modify inte... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.delete_checkpoint | Removes subdirectory within checkpoint_folder
Parameters
----------
checkpoint_dir : path to checkpoint | python/ray/tune/trainable.py | def delete_checkpoint(self, checkpoint_dir):
"""Removes subdirectory within checkpoint_folder
Parameters
----------
checkpoint_dir : path to checkpoint
"""
if os.path.isfile(checkpoint_dir):
shutil.rmtree(os.path.dirname(checkpoint_dir))
else:
... | def delete_checkpoint(self, checkpoint_dir):
"""Removes subdirectory within checkpoint_folder
Parameters
----------
checkpoint_dir : path to checkpoint
"""
if os.path.isfile(checkpoint_dir):
shutil.rmtree(os.path.dirname(checkpoint_dir))
else:
... | [
"Removes",
"subdirectory",
"within",
"checkpoint_folder",
"Parameters",
"----------",
"checkpoint_dir",
":",
"path",
"to",
"checkpoint"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L213-L222 | [
"def",
"delete_checkpoint",
"(",
"self",
",",
"checkpoint_dir",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"checkpoint_dir",
")",
":",
"shutil",
".",
"rmtree",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"checkpoint_dir",
")",
")",
"else",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.save | Saves the current model state to a checkpoint.
Subclasses should override ``_save()`` instead to save state.
This method dumps additional metadata alongside the saved path.
Args:
checkpoint_dir (str): Optional dir to place the checkpoint.
Returns:
Checkpoint pa... | python/ray/tune/trainable.py | def save(self, checkpoint_dir=None):
"""Saves the current model state to a checkpoint.
Subclasses should override ``_save()`` instead to save state.
This method dumps additional metadata alongside the saved path.
Args:
checkpoint_dir (str): Optional dir to place the checkpo... | def save(self, checkpoint_dir=None):
"""Saves the current model state to a checkpoint.
Subclasses should override ``_save()`` instead to save state.
This method dumps additional metadata alongside the saved path.
Args:
checkpoint_dir (str): Optional dir to place the checkpo... | [
"Saves",
"the",
"current",
"model",
"state",
"to",
"a",
"checkpoint",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L224-L273 | [
"def",
"save",
"(",
"self",
",",
"checkpoint_dir",
"=",
"None",
")",
":",
"checkpoint_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"checkpoint_dir",
"or",
"self",
".",
"logdir",
",",
"\"checkpoint_{}\"",
".",
"format",
"(",
"self",
".",
"_iteration",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.save_to_object | Saves the current model state to a Python object. It also
saves to disk but does not return the checkpoint path.
Returns:
Object holding checkpoint data. | python/ray/tune/trainable.py | def save_to_object(self):
"""Saves the current model state to a Python object. It also
saves to disk but does not return the checkpoint path.
Returns:
Object holding checkpoint data.
"""
tmpdir = tempfile.mkdtemp("save_to_object", dir=self.logdir)
checkpoint... | def save_to_object(self):
"""Saves the current model state to a Python object. It also
saves to disk but does not return the checkpoint path.
Returns:
Object holding checkpoint data.
"""
tmpdir = tempfile.mkdtemp("save_to_object", dir=self.logdir)
checkpoint... | [
"Saves",
"the",
"current",
"model",
"state",
"to",
"a",
"Python",
"object",
".",
"It",
"also",
"saves",
"to",
"disk",
"but",
"does",
"not",
"return",
"the",
"checkpoint",
"path",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L275-L304 | [
"def",
"save_to_object",
"(",
"self",
")",
":",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"\"save_to_object\"",
",",
"dir",
"=",
"self",
".",
"logdir",
")",
"checkpoint_prefix",
"=",
"self",
".",
"save",
"(",
"tmpdir",
")",
"data",
"=",
"{",
"}",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.restore | Restores training state from a given model checkpoint.
These checkpoints are returned from calls to save().
Subclasses should override ``_restore()`` instead to restore state.
This method restores additional metadata saved with the checkpoint. | python/ray/tune/trainable.py | def restore(self, checkpoint_path):
"""Restores training state from a given model checkpoint.
These checkpoints are returned from calls to save().
Subclasses should override ``_restore()`` instead to restore state.
This method restores additional metadata saved with the checkpoint.
... | def restore(self, checkpoint_path):
"""Restores training state from a given model checkpoint.
These checkpoints are returned from calls to save().
Subclasses should override ``_restore()`` instead to restore state.
This method restores additional metadata saved with the checkpoint.
... | [
"Restores",
"training",
"state",
"from",
"a",
"given",
"model",
"checkpoint",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L306-L332 | [
"def",
"restore",
"(",
"self",
",",
"checkpoint_path",
")",
":",
"with",
"open",
"(",
"checkpoint_path",
"+",
"\".tune_metadata\"",
",",
"\"rb\"",
")",
"as",
"f",
":",
"metadata",
"=",
"pickle",
".",
"load",
"(",
"f",
")",
"self",
".",
"_experiment_id",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.restore_from_object | Restores training state from a checkpoint object.
These checkpoints are returned from calls to save_to_object(). | python/ray/tune/trainable.py | def restore_from_object(self, obj):
"""Restores training state from a checkpoint object.
These checkpoints are returned from calls to save_to_object().
"""
info = pickle.loads(obj)
data = info["data"]
tmpdir = tempfile.mkdtemp("restore_from_object", dir=self.logdir)
... | def restore_from_object(self, obj):
"""Restores training state from a checkpoint object.
These checkpoints are returned from calls to save_to_object().
"""
info = pickle.loads(obj)
data = info["data"]
tmpdir = tempfile.mkdtemp("restore_from_object", dir=self.logdir)
... | [
"Restores",
"training",
"state",
"from",
"a",
"checkpoint",
"object",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L334-L350 | [
"def",
"restore_from_object",
"(",
"self",
",",
"obj",
")",
":",
"info",
"=",
"pickle",
".",
"loads",
"(",
"obj",
")",
"data",
"=",
"info",
"[",
"\"data\"",
"]",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"\"restore_from_object\"",
",",
"dir",
"=",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Trainable.export_model | Exports model based on export_formats.
Subclasses should override _export_model() to actually
export model to local directory.
Args:
export_formats (list): List of formats that should be exported.
export_dir (str): Optional dir to place the exported model.
... | python/ray/tune/trainable.py | def export_model(self, export_formats, export_dir=None):
"""Exports model based on export_formats.
Subclasses should override _export_model() to actually
export model to local directory.
Args:
export_formats (list): List of formats that should be exported.
expor... | def export_model(self, export_formats, export_dir=None):
"""Exports model based on export_formats.
Subclasses should override _export_model() to actually
export model to local directory.
Args:
export_formats (list): List of formats that should be exported.
expor... | [
"Exports",
"model",
"based",
"on",
"export_formats",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trainable.py#L352-L367 | [
"def",
"export_model",
"(",
"self",
",",
"export_formats",
",",
"export_dir",
"=",
"None",
")",
":",
"export_dir",
"=",
"export_dir",
"or",
"self",
".",
"logdir",
"return",
"self",
".",
"_export_model",
"(",
"export_formats",
",",
"export_dir",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LinearSchedule.value | See Schedule.value | python/ray/rllib/utils/schedules.py | def value(self, t):
"""See Schedule.value"""
fraction = min(float(t) / max(1, self.schedule_timesteps), 1.0)
return self.initial_p + fraction * (self.final_p - self.initial_p) | def value(self, t):
"""See Schedule.value"""
fraction = min(float(t) / max(1, self.schedule_timesteps), 1.0)
return self.initial_p + fraction * (self.final_p - self.initial_p) | [
"See",
"Schedule",
".",
"value"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/schedules.py#L105-L108 | [
"def",
"value",
"(",
"self",
",",
"t",
")",
":",
"fraction",
"=",
"min",
"(",
"float",
"(",
"t",
")",
"/",
"max",
"(",
"1",
",",
"self",
".",
"schedule_timesteps",
")",
",",
"1.0",
")",
"return",
"self",
".",
"initial_p",
"+",
"fraction",
"*",
"(... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | dump_json | Dump a whole json record into the given file.
Overwrite the file if the overwrite flag set.
Args:
json_info (dict): Information dict to be dumped.
json_file (str): File path to be dumped to.
overwrite(boolean) | python/ray/tune/automlboard/common/utils.py | def dump_json(json_info, json_file, overwrite=True):
"""Dump a whole json record into the given file.
Overwrite the file if the overwrite flag set.
Args:
json_info (dict): Information dict to be dumped.
json_file (str): File path to be dumped to.
overwrite(boolean)
"""
if o... | def dump_json(json_info, json_file, overwrite=True):
"""Dump a whole json record into the given file.
Overwrite the file if the overwrite flag set.
Args:
json_info (dict): Information dict to be dumped.
json_file (str): File path to be dumped to.
overwrite(boolean)
"""
if o... | [
"Dump",
"a",
"whole",
"json",
"record",
"into",
"the",
"given",
"file",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/common/utils.py#L11-L30 | [
"def",
"dump_json",
"(",
"json_info",
",",
"json_file",
",",
"overwrite",
"=",
"True",
")",
":",
"if",
"overwrite",
":",
"mode",
"=",
"\"w\"",
"else",
":",
"mode",
"=",
"\"w+\"",
"try",
":",
"with",
"open",
"(",
"json_file",
",",
"mode",
")",
"as",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | parse_json | Parse a whole json record from the given file.
Return None if the json file does not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
Returns:
A dict of json info. | python/ray/tune/automlboard/common/utils.py | def parse_json(json_file):
"""Parse a whole json record from the given file.
Return None if the json file does not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
Returns:
A dict of json info.
"""
if not os.path.exists(json_file):
return None... | def parse_json(json_file):
"""Parse a whole json record from the given file.
Return None if the json file does not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
Returns:
A dict of json info.
"""
if not os.path.exists(json_file):
return None... | [
"Parse",
"a",
"whole",
"json",
"record",
"from",
"the",
"given",
"file",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/common/utils.py#L33-L55 | [
"def",
"parse_json",
"(",
"json_file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"json_file",
")",
":",
"return",
"None",
"try",
":",
"with",
"open",
"(",
"json_file",
",",
"\"r\"",
")",
"as",
"f",
":",
"info_str",
"=",
"f",
"."... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | parse_multiple_json | Parse multiple json records from the given file.
Seek to the offset as the start point before parsing
if offset set. return empty list if the json file does
not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
offset (int): Initial seek position of the file.
... | python/ray/tune/automlboard/common/utils.py | def parse_multiple_json(json_file, offset=None):
"""Parse multiple json records from the given file.
Seek to the offset as the start point before parsing
if offset set. return empty list if the json file does
not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
... | def parse_multiple_json(json_file, offset=None):
"""Parse multiple json records from the given file.
Seek to the offset as the start point before parsing
if offset set. return empty list if the json file does
not exists or exception occurs.
Args:
json_file (str): File path to be parsed.
... | [
"Parse",
"multiple",
"json",
"records",
"from",
"the",
"given",
"file",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/common/utils.py#L58-L92 | [
"def",
"parse_multiple_json",
"(",
"json_file",
",",
"offset",
"=",
"None",
")",
":",
"json_info_list",
"=",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"json_file",
")",
":",
"return",
"json_info_list",
"try",
":",
"with",
"open",
"(",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | unicode2str | Convert the unicode element of the content to str recursively. | python/ray/tune/automlboard/common/utils.py | def unicode2str(content):
"""Convert the unicode element of the content to str recursively."""
if isinstance(content, dict):
result = {}
for key in content.keys():
result[unicode2str(key)] = unicode2str(content[key])
return result
elif isinstance(content, list):
r... | def unicode2str(content):
"""Convert the unicode element of the content to str recursively."""
if isinstance(content, dict):
result = {}
for key in content.keys():
result[unicode2str(key)] = unicode2str(content[key])
return result
elif isinstance(content, list):
r... | [
"Convert",
"the",
"unicode",
"element",
"of",
"the",
"content",
"to",
"str",
"recursively",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/common/utils.py#L100-L112 | [
"def",
"unicode2str",
"(",
"content",
")",
":",
"if",
"isinstance",
"(",
"content",
",",
"dict",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"content",
".",
"keys",
"(",
")",
":",
"result",
"[",
"unicode2str",
"(",
"key",
")",
"]",
"=",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LinearModel.loss | Computes the loss of the network. | examples/lbfgs/driver.py | def loss(self, xs, ys):
"""Computes the loss of the network."""
return float(
self.sess.run(
self.cross_entropy, feed_dict={
self.x: xs,
self.y_: ys
})) | def loss(self, xs, ys):
"""Computes the loss of the network."""
return float(
self.sess.run(
self.cross_entropy, feed_dict={
self.x: xs,
self.y_: ys
})) | [
"Computes",
"the",
"loss",
"of",
"the",
"network",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/lbfgs/driver.py#L63-L70 | [
"def",
"loss",
"(",
"self",
",",
"xs",
",",
"ys",
")",
":",
"return",
"float",
"(",
"self",
".",
"sess",
".",
"run",
"(",
"self",
".",
"cross_entropy",
",",
"feed_dict",
"=",
"{",
"self",
".",
"x",
":",
"xs",
",",
"self",
".",
"y_",
":",
"ys",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LinearModel.grad | Computes the gradients of the network. | examples/lbfgs/driver.py | def grad(self, xs, ys):
"""Computes the gradients of the network."""
return self.sess.run(
self.cross_entropy_grads, feed_dict={
self.x: xs,
self.y_: ys
}) | def grad(self, xs, ys):
"""Computes the gradients of the network."""
return self.sess.run(
self.cross_entropy_grads, feed_dict={
self.x: xs,
self.y_: ys
}) | [
"Computes",
"the",
"gradients",
"of",
"the",
"network",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/lbfgs/driver.py#L72-L78 | [
"def",
"grad",
"(",
"self",
",",
"xs",
",",
"ys",
")",
":",
"return",
"self",
".",
"sess",
".",
"run",
"(",
"self",
".",
"cross_entropy_grads",
",",
"feed_dict",
"=",
"{",
"self",
".",
"x",
":",
"xs",
",",
"self",
".",
"y_",
":",
"ys",
"}",
")"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | build_data | Creates the queue and preprocessing operations for the dataset.
Args:
data_path: Filename for cifar10 data.
size: The number of images in the dataset.
dataset: The dataset we are using.
Returns:
queue: A Tensorflow queue for extracting the images and labels. | examples/resnet/cifar_input.py | def build_data(data_path, size, dataset):
"""Creates the queue and preprocessing operations for the dataset.
Args:
data_path: Filename for cifar10 data.
size: The number of images in the dataset.
dataset: The dataset we are using.
Returns:
queue: A Tensorflow queue for extr... | def build_data(data_path, size, dataset):
"""Creates the queue and preprocessing operations for the dataset.
Args:
data_path: Filename for cifar10 data.
size: The number of images in the dataset.
dataset: The dataset we are using.
Returns:
queue: A Tensorflow queue for extr... | [
"Creates",
"the",
"queue",
"and",
"preprocessing",
"operations",
"for",
"the",
"dataset",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/cifar_input.py#L12-L54 | [
"def",
"build_data",
"(",
"data_path",
",",
"size",
",",
"dataset",
")",
":",
"image_size",
"=",
"32",
"if",
"dataset",
"==",
"\"cifar10\"",
":",
"label_bytes",
"=",
"1",
"label_offset",
"=",
"0",
"elif",
"dataset",
"==",
"\"cifar100\"",
":",
"label_bytes",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | build_input | Build CIFAR image and labels.
Args:
data_path: Filename for cifar10 data.
batch_size: Input batch size.
train: True if we are training and false if we are testing.
Returns:
images: Batches of images of size
[batch_size, image_size, image_size, 3].
labels: Ba... | examples/resnet/cifar_input.py | def build_input(data, batch_size, dataset, train):
"""Build CIFAR image and labels.
Args:
data_path: Filename for cifar10 data.
batch_size: Input batch size.
train: True if we are training and false if we are testing.
Returns:
images: Batches of images of size
[... | def build_input(data, batch_size, dataset, train):
"""Build CIFAR image and labels.
Args:
data_path: Filename for cifar10 data.
batch_size: Input batch size.
train: True if we are training and false if we are testing.
Returns:
images: Batches of images of size
[... | [
"Build",
"CIFAR",
"image",
"and",
"labels",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/cifar_input.py#L57-L116 | [
"def",
"build_input",
"(",
"data",
",",
"batch_size",
",",
"dataset",
",",
"train",
")",
":",
"image_size",
"=",
"32",
"depth",
"=",
"3",
"num_classes",
"=",
"10",
"if",
"dataset",
"==",
"\"cifar10\"",
"else",
"100",
"images",
",",
"labels",
"=",
"data",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | create_or_update | Create or update a Ray cluster. | python/ray/scripts/scripts.py | def create_or_update(cluster_config_file, min_workers, max_workers, no_restart,
restart_only, yes, cluster_name):
"""Create or update a Ray cluster."""
if restart_only or no_restart:
assert restart_only != no_restart, "Cannot set both 'restart_only' " \
"and 'no_restart'... | def create_or_update(cluster_config_file, min_workers, max_workers, no_restart,
restart_only, yes, cluster_name):
"""Create or update a Ray cluster."""
if restart_only or no_restart:
assert restart_only != no_restart, "Cannot set both 'restart_only' " \
"and 'no_restart'... | [
"Create",
"or",
"update",
"a",
"Ray",
"cluster",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/scripts/scripts.py#L453-L460 | [
"def",
"create_or_update",
"(",
"cluster_config_file",
",",
"min_workers",
",",
"max_workers",
",",
"no_restart",
",",
"restart_only",
",",
"yes",
",",
"cluster_name",
")",
":",
"if",
"restart_only",
"or",
"no_restart",
":",
"assert",
"restart_only",
"!=",
"no_res... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | teardown | Tear down the Ray cluster. | python/ray/scripts/scripts.py | def teardown(cluster_config_file, yes, workers_only, cluster_name):
"""Tear down the Ray cluster."""
teardown_cluster(cluster_config_file, yes, workers_only, cluster_name) | def teardown(cluster_config_file, yes, workers_only, cluster_name):
"""Tear down the Ray cluster."""
teardown_cluster(cluster_config_file, yes, workers_only, cluster_name) | [
"Tear",
"down",
"the",
"Ray",
"cluster",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/scripts/scripts.py#L482-L484 | [
"def",
"teardown",
"(",
"cluster_config_file",
",",
"yes",
",",
"workers_only",
",",
"cluster_name",
")",
":",
"teardown_cluster",
"(",
"cluster_config_file",
",",
"yes",
",",
"workers_only",
",",
"cluster_name",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | kill_random_node | Kills a random Ray node. For testing purposes only. | python/ray/scripts/scripts.py | def kill_random_node(cluster_config_file, yes, cluster_name):
"""Kills a random Ray node. For testing purposes only."""
click.echo("Killed node with IP " +
kill_node(cluster_config_file, yes, cluster_name)) | def kill_random_node(cluster_config_file, yes, cluster_name):
"""Kills a random Ray node. For testing purposes only."""
click.echo("Killed node with IP " +
kill_node(cluster_config_file, yes, cluster_name)) | [
"Kills",
"a",
"random",
"Ray",
"node",
".",
"For",
"testing",
"purposes",
"only",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/scripts/scripts.py#L501-L504 | [
"def",
"kill_random_node",
"(",
"cluster_config_file",
",",
"yes",
",",
"cluster_name",
")",
":",
"click",
".",
"echo",
"(",
"\"Killed node with IP \"",
"+",
"kill_node",
"(",
"cluster_config_file",
",",
"yes",
",",
"cluster_name",
")",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | submit | Uploads and runs a script on the specified cluster.
The script is automatically synced to the following location:
os.path.join("~", os.path.basename(script)) | python/ray/scripts/scripts.py | def submit(cluster_config_file, docker, screen, tmux, stop, start,
cluster_name, port_forward, script, script_args):
"""Uploads and runs a script on the specified cluster.
The script is automatically synced to the following location:
os.path.join("~", os.path.basename(script))
"""
a... | def submit(cluster_config_file, docker, screen, tmux, stop, start,
cluster_name, port_forward, script, script_args):
"""Uploads and runs a script on the specified cluster.
The script is automatically synced to the following location:
os.path.join("~", os.path.basename(script))
"""
a... | [
"Uploads",
"and",
"runs",
"a",
"script",
"on",
"the",
"specified",
"cluster",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/scripts/scripts.py#L590-L609 | [
"def",
"submit",
"(",
"cluster_config_file",
",",
"docker",
",",
"screen",
",",
"tmux",
",",
"stop",
",",
"start",
",",
"cluster_name",
",",
"port_forward",
",",
"script",
",",
"script_args",
")",
":",
"assert",
"not",
"(",
"screen",
"and",
"tmux",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet.build_graph | Build a whole graph for the model. | examples/resnet/resnet_model.py | def build_graph(self):
"""Build a whole graph for the model."""
self.global_step = tf.Variable(0, trainable=False)
self._build_model()
if self.mode == "train":
self._build_train_op()
else:
# Additional initialization for the test network.
self.... | def build_graph(self):
"""Build a whole graph for the model."""
self.global_step = tf.Variable(0, trainable=False)
self._build_model()
if self.mode == "train":
self._build_train_op()
else:
# Additional initialization for the test network.
self.... | [
"Build",
"a",
"whole",
"graph",
"for",
"the",
"model",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L49-L59 | [
"def",
"build_graph",
"(",
"self",
")",
":",
"self",
".",
"global_step",
"=",
"tf",
".",
"Variable",
"(",
"0",
",",
"trainable",
"=",
"False",
")",
"self",
".",
"_build_model",
"(",
")",
"if",
"self",
".",
"mode",
"==",
"\"train\"",
":",
"self",
".",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._build_model | Build the core model within the graph. | examples/resnet/resnet_model.py | def _build_model(self):
"""Build the core model within the graph."""
with tf.variable_scope("init"):
x = self._conv("init_conv", self._images, 3, 3, 16,
self._stride_arr(1))
strides = [1, 2, 2]
activate_before_residual = [True, False, False]
... | def _build_model(self):
"""Build the core model within the graph."""
with tf.variable_scope("init"):
x = self._conv("init_conv", self._images, 3, 3, 16,
self._stride_arr(1))
strides = [1, 2, 2]
activate_before_residual = [True, False, False]
... | [
"Build",
"the",
"core",
"model",
"within",
"the",
"graph",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L65-L120 | [
"def",
"_build_model",
"(",
"self",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"init\"",
")",
":",
"x",
"=",
"self",
".",
"_conv",
"(",
"\"init_conv\"",
",",
"self",
".",
"_images",
",",
"3",
",",
"3",
",",
"16",
",",
"self",
".",
"_stri... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._build_train_op | Build training specific ops for the graph. | examples/resnet/resnet_model.py | def _build_train_op(self):
"""Build training specific ops for the graph."""
num_gpus = self.hps.num_gpus if self.hps.num_gpus != 0 else 1
# The learning rate schedule is dependent on the number of gpus.
boundaries = [int(20000 * i / np.sqrt(num_gpus)) for i in range(2, 5)]
values... | def _build_train_op(self):
"""Build training specific ops for the graph."""
num_gpus = self.hps.num_gpus if self.hps.num_gpus != 0 else 1
# The learning rate schedule is dependent on the number of gpus.
boundaries = [int(20000 * i / np.sqrt(num_gpus)) for i in range(2, 5)]
values... | [
"Build",
"training",
"specific",
"ops",
"for",
"the",
"graph",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L122-L141 | [
"def",
"_build_train_op",
"(",
"self",
")",
":",
"num_gpus",
"=",
"self",
".",
"hps",
".",
"num_gpus",
"if",
"self",
".",
"hps",
".",
"num_gpus",
"!=",
"0",
"else",
"1",
"# The learning rate schedule is dependent on the number of gpus.",
"boundaries",
"=",
"[",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._batch_norm | Batch normalization. | examples/resnet/resnet_model.py | def _batch_norm(self, name, x):
"""Batch normalization."""
with tf.variable_scope(name):
params_shape = [x.get_shape()[-1]]
beta = tf.get_variable(
"beta",
params_shape,
tf.float32,
initializer=tf.constant_initializ... | def _batch_norm(self, name, x):
"""Batch normalization."""
with tf.variable_scope(name):
params_shape = [x.get_shape()[-1]]
beta = tf.get_variable(
"beta",
params_shape,
tf.float32,
initializer=tf.constant_initializ... | [
"Batch",
"normalization",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L143-L201 | [
"def",
"_batch_norm",
"(",
"self",
",",
"name",
",",
"x",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"name",
")",
":",
"params_shape",
"=",
"[",
"x",
".",
"get_shape",
"(",
")",
"[",
"-",
"1",
"]",
"]",
"beta",
"=",
"tf",
".",
"get_varia... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._decay | L2 weight decay loss. | examples/resnet/resnet_model.py | def _decay(self):
"""L2 weight decay loss."""
costs = []
for var in tf.trainable_variables():
if var.op.name.find(r"DW") > 0:
costs.append(tf.nn.l2_loss(var))
return tf.multiply(self.hps.weight_decay_rate, tf.add_n(costs)) | def _decay(self):
"""L2 weight decay loss."""
costs = []
for var in tf.trainable_variables():
if var.op.name.find(r"DW") > 0:
costs.append(tf.nn.l2_loss(var))
return tf.multiply(self.hps.weight_decay_rate, tf.add_n(costs)) | [
"L2",
"weight",
"decay",
"loss",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L281-L288 | [
"def",
"_decay",
"(",
"self",
")",
":",
"costs",
"=",
"[",
"]",
"for",
"var",
"in",
"tf",
".",
"trainable_variables",
"(",
")",
":",
"if",
"var",
".",
"op",
".",
"name",
".",
"find",
"(",
"r\"DW\"",
")",
">",
"0",
":",
"costs",
".",
"append",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._conv | Convolution. | examples/resnet/resnet_model.py | def _conv(self, name, x, filter_size, in_filters, out_filters, strides):
"""Convolution."""
with tf.variable_scope(name):
n = filter_size * filter_size * out_filters
kernel = tf.get_variable(
"DW", [filter_size, filter_size, in_filters, out_filters],
... | def _conv(self, name, x, filter_size, in_filters, out_filters, strides):
"""Convolution."""
with tf.variable_scope(name):
n = filter_size * filter_size * out_filters
kernel = tf.get_variable(
"DW", [filter_size, filter_size, in_filters, out_filters],
... | [
"Convolution",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L290-L299 | [
"def",
"_conv",
"(",
"self",
",",
"name",
",",
"x",
",",
"filter_size",
",",
"in_filters",
",",
"out_filters",
",",
"strides",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"name",
")",
":",
"n",
"=",
"filter_size",
"*",
"filter_size",
"*",
"out_... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ResNet._fully_connected | FullyConnected layer for final output. | examples/resnet/resnet_model.py | def _fully_connected(self, x, out_dim):
"""FullyConnected layer for final output."""
x = tf.reshape(x, [self.hps.batch_size, -1])
w = tf.get_variable(
"DW", [x.get_shape()[1], out_dim],
initializer=tf.uniform_unit_scaling_initializer(factor=1.0))
b = tf.get_variab... | def _fully_connected(self, x, out_dim):
"""FullyConnected layer for final output."""
x = tf.reshape(x, [self.hps.batch_size, -1])
w = tf.get_variable(
"DW", [x.get_shape()[1], out_dim],
initializer=tf.uniform_unit_scaling_initializer(factor=1.0))
b = tf.get_variab... | [
"FullyConnected",
"layer",
"for",
"final",
"output",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/resnet/resnet_model.py#L305-L313 | [
"def",
"_fully_connected",
"(",
"self",
",",
"x",
",",
"out_dim",
")",
":",
"x",
"=",
"tf",
".",
"reshape",
"(",
"x",
",",
"[",
"self",
".",
"hps",
".",
"batch_size",
",",
"-",
"1",
"]",
")",
"w",
"=",
"tf",
".",
"get_variable",
"(",
"\"DW\"",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | _mac | Forward pass of the multi-agent controller.
Arguments:
model: TorchModel class
obs: Tensor of shape [B, n_agents, obs_size]
h: List of tensors of shape [B, n_agents, h_size]
Returns:
q_vals: Tensor of shape [B, n_agents, n_actions]
h: Tensor of shape [B, n_agents, h_siz... | python/ray/rllib/agents/qmix/qmix_policy_graph.py | def _mac(model, obs, h):
"""Forward pass of the multi-agent controller.
Arguments:
model: TorchModel class
obs: Tensor of shape [B, n_agents, obs_size]
h: List of tensors of shape [B, n_agents, h_size]
Returns:
q_vals: Tensor of shape [B, n_agents, n_actions]
h: Ten... | def _mac(model, obs, h):
"""Forward pass of the multi-agent controller.
Arguments:
model: TorchModel class
obs: Tensor of shape [B, n_agents, obs_size]
h: List of tensors of shape [B, n_agents, h_size]
Returns:
q_vals: Tensor of shape [B, n_agents, n_actions]
h: Ten... | [
"Forward",
"pass",
"of",
"the",
"multi",
"-",
"agent",
"controller",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/qmix/qmix_policy_graph.py#L409-L426 | [
"def",
"_mac",
"(",
"model",
",",
"obs",
",",
"h",
")",
":",
"B",
",",
"n_agents",
"=",
"obs",
".",
"size",
"(",
"0",
")",
",",
"obs",
".",
"size",
"(",
"1",
")",
"obs_flat",
"=",
"obs",
".",
"reshape",
"(",
"[",
"B",
"*",
"n_agents",
",",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | QMixLoss.forward | Forward pass of the loss.
Arguments:
rewards: Tensor of shape [B, T-1, n_agents]
actions: Tensor of shape [B, T-1, n_agents]
terminated: Tensor of shape [B, T-1, n_agents]
mask: Tensor of shape [B, T-1, n_agents]
obs: Tensor of shape [B, T, n_agents, ... | python/ray/rllib/agents/qmix/qmix_policy_graph.py | def forward(self, rewards, actions, terminated, mask, obs, action_mask):
"""Forward pass of the loss.
Arguments:
rewards: Tensor of shape [B, T-1, n_agents]
actions: Tensor of shape [B, T-1, n_agents]
terminated: Tensor of shape [B, T-1, n_agents]
mask: T... | def forward(self, rewards, actions, terminated, mask, obs, action_mask):
"""Forward pass of the loss.
Arguments:
rewards: Tensor of shape [B, T-1, n_agents]
actions: Tensor of shape [B, T-1, n_agents]
terminated: Tensor of shape [B, T-1, n_agents]
mask: T... | [
"Forward",
"pass",
"of",
"the",
"loss",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/qmix/qmix_policy_graph.py#L49-L122 | [
"def",
"forward",
"(",
"self",
",",
"rewards",
",",
"actions",
",",
"terminated",
",",
"mask",
",",
"obs",
",",
"action_mask",
")",
":",
"B",
",",
"T",
"=",
"obs",
".",
"size",
"(",
"0",
")",
",",
"obs",
".",
"size",
"(",
"1",
")",
"# Calculate e... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | QMixPolicyGraph._unpack_observation | Unpacks the action mask / tuple obs from agent grouping.
Returns:
obs (Tensor): flattened obs tensor of shape [B, n_agents, obs_size]
mask (Tensor): action mask, if any | python/ray/rllib/agents/qmix/qmix_policy_graph.py | def _unpack_observation(self, obs_batch):
"""Unpacks the action mask / tuple obs from agent grouping.
Returns:
obs (Tensor): flattened obs tensor of shape [B, n_agents, obs_size]
mask (Tensor): action mask, if any
"""
unpacked = _unpack_obs(
np.array(... | def _unpack_observation(self, obs_batch):
"""Unpacks the action mask / tuple obs from agent grouping.
Returns:
obs (Tensor): flattened obs tensor of shape [B, n_agents, obs_size]
mask (Tensor): action mask, if any
"""
unpacked = _unpack_obs(
np.array(... | [
"Unpacks",
"the",
"action",
"mask",
"/",
"tuple",
"obs",
"from",
"agent",
"grouping",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/qmix/qmix_policy_graph.py#L356-L380 | [
"def",
"_unpack_observation",
"(",
"self",
",",
"obs_batch",
")",
":",
"unpacked",
"=",
"_unpack_obs",
"(",
"np",
".",
"array",
"(",
"obs_batch",
")",
",",
"self",
".",
"observation_space",
".",
"original_space",
",",
"tensorlib",
"=",
"np",
")",
"if",
"se... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_actor | Get a named actor which was previously created.
If the actor doesn't exist, an exception will be raised.
Args:
name: The name of the named actor.
Returns:
The ActorHandle object corresponding to the name. | python/ray/experimental/named_actors.py | def get_actor(name):
"""Get a named actor which was previously created.
If the actor doesn't exist, an exception will be raised.
Args:
name: The name of the named actor.
Returns:
The ActorHandle object corresponding to the name.
"""
actor_name = _calculate_key(name)
pickle... | def get_actor(name):
"""Get a named actor which was previously created.
If the actor doesn't exist, an exception will be raised.
Args:
name: The name of the named actor.
Returns:
The ActorHandle object corresponding to the name.
"""
actor_name = _calculate_key(name)
pickle... | [
"Get",
"a",
"named",
"actor",
"which",
"was",
"previously",
"created",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/named_actors.py#L22-L38 | [
"def",
"get_actor",
"(",
"name",
")",
":",
"actor_name",
"=",
"_calculate_key",
"(",
"name",
")",
"pickled_state",
"=",
"_internal_kv_get",
"(",
"actor_name",
")",
"if",
"pickled_state",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"The actor with name={} does... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | register_actor | Register a named actor under a string key.
Args:
name: The name of the named actor.
actor_handle: The actor object to be associated with this name | python/ray/experimental/named_actors.py | def register_actor(name, actor_handle):
"""Register a named actor under a string key.
Args:
name: The name of the named actor.
actor_handle: The actor object to be associated with this name
"""
if not isinstance(name, str):
raise TypeError("The name argument must be a string.")
... | def register_actor(name, actor_handle):
"""Register a named actor under a string key.
Args:
name: The name of the named actor.
actor_handle: The actor object to be associated with this name
"""
if not isinstance(name, str):
raise TypeError("The name argument must be a string.")
... | [
"Register",
"a",
"named",
"actor",
"under",
"a",
"string",
"key",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/named_actors.py#L41-L63 | [
"def",
"register_actor",
"(",
"name",
",",
"actor_handle",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"\"The name argument must be a string.\"",
")",
"if",
"not",
"isinstance",
"(",
"actor_handle",
",",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | check_extraneous | Make sure all items of config are in schema | python/ray/autoscaler/autoscaler.py | def check_extraneous(config, schema):
"""Make sure all items of config are in schema"""
if not isinstance(config, dict):
raise ValueError("Config {} is not a dictionary".format(config))
for k in config:
if k not in schema:
raise ValueError("Unexpected config key `{}` not in {}".f... | def check_extraneous(config, schema):
"""Make sure all items of config are in schema"""
if not isinstance(config, dict):
raise ValueError("Config {} is not a dictionary".format(config))
for k in config:
if k not in schema:
raise ValueError("Unexpected config key `{}` not in {}".f... | [
"Make",
"sure",
"all",
"items",
"of",
"config",
"are",
"in",
"schema"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/autoscaler.py#L681-L701 | [
"def",
"check_extraneous",
"(",
"config",
",",
"schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"config",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"Config {} is not a dictionary\"",
".",
"format",
"(",
"config",
")",
")",
"for",
"k",
"in",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | validate_config | Required Dicts indicate that no extra fields can be introduced. | python/ray/autoscaler/autoscaler.py | def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
"""Required Dicts indicate that no extra fields can be introduced."""
if not isinstance(config, dict):
raise ValueError("Config {} is not a dictionary".format(config))
check_required(config, schema)
check_extraneous(config, schema) | def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
"""Required Dicts indicate that no extra fields can be introduced."""
if not isinstance(config, dict):
raise ValueError("Config {} is not a dictionary".format(config))
check_required(config, schema)
check_extraneous(config, schema) | [
"Required",
"Dicts",
"indicate",
"that",
"no",
"extra",
"fields",
"can",
"be",
"introduced",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/autoscaler.py#L704-L710 | [
"def",
"validate_config",
"(",
"config",
",",
"schema",
"=",
"CLUSTER_CONFIG_SCHEMA",
")",
":",
"if",
"not",
"isinstance",
"(",
"config",
",",
"dict",
")",
":",
"raise",
"ValueError",
"(",
"\"Config {} is not a dictionary\"",
".",
"format",
"(",
"config",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayParams.update | Update the settings according to the keyword arguments.
Args:
kwargs: The keyword arguments to set corresponding fields. | python/ray/parameter.py | def update(self, **kwargs):
"""Update the settings according to the keyword arguments.
Args:
kwargs: The keyword arguments to set corresponding fields.
"""
for arg in kwargs:
if hasattr(self, arg):
setattr(self, arg, kwargs[arg])
else:... | def update(self, **kwargs):
"""Update the settings according to the keyword arguments.
Args:
kwargs: The keyword arguments to set corresponding fields.
"""
for arg in kwargs:
if hasattr(self, arg):
setattr(self, arg, kwargs[arg])
else:... | [
"Update",
"the",
"settings",
"according",
"to",
"the",
"keyword",
"arguments",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/parameter.py#L149-L162 | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"arg",
"in",
"kwargs",
":",
"if",
"hasattr",
"(",
"self",
",",
"arg",
")",
":",
"setattr",
"(",
"self",
",",
"arg",
",",
"kwargs",
"[",
"arg",
"]",
")",
"else",
":",
"raise... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayParams.update_if_absent | Update the settings when the target fields are None.
Args:
kwargs: The keyword arguments to set corresponding fields. | python/ray/parameter.py | def update_if_absent(self, **kwargs):
"""Update the settings when the target fields are None.
Args:
kwargs: The keyword arguments to set corresponding fields.
"""
for arg in kwargs:
if hasattr(self, arg):
if getattr(self, arg) is None:
... | def update_if_absent(self, **kwargs):
"""Update the settings when the target fields are None.
Args:
kwargs: The keyword arguments to set corresponding fields.
"""
for arg in kwargs:
if hasattr(self, arg):
if getattr(self, arg) is None:
... | [
"Update",
"the",
"settings",
"when",
"the",
"target",
"fields",
"are",
"None",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/parameter.py#L164-L178 | [
"def",
"update_if_absent",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"arg",
"in",
"kwargs",
":",
"if",
"hasattr",
"(",
"self",
",",
"arg",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"arg",
")",
"is",
"None",
":",
"setattr",
"(",
"s... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | compute_actor_handle_id | Deterministically compute an actor handle ID.
A new actor handle ID is generated when it is forked from another actor
handle. The new handle ID is computed as hash(old_handle_id || num_forks).
Args:
actor_handle_id (common.ObjectID): The original actor handle ID.
num_forks: The number of t... | python/ray/actor.py | def compute_actor_handle_id(actor_handle_id, num_forks):
"""Deterministically compute an actor handle ID.
A new actor handle ID is generated when it is forked from another actor
handle. The new handle ID is computed as hash(old_handle_id || num_forks).
Args:
actor_handle_id (common.ObjectID): ... | def compute_actor_handle_id(actor_handle_id, num_forks):
"""Deterministically compute an actor handle ID.
A new actor handle ID is generated when it is forked from another actor
handle. The new handle ID is computed as hash(old_handle_id || num_forks).
Args:
actor_handle_id (common.ObjectID): ... | [
"Deterministically",
"compute",
"an",
"actor",
"handle",
"ID",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L27-L46 | [
"def",
"compute_actor_handle_id",
"(",
"actor_handle_id",
",",
"num_forks",
")",
":",
"assert",
"isinstance",
"(",
"actor_handle_id",
",",
"ActorHandleID",
")",
"handle_id_hash",
"=",
"hashlib",
".",
"sha1",
"(",
")",
"handle_id_hash",
".",
"update",
"(",
"actor_h... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | compute_actor_handle_id_non_forked | Deterministically compute an actor handle ID in the non-forked case.
This code path is used whenever an actor handle is pickled and unpickled
(for example, if a remote function closes over an actor handle). Then,
whenever the actor handle is used, a new actor handle ID will be generated
on the fly as a... | python/ray/actor.py | def compute_actor_handle_id_non_forked(actor_handle_id, current_task_id):
"""Deterministically compute an actor handle ID in the non-forked case.
This code path is used whenever an actor handle is pickled and unpickled
(for example, if a remote function closes over an actor handle). Then,
whenever the ... | def compute_actor_handle_id_non_forked(actor_handle_id, current_task_id):
"""Deterministically compute an actor handle ID in the non-forked case.
This code path is used whenever an actor handle is pickled and unpickled
(for example, if a remote function closes over an actor handle). Then,
whenever the ... | [
"Deterministically",
"compute",
"an",
"actor",
"handle",
"ID",
"in",
"the",
"non",
"-",
"forked",
"case",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L49-L75 | [
"def",
"compute_actor_handle_id_non_forked",
"(",
"actor_handle_id",
",",
"current_task_id",
")",
":",
"assert",
"isinstance",
"(",
"actor_handle_id",
",",
"ActorHandleID",
")",
"assert",
"isinstance",
"(",
"current_task_id",
",",
"TaskID",
")",
"handle_id_hash",
"=",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | method | Annotate an actor method.
.. code-block:: python
@ray.remote
class Foo(object):
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2
f = Foo.remote()
_, _ = f.bar.remote()
Args:
num_return_vals: The number of object IDs th... | python/ray/actor.py | def method(*args, **kwargs):
"""Annotate an actor method.
.. code-block:: python
@ray.remote
class Foo(object):
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2
f = Foo.remote()
_, _ = f.bar.remote()
Args:
num_retu... | def method(*args, **kwargs):
"""Annotate an actor method.
.. code-block:: python
@ray.remote
class Foo(object):
@ray.method(num_return_vals=2)
def bar(self):
return 1, 2
f = Foo.remote()
_, _ = f.bar.remote()
Args:
num_retu... | [
"Annotate",
"an",
"actor",
"method",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L78-L106 | [
"def",
"method",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"args",
")",
"==",
"0",
"assert",
"len",
"(",
"kwargs",
")",
"==",
"1",
"assert",
"\"num_return_vals\"",
"in",
"kwargs",
"num_return_vals",
"=",
"kwargs",
"[",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | exit_actor | Intentionally exit the current actor.
This function is used to disconnect an actor and exit the worker.
Raises:
Exception: An exception is raised if this is a driver or this
worker is not an actor. | python/ray/actor.py | def exit_actor():
"""Intentionally exit the current actor.
This function is used to disconnect an actor and exit the worker.
Raises:
Exception: An exception is raised if this is a driver or this
worker is not an actor.
"""
worker = ray.worker.global_worker
if worker.mode ==... | def exit_actor():
"""Intentionally exit the current actor.
This function is used to disconnect an actor and exit the worker.
Raises:
Exception: An exception is raised if this is a driver or this
worker is not an actor.
"""
worker = ray.worker.global_worker
if worker.mode ==... | [
"Intentionally",
"exit",
"the",
"current",
"actor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L736-L757 | [
"def",
"exit_actor",
"(",
")",
":",
"worker",
"=",
"ray",
".",
"worker",
".",
"global_worker",
"if",
"worker",
".",
"mode",
"==",
"ray",
".",
"WORKER_MODE",
"and",
"not",
"worker",
".",
"actor_id",
".",
"is_nil",
"(",
")",
":",
"# Disconnect the worker fro... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_checkpoints_for_actor | Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order. | python/ray/actor.py | def get_checkpoints_for_actor(actor_id):
"""Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order.
"""
checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
if checkpoint_info is None:
return []
checkpoi... | def get_checkpoints_for_actor(actor_id):
"""Get the available checkpoints for the given actor ID, return a list
sorted by checkpoint timestamp in descending order.
"""
checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
if checkpoint_info is None:
return []
checkpoi... | [
"Get",
"the",
"available",
"checkpoints",
"for",
"the",
"given",
"actor",
"ID",
"return",
"a",
"list",
"sorted",
"by",
"checkpoint",
"timestamp",
"in",
"descending",
"order",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L869-L884 | [
"def",
"get_checkpoints_for_actor",
"(",
"actor_id",
")",
":",
"checkpoint_info",
"=",
"ray",
".",
"worker",
".",
"global_state",
".",
"actor_checkpoint_info",
"(",
"actor_id",
")",
"if",
"checkpoint_info",
"is",
"None",
":",
"return",
"[",
"]",
"checkpoints",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ActorClass.remote | Create an actor.
Args:
args: These arguments are forwarded directly to the actor
constructor.
kwargs: These arguments are forwarded directly to the actor
constructor.
Returns:
A handle to the newly created actor. | python/ray/actor.py | def remote(self, *args, **kwargs):
"""Create an actor.
Args:
args: These arguments are forwarded directly to the actor
constructor.
kwargs: These arguments are forwarded directly to the actor
constructor.
Returns:
A handle to ... | def remote(self, *args, **kwargs):
"""Create an actor.
Args:
args: These arguments are forwarded directly to the actor
constructor.
kwargs: These arguments are forwarded directly to the actor
constructor.
Returns:
A handle to ... | [
"Create",
"an",
"actor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L222-L234 | [
"def",
"remote",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_remote",
"(",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
")"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ActorClass._remote | Create an actor.
This method allows more flexibility than the remote method because
resource requirements can be specified and override the defaults in the
decorator.
Args:
args: The arguments to forward to the actor constructor.
kwargs: The keyword arguments to... | python/ray/actor.py | def _remote(self,
args=None,
kwargs=None,
num_cpus=None,
num_gpus=None,
resources=None):
"""Create an actor.
This method allows more flexibility than the remote method because
resource requirements can be specified ... | def _remote(self,
args=None,
kwargs=None,
num_cpus=None,
num_gpus=None,
resources=None):
"""Create an actor.
This method allows more flexibility than the remote method because
resource requirements can be specified ... | [
"Create",
"an",
"actor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L236-L347 | [
"def",
"_remote",
"(",
"self",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"num_cpus",
"=",
"None",
",",
"num_gpus",
"=",
"None",
",",
"resources",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"[",
"]",
"if"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ActorHandle._actor_method_call | Method execution stub for an actor handle.
This is the function that executes when
`actor.method_name.remote(*args, **kwargs)` is called. Instead of
executing locally, the method is packaged as a task and scheduled
to the remote actor instance.
Args:
method_name: Th... | python/ray/actor.py | def _actor_method_call(self,
method_name,
args=None,
kwargs=None,
num_return_vals=None):
"""Method execution stub for an actor handle.
This is the function that executes when
`actor.metho... | def _actor_method_call(self,
method_name,
args=None,
kwargs=None,
num_return_vals=None):
"""Method execution stub for an actor handle.
This is the function that executes when
`actor.metho... | [
"Method",
"execution",
"stub",
"for",
"an",
"actor",
"handle",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L442-L515 | [
"def",
"_actor_method_call",
"(",
"self",
",",
"method_name",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"num_return_vals",
"=",
"None",
")",
":",
"worker",
"=",
"ray",
".",
"worker",
".",
"get_global_worker",
"(",
")",
"worker",
".",
"ch... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ActorHandle._serialization_helper | This is defined in order to make pickling work.
Args:
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is being called by pickling.
Returns:
A dictionary of the information needed to reconstruct the object. | python/ray/actor.py | def _serialization_helper(self, ray_forking):
"""This is defined in order to make pickling work.
Args:
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is being called by pickling.
Returns:
A dictionary of... | def _serialization_helper(self, ray_forking):
"""This is defined in order to make pickling work.
Args:
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is being called by pickling.
Returns:
A dictionary of... | [
"This",
"is",
"defined",
"in",
"order",
"to",
"make",
"pickling",
"work",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L578-L629 | [
"def",
"_serialization_helper",
"(",
"self",
",",
"ray_forking",
")",
":",
"if",
"ray_forking",
":",
"actor_handle_id",
"=",
"compute_actor_handle_id",
"(",
"self",
".",
"_ray_actor_handle_id",
",",
"self",
".",
"_ray_actor_forks",
")",
"else",
":",
"actor_handle_id... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | ActorHandle._deserialization_helper | This is defined in order to make pickling work.
Args:
state: The serialized state of the actor handle.
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is being called by pickling. | python/ray/actor.py | def _deserialization_helper(self, state, ray_forking):
"""This is defined in order to make pickling work.
Args:
state: The serialized state of the actor handle.
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is b... | def _deserialization_helper(self, state, ray_forking):
"""This is defined in order to make pickling work.
Args:
state: The serialized state of the actor handle.
ray_forking: True if this is being called because Ray is forking
the actor handle and false if it is b... | [
"This",
"is",
"defined",
"in",
"order",
"to",
"make",
"pickling",
"work",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/actor.py#L631-L672 | [
"def",
"_deserialization_helper",
"(",
"self",
",",
"state",
",",
"ray_forking",
")",
":",
"worker",
"=",
"ray",
".",
"worker",
".",
"get_global_worker",
"(",
")",
"worker",
".",
"check_connected",
"(",
")",
"if",
"state",
"[",
"\"ray_forking\"",
"]",
":",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LocalSyncParallelOptimizer.load_data | Bulk loads the specified inputs into device memory.
The shape of the inputs must conform to the shapes of the input
placeholders this optimizer was constructed with.
The data is split equally across all the devices. If the data is not
evenly divisible by the batch size, excess data wil... | python/ray/rllib/optimizers/multi_gpu_impl.py | def load_data(self, sess, inputs, state_inputs):
"""Bulk loads the specified inputs into device memory.
The shape of the inputs must conform to the shapes of the input
placeholders this optimizer was constructed with.
The data is split equally across all the devices. If the data is not... | def load_data(self, sess, inputs, state_inputs):
"""Bulk loads the specified inputs into device memory.
The shape of the inputs must conform to the shapes of the input
placeholders this optimizer was constructed with.
The data is split equally across all the devices. If the data is not... | [
"Bulk",
"loads",
"the",
"specified",
"inputs",
"into",
"device",
"memory",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/multi_gpu_impl.py#L118-L225 | [
"def",
"load_data",
"(",
"self",
",",
"sess",
",",
"inputs",
",",
"state_inputs",
")",
":",
"if",
"log_once",
"(",
"\"load_data\"",
")",
":",
"logger",
".",
"info",
"(",
"\"Training on concatenated sample batches:\\n\\n{}\\n\"",
".",
"format",
"(",
"summarize",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LocalSyncParallelOptimizer.optimize | Run a single step of SGD.
Runs a SGD step over a slice of the preloaded batch with size given by
self._loaded_per_device_batch_size and offset given by the batch_index
argument.
Updates shared model weights based on the averaged per-device
gradients.
Args:
... | python/ray/rllib/optimizers/multi_gpu_impl.py | def optimize(self, sess, batch_index):
"""Run a single step of SGD.
Runs a SGD step over a slice of the preloaded batch with size given by
self._loaded_per_device_batch_size and offset given by the batch_index
argument.
Updates shared model weights based on the averaged per-dev... | def optimize(self, sess, batch_index):
"""Run a single step of SGD.
Runs a SGD step over a slice of the preloaded batch with size given by
self._loaded_per_device_batch_size and offset given by the batch_index
argument.
Updates shared model weights based on the averaged per-dev... | [
"Run",
"a",
"single",
"step",
"of",
"SGD",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/multi_gpu_impl.py#L227-L258 | [
"def",
"optimize",
"(",
"self",
",",
"sess",
",",
"batch_index",
")",
":",
"feed_dict",
"=",
"{",
"self",
".",
"_batch_index",
":",
"batch_index",
",",
"self",
".",
"_per_device_batch_size",
":",
"self",
".",
"_loaded_per_device_batch_size",
",",
"self",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | GeneticSearch._next_generation | Generate genes (encodings) for the next generation.
Use the top K (_keep_top_ratio) trials of the last generation
as candidates to generate the next generation. The action could
be selection, crossover and mutation according corresponding
ratio (_selection_bound, _crossover_bound).
... | python/ray/tune/automl/genetic_searcher.py | def _next_generation(self, sorted_trials):
"""Generate genes (encodings) for the next generation.
Use the top K (_keep_top_ratio) trials of the last generation
as candidates to generate the next generation. The action could
be selection, crossover and mutation according corresponding
... | def _next_generation(self, sorted_trials):
"""Generate genes (encodings) for the next generation.
Use the top K (_keep_top_ratio) trials of the last generation
as candidates to generate the next generation. The action could
be selection, crossover and mutation according corresponding
... | [
"Generate",
"genes",
"(",
"encodings",
")",
"for",
"the",
"next",
"generation",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L88-L122 | [
"def",
"_next_generation",
"(",
"self",
",",
"sorted_trials",
")",
":",
"candidate",
"=",
"[",
"]",
"next_generation",
"=",
"[",
"]",
"num_population",
"=",
"self",
".",
"_next_population_size",
"(",
"len",
"(",
"sorted_trials",
")",
")",
"top_num",
"=",
"in... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | GeneticSearch._selection | Perform selection action to candidates.
For example, new gene = sample_1 + the 5th bit of sample2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.array([[0, 0, 1], [0, 1], [1, 0]])
... | python/ray/tune/automl/genetic_searcher.py | def _selection(candidate):
"""Perform selection action to candidates.
For example, new gene = sample_1 + the 5th bit of sample2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.a... | def _selection(candidate):
"""Perform selection action to candidates.
For example, new gene = sample_1 + the 5th bit of sample2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.a... | [
"Perform",
"selection",
"action",
"to",
"candidates",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L140-L178 | [
"def",
"_selection",
"(",
"candidate",
")",
":",
"sample_index1",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"len",
"(",
"candidate",
")",
")",
"sample_index2",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"len",
"(",
"candidate",
")",
")",
"sample... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | GeneticSearch._crossover | Perform crossover action to candidates.
For example, new gene = 60% sample_1 + 40% sample_2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.array([[0, 0, 1], [0, 1], [1, 0]])
... | python/ray/tune/automl/genetic_searcher.py | def _crossover(candidate):
"""Perform crossover action to candidates.
For example, new gene = 60% sample_1 + 40% sample_2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.array([... | def _crossover(candidate):
"""Perform crossover action to candidates.
For example, new gene = 60% sample_1 + 40% sample_2.
Args:
candidate: List of candidate genes (encodings).
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.array([... | [
"Perform",
"crossover",
"action",
"to",
"candidates",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L181-L220 | [
"def",
"_crossover",
"(",
"candidate",
")",
":",
"sample_index1",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"len",
"(",
"candidate",
")",
")",
"sample_index2",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"len",
"(",
"candidate",
")",
")",
"sample... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | GeneticSearch._mutation | Perform mutation action to candidates.
For example, randomly change 10% of original sample
Args:
candidate: List of candidate genes (encodings).
rate: Percentage of mutation bits
Examples:
>>> # Genes that represent 3 parameters
>>> gene1 = np.a... | python/ray/tune/automl/genetic_searcher.py | def _mutation(candidate, rate=0.1):
"""Perform mutation action to candidates.
For example, randomly change 10% of original sample
Args:
candidate: List of candidate genes (encodings).
rate: Percentage of mutation bits
Examples:
>>> # Genes that repr... | def _mutation(candidate, rate=0.1):
"""Perform mutation action to candidates.
For example, randomly change 10% of original sample
Args:
candidate: List of candidate genes (encodings).
rate: Percentage of mutation bits
Examples:
>>> # Genes that repr... | [
"Perform",
"mutation",
"action",
"to",
"candidates",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L223-L258 | [
"def",
"_mutation",
"(",
"candidate",
",",
"rate",
"=",
"0.1",
")",
":",
"sample_index",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"len",
"(",
"candidate",
")",
")",
"sample",
"=",
"candidate",
"[",
"sample_index",
"]",
"idx_list",
"=",
"[",
"]",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | list_trials | Lists trials in the directory subtree starting at the given path. | python/ray/tune/scripts.py | def list_trials(experiment_path, sort, output, filter_op, columns,
result_columns):
"""Lists trials in the directory subtree starting at the given path."""
if columns:
columns = columns.split(",")
if result_columns:
result_columns = result_columns.split(",")
commands.list... | def list_trials(experiment_path, sort, output, filter_op, columns,
result_columns):
"""Lists trials in the directory subtree starting at the given path."""
if columns:
columns = columns.split(",")
if result_columns:
result_columns = result_columns.split(",")
commands.list... | [
"Lists",
"trials",
"in",
"the",
"directory",
"subtree",
"starting",
"at",
"the",
"given",
"path",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/scripts.py#L42-L50 | [
"def",
"list_trials",
"(",
"experiment_path",
",",
"sort",
",",
"output",
",",
"filter_op",
",",
"columns",
",",
"result_columns",
")",
":",
"if",
"columns",
":",
"columns",
"=",
"columns",
".",
"split",
"(",
"\",\"",
")",
"if",
"result_columns",
":",
"res... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | list_experiments | Lists experiments in the directory subtree. | python/ray/tune/scripts.py | def list_experiments(project_path, sort, output, filter_op, columns):
"""Lists experiments in the directory subtree."""
if columns:
columns = columns.split(",")
commands.list_experiments(project_path, sort, output, filter_op, columns) | def list_experiments(project_path, sort, output, filter_op, columns):
"""Lists experiments in the directory subtree."""
if columns:
columns = columns.split(",")
commands.list_experiments(project_path, sort, output, filter_op, columns) | [
"Lists",
"experiments",
"in",
"the",
"directory",
"subtree",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/scripts.py#L75-L79 | [
"def",
"list_experiments",
"(",
"project_path",
",",
"sort",
",",
"output",
",",
"filter_op",
",",
"columns",
")",
":",
"if",
"columns",
":",
"columns",
"=",
"columns",
".",
"split",
"(",
"\",\"",
")",
"commands",
".",
"list_experiments",
"(",
"project_path"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor._train | Start one iteration of training and save remote id. | python/ray/tune/ray_trial_executor.py | def _train(self, trial):
"""Start one iteration of training and save remote id."""
assert trial.status == Trial.RUNNING, trial.status
remote = trial.runner.train.remote()
# Local Mode
if isinstance(remote, dict):
remote = _LocalWrapper(remote)
self._running... | def _train(self, trial):
"""Start one iteration of training and save remote id."""
assert trial.status == Trial.RUNNING, trial.status
remote = trial.runner.train.remote()
# Local Mode
if isinstance(remote, dict):
remote = _LocalWrapper(remote)
self._running... | [
"Start",
"one",
"iteration",
"of",
"training",
"and",
"save",
"remote",
"id",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L107-L117 | [
"def",
"_train",
"(",
"self",
",",
"trial",
")",
":",
"assert",
"trial",
".",
"status",
"==",
"Trial",
".",
"RUNNING",
",",
"trial",
".",
"status",
"remote",
"=",
"trial",
".",
"runner",
".",
"train",
".",
"remote",
"(",
")",
"# Local Mode",
"if",
"i... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor._start_trial | Starts trial and restores last result if trial was paused.
Raises:
ValueError if restoring from checkpoint fails. | python/ray/tune/ray_trial_executor.py | def _start_trial(self, trial, checkpoint=None):
"""Starts trial and restores last result if trial was paused.
Raises:
ValueError if restoring from checkpoint fails.
"""
prior_status = trial.status
self.set_status(trial, Trial.RUNNING)
trial.runner = self._set... | def _start_trial(self, trial, checkpoint=None):
"""Starts trial and restores last result if trial was paused.
Raises:
ValueError if restoring from checkpoint fails.
"""
prior_status = trial.status
self.set_status(trial, Trial.RUNNING)
trial.runner = self._set... | [
"Starts",
"trial",
"and",
"restores",
"last",
"result",
"if",
"trial",
"was",
"paused",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L119-L143 | [
"def",
"_start_trial",
"(",
"self",
",",
"trial",
",",
"checkpoint",
"=",
"None",
")",
":",
"prior_status",
"=",
"trial",
".",
"status",
"self",
".",
"set_status",
"(",
"trial",
",",
"Trial",
".",
"RUNNING",
")",
"trial",
".",
"runner",
"=",
"self",
".... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor._stop_trial | Stops this trial.
Stops this trial, releasing all allocating resources. If stopping the
trial fails, the run will be marked as terminated in error, but no
exception will be thrown.
Args:
error (bool): Whether to mark this trial as terminated in error.
error_msg ... | python/ray/tune/ray_trial_executor.py | def _stop_trial(self, trial, error=False, error_msg=None,
stop_logger=True):
"""Stops this trial.
Stops this trial, releasing all allocating resources. If stopping the
trial fails, the run will be marked as terminated in error, but no
exception will be thrown.
... | def _stop_trial(self, trial, error=False, error_msg=None,
stop_logger=True):
"""Stops this trial.
Stops this trial, releasing all allocating resources. If stopping the
trial fails, the run will be marked as terminated in error, but no
exception will be thrown.
... | [
"Stops",
"this",
"trial",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L145-L186 | [
"def",
"_stop_trial",
"(",
"self",
",",
"trial",
",",
"error",
"=",
"False",
",",
"error_msg",
"=",
"None",
",",
"stop_logger",
"=",
"True",
")",
":",
"if",
"stop_logger",
":",
"trial",
".",
"close_logger",
"(",
")",
"if",
"error",
":",
"self",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.start_trial | Starts the trial.
Will not return resources if trial repeatedly fails on start.
Args:
trial (Trial): Trial to be started.
checkpoint (Checkpoint): A Python object or path storing the state
of trial. | python/ray/tune/ray_trial_executor.py | def start_trial(self, trial, checkpoint=None):
"""Starts the trial.
Will not return resources if trial repeatedly fails on start.
Args:
trial (Trial): Trial to be started.
checkpoint (Checkpoint): A Python object or path storing the state
of trial.
... | def start_trial(self, trial, checkpoint=None):
"""Starts the trial.
Will not return resources if trial repeatedly fails on start.
Args:
trial (Trial): Trial to be started.
checkpoint (Checkpoint): A Python object or path storing the state
of trial.
... | [
"Starts",
"the",
"trial",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L188-L221 | [
"def",
"start_trial",
"(",
"self",
",",
"trial",
",",
"checkpoint",
"=",
"None",
")",
":",
"self",
".",
"_commit_resources",
"(",
"trial",
".",
"resources",
")",
"try",
":",
"self",
".",
"_start_trial",
"(",
"trial",
",",
"checkpoint",
")",
"except",
"Ex... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.stop_trial | Only returns resources if resources allocated. | python/ray/tune/ray_trial_executor.py | def stop_trial(self, trial, error=False, error_msg=None, stop_logger=True):
"""Only returns resources if resources allocated."""
prior_status = trial.status
self._stop_trial(
trial, error=error, error_msg=error_msg, stop_logger=stop_logger)
if prior_status == Trial.RUNNING:
... | def stop_trial(self, trial, error=False, error_msg=None, stop_logger=True):
"""Only returns resources if resources allocated."""
prior_status = trial.status
self._stop_trial(
trial, error=error, error_msg=error_msg, stop_logger=stop_logger)
if prior_status == Trial.RUNNING:
... | [
"Only",
"returns",
"resources",
"if",
"resources",
"allocated",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L229-L239 | [
"def",
"stop_trial",
"(",
"self",
",",
"trial",
",",
"error",
"=",
"False",
",",
"error_msg",
"=",
"None",
",",
"stop_logger",
"=",
"True",
")",
":",
"prior_status",
"=",
"trial",
".",
"status",
"self",
".",
"_stop_trial",
"(",
"trial",
",",
"error",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.pause_trial | Pauses the trial.
If trial is in-flight, preserves return value in separate queue
before pausing, which is restored when Trial is resumed. | python/ray/tune/ray_trial_executor.py | def pause_trial(self, trial):
"""Pauses the trial.
If trial is in-flight, preserves return value in separate queue
before pausing, which is restored when Trial is resumed.
"""
trial_future = self._find_item(self._running, trial)
if trial_future:
self._paused... | def pause_trial(self, trial):
"""Pauses the trial.
If trial is in-flight, preserves return value in separate queue
before pausing, which is restored when Trial is resumed.
"""
trial_future = self._find_item(self._running, trial)
if trial_future:
self._paused... | [
"Pauses",
"the",
"trial",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L246-L256 | [
"def",
"pause_trial",
"(",
"self",
",",
"trial",
")",
":",
"trial_future",
"=",
"self",
".",
"_find_item",
"(",
"self",
".",
"_running",
",",
"trial",
")",
"if",
"trial_future",
":",
"self",
".",
"_paused",
"[",
"trial_future",
"[",
"0",
"]",
"]",
"=",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.reset_trial | Tries to invoke `Trainable.reset_config()` to reset trial.
Args:
trial (Trial): Trial to be reset.
new_config (dict): New configuration for Trial
trainable.
new_experiment_tag (str): New experiment name
for trial.
Returns:
... | python/ray/tune/ray_trial_executor.py | def reset_trial(self, trial, new_config, new_experiment_tag):
"""Tries to invoke `Trainable.reset_config()` to reset trial.
Args:
trial (Trial): Trial to be reset.
new_config (dict): New configuration for Trial
trainable.
new_experiment_tag (str): New... | def reset_trial(self, trial, new_config, new_experiment_tag):
"""Tries to invoke `Trainable.reset_config()` to reset trial.
Args:
trial (Trial): Trial to be reset.
new_config (dict): New configuration for Trial
trainable.
new_experiment_tag (str): New... | [
"Tries",
"to",
"invoke",
"Trainable",
".",
"reset_config",
"()",
"to",
"reset",
"trial",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L258-L276 | [
"def",
"reset_trial",
"(",
"self",
",",
"trial",
",",
"new_config",
",",
"new_experiment_tag",
")",
":",
"trial",
".",
"experiment_tag",
"=",
"new_experiment_tag",
"trial",
".",
"config",
"=",
"new_config",
"trainable",
"=",
"trial",
".",
"runner",
"with",
"wa... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.fetch_result | Fetches one result of the running trials.
Returns:
Result of the most recent trial training run. | python/ray/tune/ray_trial_executor.py | def fetch_result(self, trial):
"""Fetches one result of the running trials.
Returns:
Result of the most recent trial training run."""
trial_future = self._find_item(self._running, trial)
if not trial_future:
raise ValueError("Trial was not running.")
self... | def fetch_result(self, trial):
"""Fetches one result of the running trials.
Returns:
Result of the most recent trial training run."""
trial_future = self._find_item(self._running, trial)
if not trial_future:
raise ValueError("Trial was not running.")
self... | [
"Fetches",
"one",
"result",
"of",
"the",
"running",
"trials",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L305-L320 | [
"def",
"fetch_result",
"(",
"self",
",",
"trial",
")",
":",
"trial_future",
"=",
"self",
".",
"_find_item",
"(",
"self",
".",
"_running",
",",
"trial",
")",
"if",
"not",
"trial_future",
":",
"raise",
"ValueError",
"(",
"\"Trial was not running.\"",
")",
"sel... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.has_resources | Returns whether this runner has at least the specified resources.
This refreshes the Ray cluster resources if the time since last update
has exceeded self._refresh_period. This also assumes that the
cluster is not resizing very frequently. | python/ray/tune/ray_trial_executor.py | def has_resources(self, resources):
"""Returns whether this runner has at least the specified resources.
This refreshes the Ray cluster resources if the time since last update
has exceeded self._refresh_period. This also assumes that the
cluster is not resizing very frequently.
... | def has_resources(self, resources):
"""Returns whether this runner has at least the specified resources.
This refreshes the Ray cluster resources if the time since last update
has exceeded self._refresh_period. This also assumes that the
cluster is not resizing very frequently.
... | [
"Returns",
"whether",
"this",
"runner",
"has",
"at",
"least",
"the",
"specified",
"resources",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L389-L430 | [
"def",
"has_resources",
"(",
"self",
",",
"resources",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"_last_resource_refresh",
">",
"self",
".",
"_refresh_period",
":",
"self",
".",
"_update_avail_resources",
"(",
")",
"currently_available",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.debug_string | Returns a human readable message for printing to the console. | python/ray/tune/ray_trial_executor.py | def debug_string(self):
"""Returns a human readable message for printing to the console."""
if self._resources_initialized:
status = "Resources requested: {}/{} CPUs, {}/{} GPUs".format(
self._committed_resources.cpu, self._avail_resources.cpu,
self._committe... | def debug_string(self):
"""Returns a human readable message for printing to the console."""
if self._resources_initialized:
status = "Resources requested: {}/{} CPUs, {}/{} GPUs".format(
self._committed_resources.cpu, self._avail_resources.cpu,
self._committe... | [
"Returns",
"a",
"human",
"readable",
"message",
"for",
"printing",
"to",
"the",
"console",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L432-L449 | [
"def",
"debug_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources_initialized",
":",
"status",
"=",
"\"Resources requested: {}/{} CPUs, {}/{} GPUs\"",
".",
"format",
"(",
"self",
".",
"_committed_resources",
".",
"cpu",
",",
"self",
".",
"_avail_resources... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.resource_string | Returns a string describing the total resources available. | python/ray/tune/ray_trial_executor.py | def resource_string(self):
"""Returns a string describing the total resources available."""
if self._resources_initialized:
res_str = "{} CPUs, {} GPUs".format(self._avail_resources.cpu,
self._avail_resources.gpu)
if self._avail_re... | def resource_string(self):
"""Returns a string describing the total resources available."""
if self._resources_initialized:
res_str = "{} CPUs, {} GPUs".format(self._avail_resources.cpu,
self._avail_resources.gpu)
if self._avail_re... | [
"Returns",
"a",
"string",
"describing",
"the",
"total",
"resources",
"available",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L451-L465 | [
"def",
"resource_string",
"(",
"self",
")",
":",
"if",
"self",
".",
"_resources_initialized",
":",
"res_str",
"=",
"\"{} CPUs, {} GPUs\"",
".",
"format",
"(",
"self",
".",
"_avail_resources",
".",
"cpu",
",",
"self",
".",
"_avail_resources",
".",
"gpu",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.save | Saves the trial's state to a checkpoint. | python/ray/tune/ray_trial_executor.py | def save(self, trial, storage=Checkpoint.DISK):
"""Saves the trial's state to a checkpoint."""
trial._checkpoint.storage = storage
trial._checkpoint.last_result = trial.last_result
if storage == Checkpoint.MEMORY:
trial._checkpoint.value = trial.runner.save_to_object.remote()... | def save(self, trial, storage=Checkpoint.DISK):
"""Saves the trial's state to a checkpoint."""
trial._checkpoint.storage = storage
trial._checkpoint.last_result = trial.last_result
if storage == Checkpoint.MEMORY:
trial._checkpoint.value = trial.runner.save_to_object.remote()... | [
"Saves",
"the",
"trial",
"s",
"state",
"to",
"a",
"checkpoint",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L471-L497 | [
"def",
"save",
"(",
"self",
",",
"trial",
",",
"storage",
"=",
"Checkpoint",
".",
"DISK",
")",
":",
"trial",
".",
"_checkpoint",
".",
"storage",
"=",
"storage",
"trial",
".",
"_checkpoint",
".",
"last_result",
"=",
"trial",
".",
"last_result",
"if",
"sto... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor._checkpoint_and_erase | Checkpoints the model and erases old checkpoints
if needed.
Parameters
----------
trial : trial to save | python/ray/tune/ray_trial_executor.py | def _checkpoint_and_erase(self, trial):
"""Checkpoints the model and erases old checkpoints
if needed.
Parameters
----------
trial : trial to save
"""
with warn_if_slow("save_to_disk"):
trial._checkpoint.value = ray.get(trial.runner.save.remot... | def _checkpoint_and_erase(self, trial):
"""Checkpoints the model and erases old checkpoints
if needed.
Parameters
----------
trial : trial to save
"""
with warn_if_slow("save_to_disk"):
trial._checkpoint.value = ray.get(trial.runner.save.remot... | [
"Checkpoints",
"the",
"model",
"and",
"erases",
"old",
"checkpoints",
"if",
"needed",
".",
"Parameters",
"----------",
"trial",
":",
"trial",
"to",
"save"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L499-L514 | [
"def",
"_checkpoint_and_erase",
"(",
"self",
",",
"trial",
")",
":",
"with",
"warn_if_slow",
"(",
"\"save_to_disk\"",
")",
":",
"trial",
".",
"_checkpoint",
".",
"value",
"=",
"ray",
".",
"get",
"(",
"trial",
".",
"runner",
".",
"save",
".",
"remote",
"(... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.restore | Restores training state from a given model checkpoint.
This will also sync the trial results to a new location
if restoring on a different node. | python/ray/tune/ray_trial_executor.py | def restore(self, trial, checkpoint=None):
"""Restores training state from a given model checkpoint.
This will also sync the trial results to a new location
if restoring on a different node.
"""
if checkpoint is None or checkpoint.value is None:
checkpoint = trial._c... | def restore(self, trial, checkpoint=None):
"""Restores training state from a given model checkpoint.
This will also sync the trial results to a new location
if restoring on a different node.
"""
if checkpoint is None or checkpoint.value is None:
checkpoint = trial._c... | [
"Restores",
"training",
"state",
"from",
"a",
"given",
"model",
"checkpoint",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L516-L545 | [
"def",
"restore",
"(",
"self",
",",
"trial",
",",
"checkpoint",
"=",
"None",
")",
":",
"if",
"checkpoint",
"is",
"None",
"or",
"checkpoint",
".",
"value",
"is",
"None",
":",
"checkpoint",
"=",
"trial",
".",
"_checkpoint",
"if",
"checkpoint",
"is",
"None"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | RayTrialExecutor.export_trial_if_needed | Exports model of this trial based on trial.export_formats.
Return:
A dict that maps ExportFormats to successfully exported models. | python/ray/tune/ray_trial_executor.py | def export_trial_if_needed(self, trial):
"""Exports model of this trial based on trial.export_formats.
Return:
A dict that maps ExportFormats to successfully exported models.
"""
if trial.export_formats and len(trial.export_formats) > 0:
return ray.get(
... | def export_trial_if_needed(self, trial):
"""Exports model of this trial based on trial.export_formats.
Return:
A dict that maps ExportFormats to successfully exported models.
"""
if trial.export_formats and len(trial.export_formats) > 0:
return ray.get(
... | [
"Exports",
"model",
"of",
"this",
"trial",
"based",
"on",
"trial",
".",
"export_formats",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/ray_trial_executor.py#L547-L556 | [
"def",
"export_trial_if_needed",
"(",
"self",
",",
"trial",
")",
":",
"if",
"trial",
".",
"export_formats",
"and",
"len",
"(",
"trial",
".",
"export_formats",
")",
">",
"0",
":",
"return",
"ray",
".",
"get",
"(",
"trial",
".",
"runner",
".",
"export_mode... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Environment.__generate_actor | Generates an actor that will execute a particular instance of
the logical operator
Attributes:
instance_id (UUID): The id of the instance the actor will execute.
operator (Operator): The metadata of the logical operator.
input (DataInput): The input gate that manages... | python/ray/experimental/streaming/streaming.py | def __generate_actor(self, instance_id, operator, input, output):
"""Generates an actor that will execute a particular instance of
the logical operator
Attributes:
instance_id (UUID): The id of the instance the actor will execute.
operator (Operator): The metadata of the... | def __generate_actor(self, instance_id, operator, input, output):
"""Generates an actor that will execute a particular instance of
the logical operator
Attributes:
instance_id (UUID): The id of the instance the actor will execute.
operator (Operator): The metadata of the... | [
"Generates",
"an",
"actor",
"that",
"will",
"execute",
"a",
"particular",
"instance",
"of",
"the",
"logical",
"operator"
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L96-L169 | [
"def",
"__generate_actor",
"(",
"self",
",",
"instance_id",
",",
"operator",
",",
"input",
",",
"output",
")",
":",
"actor_id",
"=",
"(",
"operator",
".",
"id",
",",
"instance_id",
")",
"# Record the physical dataflow graph (for debugging purposes)",
"self",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Environment.__generate_actors | Generates one actor for each instance of the given logical
operator.
Attributes:
operator (Operator): The logical operator metadata.
upstream_channels (list): A list of all upstream channels for
all instances of the operator.
downstream_channels (list): A... | python/ray/experimental/streaming/streaming.py | def __generate_actors(self, operator, upstream_channels,
downstream_channels):
"""Generates one actor for each instance of the given logical
operator.
Attributes:
operator (Operator): The logical operator metadata.
upstream_channels (list): A li... | def __generate_actors(self, operator, upstream_channels,
downstream_channels):
"""Generates one actor for each instance of the given logical
operator.
Attributes:
operator (Operator): The logical operator metadata.
upstream_channels (list): A li... | [
"Generates",
"one",
"actor",
"for",
"each",
"instance",
"of",
"the",
"given",
"logical",
"operator",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L173-L210 | [
"def",
"__generate_actors",
"(",
"self",
",",
"operator",
",",
"upstream_channels",
",",
"downstream_channels",
")",
":",
"num_instances",
"=",
"operator",
".",
"num_instances",
"logger",
".",
"info",
"(",
"\"Generating {} actors of type {}...\"",
".",
"format",
"(",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Environment._generate_channels | Generates all output data channels
(see: DataChannel in communication.py) for all instances of
the given logical operator.
The function constructs one data channel for each pair of
communicating operator instances (instance_1,instance_2),
where instance_1 is an instance of the g... | python/ray/experimental/streaming/streaming.py | def _generate_channels(self, operator):
"""Generates all output data channels
(see: DataChannel in communication.py) for all instances of
the given logical operator.
The function constructs one data channel for each pair of
communicating operator instances (instance_1,instance_2... | def _generate_channels(self, operator):
"""Generates all output data channels
(see: DataChannel in communication.py) for all instances of
the given logical operator.
The function constructs one data channel for each pair of
communicating operator instances (instance_1,instance_2... | [
"Generates",
"all",
"output",
"data",
"channels",
"(",
"see",
":",
"DataChannel",
"in",
"communication",
".",
"py",
")",
"for",
"all",
"instances",
"of",
"the",
"given",
"logical",
"operator",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L219-L253 | [
"def",
"_generate_channels",
"(",
"self",
",",
"operator",
")",
":",
"channels",
"=",
"{",
"}",
"# destination operator id -> channels",
"strategies",
"=",
"operator",
".",
"partitioning_strategies",
"for",
"dst_operator",
",",
"p_scheme",
"in",
"strategies",
".",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | Environment.execute | Deploys and executes the physical dataflow. | python/ray/experimental/streaming/streaming.py | def execute(self):
"""Deploys and executes the physical dataflow."""
self._collect_garbage() # Make sure everything is clean
# TODO (john): Check if dataflow has any 'logical inconsistencies'
# For example, if there is a forward partitioning strategy but
# the number of downstre... | def execute(self):
"""Deploys and executes the physical dataflow."""
self._collect_garbage() # Make sure everything is clean
# TODO (john): Check if dataflow has any 'logical inconsistencies'
# For example, if there is a forward partitioning strategy but
# the number of downstre... | [
"Deploys",
"and",
"executes",
"the",
"physical",
"dataflow",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L306-L332 | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"_collect_garbage",
"(",
")",
"# Make sure everything is clean",
"# TODO (john): Check if dataflow has any 'logical inconsistencies'",
"# For example, if there is a forward partitioning strategy but",
"# the number of downstream insta... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.__register | Registers the given logical operator to the environment and
connects it to its upstream operator (if any).
A call to this function adds a new edge to the logical topology.
Attributes:
operator (Operator): The metadata of the logical operator. | python/ray/experimental/streaming/streaming.py | def __register(self, operator):
"""Registers the given logical operator to the environment and
connects it to its upstream operator (if any).
A call to this function adds a new edge to the logical topology.
Attributes:
operator (Operator): The metadata of the logical opera... | def __register(self, operator):
"""Registers the given logical operator to the environment and
connects it to its upstream operator (if any).
A call to this function adds a new edge to the logical topology.
Attributes:
operator (Operator): The metadata of the logical opera... | [
"Registers",
"the",
"given",
"logical",
"operator",
"to",
"the",
"environment",
"and",
"connects",
"it",
"to",
"its",
"upstream",
"operator",
"(",
"if",
"any",
")",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L429-L462 | [
"def",
"__register",
"(",
"self",
",",
"operator",
")",
":",
"self",
".",
"env",
".",
"operators",
"[",
"operator",
".",
"id",
"]",
"=",
"operator",
"self",
".",
"dst_operator_id",
"=",
"operator",
".",
"id",
"logger",
".",
"debug",
"(",
"\"Adding new da... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.set_parallelism | Sets the number of instances for the source operator of the stream.
Attributes:
num_instances (int): The level of parallelism for the source
operator of the stream. | python/ray/experimental/streaming/streaming.py | def set_parallelism(self, num_instances):
"""Sets the number of instances for the source operator of the stream.
Attributes:
num_instances (int): The level of parallelism for the source
operator of the stream.
"""
assert (num_instances > 0)
self.env._se... | def set_parallelism(self, num_instances):
"""Sets the number of instances for the source operator of the stream.
Attributes:
num_instances (int): The level of parallelism for the source
operator of the stream.
"""
assert (num_instances > 0)
self.env._se... | [
"Sets",
"the",
"number",
"of",
"instances",
"for",
"the",
"source",
"operator",
"of",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L467-L476 | [
"def",
"set_parallelism",
"(",
"self",
",",
"num_instances",
")",
":",
"assert",
"(",
"num_instances",
">",
"0",
")",
"self",
".",
"env",
".",
"_set_parallelism",
"(",
"self",
".",
"src_operator_id",
",",
"num_instances",
")",
"return",
"self"
] | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.map | Applies a map operator to the stream.
Attributes:
map_fn (function): The user-defined logic of the map. | python/ray/experimental/streaming/streaming.py | def map(self, map_fn, name="Map"):
"""Applies a map operator to the stream.
Attributes:
map_fn (function): The user-defined logic of the map.
"""
op = Operator(
_generate_uuid(),
OpType.Map,
name,
map_fn,
num_insta... | def map(self, map_fn, name="Map"):
"""Applies a map operator to the stream.
Attributes:
map_fn (function): The user-defined logic of the map.
"""
op = Operator(
_generate_uuid(),
OpType.Map,
name,
map_fn,
num_insta... | [
"Applies",
"a",
"map",
"operator",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L521-L533 | [
"def",
"map",
"(",
"self",
",",
"map_fn",
",",
"name",
"=",
"\"Map\"",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Map",
",",
"name",
",",
"map_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"con... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.flat_map | Applies a flatmap operator to the stream.
Attributes:
flatmap_fn (function): The user-defined logic of the flatmap
(e.g. split()). | python/ray/experimental/streaming/streaming.py | 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):
"""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... | [
"Applies",
"a",
"flatmap",
"operator",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L536-L549 | [
"def",
"flat_map",
"(",
"self",
",",
"flatmap_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"FlatMap",
",",
"\"FlatMap\"",
",",
"flatmap_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.key_by | Applies a key_by operator to the stream.
Attributes:
key_attribute_index (int): The index of the key attributed
(assuming tuple records). | python/ray/experimental/streaming/streaming.py | 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):
"""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,
"... | [
"Applies",
"a",
"key_by",
"operator",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L553-L566 | [
"def",
"key_by",
"(",
"self",
",",
"key_selector",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"KeyBy",
",",
"\"KeyBy\"",
",",
"other",
"=",
"key_selector",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.reduce | Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records). | python/ray/experimental/streaming/streaming.py | 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):
"""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,
... | [
"Applies",
"a",
"rolling",
"sum",
"operator",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L569-L582 | [
"def",
"reduce",
"(",
"self",
",",
"reduce_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Reduce",
",",
"\"Sum\"",
",",
"reduce_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parall... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.sum | Applies a rolling sum operator to the stream.
Attributes:
sum_attribute_index (int): The index of the attribute to sum
(assuming tuple records). | python/ray/experimental/streaming/streaming.py | 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):
"""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(),
... | [
"Applies",
"a",
"rolling",
"sum",
"operator",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L585-L600 | [
"def",
"sum",
"(",
"self",
",",
"attribute_selector",
",",
"state_keeper",
"=",
"None",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Sum",
",",
"\"Sum\"",
",",
"_sum",
",",
"other",
"=",
"attribute_selector",
","... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.time_window | Applies a system time window to the stream.
Attributes:
window_width_ms (int): The length of the window in ms. | python/ray/experimental/streaming/streaming.py | 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):
"""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... | [
"Applies",
"a",
"system",
"time",
"window",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L605-L617 | [
"def",
"time_window",
"(",
"self",
",",
"window_width_ms",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"TimeWindow",
",",
"\"TimeWindow\"",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parall... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.filter | Applies a filter to the stream.
Attributes:
filter_fn (function): The user-defined filter function. | python/ray/experimental/streaming/streaming.py | 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):
"""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... | [
"Applies",
"a",
"filter",
"to",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L620-L632 | [
"def",
"filter",
"(",
"self",
",",
"filter_fn",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Filter",
",",
"\"Filter\"",
",",
"filter_fn",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"par... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.inspect | Inspects the content of the stream.
Attributes:
inspect_logic (function): The user-defined inspect function. | python/ray/experimental/streaming/streaming.py | 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):
"""Inspects the content of the stream.
Attributes:
inspect_logic (function): The user-defined inspect function.
"""
op = Operator(
_generate_uuid(),
OpType.Inspect,
"Inspect",
inspect_logic,
... | [
"Inspects",
"the",
"content",
"of",
"the",
"stream",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L644-L656 | [
"def",
"inspect",
"(",
"self",
",",
"inspect_logic",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Inspect",
",",
"\"Inspect\"",
",",
"inspect_logic",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataStream.sink | Closes the stream with a sink operator. | python/ray/experimental/streaming/streaming.py | 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):
"""Closes the stream with a sink operator."""
op = Operator(
_generate_uuid(),
OpType.Sink,
"Sink",
num_instances=self.env.config.parallelism)
return self.__register(op) | [
"Closes",
"the",
"stream",
"with",
"a",
"sink",
"operator",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/streaming.py#L661-L668 | [
"def",
"sink",
"(",
"self",
")",
":",
"op",
"=",
"Operator",
"(",
"_generate_uuid",
"(",
")",
",",
"OpType",
".",
"Sink",
",",
"\"Sink\"",
",",
"num_instances",
"=",
"self",
".",
"env",
".",
"config",
".",
"parallelism",
")",
"return",
"self",
".",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LogMonitor.close_all_files | Close all open files (so that we can open more). | python/ray/log_monitor.py | 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):
"""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... | [
"Close",
"all",
"open",
"files",
"(",
"so",
"that",
"we",
"can",
"open",
"more",
")",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L81-L88 | [
"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",
"(",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LogMonitor.update_log_filenames | Update the list of log files to monitor. | python/ray/log_monitor.py | 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):
"""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.... | [
"Update",
"the",
"list",
"of",
"log",
"files",
"to",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L90-L104 | [
"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... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LogMonitor.open_closed_files | Open some closed files if they may have new lines.
Opening more files may require us to close some of the already open
files. | python/ray/log_monitor.py | 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):
"""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... | [
"Open",
"some",
"closed",
"files",
"if",
"they",
"may",
"have",
"new",
"lines",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L106-L160 | [
"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",
"("... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LogMonitor.check_log_files_and_publish_updates | Get any changes to the log files and push updates to Redis.
Returns:
True if anything was published and false otherwise. | python/ray/log_monitor.py | 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):
"""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... | [
"Get",
"any",
"changes",
"to",
"the",
"log",
"files",
"and",
"push",
"updates",
"to",
"Redis",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L162-L208 | [
"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",
"=",
"[",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | LogMonitor.run | 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. | python/ray/log_monitor.py | 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):
"""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... | [
"Run",
"the",
"log",
"monitor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/log_monitor.py#L210-L223 | [
"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... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | SuggestionAlgorithm.add_configurations | Chains generator given experiment specifications.
Arguments:
experiments (Experiment | list | dict): Experiments to run. | python/ray/tune/suggest/suggestion.py | 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):
"""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:
... | [
"Chains",
"generator",
"given",
"experiment",
"specifications",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L43-L53 | [
"def",
"add_configurations",
"(",
"self",
",",
"experiments",
")",
":",
"experiment_list",
"=",
"convert_to_experiment_list",
"(",
"experiments",
")",
"for",
"experiment",
"in",
"experiment_list",
":",
"self",
".",
"_trial_generator",
"=",
"itertools",
".",
"chain",... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | SuggestionAlgorithm.next_trials | 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. | python/ray/tune/suggest/suggestion.py | 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):
"""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:
... | [
"Provides",
"a",
"batch",
"of",
"Trial",
"objects",
"to",
"be",
"queued",
"into",
"the",
"TrialRunner",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L55-L71 | [
"def",
"next_trials",
"(",
"self",
")",
":",
"trials",
"=",
"[",
"]",
"for",
"trial",
"in",
"self",
".",
"_trial_generator",
":",
"if",
"trial",
"is",
"None",
":",
"return",
"trials",
"trials",
"+=",
"[",
"trial",
"]",
"self",
".",
"_finished",
"=",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | SuggestionAlgorithm._generate_trials | Generates trials with configurations from `_suggest`.
Creates a trial_id that is passed into `_suggest`.
Yields:
Trial objects constructed according to `spec` | python/ray/tune/suggest/suggestion.py | 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=""):
"""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:
... | [
"Generates",
"trials",
"with",
"configurations",
"from",
"_suggest",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/suggestion.py#L73-L102 | [
"def",
"_generate_trials",
"(",
"self",
",",
"experiment_spec",
",",
"output_path",
"=",
"\"\"",
")",
":",
"if",
"\"run\"",
"not",
"in",
"experiment_spec",
":",
"raise",
"TuneError",
"(",
"\"Must specify `run` in {}\"",
".",
"format",
"(",
"experiment_spec",
")",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | generate_variants | 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":... | python/ray/tune/suggest/variant_generator.py | 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):
"""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... | [
"Generates",
"variants",
"from",
"a",
"spec",
"(",
"dict",
")",
"with",
"unresolved",
"values",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/variant_generator.py#L16-L44 | [
"def",
"generate_variants",
"(",
"unresolved_spec",
")",
":",
"for",
"resolved_vars",
",",
"spec",
"in",
"_generate_variants",
"(",
"unresolved_spec",
")",
":",
"assert",
"not",
"_unresolved_values",
"(",
"spec",
")",
"yield",
"format_vars",
"(",
"resolved_vars",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | resolve_nested_dict | Flattens a nested dict by joining keys into tuple of paths.
Can then be passed into `format_vars`. | python/ray/tune/suggest/variant_generator.py | 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):
"""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,... | [
"Flattens",
"a",
"nested",
"dict",
"by",
"joining",
"keys",
"into",
"tuple",
"of",
"paths",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/suggest/variant_generator.py#L108-L120 | [
"def",
"resolve_nested_dict",
"(",
"nested_dict",
")",
":",
"res",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"nested_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"dict",
")",
":",
"for",
"k_",
",",
"v_",
"in",
"resolve_ne... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | run_board | Run main entry for AutoMLBoard.
Args:
args: args parsed from command line | python/ray/tune/automlboard/run.py | 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):
"""
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... | [
"Run",
"main",
"entry",
"for",
"AutoMLBoard",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L18-L43 | [
"def",
"run_board",
"(",
"args",
")",
":",
"init_config",
"(",
"args",
")",
"# backend service, should import after django settings initialized",
"from",
"backend",
".",
"collector",
"import",
"CollectorService",
"service",
"=",
"CollectorService",
"(",
"args",
".",
"lo... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | init_config | Initialize configs of the service.
Do the following things:
1. automl board settings
2. database settings
3. django settings | python/ray/tune/automlboard/run.py | 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):
"""
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_... | [
"Initialize",
"configs",
"of",
"the",
"service",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L46-L80 | [
"def",
"init_config",
"(",
"args",
")",
":",
"os",
".",
"environ",
"[",
"\"AUTOMLBOARD_LOGDIR\"",
"]",
"=",
"args",
".",
"logdir",
"os",
".",
"environ",
"[",
"\"AUTOMLBOARD_LOGLEVEL\"",
"]",
"=",
"args",
".",
"log_level",
"os",
".",
"environ",
"[",
"\"AUTO... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | 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, NUM_GPUS - 1], where NUM_GP... | python/ray/worker.py | 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():
"""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... | [
"Get",
"the",
"IDs",
"of",
"the",
"GPUs",
"that",
"are",
"available",
"to",
"the",
"worker",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1042-L1069 | [
"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... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | error_info | Return information about failed tasks. | python/ray/worker.py | 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():
"""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())) | [
"Return",
"information",
"about",
"failed",
"tasks",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1134-L1139 | [
"def",
"error_info",
"(",
")",
":",
"worker",
"=",
"global_worker",
"worker",
".",
"check_connected",
"(",
")",
"return",
"(",
"global_state",
".",
"error_messages",
"(",
"driver_id",
"=",
"worker",
".",
"task_driver_id",
")",
"+",
"global_state",
".",
"error_... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | _initialize_serialization | 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. | python/ray/worker.py | 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):
"""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... | [
"Initialize",
"the",
"serialization",
"library",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1142-L1210 | [
"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... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | init | 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... | python/ray/worker.py | 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,
node_ip_address=None,
object_id_seed=None,
local_mode=False,
redirect_worker_output=No... | [
"Connect",
"to",
"an",
"existing",
"Ray",
"cluster",
"or",
"start",
"one",
"and",
"connect",
"to",
"it",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L1213-L1455 | [
"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",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.