hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
check_health
bool
def check_health(self) -> bool: """Check if the actor is healthy. self._healthy should *only* be modified in this method. This is responsible for: 1) Checking the outstanding health check (if any). 2) Determining the replica health based on the health check results. ...
Check if the actor is healthy. self._healthy should *only* be modified in this method. This is responsible for: 1) Checking the outstanding health check (if any). 2) Determining the replica health based on the health check results. 3) Kicking off a new health check ...
Check if the actor is healthy. self._healthy should *only* be modified in this method. This is responsible for: 1) Checking the outstanding health check (if any). 2) Determining the replica health based on the health check results. 3) Kicking off a new health check if needed.
[ "Check", "if", "the", "actor", "is", "healthy", ".", "self", ".", "_healthy", "should", "*", "only", "*", "be", "modified", "in", "this", "method", ".", "This", "is", "responsible", "for", ":", "1", ")", "Checking", "the", "outstanding", "health", "check...
def check_health(self) -> bool: response: ReplicaHealthCheckResponse = self._check_active_health_check() if response is ReplicaHealthCheckResponse.NONE: pass elif response is ReplicaHealthCheckResponse.SUCCEEDED: self._consecutive_health_check_failures = 0 sel...
[ "def", "check_health", "(", "self", ")", "->", "bool", ":", "response", ":", "ReplicaHealthCheckResponse", "=", "self", ".", "_check_active_health_check", "(", ")", "if", "response", "is", "ReplicaHealthCheckResponse", ".", "NONE", ":", "pass", "elif", "response",...
Check if the actor is healthy.
[ "Check", "if", "the", "actor", "is", "healthy", "." ]
[ "\"\"\"Check if the actor is healthy.\n\n self._healthy should *only* be modified in this method.\n\n This is responsible for:\n 1) Checking the outstanding health check (if any).\n 2) Determining the replica health based on the health check results.\n 3) Kicking off a...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
force_stop
null
def force_stop(self): """Force the actor to exit without shutting down gracefully.""" try: ray.kill( ray.get_actor(self._actor_name, namespace=self._controller_namespace) ) except ValueError: pass
Force the actor to exit without shutting down gracefully.
Force the actor to exit without shutting down gracefully.
[ "Force", "the", "actor", "to", "exit", "without", "shutting", "down", "gracefully", "." ]
def force_stop(self): try: ray.kill( ray.get_actor(self._actor_name, namespace=self._controller_namespace) ) except ValueError: pass
[ "def", "force_stop", "(", "self", ")", ":", "try", ":", "ray", ".", "kill", "(", "ray", ".", "get_actor", "(", "self", ".", "_actor_name", ",", "namespace", "=", "self", ".", "_controller_namespace", ")", ")", "except", "ValueError", ":", "pass" ]
Force the actor to exit without shutting down gracefully.
[ "Force", "the", "actor", "to", "exit", "without", "shutting", "down", "gracefully", "." ]
[ "\"\"\"Force the actor to exit without shutting down gracefully.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
cleanup
<not_specific>
def cleanup(self): """Clean up any remaining resources after the actor has exited. Currently, this just removes the placement group. """ if not USE_PLACEMENT_GROUP: return try: if self._placement_group is not None: ray.util.remove_placeme...
Clean up any remaining resources after the actor has exited. Currently, this just removes the placement group.
Clean up any remaining resources after the actor has exited. Currently, this just removes the placement group.
[ "Clean", "up", "any", "remaining", "resources", "after", "the", "actor", "has", "exited", ".", "Currently", "this", "just", "removes", "the", "placement", "group", "." ]
def cleanup(self): if not USE_PLACEMENT_GROUP: return try: if self._placement_group is not None: ray.util.remove_placement_group(self._placement_group) except ValueError: pass
[ "def", "cleanup", "(", "self", ")", ":", "if", "not", "USE_PLACEMENT_GROUP", ":", "return", "try", ":", "if", "self", ".", "_placement_group", "is", "not", "None", ":", "ray", ".", "util", ".", "remove_placement_group", "(", "self", ".", "_placement_group", ...
Clean up any remaining resources after the actor has exited.
[ "Clean", "up", "any", "remaining", "resources", "after", "the", "actor", "has", "exited", "." ]
[ "\"\"\"Clean up any remaining resources after the actor has exited.\n\n Currently, this just removes the placement group.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
start
null
def start(self, deployment_info: DeploymentInfo, version: DeploymentVersion): """ Start a new actor for current DeploymentReplica instance. """ self._actor.start(deployment_info, version) self._start_time = time.time() self._prev_slow_startup_warning_time = time.time() ...
Start a new actor for current DeploymentReplica instance.
Start a new actor for current DeploymentReplica instance.
[ "Start", "a", "new", "actor", "for", "current", "DeploymentReplica", "instance", "." ]
def start(self, deployment_info: DeploymentInfo, version: DeploymentVersion): self._actor.start(deployment_info, version) self._start_time = time.time() self._prev_slow_startup_warning_time = time.time() self._version = version
[ "def", "start", "(", "self", ",", "deployment_info", ":", "DeploymentInfo", ",", "version", ":", "DeploymentVersion", ")", ":", "self", ".", "_actor", ".", "start", "(", "deployment_info", ",", "version", ")", "self", ".", "_start_time", "=", "time", ".", ...
Start a new actor for current DeploymentReplica instance.
[ "Start", "a", "new", "actor", "for", "current", "DeploymentReplica", "instance", "." ]
[ "\"\"\"\n Start a new actor for current DeploymentReplica instance.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "deployment_info", "type": "DeploymentInfo" }, { "param": "version", "type": "DeploymentVersion" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "deployment_info", "type": "DeploymentInfo", "docstring": null, ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
update_user_config
null
def update_user_config(self, user_config: Any): """ Update user config of existing actor behind current DeploymentReplica instance. """ self._actor.update_user_config(user_config) self._version = DeploymentVersion( self._version.code_version, user_config=user_...
Update user config of existing actor behind current DeploymentReplica instance.
Update user config of existing actor behind current DeploymentReplica instance.
[ "Update", "user", "config", "of", "existing", "actor", "behind", "current", "DeploymentReplica", "instance", "." ]
def update_user_config(self, user_config: Any): self._actor.update_user_config(user_config) self._version = DeploymentVersion( self._version.code_version, user_config=user_config )
[ "def", "update_user_config", "(", "self", ",", "user_config", ":", "Any", ")", ":", "self", ".", "_actor", ".", "update_user_config", "(", "user_config", ")", "self", ".", "_version", "=", "DeploymentVersion", "(", "self", ".", "_version", ".", "code_version",...
Update user config of existing actor behind current DeploymentReplica instance.
[ "Update", "user", "config", "of", "existing", "actor", "behind", "current", "DeploymentReplica", "instance", "." ]
[ "\"\"\"\n Update user config of existing actor behind current\n DeploymentReplica instance.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user_config", "type": "Any" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user_config", "type": "Any", "docstring": null, "docstring_to...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
recover
null
def recover(self): """ Recover states in DeploymentReplica instance by fetching running actor status """ self._actor.recover() self._start_time = time.time() # Replica version is fetched from recovered replica dynamically in # check_started() below
Recover states in DeploymentReplica instance by fetching running actor status
Recover states in DeploymentReplica instance by fetching running actor status
[ "Recover", "states", "in", "DeploymentReplica", "instance", "by", "fetching", "running", "actor", "status" ]
def recover(self): self._actor.recover() self._start_time = time.time()
[ "def", "recover", "(", "self", ")", ":", "self", ".", "_actor", ".", "recover", "(", ")", "self", ".", "_start_time", "=", "time", ".", "time", "(", ")" ]
Recover states in DeploymentReplica instance by fetching running actor status
[ "Recover", "states", "in", "DeploymentReplica", "instance", "by", "fetching", "running", "actor", "status" ]
[ "\"\"\"\n Recover states in DeploymentReplica instance by fetching running actor\n status\n \"\"\"", "# Replica version is fetched from recovered replica dynamically in", "# check_started() below" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
check_started
ReplicaStartupStatus
def check_started(self) -> ReplicaStartupStatus: """Check if the replica has started. If so, transition to RUNNING. Should handle the case where the replica has already stopped. Returns: status (ReplicaStartupStatus): Most recent state of replica by querying actor o...
Check if the replica has started. If so, transition to RUNNING. Should handle the case where the replica has already stopped. Returns: status (ReplicaStartupStatus): Most recent state of replica by querying actor obj ref
Check if the replica has started. If so, transition to RUNNING. Should handle the case where the replica has already stopped.
[ "Check", "if", "the", "replica", "has", "started", ".", "If", "so", "transition", "to", "RUNNING", ".", "Should", "handle", "the", "case", "where", "the", "replica", "has", "already", "stopped", "." ]
def check_started(self) -> ReplicaStartupStatus: status, version = self._actor.check_ready() if status == ReplicaStartupStatus.SUCCEEDED: if version is not None: self._version = version return status
[ "def", "check_started", "(", "self", ")", "->", "ReplicaStartupStatus", ":", "status", ",", "version", "=", "self", ".", "_actor", ".", "check_ready", "(", ")", "if", "status", "==", "ReplicaStartupStatus", ".", "SUCCEEDED", ":", "if", "version", "is", "not"...
Check if the replica has started.
[ "Check", "if", "the", "replica", "has", "started", "." ]
[ "\"\"\"Check if the replica has started. If so, transition to RUNNING.\n\n Should handle the case where the replica has already stopped.\n\n Returns:\n status (ReplicaStartupStatus): Most recent state of replica by\n querying actor obj ref\n \"\"\"", "# Re-assign Dep...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "status (ReplicaStartupStatus): Most recent state of replica by\nquerying actor obj ref", "docstring_tokens": [ "status", "(", "ReplicaStartupStatus", ")", ":", "Most", "recent", "state", "of", ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
stop
None
def stop(self, graceful: bool = True) -> None: """Stop the replica. Should handle the case where the replica is already stopped. """ timeout_s = self._actor.graceful_stop() if not graceful: timeout_s = 0 self._shutdown_deadline = time.time() + timeout_s
Stop the replica. Should handle the case where the replica is already stopped.
Stop the replica. Should handle the case where the replica is already stopped.
[ "Stop", "the", "replica", ".", "Should", "handle", "the", "case", "where", "the", "replica", "is", "already", "stopped", "." ]
def stop(self, graceful: bool = True) -> None: timeout_s = self._actor.graceful_stop() if not graceful: timeout_s = 0 self._shutdown_deadline = time.time() + timeout_s
[ "def", "stop", "(", "self", ",", "graceful", ":", "bool", "=", "True", ")", "->", "None", ":", "timeout_s", "=", "self", ".", "_actor", ".", "graceful_stop", "(", ")", "if", "not", "graceful", ":", "timeout_s", "=", "0", "self", ".", "_shutdown_deadlin...
Stop the replica.
[ "Stop", "the", "replica", "." ]
[ "\"\"\"Stop the replica.\n\n Should handle the case where the replica is already stopped.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "graceful", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "graceful", "type": "bool", "docstring": null, "docstring_toke...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
check_stopped
bool
def check_stopped(self) -> bool: """Check if the replica has finished stopping.""" if self._actor.check_stopped(): # Clean up any associated resources (e.g., placement group). self._actor.cleanup() return True timeout_passed = time.time() > self._shutdown_dea...
Check if the replica has finished stopping.
Check if the replica has finished stopping.
[ "Check", "if", "the", "replica", "has", "finished", "stopping", "." ]
def check_stopped(self) -> bool: if self._actor.check_stopped(): self._actor.cleanup() return True timeout_passed = time.time() > self._shutdown_deadline if timeout_passed: logger.debug( f"Replica {self.replica_tag} did not shut down after grac...
[ "def", "check_stopped", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_actor", ".", "check_stopped", "(", ")", ":", "self", ".", "_actor", ".", "cleanup", "(", ")", "return", "True", "timeout_passed", "=", "time", ".", "time", "(", ")", ">...
Check if the replica has finished stopping.
[ "Check", "if", "the", "replica", "has", "finished", "stopping", "." ]
[ "\"\"\"Check if the replica has finished stopping.\"\"\"", "# Clean up any associated resources (e.g., placement group).", "# Graceful period passed, kill it forcefully.", "# This will be called repeatedly until the replica shuts down." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
resource_requirements
Tuple[str, str]
def resource_requirements(self) -> Tuple[str, str]: """Returns required and currently available resources. Only resources with nonzero requirements will be included in the required dict and only resources in the required dict will be included in the available dict (filtered for relevanc...
Returns required and currently available resources. Only resources with nonzero requirements will be included in the required dict and only resources in the required dict will be included in the available dict (filtered for relevance).
Returns required and currently available resources. Only resources with nonzero requirements will be included in the required dict and only resources in the required dict will be included in the available dict (filtered for relevance).
[ "Returns", "required", "and", "currently", "available", "resources", ".", "Only", "resources", "with", "nonzero", "requirements", "will", "be", "included", "in", "the", "required", "dict", "and", "only", "resources", "in", "the", "required", "dict", "will", "be"...
def resource_requirements(self) -> Tuple[str, str]: if self._actor.actor_resources is None: return "UNKNOWN", "UNKNOWN" required = { k: v for k, v in self._actor.actor_resources.items() if v is not None and v > 0 } available = { ...
[ "def", "resource_requirements", "(", "self", ")", "->", "Tuple", "[", "str", ",", "str", "]", ":", "if", "self", ".", "_actor", ".", "actor_resources", "is", "None", ":", "return", "\"UNKNOWN\"", ",", "\"UNKNOWN\"", "required", "=", "{", "k", ":", "v", ...
Returns required and currently available resources.
[ "Returns", "required", "and", "currently", "available", "resources", "." ]
[ "\"\"\"Returns required and currently available resources.\n\n Only resources with nonzero requirements will be included in the\n required dict and only resources in the required dict will be\n included in the available dict (filtered for relevance).\n \"\"\"", "# NOTE(edoakes):" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
add
null
def add(self, state: ReplicaState, replica: VersionedReplica): """Add the provided replica under the provided state. Args: state (ReplicaState): state to add the replica under. replica (VersionedReplica): replica to add. """ assert isinstance(state, ReplicaState)...
Add the provided replica under the provided state. Args: state (ReplicaState): state to add the replica under. replica (VersionedReplica): replica to add.
Add the provided replica under the provided state.
[ "Add", "the", "provided", "replica", "under", "the", "provided", "state", "." ]
def add(self, state: ReplicaState, replica: VersionedReplica): assert isinstance(state, ReplicaState) assert isinstance(replica, VersionedReplica) self._replicas[state].append(replica)
[ "def", "add", "(", "self", ",", "state", ":", "ReplicaState", ",", "replica", ":", "VersionedReplica", ")", ":", "assert", "isinstance", "(", "state", ",", "ReplicaState", ")", "assert", "isinstance", "(", "replica", ",", "VersionedReplica", ")", "self", "."...
Add the provided replica under the provided state.
[ "Add", "the", "provided", "replica", "under", "the", "provided", "state", "." ]
[ "\"\"\"Add the provided replica under the provided state.\n\n Args:\n state (ReplicaState): state to add the replica under.\n replica (VersionedReplica): replica to add.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "state", "type": "ReplicaState" }, { "param": "replica", "type": "VersionedReplica" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": "ReplicaState", "docstring": "state to add the repl...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
pop
List[VersionedReplica]
def pop( self, exclude_version: Optional[DeploymentVersion] = None, states: Optional[List[ReplicaState]] = None, max_replicas: Optional[int] = math.inf, ranking_function: Optional[ Callable[[List["DeploymentReplica"]], List["DeploymentReplica"]] ] = None, ...
Get and remove all replicas of the given states. This removes the replicas from the container. Replicas are returned in order of state as passed in. Args: exclude_version (DeploymentVersion): if specified, replicas of the provided version will *not* be removed. ...
Get and remove all replicas of the given states. This removes the replicas from the container. Replicas are returned in order of state as passed in.
[ "Get", "and", "remove", "all", "replicas", "of", "the", "given", "states", ".", "This", "removes", "the", "replicas", "from", "the", "container", ".", "Replicas", "are", "returned", "in", "order", "of", "state", "as", "passed", "in", "." ]
def pop( self, exclude_version: Optional[DeploymentVersion] = None, states: Optional[List[ReplicaState]] = None, max_replicas: Optional[int] = math.inf, ranking_function: Optional[ Callable[[List["DeploymentReplica"]], List["DeploymentReplica"]] ] = None, ...
[ "def", "pop", "(", "self", ",", "exclude_version", ":", "Optional", "[", "DeploymentVersion", "]", "=", "None", ",", "states", ":", "Optional", "[", "List", "[", "ReplicaState", "]", "]", "=", "None", ",", "max_replicas", ":", "Optional", "[", "int", "]"...
Get and remove all replicas of the given states.
[ "Get", "and", "remove", "all", "replicas", "of", "the", "given", "states", "." ]
[ "\"\"\"Get and remove all replicas of the given states.\n\n This removes the replicas from the container. Replicas are returned\n in order of state as passed in.\n\n Args:\n exclude_version (DeploymentVersion): if specified, replicas of the\n provided version will *not...
[ { "param": "self", "type": null }, { "param": "exclude_version", "type": "Optional[DeploymentVersion]" }, { "param": "states", "type": "Optional[List[ReplicaState]]" }, { "param": "max_replicas", "type": "Optional[int]" }, { "param": "ranking_function", "type"...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "exclude_version", "type": "Optional[DeploymentVersion]", "docstring...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
count
<not_specific>
def count( self, exclude_version: Optional[DeploymentVersion] = None, version: Optional[DeploymentVersion] = None, states: Optional[List[ReplicaState]] = None, ): """Get the total count of replicas of the given states. Args: exclude_version(DeploymentVers...
Get the total count of replicas of the given states. Args: exclude_version(DeploymentVersion): version to exclude. If not specified, all versions are considered. version(DeploymentVersion): version to filter to. If not specified, all versions are consider...
Get the total count of replicas of the given states.
[ "Get", "the", "total", "count", "of", "replicas", "of", "the", "given", "states", "." ]
def count( self, exclude_version: Optional[DeploymentVersion] = None, version: Optional[DeploymentVersion] = None, states: Optional[List[ReplicaState]] = None, ): if states is None: states = ALL_REPLICA_STATES assert isinstance(states, list) assert...
[ "def", "count", "(", "self", ",", "exclude_version", ":", "Optional", "[", "DeploymentVersion", "]", "=", "None", ",", "version", ":", "Optional", "[", "DeploymentVersion", "]", "=", "None", ",", "states", ":", "Optional", "[", "List", "[", "ReplicaState", ...
Get the total count of replicas of the given states.
[ "Get", "the", "total", "count", "of", "replicas", "of", "the", "given", "states", "." ]
[ "\"\"\"Get the total count of replicas of the given states.\n\n Args:\n exclude_version(DeploymentVersion): version to exclude. If not\n specified, all versions are considered.\n version(DeploymentVersion): version to filter to. If not specified,\n all vers...
[ { "param": "self", "type": null }, { "param": "exclude_version", "type": "Optional[DeploymentVersion]" }, { "param": "version", "type": "Optional[DeploymentVersion]" }, { "param": "states", "type": "Optional[List[ReplicaState]]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "exclude_version", "type": "Optional[DeploymentVersion]", "docstring...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_set_deployment_goal
None
def _set_deployment_goal(self, deployment_info: Optional[DeploymentInfo]) -> None: """ Set desirable state for a given deployment, identified by tag. Args: deployment_info (Optional[DeploymentInfo]): Contains deployment and replica config, if passed in as None, we're...
Set desirable state for a given deployment, identified by tag. Args: deployment_info (Optional[DeploymentInfo]): Contains deployment and replica config, if passed in as None, we're marking target deployment as shutting down.
Set desirable state for a given deployment, identified by tag.
[ "Set", "desirable", "state", "for", "a", "given", "deployment", "identified", "by", "tag", "." ]
def _set_deployment_goal(self, deployment_info: Optional[DeploymentInfo]) -> None: if deployment_info is not None: self._target_info = deployment_info self._target_replicas = deployment_info.deployment_config.num_replicas self._target_version = DeploymentVersion( ...
[ "def", "_set_deployment_goal", "(", "self", ",", "deployment_info", ":", "Optional", "[", "DeploymentInfo", "]", ")", "->", "None", ":", "if", "deployment_info", "is", "not", "None", ":", "self", ".", "_target_info", "=", "deployment_info", "self", ".", "_targ...
Set desirable state for a given deployment, identified by tag.
[ "Set", "desirable", "state", "for", "a", "given", "deployment", "identified", "by", "tag", "." ]
[ "\"\"\"\n Set desirable state for a given deployment, identified by tag.\n\n Args:\n deployment_info (Optional[DeploymentInfo]): Contains deployment and\n replica config, if passed in as None, we're marking\n target deployment as shutting down.\n \"\"\""...
[ { "param": "self", "type": null }, { "param": "deployment_info", "type": "Optional[DeploymentInfo]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "deployment_info", "type": "Optional[DeploymentInfo]", "docstring": ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
deploy
bool
def deploy(self, deployment_info: DeploymentInfo) -> bool: """Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False. Returns: bool: Whether or not the deployment is being updated. """ # En...
Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False. Returns: bool: Whether or not the deployment is being updated.
Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False.
[ "Deploy", "the", "deployment", ".", "If", "the", "deployment", "already", "exists", "with", "the", "same", "version", "and", "config", "this", "is", "a", "no", "-", "op", "and", "returns", "False", "." ]
def deploy(self, deployment_info: DeploymentInfo) -> bool: existing_info = self._target_info if existing_info is not None: deployment_info.start_time_ms = existing_info.start_time_ms if ( existing_info.deployment_config == deployment_info.deployment_config ...
[ "def", "deploy", "(", "self", ",", "deployment_info", ":", "DeploymentInfo", ")", "->", "bool", ":", "existing_info", "=", "self", ".", "_target_info", "if", "existing_info", "is", "not", "None", ":", "deployment_info", ".", "start_time_ms", "=", "existing_info"...
Deploy the deployment.
[ "Deploy", "the", "deployment", "." ]
[ "\"\"\"Deploy the deployment.\n\n If the deployment already exists with the same version and config,\n this is a no-op and returns False.\n\n Returns:\n bool: Whether or not the deployment is being updated.\n \"\"\"", "# Ensures this method is idempotent.", "# Redeploying ...
[ { "param": "self", "type": null }, { "param": "deployment_info", "type": "DeploymentInfo" } ]
{ "returns": [ { "docstring": "Whether or not the deployment is being updated.", "docstring_tokens": [ "Whether", "or", "not", "the", "deployment", "is", "being", "updated", "." ], "type": "bool" } ], "raises":...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_stop_wrong_version_replicas
bool
def _stop_wrong_version_replicas(self) -> bool: """Stops replicas with outdated versions to implement rolling updates. This includes both explicit code version updates and changes to the user_config. Returns whether any replicas were stopped. """ # Short circuit if targ...
Stops replicas with outdated versions to implement rolling updates. This includes both explicit code version updates and changes to the user_config. Returns whether any replicas were stopped.
Stops replicas with outdated versions to implement rolling updates. This includes both explicit code version updates and changes to the user_config. Returns whether any replicas were stopped.
[ "Stops", "replicas", "with", "outdated", "versions", "to", "implement", "rolling", "updates", ".", "This", "includes", "both", "explicit", "code", "version", "updates", "and", "changes", "to", "the", "user_config", ".", "Returns", "whether", "any", "replicas", "...
def _stop_wrong_version_replicas(self) -> bool: if self._target_replicas == 0: return False old_running_replicas = self._replicas.count( exclude_version=self._target_version, states=[ReplicaState.STARTING, ReplicaState.UPDATING, ReplicaState.RUNNING], ) ...
[ "def", "_stop_wrong_version_replicas", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_target_replicas", "==", "0", ":", "return", "False", "old_running_replicas", "=", "self", ".", "_replicas", ".", "count", "(", "exclude_version", "=", "self", ".",...
Stops replicas with outdated versions to implement rolling updates.
[ "Stops", "replicas", "with", "outdated", "versions", "to", "implement", "rolling", "updates", "." ]
[ "\"\"\"Stops replicas with outdated versions to implement rolling updates.\n\n This includes both explicit code version updates and changes to the\n user_config.\n\n Returns whether any replicas were stopped.\n \"\"\"", "# Short circuit if target replicas is 0 (the deployment is being"...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_scale_deployment_replicas
bool
def _scale_deployment_replicas(self) -> bool: """Scale the given deployment to the number of replicas.""" assert ( self._target_replicas >= 0 ), "Number of replicas must be greater than or equal to 0." replicas_stopped = self._stop_wrong_version_replicas() current_...
Scale the given deployment to the number of replicas.
Scale the given deployment to the number of replicas.
[ "Scale", "the", "given", "deployment", "to", "the", "number", "of", "replicas", "." ]
def _scale_deployment_replicas(self) -> bool: assert ( self._target_replicas >= 0 ), "Number of replicas must be greater than or equal to 0." replicas_stopped = self._stop_wrong_version_replicas() current_replicas = self._replicas.count( states=[ReplicaState.START...
[ "def", "_scale_deployment_replicas", "(", "self", ")", "->", "bool", ":", "assert", "(", "self", ".", "_target_replicas", ">=", "0", ")", ",", "\"Number of replicas must be greater than or equal to 0.\"", "replicas_stopped", "=", "self", ".", "_stop_wrong_version_replicas...
Scale the given deployment to the number of replicas.
[ "Scale", "the", "given", "deployment", "to", "the", "number", "of", "replicas", "." ]
[ "\"\"\"Scale the given deployment to the number of replicas.\"\"\"", "# Don't ever exceed self._target_replicas." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_check_curr_status
bool
def _check_curr_status(self) -> bool: """Check the current deployment status. Checks the difference between the target vs. running replica count for the target version. This will update the current deployment status depending on the state of the replicas. Returns: ...
Check the current deployment status. Checks the difference between the target vs. running replica count for the target version. This will update the current deployment status depending on the state of the replicas. Returns: was_deleted
Check the current deployment status. Checks the difference between the target vs. running replica count for the target version. This will update the current deployment status depending on the state of the replicas.
[ "Check", "the", "current", "deployment", "status", ".", "Checks", "the", "difference", "between", "the", "target", "vs", ".", "running", "replica", "count", "for", "the", "target", "version", ".", "This", "will", "update", "the", "current", "deployment", "stat...
def _check_curr_status(self) -> bool: target_version = self._target_version target_replica_count = self._target_replicas all_running_replica_cnt = self._replicas.count(states=[ReplicaState.RUNNING]) running_at_target_version_replica_cnt = self._replicas.count( states=[Replica...
[ "def", "_check_curr_status", "(", "self", ")", "->", "bool", ":", "target_version", "=", "self", ".", "_target_version", "target_replica_count", "=", "self", ".", "_target_replicas", "all_running_replica_cnt", "=", "self", ".", "_replicas", ".", "count", "(", "sta...
Check the current deployment status.
[ "Check", "the", "current", "deployment", "status", "." ]
[ "\"\"\"Check the current deployment status.\n\n Checks the difference between the target vs. running replica count for\n the target version.\n\n This will update the current deployment status depending on the state\n of the replicas.\n\n Returns:\n was_deleted\n ...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_check_startup_replicas
Tuple[List[Tuple[DeploymentReplica, ReplicaStartupStatus]], bool]
def _check_startup_replicas( self, original_state: ReplicaState, stop_on_slow=False ) -> Tuple[List[Tuple[DeploymentReplica, ReplicaStartupStatus]], bool]: """ Common helper function for startup actions tracking and status transition: STARTING, UPDATING and RECOVERING. Args:...
Common helper function for startup actions tracking and status transition: STARTING, UPDATING and RECOVERING. Args: stop_on_slow: If we consider a replica failed upon observing it's slow to reach running state.
Common helper function for startup actions tracking and status transition: STARTING, UPDATING and RECOVERING.
[ "Common", "helper", "function", "for", "startup", "actions", "tracking", "and", "status", "transition", ":", "STARTING", "UPDATING", "and", "RECOVERING", "." ]
def _check_startup_replicas( self, original_state: ReplicaState, stop_on_slow=False ) -> Tuple[List[Tuple[DeploymentReplica, ReplicaStartupStatus]], bool]: slow_replicas = [] transitioned_to_running = False for replica in self._replicas.pop(states=[original_state]): start...
[ "def", "_check_startup_replicas", "(", "self", ",", "original_state", ":", "ReplicaState", ",", "stop_on_slow", "=", "False", ")", "->", "Tuple", "[", "List", "[", "Tuple", "[", "DeploymentReplica", ",", "ReplicaStartupStatus", "]", "]", ",", "bool", "]", ":",...
Common helper function for startup actions tracking and status transition: STARTING, UPDATING and RECOVERING.
[ "Common", "helper", "function", "for", "startup", "actions", "tracking", "and", "status", "transition", ":", "STARTING", "UPDATING", "and", "RECOVERING", "." ]
[ "\"\"\"\n Common helper function for startup actions tracking and status\n transition: STARTING, UPDATING and RECOVERING.\n\n Args:\n stop_on_slow: If we consider a replica failed upon observing it's\n slow to reach running state.\n \"\"\"", "# This replica sh...
[ { "param": "self", "type": null }, { "param": "original_state", "type": "ReplicaState" }, { "param": "stop_on_slow", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "original_state", "type": "ReplicaState", "docstring": null, "...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_check_and_update_replicas
bool
def _check_and_update_replicas(self) -> bool: """ Check current state of all DeploymentReplica being tracked, and compare with state container from previous update() cycle to see if any state transition happened. Returns if any running replicas transitioned to another state. ...
Check current state of all DeploymentReplica being tracked, and compare with state container from previous update() cycle to see if any state transition happened. Returns if any running replicas transitioned to another state.
Check current state of all DeploymentReplica being tracked, and compare with state container from previous update() cycle to see if any state transition happened. Returns if any running replicas transitioned to another state.
[ "Check", "current", "state", "of", "all", "DeploymentReplica", "being", "tracked", "and", "compare", "with", "state", "container", "from", "previous", "update", "()", "cycle", "to", "see", "if", "any", "state", "transition", "happened", ".", "Returns", "if", "...
def _check_and_update_replicas(self) -> bool: running_replicas_changed = False for replica in self._replicas.pop(states=[ReplicaState.RUNNING]): if replica.check_health(): self._replicas.add(ReplicaState.RUNNING, replica) else: running_replicas_cha...
[ "def", "_check_and_update_replicas", "(", "self", ")", "->", "bool", ":", "running_replicas_changed", "=", "False", "for", "replica", "in", "self", ".", "_replicas", ".", "pop", "(", "states", "=", "[", "ReplicaState", ".", "RUNNING", "]", ")", ":", "if", ...
Check current state of all DeploymentReplica being tracked, and compare with state container from previous update() cycle to see if any state transition happened.
[ "Check", "current", "state", "of", "all", "DeploymentReplica", "being", "tracked", "and", "compare", "with", "state", "container", "from", "previous", "update", "()", "cycle", "to", "see", "if", "any", "state", "transition", "happened", "." ]
[ "\"\"\"\n Check current state of all DeploymentReplica being tracked, and compare\n with state container from previous update() cycle to see if any state\n transition happened.\n\n Returns if any running replicas transitioned to another state.\n \"\"\"", "# If this is a replica ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
update
bool
def update(self) -> bool: """Attempts to reconcile this deployment to match its goal state. This is an asynchronous call; it's expected to be called repeatedly. Also updates the internal DeploymentStatusInfo based on the current state of the system. Returns true if this deploy...
Attempts to reconcile this deployment to match its goal state. This is an asynchronous call; it's expected to be called repeatedly. Also updates the internal DeploymentStatusInfo based on the current state of the system. Returns true if this deployment was successfully deleted. ...
Attempts to reconcile this deployment to match its goal state. This is an asynchronous call; it's expected to be called repeatedly. Also updates the internal DeploymentStatusInfo based on the current state of the system. Returns true if this deployment was successfully deleted.
[ "Attempts", "to", "reconcile", "this", "deployment", "to", "match", "its", "goal", "state", ".", "This", "is", "an", "asynchronous", "call", ";", "it", "'", "s", "expected", "to", "be", "called", "repeatedly", ".", "Also", "updates", "the", "internal", "De...
def update(self) -> bool: try: running_replicas_changed = self._scale_deployment_replicas() running_replicas_changed |= self._check_and_update_replicas() if running_replicas_changed: self._notify_running_replicas_changed() deleted = self._check_cur...
[ "def", "update", "(", "self", ")", "->", "bool", ":", "try", ":", "running_replicas_changed", "=", "self", ".", "_scale_deployment_replicas", "(", ")", "running_replicas_changed", "|=", "self", ".", "_check_and_update_replicas", "(", ")", "if", "running_replicas_cha...
Attempts to reconcile this deployment to match its goal state.
[ "Attempts", "to", "reconcile", "this", "deployment", "to", "match", "its", "goal", "state", "." ]
[ "\"\"\"Attempts to reconcile this deployment to match its goal state.\n\n This is an asynchronous call; it's expected to be called repeatedly.\n\n Also updates the internal DeploymentStatusInfo based on the current\n state of the system.\n\n Returns true if this deployment was successful...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_map_actor_names_to_deployment
Dict[str, List[str]]
def _map_actor_names_to_deployment( self, all_current_actor_names: List[str] ) -> Dict[str, List[str]]: """ Given a list of all actor names queried from current ray cluster, map them to corresponding deployments. Example: Args: [A#zxc123, B#xcv234...
Given a list of all actor names queried from current ray cluster, map them to corresponding deployments. Example: Args: [A#zxc123, B#xcv234, A#qwe234] Returns: { A: [A#zxc123, A#qwe234] B: [B#xcv234...
Given a list of all actor names queried from current ray cluster, map them to corresponding deployments.
[ "Given", "a", "list", "of", "all", "actor", "names", "queried", "from", "current", "ray", "cluster", "map", "them", "to", "corresponding", "deployments", "." ]
def _map_actor_names_to_deployment( self, all_current_actor_names: List[str] ) -> Dict[str, List[str]]: all_replica_names = [ actor_name for actor_name in all_current_actor_names if ReplicaName.is_replica_name(actor_name) ] deployment_to_current_re...
[ "def", "_map_actor_names_to_deployment", "(", "self", ",", "all_current_actor_names", ":", "List", "[", "str", "]", ")", "->", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ":", "all_replica_names", "=", "[", "actor_name", "for", "actor_name", "in",...
Given a list of all actor names queried from current ray cluster, map them to corresponding deployments.
[ "Given", "a", "list", "of", "all", "actor", "names", "queried", "from", "current", "ray", "cluster", "map", "them", "to", "corresponding", "deployments", "." ]
[ "\"\"\"\n Given a list of all actor names queried from current ray cluster,\n map them to corresponding deployments.\n\n Example:\n Args:\n [A#zxc123, B#xcv234, A#qwe234]\n Returns:\n {\n A: [A#zxc123, A#qwe234]\n ...
[ { "param": "self", "type": null }, { "param": "all_current_actor_names", "type": "List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "all_current_actor_names", "type": "List[str]", "docstring": null, ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
_recover_from_checkpoint
None
def _recover_from_checkpoint(self, all_current_actor_names: List[str]) -> None: """ Recover from checkpoint upon controller failure with all actor names found in current cluster. Each deployment resumes target state from checkpoint if available. For current state it will priori...
Recover from checkpoint upon controller failure with all actor names found in current cluster. Each deployment resumes target state from checkpoint if available. For current state it will prioritize reconstructing from current actor names found that matches deployment tag if a...
Recover from checkpoint upon controller failure with all actor names found in current cluster. Each deployment resumes target state from checkpoint if available. For current state it will prioritize reconstructing from current actor names found that matches deployment tag if applicable.
[ "Recover", "from", "checkpoint", "upon", "controller", "failure", "with", "all", "actor", "names", "found", "in", "current", "cluster", ".", "Each", "deployment", "resumes", "target", "state", "from", "checkpoint", "if", "available", ".", "For", "current", "stat...
def _recover_from_checkpoint(self, all_current_actor_names: List[str]) -> None: deployment_to_current_replicas = self._map_actor_names_to_deployment( all_current_actor_names ) checkpoint = self._kv_store.get(CHECKPOINT_KEY) if checkpoint is not None: ( ...
[ "def", "_recover_from_checkpoint", "(", "self", ",", "all_current_actor_names", ":", "List", "[", "str", "]", ")", "->", "None", ":", "deployment_to_current_replicas", "=", "self", ".", "_map_actor_names_to_deployment", "(", "all_current_actor_names", ")", "checkpoint",...
Recover from checkpoint upon controller failure with all actor names found in current cluster.
[ "Recover", "from", "checkpoint", "upon", "controller", "failure", "with", "all", "actor", "names", "found", "in", "current", "cluster", "." ]
[ "\"\"\"\n Recover from checkpoint upon controller failure with all actor names\n found in current cluster.\n\n Each deployment resumes target state from checkpoint if available.\n\n For current state it will prioritize reconstructing from current\n actor names found that matches d...
[ { "param": "self", "type": null }, { "param": "all_current_actor_names", "type": "List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "all_current_actor_names", "type": "List[str]", "docstring": null, ...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
shutdown
null
def shutdown(self): """ Shutdown all running replicas by notifying the controller, and leave it to the controller event loop to take actions afterwards. Once shutdown signal is received, it will also prevent any new deployments or replicas from being created. One can se...
Shutdown all running replicas by notifying the controller, and leave it to the controller event loop to take actions afterwards. Once shutdown signal is received, it will also prevent any new deployments or replicas from being created. One can send multiple shutdown signals bu...
Shutdown all running replicas by notifying the controller, and leave it to the controller event loop to take actions afterwards. Once shutdown signal is received, it will also prevent any new deployments or replicas from being created. One can send multiple shutdown signals but won't effectively make any difference c...
[ "Shutdown", "all", "running", "replicas", "by", "notifying", "the", "controller", "and", "leave", "it", "to", "the", "controller", "event", "loop", "to", "take", "actions", "afterwards", ".", "Once", "shutdown", "signal", "is", "received", "it", "will", "also"...
def shutdown(self): for deployment_state in self._deployment_states.values(): deployment_state.delete() self._kv_store.delete(CHECKPOINT_KEY)
[ "def", "shutdown", "(", "self", ")", ":", "for", "deployment_state", "in", "self", ".", "_deployment_states", ".", "values", "(", ")", ":", "deployment_state", ".", "delete", "(", ")", "self", ".", "_kv_store", ".", "delete", "(", "CHECKPOINT_KEY", ")" ]
Shutdown all running replicas by notifying the controller, and leave it to the controller event loop to take actions afterwards.
[ "Shutdown", "all", "running", "replicas", "by", "notifying", "the", "controller", "and", "leave", "it", "to", "the", "controller", "event", "loop", "to", "take", "actions", "afterwards", "." ]
[ "\"\"\"\n Shutdown all running replicas by notifying the controller, and leave\n it to the controller event loop to take actions afterwards.\n\n Once shutdown signal is received, it will also prevent any new\n deployments or replicas from being created.\n\n One can send multiple s...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
deploy
bool
def deploy(self, deployment_name: str, deployment_info: DeploymentInfo) -> bool: """Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False. Returns: bool: Whether or not the deployment is being updated. ...
Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False. Returns: bool: Whether or not the deployment is being updated.
Deploy the deployment. If the deployment already exists with the same version and config, this is a no-op and returns False.
[ "Deploy", "the", "deployment", ".", "If", "the", "deployment", "already", "exists", "with", "the", "same", "version", "and", "config", "this", "is", "a", "no", "-", "op", "and", "returns", "False", "." ]
def deploy(self, deployment_name: str, deployment_info: DeploymentInfo) -> bool: if deployment_name in self._deleted_deployment_metadata: del self._deleted_deployment_metadata[deployment_name] if deployment_name not in self._deployment_states: self._deployment_states[deployment_n...
[ "def", "deploy", "(", "self", ",", "deployment_name", ":", "str", ",", "deployment_info", ":", "DeploymentInfo", ")", "->", "bool", ":", "if", "deployment_name", "in", "self", ".", "_deleted_deployment_metadata", ":", "del", "self", ".", "_deleted_deployment_metad...
Deploy the deployment.
[ "Deploy", "the", "deployment", "." ]
[ "\"\"\"Deploy the deployment.\n\n If the deployment already exists with the same version and config,\n this is a no-op and returns False.\n\n Returns:\n bool: Whether or not the deployment is being updated.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "deployment_name", "type": "str" }, { "param": "deployment_info", "type": "DeploymentInfo" } ]
{ "returns": [ { "docstring": "Whether or not the deployment is being updated.", "docstring_tokens": [ "Whether", "or", "not", "the", "deployment", "is", "being", "updated", "." ], "type": "bool" } ], "raises":...
ab1cc8af10ed239587445b410df0435b41c4631e
kisuke95/ray
python/ray/serve/deployment_state.py
[ "Apache-2.0" ]
Python
update
null
def update(self): """Updates the state of all deployments to match their goal state.""" deleted_tags = [] for deployment_name, deployment_state in self._deployment_states.items(): deleted = deployment_state.update() if deleted: deleted_tags.append(deployme...
Updates the state of all deployments to match their goal state.
Updates the state of all deployments to match their goal state.
[ "Updates", "the", "state", "of", "all", "deployments", "to", "match", "their", "goal", "state", "." ]
def update(self): deleted_tags = [] for deployment_name, deployment_state in self._deployment_states.items(): deleted = deployment_state.update() if deleted: deleted_tags.append(deployment_name) deployment_info = deployment_state.target_info ...
[ "def", "update", "(", "self", ")", ":", "deleted_tags", "=", "[", "]", "for", "deployment_name", ",", "deployment_state", "in", "self", ".", "_deployment_states", ".", "items", "(", ")", ":", "deleted", "=", "deployment_state", ".", "update", "(", ")", "if...
Updates the state of all deployments to match their goal state.
[ "Updates", "the", "state", "of", "all", "deployments", "to", "match", "their", "goal", "state", "." ]
[ "\"\"\"Updates the state of all deployments to match their goal state.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15ec7b653d9215be07afd1912e6d6a18ad9ed8dd
kisuke95/ray
dashboard/modules/job/sdk.py
[ "Apache-2.0" ]
Python
submit_job
str
def submit_job( self, *, entrypoint: str, job_id: Optional[str] = None, runtime_env: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, str]] = None, ) -> str: """Submit and execute a job asynchronously. When a job is submitted, it runs onc...
Submit and execute a job asynchronously. When a job is submitted, it runs once to completion or failure. Retries or different runs with different parameters should be handled by the submitter. Jobs are bound to the lifetime of a Ray cluster, so if the cluster goes down, all running jobs...
Submit and execute a job asynchronously. When a job is submitted, it runs once to completion or failure. Retries or different runs with different parameters should be handled by the submitter. Jobs are bound to the lifetime of a Ray cluster, so if the cluster goes down, all running jobs on that cluster will be terminat...
[ "Submit", "and", "execute", "a", "job", "asynchronously", ".", "When", "a", "job", "is", "submitted", "it", "runs", "once", "to", "completion", "or", "failure", ".", "Retries", "or", "different", "runs", "with", "different", "parameters", "should", "be", "ha...
def submit_job( self, *, entrypoint: str, job_id: Optional[str] = None, runtime_env: Optional[Dict[str, Any]] = None, metadata: Optional[Dict[str, str]] = None, ) -> str: runtime_env = runtime_env or {} metadata = metadata or {} metadata.update...
[ "def", "submit_job", "(", "self", ",", "*", ",", "entrypoint", ":", "str", ",", "job_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "runtime_env", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", "metadata...
Submit and execute a job asynchronously.
[ "Submit", "and", "execute", "a", "job", "asynchronously", "." ]
[ "\"\"\"Submit and execute a job asynchronously.\n\n When a job is submitted, it runs once to completion or failure. Retries or\n different runs with different parameters should be handled by the\n submitter. Jobs are bound to the lifetime of a Ray cluster, so if the\n cluster goes down, ...
[ { "param": "self", "type": null }, { "param": "entrypoint", "type": "str" }, { "param": "job_id", "type": "Optional[str]" }, { "param": "runtime_env", "type": "Optional[Dict[str, Any]]" }, { "param": "metadata", "type": "Optional[Dict[str, str]]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entrypoint", "type": "str", "docstring": null, "docstring_tok...
15ec7b653d9215be07afd1912e6d6a18ad9ed8dd
kisuke95/ray
dashboard/modules/job/sdk.py
[ "Apache-2.0" ]
Python
stop_job
bool
def stop_job( self, job_id: str, ) -> bool: """Request a job to exit asynchronously. Example: >>> from ray.job_submission import JobSubmissionClient >>> client = JobSubmissionClient("http://127.0.0.1:8265") # doctest: +SKIP >>> job_id = client.sub...
Request a job to exit asynchronously. Example: >>> from ray.job_submission import JobSubmissionClient >>> client = JobSubmissionClient("http://127.0.0.1:8265") # doctest: +SKIP >>> job_id = client.submit_job(entrypoint="sleep 10") # doctest: +SKIP >>> client.stop...
Request a job to exit asynchronously. The job ID for the job to be stopped. True if the job was running, otherwise False. If the job does not exist or if the request to the job server fails.
[ "Request", "a", "job", "to", "exit", "asynchronously", ".", "The", "job", "ID", "for", "the", "job", "to", "be", "stopped", ".", "True", "if", "the", "job", "was", "running", "otherwise", "False", ".", "If", "the", "job", "does", "not", "exist", "or", ...
def stop_job( self, job_id: str, ) -> bool: logger.debug(f"Stopping job with job_id={job_id}.") r = self._do_request("POST", f"/api/jobs/{job_id}/stop") if r.status_code == 200: return JobStopResponse(**r.json()).stopped else: self._raise_error...
[ "def", "stop_job", "(", "self", ",", "job_id", ":", "str", ",", ")", "->", "bool", ":", "logger", ".", "debug", "(", "f\"Stopping job with job_id={job_id}.\"", ")", "r", "=", "self", ".", "_do_request", "(", "\"POST\"", ",", "f\"/api/jobs/{job_id}/stop\"", ")"...
Request a job to exit asynchronously.
[ "Request", "a", "job", "to", "exit", "asynchronously", "." ]
[ "\"\"\"Request a job to exit asynchronously.\n\n Example:\n >>> from ray.job_submission import JobSubmissionClient\n >>> client = JobSubmissionClient(\"http://127.0.0.1:8265\") # doctest: +SKIP\n >>> job_id = client.submit_job(entrypoint=\"sleep 10\") # doctest: +SKIP\n ...
[ { "param": "self", "type": null }, { "param": "job_id", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "job_id", "type": "str", "docstring": null, "docstring_tokens"...
15ec7b653d9215be07afd1912e6d6a18ad9ed8dd
kisuke95/ray
dashboard/modules/job/sdk.py
[ "Apache-2.0" ]
Python
list_jobs
Dict[str, JobInfo]
def list_jobs(self) -> Dict[str, JobInfo]: """List all jobs along with their status and other information. Lists all jobs that have ever run on the cluster, including jobs that are currently running and jobs that are no longer running. Example: >>> from ray.job_submission i...
List all jobs along with their status and other information. Lists all jobs that have ever run on the cluster, including jobs that are currently running and jobs that are no longer running. Example: >>> from ray.job_submission import JobSubmissionClient >>> client = Job...
List all jobs along with their status and other information. Lists all jobs that have ever run on the cluster, including jobs that are currently running and jobs that are no longer running.
[ "List", "all", "jobs", "along", "with", "their", "status", "and", "other", "information", ".", "Lists", "all", "jobs", "that", "have", "ever", "run", "on", "the", "cluster", "including", "jobs", "that", "are", "currently", "running", "and", "jobs", "that", ...
def list_jobs(self) -> Dict[str, JobInfo]: r = self._do_request("GET", "/api/jobs/") if r.status_code == 200: jobs_info_json = r.json() jobs_info = { job_id: JobInfo(**job_info_json) for job_id, job_info_json in jobs_info_json.items() }...
[ "def", "list_jobs", "(", "self", ")", "->", "Dict", "[", "str", ",", "JobInfo", "]", ":", "r", "=", "self", ".", "_do_request", "(", "\"GET\"", ",", "\"/api/jobs/\"", ")", "if", "r", ".", "status_code", "==", "200", ":", "jobs_info_json", "=", "r", "...
List all jobs along with their status and other information.
[ "List", "all", "jobs", "along", "with", "their", "status", "and", "other", "information", "." ]
[ "\"\"\"List all jobs along with their status and other information.\n\n Lists all jobs that have ever run on the cluster, including jobs that are\n currently running and jobs that are no longer running.\n\n Example:\n >>> from ray.job_submission import JobSubmissionClient\n ...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "A dictionary mapping job_ids to their information.", "docstring_tokens": [ "A", "dictionary", "mapping", "job_ids", "to", "their", "information", "." ], "type": null } ], "raises": [ ...
15ec7b653d9215be07afd1912e6d6a18ad9ed8dd
kisuke95/ray
dashboard/modules/job/sdk.py
[ "Apache-2.0" ]
Python
tail_job_logs
Iterator[str]
async def tail_job_logs(self, job_id: str) -> Iterator[str]: """Get an iterator that follows the logs of a job. Example: >>> from ray.job_submission import JobSubmissionClient >>> client = JobSubmissionClient("http://127.0.0.1:8265") # doctest: +SKIP >>> job_id = cli...
Get an iterator that follows the logs of a job. Example: >>> from ray.job_submission import JobSubmissionClient >>> client = JobSubmissionClient("http://127.0.0.1:8265") # doctest: +SKIP >>> job_id = client.submit_job( # doctest: +SKIP ... entrypoint="echo hi...
Get an iterator that follows the logs of a job. The ID of the job whose logs are being requested. The iterator. If the job does not exist or if the request to the job server fails.
[ "Get", "an", "iterator", "that", "follows", "the", "logs", "of", "a", "job", ".", "The", "ID", "of", "the", "job", "whose", "logs", "are", "being", "requested", ".", "The", "iterator", ".", "If", "the", "job", "does", "not", "exist", "or", "if", "the...
async def tail_job_logs(self, job_id: str) -> Iterator[str]: async with aiohttp.ClientSession( cookies=self._cookies, headers=self._headers ) as session: ws = await session.ws_connect( f"{self._address}/api/jobs/{job_id}/logs/tail" ) while ...
[ "async", "def", "tail_job_logs", "(", "self", ",", "job_id", ":", "str", ")", "->", "Iterator", "[", "str", "]", ":", "async", "with", "aiohttp", ".", "ClientSession", "(", "cookies", "=", "self", ".", "_cookies", ",", "headers", "=", "self", ".", "_he...
Get an iterator that follows the logs of a job.
[ "Get", "an", "iterator", "that", "follows", "the", "logs", "of", "a", "job", "." ]
[ "\"\"\"Get an iterator that follows the logs of a job.\n\n Example:\n >>> from ray.job_submission import JobSubmissionClient\n >>> client = JobSubmissionClient(\"http://127.0.0.1:8265\") # doctest: +SKIP\n >>> job_id = client.submit_job( # doctest: +SKIP\n ... ...
[ { "param": "self", "type": null }, { "param": "job_id", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "job_id", "type": "str", "docstring": null, "docstring_tokens"...
6b0a70ec8a5b4ecec4000b6e60f1b6841c9bf7f6
kisuke95/ray
python/ray/data/impl/sort.py
[ "Apache-2.0" ]
Python
sample_boundaries
List[T]
def sample_boundaries( blocks: List[ObjectRef[Block]], key: SortKeyT, num_reducers: int ) -> List[T]: """ Return (num_reducers - 1) items in ascending order from the blocks that partition the domain into ranges with approximately equally many elements. """ # TODO(Clark): Support multiple boundar...
Return (num_reducers - 1) items in ascending order from the blocks that partition the domain into ranges with approximately equally many elements.
Return (num_reducers - 1) items in ascending order from the blocks that partition the domain into ranges with approximately equally many elements.
[ "Return", "(", "num_reducers", "-", "1", ")", "items", "in", "ascending", "order", "from", "the", "blocks", "that", "partition", "the", "domain", "into", "ranges", "with", "approximately", "equally", "many", "elements", "." ]
def sample_boundaries( blocks: List[ObjectRef[Block]], key: SortKeyT, num_reducers: int ) -> List[T]: if isinstance(key, list) and len(key) > 1: raise ValueError("Multiple boundary sampling keys not supported.") n_samples = int(num_reducers * 10 / len(blocks)) sample_block = cached_remote_fn(_sa...
[ "def", "sample_boundaries", "(", "blocks", ":", "List", "[", "ObjectRef", "[", "Block", "]", "]", ",", "key", ":", "SortKeyT", ",", "num_reducers", ":", "int", ")", "->", "List", "[", "T", "]", ":", "if", "isinstance", "(", "key", ",", "list", ")", ...
Return (num_reducers - 1) items in ascending order from the blocks that partition the domain into ranges with approximately equally many elements.
[ "Return", "(", "num_reducers", "-", "1", ")", "items", "in", "ascending", "order", "from", "the", "blocks", "that", "partition", "the", "domain", "into", "ranges", "with", "approximately", "equally", "many", "elements", "." ]
[ "\"\"\"\n Return (num_reducers - 1) items in ascending order from the blocks that\n partition the domain into ranges with approximately equally many elements.\n \"\"\"", "# TODO(Clark): Support multiple boundary sampling keys.", "# The dataset is empty" ]
[ { "param": "blocks", "type": "List[ObjectRef[Block]]" }, { "param": "key", "type": "SortKeyT" }, { "param": "num_reducers", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "blocks", "type": "List[ObjectRef[Block]]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": "SortKeyT", "docstring": null, ...
158ca292f1018283d8351be1f1e7f66ae463b8a6
kisuke95/ray
python/ray/ml/predictors/integrations/xgboost/xgboost_predictor.py
[ "Apache-2.0" ]
Python
from_checkpoint
"XGBoostPredictor"
def from_checkpoint(cls, checkpoint: Checkpoint) -> "XGBoostPredictor": """Instantiate the predictor from a Checkpoint. The checkpoint is expected to be a result of ``XGBoostTrainer``. Args: checkpoint (Checkpoint): The checkpoint to load the model and preprocessor ...
Instantiate the predictor from a Checkpoint. The checkpoint is expected to be a result of ``XGBoostTrainer``. Args: checkpoint (Checkpoint): The checkpoint to load the model and preprocessor from. It is expected to be from the result of a ``XGBoostTrainer`` ...
Instantiate the predictor from a Checkpoint. The checkpoint is expected to be a result of ``XGBoostTrainer``.
[ "Instantiate", "the", "predictor", "from", "a", "Checkpoint", ".", "The", "checkpoint", "is", "expected", "to", "be", "a", "result", "of", "`", "`", "XGBoostTrainer", "`", "`", "." ]
def from_checkpoint(cls, checkpoint: Checkpoint) -> "XGBoostPredictor": with checkpoint.as_directory() as path: bst = xgboost.Booster() bst.load_model(os.path.join(path, MODEL_KEY)) preprocessor_path = os.path.join(path, PREPROCESSOR_KEY) if os.path.exists(preproc...
[ "def", "from_checkpoint", "(", "cls", ",", "checkpoint", ":", "Checkpoint", ")", "->", "\"XGBoostPredictor\"", ":", "with", "checkpoint", ".", "as_directory", "(", ")", "as", "path", ":", "bst", "=", "xgboost", ".", "Booster", "(", ")", "bst", ".", "load_m...
Instantiate the predictor from a Checkpoint.
[ "Instantiate", "the", "predictor", "from", "a", "Checkpoint", "." ]
[ "\"\"\"Instantiate the predictor from a Checkpoint.\n\n The checkpoint is expected to be a result of ``XGBoostTrainer``.\n\n Args:\n checkpoint (Checkpoint): The checkpoint to load the model and\n preprocessor from. It is expected to be from the result of a\n `...
[ { "param": "cls", "type": null }, { "param": "checkpoint", "type": "Checkpoint" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "checkpoint", "type": "Checkpoint", "docstring": "The checkpoint to l...
158ca292f1018283d8351be1f1e7f66ae463b8a6
kisuke95/ray
python/ray/ml/predictors/integrations/xgboost/xgboost_predictor.py
[ "Apache-2.0" ]
Python
predict
pd.DataFrame
def predict( self, data: DataBatchType, feature_columns: Optional[Union[List[str], List[int]]] = None, dmatrix_kwargs: Optional[Dict[str, Any]] = None, **predict_kwargs, ) -> pd.DataFrame: """Run inference on data batch. The data is converted into an XGBoost ...
Run inference on data batch. The data is converted into an XGBoost DMatrix before being inputted to the model. Args: data: A batch of input data. Either a pandas DataFrame or numpy array. feature_columns: The names or indices of the columns in the ...
Run inference on data batch. The data is converted into an XGBoost DMatrix before being inputted to the model.
[ "Run", "inference", "on", "data", "batch", ".", "The", "data", "is", "converted", "into", "an", "XGBoost", "DMatrix", "before", "being", "inputted", "to", "the", "model", "." ]
def predict( self, data: DataBatchType, feature_columns: Optional[Union[List[str], List[int]]] = None, dmatrix_kwargs: Optional[Dict[str, Any]] = None, **predict_kwargs, ) -> pd.DataFrame: dmatrix_kwargs = dmatrix_kwargs or {} if self.preprocessor: ...
[ "def", "predict", "(", "self", ",", "data", ":", "DataBatchType", ",", "feature_columns", ":", "Optional", "[", "Union", "[", "List", "[", "str", "]", ",", "List", "[", "int", "]", "]", "]", "=", "None", ",", "dmatrix_kwargs", ":", "Optional", "[", "...
Run inference on data batch.
[ "Run", "inference", "on", "data", "batch", "." ]
[ "\"\"\"Run inference on data batch.\n\n The data is converted into an XGBoost DMatrix before being inputted to\n the model.\n\n Args:\n data: A batch of input data. Either a pandas DataFrame or numpy\n array.\n feature_columns: The names or indices of the co...
[ { "param": "self", "type": null }, { "param": "data", "type": "DataBatchType" }, { "param": "feature_columns", "type": "Optional[Union[List[str], List[int]]]" }, { "param": "dmatrix_kwargs", "type": "Optional[Dict[str, Any]]" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "pd.DataFrame" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional...
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
_check_if_cleared
None
def _check_if_cleared(self) -> None: """Raise an error if this BlockList has been previously cleared.""" if self._blocks is None: raise ValueError( "This Dataset's blocks have been moved, which means that you " "can no longer use this Dataset." )
Raise an error if this BlockList has been previously cleared.
Raise an error if this BlockList has been previously cleared.
[ "Raise", "an", "error", "if", "this", "BlockList", "has", "been", "previously", "cleared", "." ]
def _check_if_cleared(self) -> None: if self._blocks is None: raise ValueError( "This Dataset's blocks have been moved, which means that you " "can no longer use this Dataset." )
[ "def", "_check_if_cleared", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_blocks", "is", "None", ":", "raise", "ValueError", "(", "\"This Dataset's blocks have been moved, which means that you \"", "\"can no longer use this Dataset.\"", ")" ]
Raise an error if this BlockList has been previously cleared.
[ "Raise", "an", "error", "if", "this", "BlockList", "has", "been", "previously", "cleared", "." ]
[ "\"\"\"Raise an error if this BlockList has been previously cleared.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
split
List["BlockList"]
def split(self, split_size: int) -> List["BlockList"]: """Split this BlockList into multiple lists. Args: split_size: The number of lists to split into. """ self._check_if_cleared() num_splits = math.ceil(len(self._blocks) / split_size) blocks = np.array_spli...
Split this BlockList into multiple lists. Args: split_size: The number of lists to split into.
Split this BlockList into multiple lists.
[ "Split", "this", "BlockList", "into", "multiple", "lists", "." ]
def split(self, split_size: int) -> List["BlockList"]: self._check_if_cleared() num_splits = math.ceil(len(self._blocks) / split_size) blocks = np.array_split(self._blocks, num_splits) meta = np.array_split(self._metadata, num_splits) output = [] for b, m in zip(blocks, m...
[ "def", "split", "(", "self", ",", "split_size", ":", "int", ")", "->", "List", "[", "\"BlockList\"", "]", ":", "self", ".", "_check_if_cleared", "(", ")", "num_splits", "=", "math", ".", "ceil", "(", "len", "(", "self", ".", "_blocks", ")", "/", "spl...
Split this BlockList into multiple lists.
[ "Split", "this", "BlockList", "into", "multiple", "lists", "." ]
[ "\"\"\"Split this BlockList into multiple lists.\n\n Args:\n split_size: The number of lists to split into.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "split_size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "split_size", "type": "int", "docstring": "The number of lists to sp...
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
split_by_bytes
List["BlockList"]
def split_by_bytes(self, bytes_per_split: int) -> List["BlockList"]: """Split this BlockList into multiple lists. Args: bytes_per_split: The max number of bytes per split. """ self._check_if_cleared() output = [] cur_blocks = [] cur_meta = [] ...
Split this BlockList into multiple lists. Args: bytes_per_split: The max number of bytes per split.
Split this BlockList into multiple lists.
[ "Split", "this", "BlockList", "into", "multiple", "lists", "." ]
def split_by_bytes(self, bytes_per_split: int) -> List["BlockList"]: self._check_if_cleared() output = [] cur_blocks = [] cur_meta = [] cur_size = 0 for b, m in zip(self._blocks, self._metadata): if m.size_bytes is None: raise RuntimeError( ...
[ "def", "split_by_bytes", "(", "self", ",", "bytes_per_split", ":", "int", ")", "->", "List", "[", "\"BlockList\"", "]", ":", "self", ".", "_check_if_cleared", "(", ")", "output", "=", "[", "]", "cur_blocks", "=", "[", "]", "cur_meta", "=", "[", "]", "c...
Split this BlockList into multiple lists.
[ "Split", "this", "BlockList", "into", "multiple", "lists", "." ]
[ "\"\"\"Split this BlockList into multiple lists.\n\n Args:\n bytes_per_split: The max number of bytes per split.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "bytes_per_split", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bytes_per_split", "type": "int", "docstring": "The max number of by...
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
size_bytes
int
def size_bytes(self) -> int: """Returns the total size in bytes of the blocks, or -1 if not known.""" size = 0 has_size = False for m in self.get_metadata(): if m.size_bytes is not None: has_size = True size += m.size_bytes if not has_s...
Returns the total size in bytes of the blocks, or -1 if not known.
Returns the total size in bytes of the blocks, or -1 if not known.
[ "Returns", "the", "total", "size", "in", "bytes", "of", "the", "blocks", "or", "-", "1", "if", "not", "known", "." ]
def size_bytes(self) -> int: size = 0 has_size = False for m in self.get_metadata(): if m.size_bytes is not None: has_size = True size += m.size_bytes if not has_size: return -1 else: return size
[ "def", "size_bytes", "(", "self", ")", "->", "int", ":", "size", "=", "0", "has_size", "=", "False", "for", "m", "in", "self", ".", "get_metadata", "(", ")", ":", "if", "m", ".", "size_bytes", "is", "not", "None", ":", "has_size", "=", "True", "siz...
Returns the total size in bytes of the blocks, or -1 if not known.
[ "Returns", "the", "total", "size", "in", "bytes", "of", "the", "blocks", "or", "-", "1", "if", "not", "known", "." ]
[ "\"\"\"Returns the total size in bytes of the blocks, or -1 if not known.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
divide
("BlockList", "BlockList")
def divide(self, block_idx: int) -> ("BlockList", "BlockList"): """Divide into two BlockLists by the given block index. Args: block_idx: The block index to divide at. """ self._check_if_cleared() return ( BlockList(self._blocks[:block_idx], self._metadata...
Divide into two BlockLists by the given block index. Args: block_idx: The block index to divide at.
Divide into two BlockLists by the given block index.
[ "Divide", "into", "two", "BlockLists", "by", "the", "given", "block", "index", "." ]
def divide(self, block_idx: int) -> ("BlockList", "BlockList"): self._check_if_cleared() return ( BlockList(self._blocks[:block_idx], self._metadata[:block_idx]), BlockList(self._blocks[block_idx:], self._metadata[block_idx:]), )
[ "def", "divide", "(", "self", ",", "block_idx", ":", "int", ")", "->", "(", "\"BlockList\"", ",", "\"BlockList\"", ")", ":", "self", ".", "_check_if_cleared", "(", ")", "return", "(", "BlockList", "(", "self", ".", "_blocks", "[", ":", "block_idx", "]", ...
Divide into two BlockLists by the given block index.
[ "Divide", "into", "two", "BlockLists", "by", "the", "given", "block", "index", "." ]
[ "\"\"\"Divide into two BlockLists by the given block index.\n\n Args:\n block_idx: The block index to divide at.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "block_idx", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "block_idx", "type": "int", "docstring": "The block index to divide ...
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
iter_blocks
Iterator[ObjectRef[Block]]
def iter_blocks(self) -> Iterator[ObjectRef[Block]]: """Iterate over the blocks of this block list. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution. """ self._check_if_cleared() outer = self ...
Iterate over the blocks of this block list. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution.
Iterate over the blocks of this block list. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution.
[ "Iterate", "over", "the", "blocks", "of", "this", "block", "list", ".", "This", "blocks", "on", "the", "execution", "of", "the", "tasks", "generating", "block", "outputs", ".", "The", "length", "of", "this", "iterator", "is", "not", "known", "until", "exec...
def iter_blocks(self) -> Iterator[ObjectRef[Block]]: self._check_if_cleared() outer = self class Iter: def __init__(self): self._base_iter = outer.iter_blocks_with_metadata() def __iter__(self): return self def __next__(self): ...
[ "def", "iter_blocks", "(", "self", ")", "->", "Iterator", "[", "ObjectRef", "[", "Block", "]", "]", ":", "self", ".", "_check_if_cleared", "(", ")", "outer", "=", "self", "class", "Iter", ":", "def", "__init__", "(", "self", ")", ":", "self", ".", "_...
Iterate over the blocks of this block list.
[ "Iterate", "over", "the", "blocks", "of", "this", "block", "list", "." ]
[ "\"\"\"Iterate over the blocks of this block list.\n\n This blocks on the execution of the tasks generating block outputs.\n The length of this iterator is not known until execution.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
iter_blocks_with_metadata
Iterator[Tuple[ObjectRef[Block], BlockMetadata]]
def iter_blocks_with_metadata( self, ) -> Iterator[Tuple[ObjectRef[Block], BlockMetadata]]: """Iterate over the blocks along with their runtime metadata. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution. ...
Iterate over the blocks along with their runtime metadata. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution.
Iterate over the blocks along with their runtime metadata. This blocks on the execution of the tasks generating block outputs. The length of this iterator is not known until execution.
[ "Iterate", "over", "the", "blocks", "along", "with", "their", "runtime", "metadata", ".", "This", "blocks", "on", "the", "execution", "of", "the", "tasks", "generating", "block", "outputs", ".", "The", "length", "of", "this", "iterator", "is", "not", "known"...
def iter_blocks_with_metadata( self, ) -> Iterator[Tuple[ObjectRef[Block], BlockMetadata]]: self._check_if_cleared() return zip(self._blocks, self._metadata)
[ "def", "iter_blocks_with_metadata", "(", "self", ",", ")", "->", "Iterator", "[", "Tuple", "[", "ObjectRef", "[", "Block", "]", ",", "BlockMetadata", "]", "]", ":", "self", ".", "_check_if_cleared", "(", ")", "return", "zip", "(", "self", ".", "_blocks", ...
Iterate over the blocks along with their runtime metadata.
[ "Iterate", "over", "the", "blocks", "along", "with", "their", "runtime", "metadata", "." ]
[ "\"\"\"Iterate over the blocks along with their runtime metadata.\n\n This blocks on the execution of the tasks generating block outputs.\n The length of this iterator is not known until execution.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
158f492335f8f84e6f93ad9d95dcaaeb1c7e4846
kisuke95/ray
python/ray/data/impl/block_list.py
[ "Apache-2.0" ]
Python
executed_num_blocks
int
def executed_num_blocks(self) -> int: """Returns the number of output blocks after execution. This may differ from initial_num_blocks() for LazyBlockList, which doesn't know how many blocks will be produced until tasks finish. """ return len(self.get_blocks())
Returns the number of output blocks after execution. This may differ from initial_num_blocks() for LazyBlockList, which doesn't know how many blocks will be produced until tasks finish.
Returns the number of output blocks after execution. This may differ from initial_num_blocks() for LazyBlockList, which doesn't know how many blocks will be produced until tasks finish.
[ "Returns", "the", "number", "of", "output", "blocks", "after", "execution", ".", "This", "may", "differ", "from", "initial_num_blocks", "()", "for", "LazyBlockList", "which", "doesn", "'", "t", "know", "how", "many", "blocks", "will", "be", "produced", "until"...
def executed_num_blocks(self) -> int: return len(self.get_blocks())
[ "def", "executed_num_blocks", "(", "self", ")", "->", "int", ":", "return", "len", "(", "self", ".", "get_blocks", "(", ")", ")" ]
Returns the number of output blocks after execution.
[ "Returns", "the", "number", "of", "output", "blocks", "after", "execution", "." ]
[ "\"\"\"Returns the number of output blocks after execution.\n\n This may differ from initial_num_blocks() for LazyBlockList, which\n doesn't know how many blocks will be produced until tasks finish.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af9bb24baf891ccd742ee9c5d5cdf1f42802871
kisuke95/ray
python/ray/serve/pipeline/deployment_method_node.py
[ "Apache-2.0" ]
Python
_execute_impl
<not_specific>
def _execute_impl(self, *args, **kwargs): """Executor of DeploymentMethodNode by ray.remote()""" # Execute with bound args. method_body = getattr(self._deployment_handle, self._deployment_method_name) return method_body.remote( *self._bound_args, **self._bound_kwa...
Executor of DeploymentMethodNode by ray.remote()
Executor of DeploymentMethodNode by ray.remote()
[ "Executor", "of", "DeploymentMethodNode", "by", "ray", ".", "remote", "()" ]
def _execute_impl(self, *args, **kwargs): method_body = getattr(self._deployment_handle, self._deployment_method_name) return method_body.remote( *self._bound_args, **self._bound_kwargs, )
[ "def", "_execute_impl", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "method_body", "=", "getattr", "(", "self", ".", "_deployment_handle", ",", "self", ".", "_deployment_method_name", ")", "return", "method_body", ".", "remote", "(", "*", ...
Executor of DeploymentMethodNode by ray.remote()
[ "Executor", "of", "DeploymentMethodNode", "by", "ray", ".", "remote", "()" ]
[ "\"\"\"Executor of DeploymentMethodNode by ray.remote()\"\"\"", "# Execute with bound args." ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1af9bb24baf891ccd742ee9c5d5cdf1f42802871
kisuke95/ray
python/ray/serve/pipeline/deployment_method_node.py
[ "Apache-2.0" ]
Python
_get_serve_deployment_handle
Union[RayServeHandle, RayServeSyncHandle]
def _get_serve_deployment_handle( self, deployment: Deployment, bound_other_args_to_resolve: Dict[str, Any], ) -> Union[RayServeHandle, RayServeSyncHandle]: """ Return a sync or async handle of the encapsulated Deployment based on config. Args: de...
Return a sync or async handle of the encapsulated Deployment based on config. Args: deployment (Deployment): Deployment instance wrapped in the DAGNode. bound_other_args_to_resolve (Dict[str, Any]): Contains args used to configure DeploymentNode. ...
Return a sync or async handle of the encapsulated Deployment based on config.
[ "Return", "a", "sync", "or", "async", "handle", "of", "the", "encapsulated", "Deployment", "based", "on", "config", "." ]
def _get_serve_deployment_handle( self, deployment: Deployment, bound_other_args_to_resolve: Dict[str, Any], ) -> Union[RayServeHandle, RayServeSyncHandle]: if USE_SYNC_HANDLE_KEY not in bound_other_args_to_resolve: return RayServeLazySyncHandle(deployment.name) e...
[ "def", "_get_serve_deployment_handle", "(", "self", ",", "deployment", ":", "Deployment", ",", "bound_other_args_to_resolve", ":", "Dict", "[", "str", ",", "Any", "]", ",", ")", "->", "Union", "[", "RayServeHandle", ",", "RayServeSyncHandle", "]", ":", "if", "...
Return a sync or async handle of the encapsulated Deployment based on config.
[ "Return", "a", "sync", "or", "async", "handle", "of", "the", "encapsulated", "Deployment", "based", "on", "config", "." ]
[ "\"\"\"\n Return a sync or async handle of the encapsulated Deployment based on\n config.\n\n Args:\n deployment (Deployment): Deployment instance wrapped in the DAGNode.\n bound_other_args_to_resolve (Dict[str, Any]): Contains args used\n to configure Deplo...
[ { "param": "self", "type": null }, { "param": "deployment", "type": "Deployment" }, { "param": "bound_other_args_to_resolve", "type": "Dict[str, Any]" } ]
{ "returns": [ { "docstring": "Default and catch-all is to return sync handle.\nreturn async handle only if user explicitly set\nUSE_SYNC_HANDLE_KEY with value of False.", "docstring_tokens": [ "Default", "and", "catch", "-", "all", "is", "to", ...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
_normalize_base_dir
null
def _normalize_base_dir(self): """Normalizes the partition base directory for compatibility with the given filesystem. This should be called once a filesystem has been resolved to ensure that this base directory is correctly discovered at the root of all partitioned file paths. ...
Normalizes the partition base directory for compatibility with the given filesystem. This should be called once a filesystem has been resolved to ensure that this base directory is correctly discovered at the root of all partitioned file paths.
Normalizes the partition base directory for compatibility with the given filesystem. This should be called once a filesystem has been resolved to ensure that this base directory is correctly discovered at the root of all partitioned file paths.
[ "Normalizes", "the", "partition", "base", "directory", "for", "compatibility", "with", "the", "given", "filesystem", ".", "This", "should", "be", "called", "once", "a", "filesystem", "has", "been", "resolved", "to", "ensure", "that", "this", "base", "directory",...
def _normalize_base_dir(self): from ray.data.datasource.file_based_datasource import ( _resolve_paths_and_filesystem, ) paths, self._resolved_filesystem = _resolve_paths_and_filesystem( self._base_dir, self._filesystem, ) assert ( l...
[ "def", "_normalize_base_dir", "(", "self", ")", ":", "from", "ray", ".", "data", ".", "datasource", ".", "file_based_datasource", "import", "(", "_resolve_paths_and_filesystem", ",", ")", "paths", ",", "self", ".", "_resolved_filesystem", "=", "_resolve_paths_and_fi...
Normalizes the partition base directory for compatibility with the given filesystem.
[ "Normalizes", "the", "partition", "base", "directory", "for", "compatibility", "with", "the", "given", "filesystem", "." ]
[ "\"\"\"Normalizes the partition base directory for compatibility with the\n given filesystem.\n\n This should be called once a filesystem has been resolved to ensure that this\n base directory is correctly discovered at the root of all partitioned file\n paths.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
of
"PathPartitionEncoder"
def of( style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionEncoder": """Creates a new partition path encoder. Args: ...
Creates a new partition path encoder. Args: style: The partition style - may be either HIVE or DIRECTORY. base_dir: "/"-delimited base directory that all partition paths will be generated under (exclusive). field_names: The partition key field names (i.e. colu...
Creates a new partition path encoder.
[ "Creates", "a", "new", "partition", "path", "encoder", "." ]
def of( style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionEncoder": scheme = PathPartitionScheme(style, base_dir, field_names, filesyst...
[ "def", "of", "(", "style", ":", "PartitionStyle", "=", "PartitionStyle", ".", "HIVE", ",", "base_dir", ":", "Optional", "[", "str", "]", "=", "None", ",", "field_names", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "filesystem"...
Creates a new partition path encoder.
[ "Creates", "a", "new", "partition", "path", "encoder", "." ]
[ "\"\"\"Creates a new partition path encoder.\n Args:\n style: The partition style - may be either HIVE or DIRECTORY.\n base_dir: \"/\"-delimited base directory that all partition paths will be\n generated under (exclusive).\n field_names: The partition key fiel...
[ { "param": "style", "type": "PartitionStyle" }, { "param": "base_dir", "type": "Optional[str]" }, { "param": "field_names", "type": "Optional[List[str]]" }, { "param": "filesystem", "type": "Optional[\"pyarrow.fs.FileSystem\"]" } ]
{ "returns": [ { "docstring": "The new partition path encoder.", "docstring_tokens": [ "The", "new", "partition", "path", "encoder", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "style", "type":...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
_as_partition_dirs
List[str]
def _as_partition_dirs(self, values: List[str]) -> List[str]: """Creates a list of partition directory names for the given values.""" field_names = self._scheme.field_names if field_names: assert len(values) == len(field_names), ( f"Expected {len(field_names)} partiti...
Creates a list of partition directory names for the given values.
Creates a list of partition directory names for the given values.
[ "Creates", "a", "list", "of", "partition", "directory", "names", "for", "the", "given", "values", "." ]
def _as_partition_dirs(self, values: List[str]) -> List[str]: field_names = self._scheme.field_names if field_names: assert len(values) == len(field_names), ( f"Expected {len(field_names)} partition value(s) but found " f"{len(values)}: {values}." ...
[ "def", "_as_partition_dirs", "(", "self", ",", "values", ":", "List", "[", "str", "]", ")", "->", "List", "[", "str", "]", ":", "field_names", "=", "self", ".", "_scheme", ".", "field_names", "if", "field_names", ":", "assert", "len", "(", "values", ")...
Creates a list of partition directory names for the given values.
[ "Creates", "a", "list", "of", "partition", "directory", "names", "for", "the", "given", "values", "." ]
[ "\"\"\"Creates a list of partition directory names for the given values.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "values", "type": "List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "values", "type": "List[str]", "docstring": null, "docstring_t...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
of
"PathPartitionParser"
def of( style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionParser": """Creates a path-based partition parser using a flattened argument ...
Creates a path-based partition parser using a flattened argument list. Args: style: The partition style - may be either HIVE or DIRECTORY. base_dir: "/"-delimited base directory to start searching for partitions (exclusive). File paths outside of this directory will be c...
Creates a path-based partition parser using a flattened argument list.
[ "Creates", "a", "path", "-", "based", "partition", "parser", "using", "a", "flattened", "argument", "list", "." ]
def of( style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionParser": scheme = PathPartitionScheme(style, base_dir, field_names, filesyste...
[ "def", "of", "(", "style", ":", "PartitionStyle", "=", "PartitionStyle", ".", "HIVE", ",", "base_dir", ":", "Optional", "[", "str", "]", "=", "None", ",", "field_names", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "filesystem"...
Creates a path-based partition parser using a flattened argument list.
[ "Creates", "a", "path", "-", "based", "partition", "parser", "using", "a", "flattened", "argument", "list", "." ]
[ "\"\"\"Creates a path-based partition parser using a flattened argument list.\n\n Args:\n style: The partition style - may be either HIVE or DIRECTORY.\n base_dir: \"/\"-delimited base directory to start searching for partitions\n (exclusive). File paths outside of this d...
[ { "param": "style", "type": "PartitionStyle" }, { "param": "base_dir", "type": "Optional[str]" }, { "param": "field_names", "type": "Optional[List[str]]" }, { "param": "filesystem", "type": "Optional[\"pyarrow.fs.FileSystem\"]" } ]
{ "returns": [ { "docstring": "The new path-based partition parser.", "docstring_tokens": [ "The", "new", "path", "-", "based", "partition", "parser", "." ], "type": null } ], "raises": [], "params": [ { "i...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
_dir_path_trim_base
Optional[str]
def _dir_path_trim_base(self, path: str) -> Optional[str]: """Trims the normalized base directory and returns the directory path. Returns None if the path does not start with the normalized base directory. Simply returns the directory path if the base directory is undefined. """ ...
Trims the normalized base directory and returns the directory path. Returns None if the path does not start with the normalized base directory. Simply returns the directory path if the base directory is undefined.
Trims the normalized base directory and returns the directory path. Returns None if the path does not start with the normalized base directory. Simply returns the directory path if the base directory is undefined.
[ "Trims", "the", "normalized", "base", "directory", "and", "returns", "the", "directory", "path", ".", "Returns", "None", "if", "the", "path", "does", "not", "start", "with", "the", "normalized", "base", "directory", ".", "Simply", "returns", "the", "directory"...
def _dir_path_trim_base(self, path: str) -> Optional[str]: if not path.startswith(self._scheme.normalized_base_dir): return None path = path[len(self._scheme.normalized_base_dir) :] return posixpath.dirname(path)
[ "def", "_dir_path_trim_base", "(", "self", ",", "path", ":", "str", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "path", ".", "startswith", "(", "self", ".", "_scheme", ".", "normalized_base_dir", ")", ":", "return", "None", "path", "=", "...
Trims the normalized base directory and returns the directory path.
[ "Trims", "the", "normalized", "base", "directory", "and", "returns", "the", "directory", "path", "." ]
[ "\"\"\"Trims the normalized base directory and returns the directory path.\n\n Returns None if the path does not start with the normalized base directory.\n Simply returns the directory path if the base directory is undefined.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": "str", "docstring": null, "docstring_tokens": ...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
_parse_dir_path
Dict[str, str]
def _parse_dir_path(self, dir_path: str) -> Dict[str, str]: """Directory partition path parser. Returns a dictionary mapping directory partition keys to values from a partition path of the form "{value1}/{value2}/..." or an empty dictionary for unpartitioned files. Requires a c...
Directory partition path parser. Returns a dictionary mapping directory partition keys to values from a partition path of the form "{value1}/{value2}/..." or an empty dictionary for unpartitioned files. Requires a corresponding ordered list of partition key field names to map the ...
Directory partition path parser. Returns a dictionary mapping directory partition keys to values from a partition path of the form "{value1}/{value2}/..." or an empty dictionary for unpartitioned files. Requires a corresponding ordered list of partition key field names to map the correct key to each value.
[ "Directory", "partition", "path", "parser", ".", "Returns", "a", "dictionary", "mapping", "directory", "partition", "keys", "to", "values", "from", "a", "partition", "path", "of", "the", "form", "\"", "{", "value1", "}", "/", "{", "value2", "}", "/", "..."...
def _parse_dir_path(self, dir_path: str) -> Dict[str, str]: dirs = [d for d in dir_path.split("/") if d] field_names = self._scheme.field_names assert not dirs or len(dirs) == len(field_names), ( f"Expected {len(field_names)} partition value(s) but found " f"{len(dirs)}: ...
[ "def", "_parse_dir_path", "(", "self", ",", "dir_path", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "dirs", "=", "[", "d", "for", "d", "in", "dir_path", ".", "split", "(", "\"/\"", ")", "if", "d", "]", "field_names", "=", "se...
Directory partition path parser.
[ "Directory", "partition", "path", "parser", "." ]
[ "\"\"\"Directory partition path parser.\n\n Returns a dictionary mapping directory partition keys to values from a\n partition path of the form \"{value1}/{value2}/...\" or an empty dictionary for\n unpartitioned files.\n\n Requires a corresponding ordered list of partition key field nam...
[ { "param": "self", "type": null }, { "param": "dir_path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dir_path", "type": "str", "docstring": null, "docstring_token...
238f37522e44380744b70cbb54103520bbfe347f
kisuke95/ray
python/ray/data/datasource/partitioning.py
[ "Apache-2.0" ]
Python
of
"PathPartitionFilter"
def of( filter_fn: Callable[[Dict[str, str]], bool], style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionFilter": """Creates a pa...
Creates a path-based partition filter using a flattened argument list. Args: filter_fn: Callback used to filter partitions. Takes a dictionary mapping partition keys to values as input. Unpartitioned files are denoted with an empty input dictionary. Returns `True` to...
Creates a path-based partition filter using a flattened argument list.
[ "Creates", "a", "path", "-", "based", "partition", "filter", "using", "a", "flattened", "argument", "list", "." ]
def of( filter_fn: Callable[[Dict[str, str]], bool], style: PartitionStyle = PartitionStyle.HIVE, base_dir: Optional[str] = None, field_names: Optional[List[str]] = None, filesystem: Optional["pyarrow.fs.FileSystem"] = None, ) -> "PathPartitionFilter": scheme = PathPa...
[ "def", "of", "(", "filter_fn", ":", "Callable", "[", "[", "Dict", "[", "str", ",", "str", "]", "]", ",", "bool", "]", ",", "style", ":", "PartitionStyle", "=", "PartitionStyle", ".", "HIVE", ",", "base_dir", ":", "Optional", "[", "str", "]", "=", "...
Creates a path-based partition filter using a flattened argument list.
[ "Creates", "a", "path", "-", "based", "partition", "filter", "using", "a", "flattened", "argument", "list", "." ]
[ "\"\"\"Creates a path-based partition filter using a flattened argument list.\n\n Args:\n filter_fn: Callback used to filter partitions. Takes a dictionary mapping\n partition keys to values as input. Unpartitioned files are denoted with\n an empty input dictionary. R...
[ { "param": "filter_fn", "type": "Callable[[Dict[str, str]], bool]" }, { "param": "style", "type": "PartitionStyle" }, { "param": "base_dir", "type": "Optional[str]" }, { "param": "field_names", "type": "Optional[List[str]]" }, { "param": "filesystem", "type": ...
{ "returns": [ { "docstring": "The new path-based partition filter.", "docstring_tokens": [ "The", "new", "path", "-", "based", "partition", "filter", "." ], "type": null } ], "raises": [], "params": [ { "i...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
_dir_travel
null
def _dir_travel( path: Path, excludes: List[Callable], handler: Callable, logger: Optional[logging.Logger] = default_logger, ): """Travels the path recursively, calling the handler on each subpath. Respects excludes, which will be called to check if this path is skipped. """ e = _get_gi...
Travels the path recursively, calling the handler on each subpath. Respects excludes, which will be called to check if this path is skipped.
Travels the path recursively, calling the handler on each subpath. Respects excludes, which will be called to check if this path is skipped.
[ "Travels", "the", "path", "recursively", "calling", "the", "handler", "on", "each", "subpath", ".", "Respects", "excludes", "which", "will", "be", "called", "to", "check", "if", "this", "path", "is", "skipped", "." ]
def _dir_travel( path: Path, excludes: List[Callable], handler: Callable, logger: Optional[logging.Logger] = default_logger, ): e = _get_gitignore(path) if e is not None: excludes.append(e) skip = any(e(path) for e in excludes) if not skip: try: handler(path) ...
[ "def", "_dir_travel", "(", "path", ":", "Path", ",", "excludes", ":", "List", "[", "Callable", "]", ",", "handler", ":", "Callable", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "default_logger", ",", ")", ":", "e", "=", "...
Travels the path recursively, calling the handler on each subpath.
[ "Travels", "the", "path", "recursively", "calling", "the", "handler", "on", "each", "subpath", "." ]
[ "\"\"\"Travels the path recursively, calling the handler on each subpath.\n\n Respects excludes, which will be called to check if this path is skipped.\n \"\"\"" ]
[ { "param": "path", "type": "Path" }, { "param": "excludes", "type": "List[Callable]" }, { "param": "handler", "type": "Callable" }, { "param": "logger", "type": "Optional[logging.Logger]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "Path", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "excludes", "type": "List[Callable]", "docstring": null, "do...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
_hash_directory
bytes
def _hash_directory( root: Path, relative_path: Path, excludes: Optional[Callable], logger: Optional[logging.Logger] = default_logger, ) -> bytes: """Helper function to create hash of a directory. It'll go through all the files in the directory and xor hash(file_name, file_content) to creat...
Helper function to create hash of a directory. It'll go through all the files in the directory and xor hash(file_name, file_content) to create a hash value.
Helper function to create hash of a directory. It'll go through all the files in the directory and xor hash(file_name, file_content) to create a hash value.
[ "Helper", "function", "to", "create", "hash", "of", "a", "directory", ".", "It", "'", "ll", "go", "through", "all", "the", "files", "in", "the", "directory", "and", "xor", "hash", "(", "file_name", "file_content", ")", "to", "create", "a", "hash", "value...
def _hash_directory( root: Path, relative_path: Path, excludes: Optional[Callable], logger: Optional[logging.Logger] = default_logger, ) -> bytes: hash_val = b"0" * 8 BUF_SIZE = 4096 * 1024 def handler(path: Path): md5 = hashlib.md5() md5.update(str(path.relative_to(relative_...
[ "def", "_hash_directory", "(", "root", ":", "Path", ",", "relative_path", ":", "Path", ",", "excludes", ":", "Optional", "[", "Callable", "]", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "default_logger", ",", ")", "->", "byt...
Helper function to create hash of a directory.
[ "Helper", "function", "to", "create", "hash", "of", "a", "directory", "." ]
[ "\"\"\"Helper function to create hash of a directory.\n\n It'll go through all the files in the directory and xor\n hash(file_name, file_content) to create a hash value.\n \"\"\"" ]
[ { "param": "root", "type": "Path" }, { "param": "relative_path", "type": "Path" }, { "param": "excludes", "type": "Optional[Callable]" }, { "param": "logger", "type": "Optional[logging.Logger]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "root", "type": "Path", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "relative_path", "type": "Path", "docstring": null, "docstri...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
parse_uri
Tuple[Protocol, str]
def parse_uri(pkg_uri: str) -> Tuple[Protocol, str]: """ Parse resource uri into protocol and package name based on its format. Note that the output of this function is not for handling actual IO, it's only for setting up local directory folders by using package name as path. For GCS URIs, netloc is...
Parse resource uri into protocol and package name based on its format. Note that the output of this function is not for handling actual IO, it's only for setting up local directory folders by using package name as path. For GCS URIs, netloc is the package name. urlparse("gcs://_ray_pkg_029f88d5...
Parse resource uri into protocol and package name based on its format. Note that the output of this function is not for handling actual IO, it's only for setting up local directory folders by using package name as path. For GCS URIs, netloc is the package name.
[ "Parse", "resource", "uri", "into", "protocol", "and", "package", "name", "based", "on", "its", "format", ".", "Note", "that", "the", "output", "of", "this", "function", "is", "not", "for", "handling", "actual", "IO", "it", "'", "s", "only", "for", "sett...
def parse_uri(pkg_uri: str) -> Tuple[Protocol, str]: uri = urlparse(pkg_uri) protocol = Protocol(uri.scheme) if protocol == Protocol.S3 or protocol == Protocol.GS: return (protocol, f"{protocol.value}_{uri.netloc}{uri.path.replace('/', '_')}") elif protocol == Protocol.HTTPS: return ( ...
[ "def", "parse_uri", "(", "pkg_uri", ":", "str", ")", "->", "Tuple", "[", "Protocol", ",", "str", "]", ":", "uri", "=", "urlparse", "(", "pkg_uri", ")", "protocol", "=", "Protocol", "(", "uri", ".", "scheme", ")", "if", "protocol", "==", "Protocol", "...
Parse resource uri into protocol and package name based on its format.
[ "Parse", "resource", "uri", "into", "protocol", "and", "package", "name", "based", "on", "its", "format", "." ]
[ "\"\"\"\n Parse resource uri into protocol and package name based on its format.\n Note that the output of this function is not for handling actual IO, it's\n only for setting up local directory folders by using package name as path.\n For GCS URIs, netloc is the package name.\n urlparse(\"gcs://...
[ { "param": "pkg_uri", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pkg_uri", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
_store_package_in_gcs
int
def _store_package_in_gcs( pkg_uri: str, data: bytes, logger: Optional[logging.Logger] = default_logger, ) -> int: """Stores package data in the Global Control Store (GCS). Args: pkg_uri (str): The GCS key to store the data in. data (bytes): The serialized package's bytes to store i...
Stores package data in the Global Control Store (GCS). Args: pkg_uri (str): The GCS key to store the data in. data (bytes): The serialized package's bytes to store in the GCS. logger (Optional[logging.Logger]): The logger used by this function. Return: int: Size of data Ra...
Stores package data in the Global Control Store (GCS).
[ "Stores", "package", "data", "in", "the", "Global", "Control", "Store", "(", "GCS", ")", "." ]
def _store_package_in_gcs( pkg_uri: str, data: bytes, logger: Optional[logging.Logger] = default_logger, ) -> int: file_size = len(data) size_str = _mib_string(file_size) if len(data) >= GCS_STORAGE_MAX_SIZE: raise ValueError( f"Package size ({size_str}) exceeds the maximum s...
[ "def", "_store_package_in_gcs", "(", "pkg_uri", ":", "str", ",", "data", ":", "bytes", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "default_logger", ",", ")", "->", "int", ":", "file_size", "=", "len", "(", "data", ")", "si...
Stores package data in the Global Control Store (GCS).
[ "Stores", "package", "data", "in", "the", "Global", "Control", "Store", "(", "GCS", ")", "." ]
[ "\"\"\"Stores package data in the Global Control Store (GCS).\n\n Args:\n pkg_uri (str): The GCS key to store the data in.\n data (bytes): The serialized package's bytes to store in the GCS.\n logger (Optional[logging.Logger]): The logger used by this function.\n\n Return:\n int: S...
[ { "param": "pkg_uri", "type": "str" }, { "param": "data", "type": "bytes" }, { "param": "logger", "type": "Optional[logging.Logger]" } ]
{ "returns": [], "raises": [ { "docstring": "If the upload to the GCS fails.", "docstring_tokens": [ "If", "the", "upload", "to", "the", "GCS", "fails", "." ], "type": "RuntimeError" }, { "docstring": "If the d...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
upload_package_if_needed
bool
def upload_package_if_needed( pkg_uri: str, base_directory: str, directory: str, include_parent_dir: bool = False, excludes: Optional[List[str]] = None, logger: Optional[logging.Logger] = default_logger, ) -> bool: """Upload the contents of the directory under the given URI. This will f...
Upload the contents of the directory under the given URI. This will first create a temporary zip file under the passed base_directory. If the package already exists in storage, this is a no-op. Args: pkg_uri: URI of the package to upload. base_directory: Directory where package files ...
Upload the contents of the directory under the given URI. This will first create a temporary zip file under the passed base_directory. If the package already exists in storage, this is a no-op.
[ "Upload", "the", "contents", "of", "the", "directory", "under", "the", "given", "URI", ".", "This", "will", "first", "create", "a", "temporary", "zip", "file", "under", "the", "passed", "base_directory", ".", "If", "the", "package", "already", "exists", "in"...
def upload_package_if_needed( pkg_uri: str, base_directory: str, directory: str, include_parent_dir: bool = False, excludes: Optional[List[str]] = None, logger: Optional[logging.Logger] = default_logger, ) -> bool: if excludes is None: excludes = [] if logger is None: log...
[ "def", "upload_package_if_needed", "(", "pkg_uri", ":", "str", ",", "base_directory", ":", "str", ",", "directory", ":", "str", ",", "include_parent_dir", ":", "bool", "=", "False", ",", "excludes", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", ...
Upload the contents of the directory under the given URI.
[ "Upload", "the", "contents", "of", "the", "directory", "under", "the", "given", "URI", "." ]
[ "\"\"\"Upload the contents of the directory under the given URI.\n\n This will first create a temporary zip file under the passed\n base_directory.\n\n If the package already exists in storage, this is a no-op.\n\n Args:\n pkg_uri: URI of the package to upload.\n base_directory: Directory ...
[ { "param": "pkg_uri", "type": "str" }, { "param": "base_directory", "type": "str" }, { "param": "directory", "type": "str" }, { "param": "include_parent_dir", "type": "bool" }, { "param": "excludes", "type": "Optional[List[str]]" }, { "param": "logger"...
{ "returns": [], "raises": [], "params": [ { "identifier": "pkg_uri", "type": "str", "docstring": "URI of the package to upload.", "docstring_tokens": [ "URI", "of", "the", "package", "to", "upload", "." ], "default": ...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
download_and_unpack_package
str
def download_and_unpack_package( pkg_uri: str, base_directory: str, logger: Optional[logging.Logger] = default_logger, ) -> str: """Download the package corresponding to this URI and unpack it if zipped. Will be written to a file or directory named {base_directory}/{uri}. Returns the path to th...
Download the package corresponding to this URI and unpack it if zipped. Will be written to a file or directory named {base_directory}/{uri}. Returns the path to this file or directory.
Download the package corresponding to this URI and unpack it if zipped. Will be written to a file or directory named {base_directory}/{uri}. Returns the path to this file or directory.
[ "Download", "the", "package", "corresponding", "to", "this", "URI", "and", "unpack", "it", "if", "zipped", ".", "Will", "be", "written", "to", "a", "file", "or", "directory", "named", "{", "base_directory", "}", "/", "{", "uri", "}", ".", "Returns", "the...
def download_and_unpack_package( pkg_uri: str, base_directory: str, logger: Optional[logging.Logger] = default_logger, ) -> str: pkg_file = Path(_get_local_path(base_directory, pkg_uri)) with FileLock(str(pkg_file) + ".lock"): if logger is None: logger = default_logger lo...
[ "def", "download_and_unpack_package", "(", "pkg_uri", ":", "str", ",", "base_directory", ":", "str", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "default_logger", ",", ")", "->", "str", ":", "pkg_file", "=", "Path", "(", "_get_...
Download the package corresponding to this URI and unpack it if zipped.
[ "Download", "the", "package", "corresponding", "to", "this", "URI", "and", "unpack", "it", "if", "zipped", "." ]
[ "\"\"\"Download the package corresponding to this URI and unpack it if zipped.\n\n Will be written to a file or directory named {base_directory}/{uri}.\n Returns the path to this file or directory.\n \"\"\"", "# Download package from the GCS.", "# Download package from remote URI", "# noqa: F401" ]
[ { "param": "pkg_uri", "type": "str" }, { "param": "base_directory", "type": "str" }, { "param": "logger", "type": "Optional[logging.Logger]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pkg_uri", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "base_directory", "type": "str", "docstring": null, "docst...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
remove_dir_from_filepaths
null
def remove_dir_from_filepaths(base_dir: str, rdir: str): """ base_dir: String path of the directory containing rdir rdir: String path of directory relative to base_dir whose contents should be moved to its base_dir, its parent directory Removes rdir from the filepaths of all files and directo...
base_dir: String path of the directory containing rdir rdir: String path of directory relative to base_dir whose contents should be moved to its base_dir, its parent directory Removes rdir from the filepaths of all files and directories inside it. In other words, moves all the files inside r...
String path of the directory containing rdir rdir: String path of directory relative to base_dir whose contents should be moved to its base_dir, its parent directory Removes rdir from the filepaths of all files and directories inside it. In other words, moves all the files inside rdir to the directory that contains rd...
[ "String", "path", "of", "the", "directory", "containing", "rdir", "rdir", ":", "String", "path", "of", "directory", "relative", "to", "base_dir", "whose", "contents", "should", "be", "moved", "to", "its", "base_dir", "its", "parent", "directory", "Removes", "r...
def remove_dir_from_filepaths(base_dir: str, rdir: str): with TemporaryDirectory() as tmp_dir: shutil.move(os.path.join(base_dir, rdir), os.path.join(tmp_dir, rdir)) rdir_children = os.listdir(os.path.join(tmp_dir, rdir)) for child in rdir_children: shutil.move( o...
[ "def", "remove_dir_from_filepaths", "(", "base_dir", ":", "str", ",", "rdir", ":", "str", ")", ":", "with", "TemporaryDirectory", "(", ")", "as", "tmp_dir", ":", "shutil", ".", "move", "(", "os", ".", "path", ".", "join", "(", "base_dir", ",", "rdir", ...
base_dir: String path of the directory containing rdir rdir: String path of directory relative to base_dir whose contents should be moved to its base_dir, its parent directory
[ "base_dir", ":", "String", "path", "of", "the", "directory", "containing", "rdir", "rdir", ":", "String", "path", "of", "directory", "relative", "to", "base_dir", "whose", "contents", "should", "be", "moved", "to", "its", "base_dir", "its", "parent", "director...
[ "\"\"\"\n base_dir: String path of the directory containing rdir\n rdir: String path of directory relative to base_dir whose contents should\n be moved to its base_dir, its parent directory\n\n Removes rdir from the filepaths of all files and directories inside it.\n In other words, moves all t...
[ { "param": "base_dir", "type": "str" }, { "param": "rdir", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "base_dir", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "rdir", "type": "str", "docstring": null, "docstring_toke...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
unzip_package
null
def unzip_package( package_path: str, target_dir: str, remove_top_level_directory: bool, unlink_zip: bool, logger: Optional[logging.Logger] = default_logger, ): """ Unzip the compressed package contained at package_path and store the contents in target_dir. If remove_top_level_directory ...
Unzip the compressed package contained at package_path and store the contents in target_dir. If remove_top_level_directory is True, the function will automatically remove the top_level_directory and store the contents directly in target_dir. If unlink_zip is True, the function will unlink the zip f...
Unzip the compressed package contained at package_path and store the contents in target_dir. If remove_top_level_directory is True, the function will automatically remove the top_level_directory and store the contents directly in target_dir. If unlink_zip is True, the function will unlink the zip file stored at package...
[ "Unzip", "the", "compressed", "package", "contained", "at", "package_path", "and", "store", "the", "contents", "in", "target_dir", ".", "If", "remove_top_level_directory", "is", "True", "the", "function", "will", "automatically", "remove", "the", "top_level_directory"...
def unzip_package( package_path: str, target_dir: str, remove_top_level_directory: bool, unlink_zip: bool, logger: Optional[logging.Logger] = default_logger, ): try: os.mkdir(target_dir) except FileExistsError: logger.info(f"Directory at {target_dir} already exists") logg...
[ "def", "unzip_package", "(", "package_path", ":", "str", ",", "target_dir", ":", "str", ",", "remove_top_level_directory", ":", "bool", ",", "unlink_zip", ":", "bool", ",", "logger", ":", "Optional", "[", "logging", ".", "Logger", "]", "=", "default_logger", ...
Unzip the compressed package contained at package_path and store the contents in target_dir.
[ "Unzip", "the", "compressed", "package", "contained", "at", "package_path", "and", "store", "the", "contents", "in", "target_dir", "." ]
[ "\"\"\"\n Unzip the compressed package contained at package_path and store the\n contents in target_dir. If remove_top_level_directory is True, the function\n will automatically remove the top_level_directory and store the contents\n directly in target_dir. If unlink_zip is True, the function will unlin...
[ { "param": "package_path", "type": "str" }, { "param": "target_dir", "type": "str" }, { "param": "remove_top_level_directory", "type": "bool" }, { "param": "unlink_zip", "type": "bool" }, { "param": "logger", "type": "Optional[logging.Logger]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "package_path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "target_dir", "type": "str", "docstring": null, "docs...
99245cce50010f8a0bc1e0e3a06c7bad8a56fe7d
kisuke95/ray
python/ray/_private/runtime_env/packaging.py
[ "Apache-2.0" ]
Python
delete_package
Tuple[bool, int]
def delete_package(pkg_uri: str, base_directory: str) -> Tuple[bool, int]: """Deletes a specific URI from the local filesystem. Args: pkg_uri (str): URI to delete. Returns: bool: True if the URI was successfully deleted, else False. """ deleted = False path = Path(_get_local_p...
Deletes a specific URI from the local filesystem. Args: pkg_uri (str): URI to delete. Returns: bool: True if the URI was successfully deleted, else False.
Deletes a specific URI from the local filesystem.
[ "Deletes", "a", "specific", "URI", "from", "the", "local", "filesystem", "." ]
def delete_package(pkg_uri: str, base_directory: str) -> Tuple[bool, int]: deleted = False path = Path(_get_local_path(base_directory, pkg_uri)) with FileLock(str(path) + ".lock"): path = path.with_suffix("") if path.exists(): if path.is_dir() and not path.is_symlink(): ...
[ "def", "delete_package", "(", "pkg_uri", ":", "str", ",", "base_directory", ":", "str", ")", "->", "Tuple", "[", "bool", ",", "int", "]", ":", "deleted", "=", "False", "path", "=", "Path", "(", "_get_local_path", "(", "base_directory", ",", "pkg_uri", ")...
Deletes a specific URI from the local filesystem.
[ "Deletes", "a", "specific", "URI", "from", "the", "local", "filesystem", "." ]
[ "\"\"\"Deletes a specific URI from the local filesystem.\n\n Args:\n pkg_uri (str): URI to delete.\n\n Returns:\n bool: True if the URI was successfully deleted, else False.\n \"\"\"" ]
[ { "param": "pkg_uri", "type": "str" }, { "param": "base_directory", "type": "str" } ]
{ "returns": [ { "docstring": "True if the URI was successfully deleted, else False.", "docstring_tokens": [ "True", "if", "the", "URI", "was", "successfully", "deleted", "else", "False", "." ], "type": "bool" ...
d81ad90b6ea6ef3bcd84e0215dd89fe25a4d1166
kisuke95/ray
dashboard/head.py
[ "Apache-2.0" ]
Python
check_once
bool
async def check_once(self) -> bool: """Ask the thread to perform a healthcheck.""" assert ( threading.current_thread != self ), "caller shouldn't be from the same thread as GCSHealthCheckThread." future = Future() self.work_queue.put(future) return await asyn...
Ask the thread to perform a healthcheck.
Ask the thread to perform a healthcheck.
[ "Ask", "the", "thread", "to", "perform", "a", "healthcheck", "." ]
async def check_once(self) -> bool: assert ( threading.current_thread != self ), "caller shouldn't be from the same thread as GCSHealthCheckThread." future = Future() self.work_queue.put(future) return await asyncio.wrap_future(future)
[ "async", "def", "check_once", "(", "self", ")", "->", "bool", ":", "assert", "(", "threading", ".", "current_thread", "!=", "self", ")", ",", "\"caller shouldn't be from the same thread as GCSHealthCheckThread.\"", "future", "=", "Future", "(", ")", "self", ".", "...
Ask the thread to perform a healthcheck.
[ "Ask", "the", "thread", "to", "perform", "a", "healthcheck", "." ]
[ "\"\"\"Ask the thread to perform a healthcheck.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
clear
null
def clear(self): """Clears all object references (block partitions and base block partitions) from this lazy block list. """ self._block_partition_refs = [None for _ in self._block_partition_refs] self._block_partition_meta_refs = [ None for _ in self._block_partition...
Clears all object references (block partitions and base block partitions) from this lazy block list.
Clears all object references (block partitions and base block partitions) from this lazy block list.
[ "Clears", "all", "object", "references", "(", "block", "partitions", "and", "base", "block", "partitions", ")", "from", "this", "lazy", "block", "list", "." ]
def clear(self): self._block_partition_refs = [None for _ in self._block_partition_refs] self._block_partition_meta_refs = [ None for _ in self._block_partition_meta_refs ] self._cached_metadata = [None for _ in self._cached_metadata]
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_block_partition_refs", "=", "[", "None", "for", "_", "in", "self", ".", "_block_partition_refs", "]", "self", ".", "_block_partition_meta_refs", "=", "[", "None", "for", "_", "in", "self", ".", "_block_...
Clears all object references (block partitions and base block partitions) from this lazy block list.
[ "Clears", "all", "object", "references", "(", "block", "partitions", "and", "base", "block", "partitions", ")", "from", "this", "lazy", "block", "list", "." ]
[ "\"\"\"Clears all object references (block partitions and base block partitions)\n from this lazy block list.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
_get_blocks_with_metadata
Tuple[List[ObjectRef[Block]], List[BlockMetadata]]
def _get_blocks_with_metadata( self, ) -> Tuple[List[ObjectRef[Block]], List[BlockMetadata]]: """Get all underlying block futures and concrete metadata. This will block on the completion of the underlying read tasks and will fetch all block metadata outputted by those tasks. ...
Get all underlying block futures and concrete metadata. This will block on the completion of the underlying read tasks and will fetch all block metadata outputted by those tasks.
Get all underlying block futures and concrete metadata. This will block on the completion of the underlying read tasks and will fetch all block metadata outputted by those tasks.
[ "Get", "all", "underlying", "block", "futures", "and", "concrete", "metadata", ".", "This", "will", "block", "on", "the", "completion", "of", "the", "underlying", "read", "tasks", "and", "will", "fetch", "all", "block", "metadata", "outputted", "by", "those", ...
def _get_blocks_with_metadata( self, ) -> Tuple[List[ObjectRef[Block]], List[BlockMetadata]]: context = DatasetContext.get_current() block_refs, meta_refs = [], [] for block_ref, meta_ref in self._iter_block_partition_refs(): block_refs.append(block_ref) meta_...
[ "def", "_get_blocks_with_metadata", "(", "self", ",", ")", "->", "Tuple", "[", "List", "[", "ObjectRef", "[", "Block", "]", "]", ",", "List", "[", "BlockMetadata", "]", "]", ":", "context", "=", "DatasetContext", ".", "get_current", "(", ")", "block_refs",...
Get all underlying block futures and concrete metadata.
[ "Get", "all", "underlying", "block", "futures", "and", "concrete", "metadata", "." ]
[ "\"\"\"Get all underlying block futures and concrete metadata.\n\n This will block on the completion of the underlying read tasks and will fetch\n all block metadata outputted by those tasks.\n \"\"\"", "# If block splitting is enabled, fetch the partitions.", "# Short-circuit on cached met...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
compute_first_block
null
def compute_first_block(self): """Kick off computation for the first block in the list. This is useful if looking to support rapid lightweight interaction with a small amount of the dataset. """ if self._tasks: self._get_or_compute(0)
Kick off computation for the first block in the list. This is useful if looking to support rapid lightweight interaction with a small amount of the dataset.
Kick off computation for the first block in the list. This is useful if looking to support rapid lightweight interaction with a small amount of the dataset.
[ "Kick", "off", "computation", "for", "the", "first", "block", "in", "the", "list", ".", "This", "is", "useful", "if", "looking", "to", "support", "rapid", "lightweight", "interaction", "with", "a", "small", "amount", "of", "the", "dataset", "." ]
def compute_first_block(self): if self._tasks: self._get_or_compute(0)
[ "def", "compute_first_block", "(", "self", ")", ":", "if", "self", ".", "_tasks", ":", "self", ".", "_get_or_compute", "(", "0", ")" ]
Kick off computation for the first block in the list.
[ "Kick", "off", "computation", "for", "the", "first", "block", "in", "the", "list", "." ]
[ "\"\"\"Kick off computation for the first block in the list.\n\n This is useful if looking to support rapid lightweight interaction with a small\n amount of the dataset.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
ensure_metadata_for_first_block
Optional[BlockMetadata]
def ensure_metadata_for_first_block(self) -> Optional[BlockMetadata]: """Ensure that the metadata is fetched and set for the first block. This will only block execution in order to fetch the post-read metadata for the first block if the pre-read metadata for the first block has no schema. ...
Ensure that the metadata is fetched and set for the first block. This will only block execution in order to fetch the post-read metadata for the first block if the pre-read metadata for the first block has no schema. Returns: None if the block list is empty, the metadata for the fi...
Ensure that the metadata is fetched and set for the first block. This will only block execution in order to fetch the post-read metadata for the first block if the pre-read metadata for the first block has no schema.
[ "Ensure", "that", "the", "metadata", "is", "fetched", "and", "set", "for", "the", "first", "block", ".", "This", "will", "only", "block", "execution", "in", "order", "to", "fetch", "the", "post", "-", "read", "metadata", "for", "the", "first", "block", "...
def ensure_metadata_for_first_block(self) -> Optional[BlockMetadata]: if not self._tasks: return None metadata = self._tasks[0].get_metadata() if metadata.schema is not None: return metadata try: _, metadata_ref = next(self._iter_block_partition_refs()...
[ "def", "ensure_metadata_for_first_block", "(", "self", ")", "->", "Optional", "[", "BlockMetadata", "]", ":", "if", "not", "self", ".", "_tasks", ":", "return", "None", "metadata", "=", "self", ".", "_tasks", "[", "0", "]", ".", "get_metadata", "(", ")", ...
Ensure that the metadata is fetched and set for the first block.
[ "Ensure", "that", "the", "metadata", "is", "fetched", "and", "set", "for", "the", "first", "block", "." ]
[ "\"\"\"Ensure that the metadata is fetched and set for the first block.\n\n This will only block execution in order to fetch the post-read metadata for the\n first block if the pre-read metadata for the first block has no schema.\n\n Returns:\n None if the block list is empty, the me...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "None if the block list is empty, the metadata for the first block otherwise.", "docstring_tokens": [ "None", "if", "the", "block", "list", "is", "empty", "the", "metadata", "for", "th...
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
iter_blocks_with_metadata
Iterator[Tuple[ObjectRef[Block], BlockMetadata]]
def iter_blocks_with_metadata( self, block_for_metadata: bool = False, ) -> Iterator[Tuple[ObjectRef[Block], BlockMetadata]]: """Iterate over the blocks along with their metadata. Note that, if block_for_metadata is False (default), this iterator returns pre-read metadata fr...
Iterate over the blocks along with their metadata. Note that, if block_for_metadata is False (default), this iterator returns pre-read metadata from the ReadTasks given to this LazyBlockList so it doesn't have to block on the execution of the read tasks. Therefore, the metadata may be u...
Iterate over the blocks along with their metadata. Note that, if block_for_metadata is False (default), this iterator returns pre-read metadata from the ReadTasks given to this LazyBlockList so it doesn't have to block on the execution of the read tasks. Therefore, the metadata may be under-specified, e.g. missing sche...
[ "Iterate", "over", "the", "blocks", "along", "with", "their", "metadata", ".", "Note", "that", "if", "block_for_metadata", "is", "False", "(", "default", ")", "this", "iterator", "returns", "pre", "-", "read", "metadata", "from", "the", "ReadTasks", "given", ...
def iter_blocks_with_metadata( self, block_for_metadata: bool = False, ) -> Iterator[Tuple[ObjectRef[Block], BlockMetadata]]: context = DatasetContext.get_current() outer = self class Iter: def __init__(self): self._base_iter = outer._iter_block_pa...
[ "def", "iter_blocks_with_metadata", "(", "self", ",", "block_for_metadata", ":", "bool", "=", "False", ",", ")", "->", "Iterator", "[", "Tuple", "[", "ObjectRef", "[", "Block", "]", ",", "BlockMetadata", "]", "]", ":", "context", "=", "DatasetContext", ".", ...
Iterate over the blocks along with their metadata.
[ "Iterate", "over", "the", "blocks", "along", "with", "their", "metadata", "." ]
[ "\"\"\"Iterate over the blocks along with their metadata.\n\n Note that, if block_for_metadata is False (default), this iterator returns\n pre-read metadata from the ReadTasks given to this LazyBlockList so it doesn't\n have to block on the execution of the read tasks. Therefore, the metadata m...
[ { "param": "self", "type": null }, { "param": "block_for_metadata", "type": "bool" } ]
{ "returns": [ { "docstring": "An iterator of block references and the corresponding block metadata.", "docstring_tokens": [ "An", "iterator", "of", "block", "references", "and", "the", "corresponding", "block", "metadata"...
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
_iter_block_partition_refs
Iterator[ Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]] ]
def _iter_block_partition_refs( self, ) -> Iterator[ Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]] ]: """Iterate over the block futures and their corresponding metadata futures. This does NOT block on the execution of each submitted task. """ ...
Iterate over the block futures and their corresponding metadata futures. This does NOT block on the execution of each submitted task.
Iterate over the block futures and their corresponding metadata futures. This does NOT block on the execution of each submitted task.
[ "Iterate", "over", "the", "block", "futures", "and", "their", "corresponding", "metadata", "futures", ".", "This", "does", "NOT", "block", "on", "the", "execution", "of", "each", "submitted", "task", "." ]
def _iter_block_partition_refs( self, ) -> Iterator[ Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]] ]: outer = self class Iter: def __init__(self): self._pos = -1 def __iter__(self): return self ...
[ "def", "_iter_block_partition_refs", "(", "self", ",", ")", "->", "Iterator", "[", "Tuple", "[", "ObjectRef", "[", "MaybeBlockPartition", "]", ",", "ObjectRef", "[", "BlockPartitionMetadata", "]", "]", "]", ":", "outer", "=", "self", "class", "Iter", ":", "d...
Iterate over the block futures and their corresponding metadata futures.
[ "Iterate", "over", "the", "block", "futures", "and", "their", "corresponding", "metadata", "futures", "." ]
[ "\"\"\"Iterate over the block futures and their corresponding metadata futures.\n\n This does NOT block on the execution of each submitted task.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
28b48e106b84189bd2ec946f00cb8395ce0cc0b1
kisuke95/ray
python/ray/data/impl/lazy_block_list.py
[ "Apache-2.0" ]
Python
_submit_task
Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]]
def _submit_task( self, task_idx: int ) -> Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]]: """Submit the task with index task_idx.""" stats_actor = _get_or_create_stats_actor() if not self._execution_started: stats_actor.record_start.remote(self....
Submit the task with index task_idx.
Submit the task with index task_idx.
[ "Submit", "the", "task", "with", "index", "task_idx", "." ]
def _submit_task( self, task_idx: int ) -> Tuple[ObjectRef[MaybeBlockPartition], ObjectRef[BlockPartitionMetadata]]: stats_actor = _get_or_create_stats_actor() if not self._execution_started: stats_actor.record_start.remote(self._stats_uuid) self._execution_started = ...
[ "def", "_submit_task", "(", "self", ",", "task_idx", ":", "int", ")", "->", "Tuple", "[", "ObjectRef", "[", "MaybeBlockPartition", "]", ",", "ObjectRef", "[", "BlockPartitionMetadata", "]", "]", ":", "stats_actor", "=", "_get_or_create_stats_actor", "(", ")", ...
Submit the task with index task_idx.
[ "Submit", "the", "task", "with", "index", "task_idx", "." ]
[ "\"\"\"Submit the task with index task_idx.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "task_idx", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "task_idx", "type": "int", "docstring": null, "docstring_token...
0c4552a40bc1094a0ba193f44cb5dab944ab764f
kisuke95/ray
python/ray/util/client/dataclient.py
[ "Apache-2.0" ]
Python
chunk_put
null
def chunk_put(req: ray_client_pb2.DataRequest): """ Chunks a put request. Doing this lazily is important for large objects, since taking slices of bytes objects does a copy. This means if we immediately materialized every chunk of a large object and inserted them into the result_queue, we would effe...
Chunks a put request. Doing this lazily is important for large objects, since taking slices of bytes objects does a copy. This means if we immediately materialized every chunk of a large object and inserted them into the result_queue, we would effectively double the memory needed on the client to h...
Chunks a put request. Doing this lazily is important for large objects, since taking slices of bytes objects does a copy. This means if we immediately materialized every chunk of a large object and inserted them into the result_queue, we would effectively double the memory needed on the client to handle the put.
[ "Chunks", "a", "put", "request", ".", "Doing", "this", "lazily", "is", "important", "for", "large", "objects", "since", "taking", "slices", "of", "bytes", "objects", "does", "a", "copy", ".", "This", "means", "if", "we", "immediately", "materialized", "every...
def chunk_put(req: ray_client_pb2.DataRequest): total_size = len(req.put.data) assert total_size > 0, "Cannot chunk object with missing data" if total_size >= OBJECT_TRANSFER_WARNING_SIZE and log_once( "client_object_put_size_warning" ): size_gb = total_size / 2 ** 30 warnings.wa...
[ "def", "chunk_put", "(", "req", ":", "ray_client_pb2", ".", "DataRequest", ")", ":", "total_size", "=", "len", "(", "req", ".", "put", ".", "data", ")", "assert", "total_size", ">", "0", ",", "\"Cannot chunk object with missing data\"", "if", "total_size", ">=...
Chunks a put request.
[ "Chunks", "a", "put", "request", "." ]
[ "\"\"\"\n Chunks a put request. Doing this lazily is important for large objects,\n since taking slices of bytes objects does a copy. This means if we\n immediately materialized every chunk of a large object and inserted them\n into the result_queue, we would effectively double the memory needed\n on...
[ { "param": "req", "type": "ray_client_pb2.DataRequest" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "req", "type": "ray_client_pb2.DataRequest", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0c4552a40bc1094a0ba193f44cb5dab944ab764f
kisuke95/ray
python/ray/util/client/dataclient.py
[ "Apache-2.0" ]
Python
_process_response
None
def _process_response(self, response: Any) -> None: """ Process responses from the data servicer. """ if response.req_id == 0: # This is not being waited for. logger.debug(f"Got unawaited response {response}") return if response.req_id in self....
Process responses from the data servicer.
Process responses from the data servicer.
[ "Process", "responses", "from", "the", "data", "servicer", "." ]
def _process_response(self, response: Any) -> None: if response.req_id == 0: logger.debug(f"Got unawaited response {response}") return if response.req_id in self.asyncio_waiting_data: can_remove = True try: callback = self.asyncio_waiting_d...
[ "def", "_process_response", "(", "self", ",", "response", ":", "Any", ")", "->", "None", ":", "if", "response", ".", "req_id", "==", "0", ":", "logger", ".", "debug", "(", "f\"Got unawaited response {response}\"", ")", "return", "if", "response", ".", "req_i...
Process responses from the data servicer.
[ "Process", "responses", "from", "the", "data", "servicer", "." ]
[ "\"\"\"\n Process responses from the data servicer.\n \"\"\"", "# This is not being waited for.", "# NOTE: calling del self.asyncio_waiting_data results", "# in the destructor of ClientObjectRef running, which", "# calls ReleaseObject(). So self.asyncio_waiting_data", "# is accessed without ...
[ { "param": "self", "type": null }, { "param": "response", "type": "Any" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "response", "type": "Any", "docstring": null, "docstring_token...
0c4552a40bc1094a0ba193f44cb5dab944ab764f
kisuke95/ray
python/ray/util/client/dataclient.py
[ "Apache-2.0" ]
Python
_can_reconnect
bool
def _can_reconnect(self, e: grpc.RpcError) -> bool: """ Processes RPC errors that occur while reading from data stream. Returns True if the error can be recovered from, False otherwise. """ if not self.client_worker._can_reconnect(e): logger.error("Unrecoverable error...
Processes RPC errors that occur while reading from data stream. Returns True if the error can be recovered from, False otherwise.
Processes RPC errors that occur while reading from data stream. Returns True if the error can be recovered from, False otherwise.
[ "Processes", "RPC", "errors", "that", "occur", "while", "reading", "from", "data", "stream", ".", "Returns", "True", "if", "the", "error", "can", "be", "recovered", "from", "False", "otherwise", "." ]
def _can_reconnect(self, e: grpc.RpcError) -> bool: if not self.client_worker._can_reconnect(e): logger.error("Unrecoverable error in data channel.") logger.debug(e) return False logger.debug("Recoverable error in data channel.") logger.debug(e) return...
[ "def", "_can_reconnect", "(", "self", ",", "e", ":", "grpc", ".", "RpcError", ")", "->", "bool", ":", "if", "not", "self", ".", "client_worker", ".", "_can_reconnect", "(", "e", ")", ":", "logger", ".", "error", "(", "\"Unrecoverable error in data channel.\"...
Processes RPC errors that occur while reading from data stream.
[ "Processes", "RPC", "errors", "that", "occur", "while", "reading", "from", "data", "stream", "." ]
[ "\"\"\"\n Processes RPC errors that occur while reading from data stream.\n Returns True if the error can be recovered from, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "e", "type": "grpc.RpcError" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "e", "type": "grpc.RpcError", "docstring": null, "docstring_to...
0c4552a40bc1094a0ba193f44cb5dab944ab764f
kisuke95/ray
python/ray/util/client/dataclient.py
[ "Apache-2.0" ]
Python
_acknowledge
None
def _acknowledge(self, req_id: int) -> None: """ Puts an acknowledge request on the request queue periodically. Lock should be held before calling this. Used when an async or blocking response is received. """ if not self.client_worker._reconnect_enabled: # Sk...
Puts an acknowledge request on the request queue periodically. Lock should be held before calling this. Used when an async or blocking response is received.
Puts an acknowledge request on the request queue periodically. Lock should be held before calling this. Used when an async or blocking response is received.
[ "Puts", "an", "acknowledge", "request", "on", "the", "request", "queue", "periodically", ".", "Lock", "should", "be", "held", "before", "calling", "this", ".", "Used", "when", "an", "async", "or", "blocking", "response", "is", "received", "." ]
def _acknowledge(self, req_id: int) -> None: if not self.client_worker._reconnect_enabled: return assert self.lock.locked() self._acknowledge_counter += 1 if self._acknowledge_counter % ACKNOWLEDGE_BATCH_SIZE == 0: self.request_queue.put( ray_clien...
[ "def", "_acknowledge", "(", "self", ",", "req_id", ":", "int", ")", "->", "None", ":", "if", "not", "self", ".", "client_worker", ".", "_reconnect_enabled", ":", "return", "assert", "self", ".", "lock", ".", "locked", "(", ")", "self", ".", "_acknowledge...
Puts an acknowledge request on the request queue periodically.
[ "Puts", "an", "acknowledge", "request", "on", "the", "request", "queue", "periodically", "." ]
[ "\"\"\"\n Puts an acknowledge request on the request queue periodically.\n Lock should be held before calling this. Used when an async or\n blocking response is received.\n \"\"\"", "# Skip ACKs if reconnect isn't enabled" ]
[ { "param": "self", "type": null }, { "param": "req_id", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "req_id", "type": "int", "docstring": null, "docstring_tokens"...
0c4552a40bc1094a0ba193f44cb5dab944ab764f
kisuke95/ray
python/ray/util/client/dataclient.py
[ "Apache-2.0" ]
Python
_reconnect_channel
None
def _reconnect_channel(self) -> None: """ Attempts to reconnect the gRPC channel and resend outstanding requests. First, the server is pinged to see if the current channel still works. If the ping fails, then the current channel is closed and replaced with a new one. Onc...
Attempts to reconnect the gRPC channel and resend outstanding requests. First, the server is pinged to see if the current channel still works. If the ping fails, then the current channel is closed and replaced with a new one. Once a working channel is available, a new request q...
Attempts to reconnect the gRPC channel and resend outstanding requests. First, the server is pinged to see if the current channel still works. If the ping fails, then the current channel is closed and replaced with a new one. Once a working channel is available, a new request queue is made and filled with any outstand...
[ "Attempts", "to", "reconnect", "the", "gRPC", "channel", "and", "resend", "outstanding", "requests", ".", "First", "the", "server", "is", "pinged", "to", "see", "if", "the", "current", "channel", "still", "works", ".", "If", "the", "ping", "fails", "then", ...
def _reconnect_channel(self) -> None: try: ping_succeeded = self.client_worker.ping_server(timeout=5) except grpc.RpcError: ping_succeeded = False if not ping_succeeded: logger.warning( "Encountered connection issues in the data channel. " ...
[ "def", "_reconnect_channel", "(", "self", ")", "->", "None", ":", "try", ":", "ping_succeeded", "=", "self", ".", "client_worker", ".", "ping_server", "(", "timeout", "=", "5", ")", "except", "grpc", ".", "RpcError", ":", "ping_succeeded", "=", "False", "i...
Attempts to reconnect the gRPC channel and resend outstanding requests.
[ "Attempts", "to", "reconnect", "the", "gRPC", "channel", "and", "resend", "outstanding", "requests", "." ]
[ "\"\"\"\n Attempts to reconnect the gRPC channel and resend outstanding\n requests. First, the server is pinged to see if the current channel\n still works. If the ping fails, then the current channel is closed\n and replaced with a new one.\n\n Once a working channel is available...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
80fbbbc8f12bfe5433e5b231fcdbad67578d33af
kisuke95/ray
rllib/agents/dqn/dqn.py
[ "Apache-2.0" ]
Python
training_iteration
ResultDict
def training_iteration(self) -> ResultDict: """DQN training iteration function. Each training iteration, we: - Sample (MultiAgentBatch) from workers. - Store new samples in replay buffer. - Sample training batch (MultiAgentBatch) from replay buffer. - Learn on training b...
DQN training iteration function. Each training iteration, we: - Sample (MultiAgentBatch) from workers. - Store new samples in replay buffer. - Sample training batch (MultiAgentBatch) from replay buffer. - Learn on training batch. - Update remote workers' new policy weigh...
DQN training iteration function. Each training iteration, we: Sample (MultiAgentBatch) from workers. Store new samples in replay buffer. Sample training batch (MultiAgentBatch) from replay buffer. Learn on training batch. Update remote workers' new policy weights. Update target network every target_network_update_freq ...
[ "DQN", "training", "iteration", "function", ".", "Each", "training", "iteration", "we", ":", "Sample", "(", "MultiAgentBatch", ")", "from", "workers", ".", "Store", "new", "samples", "in", "replay", "buffer", ".", "Sample", "training", "batch", "(", "MultiAgen...
def training_iteration(self) -> ResultDict: local_worker = self.workers.local_worker() train_results = {} store_weight, sample_and_train_weight = calculate_rr_weights(self.config) for _ in range(store_weight): new_sample_batch = synchronous_parallel_sample( wo...
[ "def", "training_iteration", "(", "self", ")", "->", "ResultDict", ":", "local_worker", "=", "self", ".", "workers", ".", "local_worker", "(", ")", "train_results", "=", "{", "}", "store_weight", ",", "sample_and_train_weight", "=", "calculate_rr_weights", "(", ...
DQN training iteration function.
[ "DQN", "training", "iteration", "function", "." ]
[ "\"\"\"DQN training iteration function.\n\n Each training iteration, we:\n - Sample (MultiAgentBatch) from workers.\n - Store new samples in replay buffer.\n - Sample training batch (MultiAgentBatch) from replay buffer.\n - Learn on training batch.\n - Update remote workers...
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "The results dict from executing the training iteration.", "docstring_tokens": [ "The", "results", "dict", "from", "executing", "the", "training", "iteration", "." ], "type": null } ...
6727e8cf6693500551fbd509af758b4932cea61b
kisuke95/ray
dashboard/modules/state/state_head.py
[ "Apache-2.0" ]
Python
_options_from_req
ListApiOptions
def _options_from_req(self, req) -> ListApiOptions: """Obtain `ListApiOptions` from the aiohttp request.""" limit = int(req.query.get("limit")) timeout = int(req.query.get("timeout")) return ListApiOptions(limit=limit, timeout=timeout)
Obtain `ListApiOptions` from the aiohttp request.
Obtain `ListApiOptions` from the aiohttp request.
[ "Obtain", "`", "ListApiOptions", "`", "from", "the", "aiohttp", "request", "." ]
def _options_from_req(self, req) -> ListApiOptions: limit = int(req.query.get("limit")) timeout = int(req.query.get("timeout")) return ListApiOptions(limit=limit, timeout=timeout)
[ "def", "_options_from_req", "(", "self", ",", "req", ")", "->", "ListApiOptions", ":", "limit", "=", "int", "(", "req", ".", "query", ".", "get", "(", "\"limit\"", ")", ")", "timeout", "=", "int", "(", "req", ".", "query", ".", "get", "(", "\"timeout...
Obtain `ListApiOptions` from the aiohttp request.
[ "Obtain", "`", "ListApiOptions", "`", "from", "the", "aiohttp", "request", "." ]
[ "\"\"\"Obtain `ListApiOptions` from the aiohttp request.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "req", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "req", "type": null, "docstring": null, "docstring_tokens": []...
9002d0ecaf0196a350fee52fad10cab59aed6e59
kisuke95/ray
python/ray/ml/utils/remote_storage.py
[ "Apache-2.0" ]
Python
fs_hint
str
def fs_hint(uri: str) -> str: """Return a hint how to install required filesystem package""" if pyarrow is None: return "Please make sure PyArrow is installed: `pip install pyarrow`." if fsspec is None: return "Try installing fsspec: `pip install fsspec`." from fsspec.registry import kn...
Return a hint how to install required filesystem package
Return a hint how to install required filesystem package
[ "Return", "a", "hint", "how", "to", "install", "required", "filesystem", "package" ]
def fs_hint(uri: str) -> str: if pyarrow is None: return "Please make sure PyArrow is installed: `pip install pyarrow`." if fsspec is None: return "Try installing fsspec: `pip install fsspec`." from fsspec.registry import known_implementations protocol = urllib.parse.urlparse(uri).scheme...
[ "def", "fs_hint", "(", "uri", ":", "str", ")", "->", "str", ":", "if", "pyarrow", "is", "None", ":", "return", "\"Please make sure PyArrow is installed: `pip install pyarrow`.\"", "if", "fsspec", "is", "None", ":", "return", "\"Try installing fsspec: `pip install fsspec...
Return a hint how to install required filesystem package
[ "Return", "a", "hint", "how", "to", "install", "required", "filesystem", "package" ]
[ "\"\"\"Return a hint how to install required filesystem package\"\"\"" ]
[ { "param": "uri", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uri", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9002d0ecaf0196a350fee52fad10cab59aed6e59
kisuke95/ray
python/ray/ml/utils/remote_storage.py
[ "Apache-2.0" ]
Python
is_non_local_path_uri
bool
def is_non_local_path_uri(uri: str) -> bool: """Check if target URI points to a non-local location""" parsed = urllib.parse.urlparse(uri) if parsed.scheme == "file" or not parsed.scheme: return False if bool(get_fs_and_path(uri)[0]): return True # Keep manual check for prefixes for ...
Check if target URI points to a non-local location
Check if target URI points to a non-local location
[ "Check", "if", "target", "URI", "points", "to", "a", "non", "-", "local", "location" ]
def is_non_local_path_uri(uri: str) -> bool: parsed = urllib.parse.urlparse(uri) if parsed.scheme == "file" or not parsed.scheme: return False if bool(get_fs_and_path(uri)[0]): return True if any(uri.startswith(p) for p in ALLOWED_REMOTE_PREFIXES): return True return False
[ "def", "is_non_local_path_uri", "(", "uri", ":", "str", ")", "->", "bool", ":", "parsed", "=", "urllib", ".", "parse", ".", "urlparse", "(", "uri", ")", "if", "parsed", ".", "scheme", "==", "\"file\"", "or", "not", "parsed", ".", "scheme", ":", "return...
Check if target URI points to a non-local location
[ "Check", "if", "target", "URI", "points", "to", "a", "non", "-", "local", "location" ]
[ "\"\"\"Check if target URI points to a non-local location\"\"\"", "# Keep manual check for prefixes for backwards compatibility with the", "# TrialCheckpoint class. Remove once fully deprecated." ]
[ { "param": "uri", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uri", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9002d0ecaf0196a350fee52fad10cab59aed6e59
kisuke95/ray
python/ray/ml/utils/remote_storage.py
[ "Apache-2.0" ]
Python
_ensure_directory
null
def _ensure_directory(uri: str): """Create directory at remote URI. Some external filesystems require directories to already exist, or at least the `netloc` to be created (e.g. PyArrows ``mock://`` filesystem). Generally this should be done before and outside of Ray applications. This utility is t...
Create directory at remote URI. Some external filesystems require directories to already exist, or at least the `netloc` to be created (e.g. PyArrows ``mock://`` filesystem). Generally this should be done before and outside of Ray applications. This utility is thus primarily used in testing, e.g. of `...
Create directory at remote URI. Some external filesystems require directories to already exist, or at least the `netloc` to be created . Generally this should be done before and outside of Ray applications. This utility is thus primarily used in testing, e.g.
[ "Create", "directory", "at", "remote", "URI", ".", "Some", "external", "filesystems", "require", "directories", "to", "already", "exist", "or", "at", "least", "the", "`", "netloc", "`", "to", "be", "created", ".", "Generally", "this", "should", "be", "done",...
def _ensure_directory(uri: str): fs, path = get_fs_and_path(uri) try: fs.create_dir(path) except Exception: pass
[ "def", "_ensure_directory", "(", "uri", ":", "str", ")", ":", "fs", ",", "path", "=", "get_fs_and_path", "(", "uri", ")", "try", ":", "fs", ".", "create_dir", "(", "path", ")", "except", "Exception", ":", "pass" ]
Create directory at remote URI.
[ "Create", "directory", "at", "remote", "URI", "." ]
[ "\"\"\"Create directory at remote URI.\n\n Some external filesystems require directories to already exist, or at least\n the `netloc` to be created (e.g. PyArrows ``mock://`` filesystem).\n\n Generally this should be done before and outside of Ray applications. This\n utility is thus primarily used in t...
[ { "param": "uri", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "uri", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
90374ece77df704ba7b52bd19bdf62e3a8a56461
kisuke95/ray
python/ray/serve/client.py
[ "Apache-2.0" ]
Python
shutdown
None
def shutdown(self) -> None: """Completely shut down the connected Serve instance. Shuts down all processes and deletes all state associated with the instance. """ if ray.is_initialized() and not self._shutdown: ray.get(self._controller.shutdown.remote()) ...
Completely shut down the connected Serve instance. Shuts down all processes and deletes all state associated with the instance.
Completely shut down the connected Serve instance. Shuts down all processes and deletes all state associated with the instance.
[ "Completely", "shut", "down", "the", "connected", "Serve", "instance", ".", "Shuts", "down", "all", "processes", "and", "deletes", "all", "state", "associated", "with", "the", "instance", "." ]
def shutdown(self) -> None: if ray.is_initialized() and not self._shutdown: ray.get(self._controller.shutdown.remote()) self._wait_for_deployments_shutdown() ray.kill(self._controller, no_restart=True) started = time.time() while True: ...
[ "def", "shutdown", "(", "self", ")", "->", "None", ":", "if", "ray", ".", "is_initialized", "(", ")", "and", "not", "self", ".", "_shutdown", ":", "ray", ".", "get", "(", "self", ".", "_controller", ".", "shutdown", ".", "remote", "(", ")", ")", "s...
Completely shut down the connected Serve instance.
[ "Completely", "shut", "down", "the", "connected", "Serve", "instance", "." ]
[ "\"\"\"Completely shut down the connected Serve instance.\n\n Shuts down all processes and deletes all state associated with the\n instance.\n \"\"\"", "# Wait for the named actor entry gets removed as well.", "# actor name is removed" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
90374ece77df704ba7b52bd19bdf62e3a8a56461
kisuke95/ray
python/ray/serve/client.py
[ "Apache-2.0" ]
Python
_wait_for_deployments_shutdown
null
def _wait_for_deployments_shutdown(self, timeout_s: int = 60): """Waits for all deployments to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s. """ start = time.time() while time.time() - start < timeout_s: statuses = self.get_de...
Waits for all deployments to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s.
Waits for all deployments to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s.
[ "Waits", "for", "all", "deployments", "to", "be", "shut", "down", "and", "deleted", ".", "Raises", "TimeoutError", "if", "this", "doesn", "'", "t", "happen", "before", "timeout_s", "." ]
def _wait_for_deployments_shutdown(self, timeout_s: int = 60): start = time.time() while time.time() - start < timeout_s: statuses = self.get_deployment_statuses() if len(statuses) == 0: break else: logger.debug( f"W...
[ "def", "_wait_for_deployments_shutdown", "(", "self", ",", "timeout_s", ":", "int", "=", "60", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "-", "start", "<", "timeout_s", ":", "statuses", "=", "self", ...
Waits for all deployments to be shut down and deleted.
[ "Waits", "for", "all", "deployments", "to", "be", "shut", "down", "and", "deleted", "." ]
[ "\"\"\"Waits for all deployments to be shut down and deleted.\n\n Raises TimeoutError if this doesn't happen before timeout_s.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "timeout_s", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "timeout_s", "type": "int", "docstring": null, "docstring_toke...
90374ece77df704ba7b52bd19bdf62e3a8a56461
kisuke95/ray
python/ray/serve/client.py
[ "Apache-2.0" ]
Python
_wait_for_deployment_healthy
null
def _wait_for_deployment_healthy(self, name: str, timeout_s: int = -1): """Waits for the named deployment to enter "HEALTHY" status. Raises RuntimeError if the deployment enters the "UNHEALTHY" status instead. Raises TimeoutError if this doesn't happen before timeout_s. """ ...
Waits for the named deployment to enter "HEALTHY" status. Raises RuntimeError if the deployment enters the "UNHEALTHY" status instead. Raises TimeoutError if this doesn't happen before timeout_s.
Waits for the named deployment to enter "HEALTHY" status. Raises RuntimeError if the deployment enters the "UNHEALTHY" status instead. Raises TimeoutError if this doesn't happen before timeout_s.
[ "Waits", "for", "the", "named", "deployment", "to", "enter", "\"", "HEALTHY", "\"", "status", ".", "Raises", "RuntimeError", "if", "the", "deployment", "enters", "the", "\"", "UNHEALTHY", "\"", "status", "instead", ".", "Raises", "TimeoutError", "if", "this", ...
def _wait_for_deployment_healthy(self, name: str, timeout_s: int = -1): start = time.time() while time.time() - start < timeout_s or timeout_s < 0: statuses = self.get_deployment_statuses() try: status = statuses[name] except KeyError: ...
[ "def", "_wait_for_deployment_healthy", "(", "self", ",", "name", ":", "str", ",", "timeout_s", ":", "int", "=", "-", "1", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "-", "start", "<", "timeout_s", ...
Waits for the named deployment to enter "HEALTHY" status.
[ "Waits", "for", "the", "named", "deployment", "to", "enter", "\"", "HEALTHY", "\"", "status", "." ]
[ "\"\"\"Waits for the named deployment to enter \"HEALTHY\" status.\n\n Raises RuntimeError if the deployment enters the \"UNHEALTHY\" status\n instead.\n\n Raises TimeoutError if this doesn't happen before timeout_s.\n \"\"\"", "# Guard against new unhandled statuses being added." ]
[ { "param": "self", "type": null }, { "param": "name", "type": "str" }, { "param": "timeout_s", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "str", "docstring": null, "docstring_tokens": ...
90374ece77df704ba7b52bd19bdf62e3a8a56461
kisuke95/ray
python/ray/serve/client.py
[ "Apache-2.0" ]
Python
_wait_for_deployment_deleted
null
def _wait_for_deployment_deleted(self, name: str, timeout_s: int = 60): """Waits for the named deployment to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s. """ start = time.time() while time.time() - start < timeout_s: statuses...
Waits for the named deployment to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s.
Waits for the named deployment to be shut down and deleted. Raises TimeoutError if this doesn't happen before timeout_s.
[ "Waits", "for", "the", "named", "deployment", "to", "be", "shut", "down", "and", "deleted", ".", "Raises", "TimeoutError", "if", "this", "doesn", "'", "t", "happen", "before", "timeout_s", "." ]
def _wait_for_deployment_deleted(self, name: str, timeout_s: int = 60): start = time.time() while time.time() - start < timeout_s: statuses = self.get_deployment_statuses() if name not in statuses: break else: curr_status = statuses[nam...
[ "def", "_wait_for_deployment_deleted", "(", "self", ",", "name", ":", "str", ",", "timeout_s", ":", "int", "=", "60", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "-", "start", "<", "timeout_s", ":", ...
Waits for the named deployment to be shut down and deleted.
[ "Waits", "for", "the", "named", "deployment", "to", "be", "shut", "down", "and", "deleted", "." ]
[ "\"\"\"Waits for the named deployment to be shut down and deleted.\n\n Raises TimeoutError if this doesn't happen before timeout_s.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "name", "type": "str" }, { "param": "timeout_s", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": "str", "docstring": null, "docstring_tokens": ...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
explained_variance
TensorType
def explained_variance(y: TensorType, pred: TensorType) -> TensorType: """Computes the explained variance for a pair of labels and predictions. The formula used is: max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2)) Args: y: The labels. pred: The predictions. Returns: The expla...
Computes the explained variance for a pair of labels and predictions. The formula used is: max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2)) Args: y: The labels. pred: The predictions. Returns: The explained variance given a pair of labels and predictions.
Computes the explained variance for a pair of labels and predictions.
[ "Computes", "the", "explained", "variance", "for", "a", "pair", "of", "labels", "and", "predictions", "." ]
def explained_variance(y: TensorType, pred: TensorType) -> TensorType: _, y_var = tf.nn.moments(y, axes=[0]) _, diff_var = tf.nn.moments(y - pred, axes=[0]) return tf.maximum(-1.0, 1 - (diff_var / y_var))
[ "def", "explained_variance", "(", "y", ":", "TensorType", ",", "pred", ":", "TensorType", ")", "->", "TensorType", ":", "_", ",", "y_var", "=", "tf", ".", "nn", ".", "moments", "(", "y", ",", "axes", "=", "[", "0", "]", ")", "_", ",", "diff_var", ...
Computes the explained variance for a pair of labels and predictions.
[ "Computes", "the", "explained", "variance", "for", "a", "pair", "of", "labels", "and", "predictions", "." ]
[ "\"\"\"Computes the explained variance for a pair of labels and predictions.\n\n The formula used is:\n max(-1.0, 1.0 - (std(y - pred)^2 / std(y)^2))\n\n Args:\n y: The labels.\n pred: The predictions.\n\n Returns:\n The explained variance given a pair of labels and predictions.\n ...
[ { "param": "y", "type": "TensorType" }, { "param": "pred", "type": "TensorType" } ]
{ "returns": [ { "docstring": "The explained variance given a pair of labels and predictions.", "docstring_tokens": [ "The", "explained", "variance", "given", "a", "pair", "of", "labels", "and", "predictions", "." ...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
flatten_inputs_to_1d_tensor
TensorType
def flatten_inputs_to_1d_tensor( inputs: TensorStructType, spaces_struct: Optional[SpaceStruct] = None, time_axis: bool = False, ) -> TensorType: """Flattens arbitrary input structs according to the given spaces struct. Returns a single 1D tensor resulting from the different input components' v...
Flattens arbitrary input structs according to the given spaces struct. Returns a single 1D tensor resulting from the different input components' values. Thereby: - Boxes (any shape) get flattened to (B, [T]?, -1). Note that image boxes are not treated differently from other types of Boxes and get ...
Flattens arbitrary input structs according to the given spaces struct. Returns a single 1D tensor resulting from the different input components' values. Boxes (any shape) get flattened to (B, [T]?, -1). Note that image boxes are not treated differently from other types of Boxes and get flattened as well. Discrete (int...
[ "Flattens", "arbitrary", "input", "structs", "according", "to", "the", "given", "spaces", "struct", ".", "Returns", "a", "single", "1D", "tensor", "resulting", "from", "the", "different", "input", "components", "'", "values", ".", "Boxes", "(", "any", "shape",...
def flatten_inputs_to_1d_tensor( inputs: TensorStructType, spaces_struct: Optional[SpaceStruct] = None, time_axis: bool = False, ) -> TensorType: flat_inputs = tree.flatten(inputs) flat_spaces = ( tree.flatten(spaces_struct) if spaces_struct is not None else [None] * len(flat...
[ "def", "flatten_inputs_to_1d_tensor", "(", "inputs", ":", "TensorStructType", ",", "spaces_struct", ":", "Optional", "[", "SpaceStruct", "]", "=", "None", ",", "time_axis", ":", "bool", "=", "False", ",", ")", "->", "TensorType", ":", "flat_inputs", "=", "tree...
Flattens arbitrary input structs according to the given spaces struct.
[ "Flattens", "arbitrary", "input", "structs", "according", "to", "the", "given", "spaces", "struct", "." ]
[ "\"\"\"Flattens arbitrary input structs according to the given spaces struct.\n\n Returns a single 1D tensor resulting from the different input\n components' values.\n\n Thereby:\n - Boxes (any shape) get flattened to (B, [T]?, -1). Note that image boxes\n are not treated differently from other types...
[ { "param": "inputs", "type": "TensorStructType" }, { "param": "spaces_struct", "type": "Optional[SpaceStruct]" }, { "param": "time_axis", "type": "bool" } ]
{ "returns": [ { "docstring": "A single 1D tensor resulting from concatenating all\nflattened/one-hot'd input components. Depending on the time_axis flag,\nthe shape is (B, n) or (B, T, n).", "docstring_tokens": [ "A", "single", "1D", "tensor", "resulting", ...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
make_tf_callable
Callable
def make_tf_callable( session_or_none: Optional["tf1.Session"], dynamic_shape: bool = False ) -> Callable: """Returns a function that can be executed in either graph or eager mode. The function must take only positional args. If eager is enabled, this will act as just a function. Otherwise, it wil...
Returns a function that can be executed in either graph or eager mode. The function must take only positional args. If eager is enabled, this will act as just a function. Otherwise, it will build a function that executes a session run with placeholders internally. Args: session_or_none: t...
Returns a function that can be executed in either graph or eager mode. The function must take only positional args. If eager is enabled, this will act as just a function. Otherwise, it will build a function that executes a session run with placeholders internally.
[ "Returns", "a", "function", "that", "can", "be", "executed", "in", "either", "graph", "or", "eager", "mode", ".", "The", "function", "must", "take", "only", "positional", "args", ".", "If", "eager", "is", "enabled", "this", "will", "act", "as", "just", "...
def make_tf_callable( session_or_none: Optional["tf1.Session"], dynamic_shape: bool = False ) -> Callable: if tf.executing_eagerly(): assert session_or_none is None else: assert session_or_none is not None def make_wrapper(fn): if session_or_none is not None: args_pla...
[ "def", "make_tf_callable", "(", "session_or_none", ":", "Optional", "[", "\"tf1.Session\"", "]", ",", "dynamic_shape", ":", "bool", "=", "False", ")", "->", "Callable", ":", "if", "tf", ".", "executing_eagerly", "(", ")", ":", "assert", "session_or_none", "is"...
Returns a function that can be executed in either graph or eager mode.
[ "Returns", "a", "function", "that", "can", "be", "executed", "in", "either", "graph", "or", "eager", "mode", "." ]
[ "\"\"\"Returns a function that can be executed in either graph or eager mode.\n\n The function must take only positional args.\n\n If eager is enabled, this will act as just a function. Otherwise, it\n will build a function that executes a session run with placeholders\n internally.\n\n Args:\n ...
[ { "param": "session_or_none", "type": "Optional[\"tf1.Session\"]" }, { "param": "dynamic_shape", "type": "bool" } ]
{ "returns": [ { "docstring": "A function that can be called in either eager or static-graph mode.", "docstring_tokens": [ "A", "function", "that", "can", "be", "called", "in", "either", "eager", "or", "static", ...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
minimize_and_clip
ModelGradients
def minimize_and_clip( optimizer: LocalOptimizer, objective: TensorType, var_list: List["tf.Variable"], clip_val: float = 10.0, ) -> ModelGradients: """Computes, then clips gradients using objective, optimizer and var list. Ensures the norm of the gradients for each variable is clipped to `...
Computes, then clips gradients using objective, optimizer and var list. Ensures the norm of the gradients for each variable is clipped to `clip_val`. Args: optimizer: Either a shim optimizer (tf eager) containing a tf.GradientTape under `self.tape` or a tf1 local optimizer ...
Computes, then clips gradients using objective, optimizer and var list. Ensures the norm of the gradients for each variable is clipped to `clip_val`.
[ "Computes", "then", "clips", "gradients", "using", "objective", "optimizer", "and", "var", "list", ".", "Ensures", "the", "norm", "of", "the", "gradients", "for", "each", "variable", "is", "clipped", "to", "`", "clip_val", "`", "." ]
def minimize_and_clip( optimizer: LocalOptimizer, objective: TensorType, var_list: List["tf.Variable"], clip_val: float = 10.0, ) -> ModelGradients: assert clip_val is None or clip_val > 0.0, clip_val if tf.executing_eagerly(): tape = optimizer.tape grads_and_vars = list(zip(list...
[ "def", "minimize_and_clip", "(", "optimizer", ":", "LocalOptimizer", ",", "objective", ":", "TensorType", ",", "var_list", ":", "List", "[", "\"tf.Variable\"", "]", ",", "clip_val", ":", "float", "=", "10.0", ",", ")", "->", "ModelGradients", ":", "assert", ...
Computes, then clips gradients using objective, optimizer and var list.
[ "Computes", "then", "clips", "gradients", "using", "objective", "optimizer", "and", "var", "list", "." ]
[ "\"\"\"Computes, then clips gradients using objective, optimizer and var list.\n\n Ensures the norm of the gradients for each variable is clipped to\n `clip_val`.\n\n Args:\n optimizer: Either a shim optimizer (tf eager) containing a\n tf.GradientTape under `self.tape` or a tf1 local opti...
[ { "param": "optimizer", "type": "LocalOptimizer" }, { "param": "objective", "type": "TensorType" }, { "param": "var_list", "type": "List[\"tf.Variable\"]" }, { "param": "clip_val", "type": "float" } ]
{ "returns": [ { "docstring": "The resulting model gradients (list or tuples of grads + vars)\ncorresponding to the input `var_list`.", "docstring_tokens": [ "The", "resulting", "model", "gradients", "(", "list", "or", "tuples", "...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
one_hot
TensorType
def one_hot(x: TensorType, space: gym.Space) -> TensorType: """Returns a one-hot tensor, given and int tensor and a space. Handles the MultiDiscrete case as well. Args: x: The input tensor. space: The space to use for generating the one-hot tensor. Returns: The resulting one-h...
Returns a one-hot tensor, given and int tensor and a space. Handles the MultiDiscrete case as well. Args: x: The input tensor. space: The space to use for generating the one-hot tensor. Returns: The resulting one-hot tensor. Raises: ValueError: If the given space is n...
Returns a one-hot tensor, given and int tensor and a space. Handles the MultiDiscrete case as well.
[ "Returns", "a", "one", "-", "hot", "tensor", "given", "and", "int", "tensor", "and", "a", "space", ".", "Handles", "the", "MultiDiscrete", "case", "as", "well", "." ]
def one_hot(x: TensorType, space: gym.Space) -> TensorType: if isinstance(space, Discrete): return tf.one_hot(x, space.n, dtype=tf.float32) elif isinstance(space, MultiDiscrete): return tf.concat( [ tf.one_hot(x[:, i], n, dtype=tf.float32) for i, n in ...
[ "def", "one_hot", "(", "x", ":", "TensorType", ",", "space", ":", "gym", ".", "Space", ")", "->", "TensorType", ":", "if", "isinstance", "(", "space", ",", "Discrete", ")", ":", "return", "tf", ".", "one_hot", "(", "x", ",", "space", ".", "n", ",",...
Returns a one-hot tensor, given and int tensor and a space.
[ "Returns", "a", "one", "-", "hot", "tensor", "given", "and", "int", "tensor", "and", "a", "space", "." ]
[ "\"\"\"Returns a one-hot tensor, given and int tensor and a space.\n\n Handles the MultiDiscrete case as well.\n\n Args:\n x: The input tensor.\n space: The space to use for generating the one-hot tensor.\n\n Returns:\n The resulting one-hot tensor.\n\n Raises:\n ValueError: ...
[ { "param": "x", "type": "TensorType" }, { "param": "space", "type": "gym.Space" } ]
{ "returns": [ { "docstring": "The resulting one-hot tensor.", "docstring_tokens": [ "The", "resulting", "one", "-", "hot", "tensor", "." ], "type": null } ], "raises": [ { "docstring": "If the given space is not a d...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
scope_vars
List["tf.Variable"]
def scope_vars( scope: Union[str, "tf1.VariableScope"], trainable_only: bool = False ) -> List["tf.Variable"]: """Get variables inside a given scope. Args: scope: Scope in which the variables reside. trainable_only: Whether or not to return only the variables that were marked as...
Get variables inside a given scope. Args: scope: Scope in which the variables reside. trainable_only: Whether or not to return only the variables that were marked as trainable. Returns: The list of variables in the given `scope`.
Get variables inside a given scope.
[ "Get", "variables", "inside", "a", "given", "scope", "." ]
def scope_vars( scope: Union[str, "tf1.VariableScope"], trainable_only: bool = False ) -> List["tf.Variable"]: return tf1.get_collection( tf1.GraphKeys.TRAINABLE_VARIABLES if trainable_only else tf1.GraphKeys.VARIABLES, scope=scope if isinstance(scope, str) else scope.name, )
[ "def", "scope_vars", "(", "scope", ":", "Union", "[", "str", ",", "\"tf1.VariableScope\"", "]", ",", "trainable_only", ":", "bool", "=", "False", ")", "->", "List", "[", "\"tf.Variable\"", "]", ":", "return", "tf1", ".", "get_collection", "(", "tf1", ".", ...
Get variables inside a given scope.
[ "Get", "variables", "inside", "a", "given", "scope", "." ]
[ "\"\"\"Get variables inside a given scope.\n\n Args:\n scope: Scope in which the variables reside.\n trainable_only: Whether or not to return only the variables that were\n marked as trainable.\n\n Returns:\n The list of variables in the given `scope`.\n \"\"\"" ]
[ { "param": "scope", "type": "Union[str, \"tf1.VariableScope\"]" }, { "param": "trainable_only", "type": "bool" } ]
{ "returns": [ { "docstring": "The list of variables in the given `scope`.", "docstring_tokens": [ "The", "list", "of", "variables", "in", "the", "given", "`", "scope", "`", "." ], "type": null } ...
c644f3dc2a721aed08b6bfcf4c896db29d14f509
kisuke95/ray
rllib/utils/tf_utils.py
[ "Apache-2.0" ]
Python
zero_logps_from_actions
TensorType
def zero_logps_from_actions(actions: TensorStructType) -> TensorType: """Helper function useful for returning dummy logp's (0) for some actions. Args: actions: The input actions. This can be any struct of complex action components or a simple tensor of different dimensions, e.g....
Helper function useful for returning dummy logp's (0) for some actions. Args: actions: The input actions. This can be any struct of complex action components or a simple tensor of different dimensions, e.g. [B], [B, 2], or {"a": [B, 4, 5], "b": [B]}. Returns: A 1D tenso...
Helper function useful for returning dummy logp's (0) for some actions.
[ "Helper", "function", "useful", "for", "returning", "dummy", "logp", "'", "s", "(", "0", ")", "for", "some", "actions", "." ]
def zero_logps_from_actions(actions: TensorStructType) -> TensorType: action_component = tree.flatten(actions)[0] logp_ = tf.zeros_like(action_component, dtype=tf.float32) while len(logp_.shape) > 1: logp_ = logp_[:, 0] return logp_
[ "def", "zero_logps_from_actions", "(", "actions", ":", "TensorStructType", ")", "->", "TensorType", ":", "action_component", "=", "tree", ".", "flatten", "(", "actions", ")", "[", "0", "]", "logp_", "=", "tf", ".", "zeros_like", "(", "action_component", ",", ...
Helper function useful for returning dummy logp's (0) for some actions.
[ "Helper", "function", "useful", "for", "returning", "dummy", "logp", "'", "s", "(", "0", ")", "for", "some", "actions", "." ]
[ "\"\"\"Helper function useful for returning dummy logp's (0) for some actions.\n\n Args:\n actions: The input actions. This can be any struct\n of complex action components or a simple tensor of different\n dimensions, e.g. [B], [B, 2], or {\"a\": [B, 4, 5], \"b\": [B]}.\n\n Retur...
[ { "param": "actions", "type": "TensorStructType" } ]
{ "returns": [ { "docstring": "A 1D tensor of 0.0 (dummy logp's) matching the batch\ndim of `actions` (shape=[B]).", "docstring_tokens": [ "A", "1D", "tensor", "of", "0", ".", "0", "(", "dummy", "logp", "'", ...
e5865db357e6cd67a3427854bb1fd24e2781e1a3
kisuke95/ray
python/ray/workflow/common.py
[ "Apache-2.0" ]
Python
from_output
<not_specific>
def from_output(cls, step_id: str, output: Any): """Create static ref from given output.""" if not isinstance(output, cls): if not isinstance(output, ray.ObjectRef): output = ray.put(output) output = cls(step_id=step_id, ref=output) return output
Create static ref from given output.
Create static ref from given output.
[ "Create", "static", "ref", "from", "given", "output", "." ]
def from_output(cls, step_id: str, output: Any): if not isinstance(output, cls): if not isinstance(output, ray.ObjectRef): output = ray.put(output) output = cls(step_id=step_id, ref=output) return output
[ "def", "from_output", "(", "cls", ",", "step_id", ":", "str", ",", "output", ":", "Any", ")", ":", "if", "not", "isinstance", "(", "output", ",", "cls", ")", ":", "if", "not", "isinstance", "(", "output", ",", "ray", ".", "ObjectRef", ")", ":", "ou...
Create static ref from given output.
[ "Create", "static", "ref", "from", "given", "output", "." ]
[ "\"\"\"Create static ref from given output.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "step_id", "type": "str" }, { "param": "output", "type": "Any" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "step_id", "type": "str", "docstring": null, "docstring_tokens"...
e5865db357e6cd67a3427854bb1fd24e2781e1a3
kisuke95/ray
python/ray/workflow/common.py
[ "Apache-2.0" ]
Python
run
Any
def run( self, workflow_id: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, ) -> Any: """Run a workflow. If the workflow with the given id already exists, it will be resumed. Examples: >>> from ray import workflow >>> Flight,...
Run a workflow. If the workflow with the given id already exists, it will be resumed. Examples: >>> from ray import workflow >>> Flight, Reservation, Trip = ... # doctest: +SKIP >>> @workflow.step # doctest: +SKIP ... def book_flight(origin: str, dest: s...
Run a workflow. If the workflow with the given id already exists, it will be resumed.
[ "Run", "a", "workflow", ".", "If", "the", "workflow", "with", "the", "given", "id", "already", "exists", "it", "will", "be", "resumed", "." ]
def run( self, workflow_id: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, ) -> Any: return ray.get(self.run_async(workflow_id, metadata))
[ "def", "run", "(", "self", ",", "workflow_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "metadata", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "Any", ":", "return", "ray", ".", "get", ...
Run a workflow.
[ "Run", "a", "workflow", "." ]
[ "\"\"\"Run a workflow.\n\n If the workflow with the given id already exists, it will be resumed.\n\n Examples:\n >>> from ray import workflow\n >>> Flight, Reservation, Trip = ... # doctest: +SKIP\n >>> @workflow.step # doctest: +SKIP\n ... def book_flight(o...
[ { "param": "self", "type": null }, { "param": "workflow_id", "type": "Optional[str]" }, { "param": "metadata", "type": "Optional[Dict[str, Any]]" } ]
{ "returns": [ { "docstring": "The running result.", "docstring_tokens": [ "The", "running", "result", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstrin...
e5865db357e6cd67a3427854bb1fd24e2781e1a3
kisuke95/ray
python/ray/workflow/common.py
[ "Apache-2.0" ]
Python
run_async
ObjectRef
def run_async( self, workflow_id: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, ) -> ObjectRef: """Run a workflow asynchronously. If the workflow with the given id already exists, it will be resumed. Examples: >>> from ray import workf...
Run a workflow asynchronously. If the workflow with the given id already exists, it will be resumed. Examples: >>> from ray import workflow >>> Flight, Reservation, Trip = ... # doctest: +SKIP >>> @workflow.step # doctest: +SKIP ... def book_flight(origi...
Run a workflow asynchronously. If the workflow with the given id already exists, it will be resumed.
[ "Run", "a", "workflow", "asynchronously", ".", "If", "the", "workflow", "with", "the", "given", "id", "already", "exists", "it", "will", "be", "resumed", "." ]
def run_async( self, workflow_id: Optional[str] = None, metadata: Optional[Dict[str, Any]] = None, ) -> ObjectRef: from ray.workflow.execution import run self._step_id = None return run(self, workflow_id, metadata)
[ "def", "run_async", "(", "self", ",", "workflow_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "metadata", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "ObjectRef", ":", "from", "ray", ".", ...
Run a workflow asynchronously.
[ "Run", "a", "workflow", "asynchronously", "." ]
[ "\"\"\"Run a workflow asynchronously.\n\n If the workflow with the given id already exists, it will be resumed.\n\n Examples:\n >>> from ray import workflow\n >>> Flight, Reservation, Trip = ... # doctest: +SKIP\n >>> @workflow.step # doctest: +SKIP\n ... de...
[ { "param": "self", "type": null }, { "param": "workflow_id", "type": "Optional[str]" }, { "param": "metadata", "type": "Optional[Dict[str, Any]]" } ]
{ "returns": [ { "docstring": "The running result as ray.ObjectRef.", "docstring_tokens": [ "The", "running", "result", "as", "ray", ".", "ObjectRef", "." ], "type": null } ], "raises": [], "params": [ { "i...
8bf6a5c267d25d8d0158ae61fdf26941f5683752
kisuke95/ray
python/ray/tune/tune.py
[ "Apache-2.0" ]
Python
run_experiments
<not_specific>
def run_experiments( experiments: Union[Experiment, Mapping, Sequence[Union[Experiment, Mapping]]], scheduler: Optional[TrialScheduler] = None, server_port: Optional[int] = None, verbose: Union[int, Verbosity] = Verbosity.V3_TRIAL_DETAILS, progress_reporter: Optional[ProgressReporter] = None, re...
Runs and blocks until all trials finish. Example: >>> from ray.tune.experiment import Experiment >>> from ray.tune.tune import run_experiments >>> def my_func(config): return {"score": 0} >>> experiment_spec = Experiment("experiment", my_func) # doctest: +SKIP >>> run_experi...
Runs and blocks until all trials finish.
[ "Runs", "and", "blocks", "until", "all", "trials", "finish", "." ]
def run_experiments( experiments: Union[Experiment, Mapping, Sequence[Union[Experiment, Mapping]]], scheduler: Optional[TrialScheduler] = None, server_port: Optional[int] = None, verbose: Union[int, Verbosity] = Verbosity.V3_TRIAL_DETAILS, progress_reporter: Optional[ProgressReporter] = None, re...
[ "def", "run_experiments", "(", "experiments", ":", "Union", "[", "Experiment", ",", "Mapping", ",", "Sequence", "[", "Union", "[", "Experiment", ",", "Mapping", "]", "]", "]", ",", "scheduler", ":", "Optional", "[", "TrialScheduler", "]", "=", "None", ",",...
Runs and blocks until all trials finish.
[ "Runs", "and", "blocks", "until", "all", "trials", "finish", "." ]
[ "# Deprecated args.", "\"\"\"Runs and blocks until all trials finish.\n\n Example:\n >>> from ray.tune.experiment import Experiment\n >>> from ray.tune.tune import run_experiments\n >>> def my_func(config): return {\"score\": 0}\n >>> experiment_spec = Experiment(\"experiment\", my_...
[ { "param": "experiments", "type": "Union[Experiment, Mapping, Sequence[Union[Experiment, Mapping]]]" }, { "param": "scheduler", "type": "Optional[TrialScheduler]" }, { "param": "server_port", "type": "Optional[int]" }, { "param": "verbose", "type": "Union[int, Verbosity]"...
{ "returns": [ { "docstring": "List of Trial objects, holding data for each executed trial.", "docstring_tokens": [ "List", "of", "Trial", "objects", "holding", "data", "for", "each", "executed", "trial", "." ...
8bf6a5c267d25d8d0158ae61fdf26941f5683752
kisuke95/ray
python/ray/tune/tune.py
[ "Apache-2.0" ]
Python
_ray_auto_init
null
def _ray_auto_init(): """Initialize Ray unless already configured.""" if os.environ.get("TUNE_DISABLE_AUTO_INIT") == "1": logger.info("'TUNE_DISABLE_AUTO_INIT=1' detected.") elif not ray.is_initialized(): logger.info( "Initializing Ray automatically." "For cluster usa...
Initialize Ray unless already configured.
Initialize Ray unless already configured.
[ "Initialize", "Ray", "unless", "already", "configured", "." ]
def _ray_auto_init(): if os.environ.get("TUNE_DISABLE_AUTO_INIT") == "1": logger.info("'TUNE_DISABLE_AUTO_INIT=1' detected.") elif not ray.is_initialized(): logger.info( "Initializing Ray automatically." "For cluster usage or custom Ray initialization, " "call...
[ "def", "_ray_auto_init", "(", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "\"TUNE_DISABLE_AUTO_INIT\"", ")", "==", "\"1\"", ":", "logger", ".", "info", "(", "\"'TUNE_DISABLE_AUTO_INIT=1' detected.\"", ")", "elif", "not", "ray", ".", "is_initialized", ...
Initialize Ray unless already configured.
[ "Initialize", "Ray", "unless", "already", "configured", "." ]
[ "\"\"\"Initialize Ray unless already configured.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
183ae73f437c0b8d47dbaefec115faaa7cf9a838
kisuke95/ray
python/ray/tests/kuberay/utils.py
[ "Apache-2.0" ]
Python
wait_for_crd
<not_specific>
def wait_for_crd(crd_name: str, tries=60, backoff_s=5): """CRD creation can take a bit of time after the client request. This function waits until the crd with the provided name is registered. """ for i in range(tries): get_crd_output = subprocess.check_output(["kubectl", "get", "crd"]).decode()...
CRD creation can take a bit of time after the client request. This function waits until the crd with the provided name is registered.
CRD creation can take a bit of time after the client request. This function waits until the crd with the provided name is registered.
[ "CRD", "creation", "can", "take", "a", "bit", "of", "time", "after", "the", "client", "request", ".", "This", "function", "waits", "until", "the", "crd", "with", "the", "provided", "name", "is", "registered", "." ]
def wait_for_crd(crd_name: str, tries=60, backoff_s=5): for i in range(tries): get_crd_output = subprocess.check_output(["kubectl", "get", "crd"]).decode() if crd_name in get_crd_output: logger.info(f"Confirmed existence of CRD {crd_name}.") return elif i < tries - 1:...
[ "def", "wait_for_crd", "(", "crd_name", ":", "str", ",", "tries", "=", "60", ",", "backoff_s", "=", "5", ")", ":", "for", "i", "in", "range", "(", "tries", ")", ":", "get_crd_output", "=", "subprocess", ".", "check_output", "(", "[", "\"kubectl\"", ","...
CRD creation can take a bit of time after the client request.
[ "CRD", "creation", "can", "take", "a", "bit", "of", "time", "after", "the", "client", "request", "." ]
[ "\"\"\"CRD creation can take a bit of time after the client request.\n This function waits until the crd with the provided name is registered.\n \"\"\"" ]
[ { "param": "crd_name", "type": "str" }, { "param": "tries", "type": null }, { "param": "backoff_s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "crd_name", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tries", "type": null, "docstring": null, "docstring_toke...
183ae73f437c0b8d47dbaefec115faaa7cf9a838
kisuke95/ray
python/ray/tests/kuberay/utils.py
[ "Apache-2.0" ]
Python
wait_for_pods
None
def wait_for_pods(goal_num_pods: int, namespace: str, tries=60, backoff_s=5) -> None: """Wait for the number of pods in the `namespace` to be exactly `num_pods`. Raise an exception after exceeding `tries` attempts with `backoff_s` second waits. """ for i in range(tries): cur_num_pods = _get_nu...
Wait for the number of pods in the `namespace` to be exactly `num_pods`. Raise an exception after exceeding `tries` attempts with `backoff_s` second waits.
Wait for the number of pods in the `namespace` to be exactly `num_pods`. Raise an exception after exceeding `tries` attempts with `backoff_s` second waits.
[ "Wait", "for", "the", "number", "of", "pods", "in", "the", "`", "namespace", "`", "to", "be", "exactly", "`", "num_pods", "`", ".", "Raise", "an", "exception", "after", "exceeding", "`", "tries", "`", "attempts", "with", "`", "backoff_s", "`", "second", ...
def wait_for_pods(goal_num_pods: int, namespace: str, tries=60, backoff_s=5) -> None: for i in range(tries): cur_num_pods = _get_num_pods(namespace) if cur_num_pods == goal_num_pods: logger.info(f"Confirmed {goal_num_pods} pod(s) in namespace {namespace}.") return eli...
[ "def", "wait_for_pods", "(", "goal_num_pods", ":", "int", ",", "namespace", ":", "str", ",", "tries", "=", "60", ",", "backoff_s", "=", "5", ")", "->", "None", ":", "for", "i", "in", "range", "(", "tries", ")", ":", "cur_num_pods", "=", "_get_num_pods"...
Wait for the number of pods in the `namespace` to be exactly `num_pods`.
[ "Wait", "for", "the", "number", "of", "pods", "in", "the", "`", "namespace", "`", "to", "be", "exactly", "`", "num_pods", "`", "." ]
[ "\"\"\"Wait for the number of pods in the `namespace` to be exactly `num_pods`.\n\n Raise an exception after exceeding `tries` attempts with `backoff_s` second waits.\n \"\"\"" ]
[ { "param": "goal_num_pods", "type": "int" }, { "param": "namespace", "type": "str" }, { "param": "tries", "type": null }, { "param": "backoff_s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "goal_num_pods", "type": "int", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namespace", "type": "str", "docstring": null, "docs...
183ae73f437c0b8d47dbaefec115faaa7cf9a838
kisuke95/ray
python/ray/tests/kuberay/utils.py
[ "Apache-2.0" ]
Python
wait_for_pod_to_start
None
def wait_for_pod_to_start( pod_name_filter: str, namespace: str, tries=60, backoff_s=5 ) -> None: """Waits for a pod to have Running status.phase. More precisely, waits until there is a pod with name containing `pod_name_filter` and the pod has Running status.phase.""" for i in range(tries): ...
Waits for a pod to have Running status.phase. More precisely, waits until there is a pod with name containing `pod_name_filter` and the pod has Running status.phase.
Waits for a pod to have Running status.phase. More precisely, waits until there is a pod with name containing `pod_name_filter` and the pod has Running status.phase.
[ "Waits", "for", "a", "pod", "to", "have", "Running", "status", ".", "phase", ".", "More", "precisely", "waits", "until", "there", "is", "a", "pod", "with", "name", "containing", "`", "pod_name_filter", "`", "and", "the", "pod", "has", "Running", "status", ...
def wait_for_pod_to_start( pod_name_filter: str, namespace: str, tries=60, backoff_s=5 ) -> None: for i in range(tries): pod = get_pod(pod_name_filter=pod_name_filter, namespace=namespace) if not pod: continue pod_status = ( subprocess.check_output( ...
[ "def", "wait_for_pod_to_start", "(", "pod_name_filter", ":", "str", ",", "namespace", ":", "str", ",", "tries", "=", "60", ",", "backoff_s", "=", "5", ")", "->", "None", ":", "for", "i", "in", "range", "(", "tries", ")", ":", "pod", "=", "get_pod", "...
Waits for a pod to have Running status.phase.
[ "Waits", "for", "a", "pod", "to", "have", "Running", "status", ".", "phase", "." ]
[ "\"\"\"Waits for a pod to have Running status.phase.\n\n More precisely, waits until there is a pod with name containing `pod_name_filter`\n and the pod has Running status.phase.\"\"\"", "# We didn't get a matching pod.", "# \"not found\" is part of the kubectl output if the pod's not there." ]
[ { "param": "pod_name_filter", "type": "str" }, { "param": "namespace", "type": "str" }, { "param": "tries", "type": null }, { "param": "backoff_s", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pod_name_filter", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namespace", "type": "str", "docstring": null, "do...
183ae73f437c0b8d47dbaefec115faaa7cf9a838
kisuke95/ray
python/ray/tests/kuberay/utils.py
[ "Apache-2.0" ]
Python
wait_for_ray_health
None
def wait_for_ray_health( pod_name_filter: str, namespace: str, tries=60, backoff_s=5, ray_container="ray-head", ) -> None: """Waits until a Ray pod passes `ray health-check`. More precisely, waits until a Ray pod whose name includes the string `pod_name_filter` passes `ray health-check`...
Waits until a Ray pod passes `ray health-check`. More precisely, waits until a Ray pod whose name includes the string `pod_name_filter` passes `ray health-check`. (Ensures Ray has completely started in the pod.) Use case: Wait until there is a Ray head pod with Ray running on it.
Waits until a Ray pod passes `ray health-check`. More precisely, waits until a Ray pod whose name includes the string `pod_name_filter` passes `ray health-check`. (Ensures Ray has completely started in the pod.) Use case: Wait until there is a Ray head pod with Ray running on it.
[ "Waits", "until", "a", "Ray", "pod", "passes", "`", "ray", "health", "-", "check", "`", ".", "More", "precisely", "waits", "until", "a", "Ray", "pod", "whose", "name", "includes", "the", "string", "`", "pod_name_filter", "`", "passes", "`", "ray", "healt...
def wait_for_ray_health( pod_name_filter: str, namespace: str, tries=60, backoff_s=5, ray_container="ray-head", ) -> None: for i in range(tries): try: pod = get_pod(pod_name_filter=pod_name_filter, namespace="default") assert pod, f"Couldn't find a pod matching {p...
[ "def", "wait_for_ray_health", "(", "pod_name_filter", ":", "str", ",", "namespace", ":", "str", ",", "tries", "=", "60", ",", "backoff_s", "=", "5", ",", "ray_container", "=", "\"ray-head\"", ",", ")", "->", "None", ":", "for", "i", "in", "range", "(", ...
Waits until a Ray pod passes `ray health-check`.
[ "Waits", "until", "a", "Ray", "pod", "passes", "`", "ray", "health", "-", "check", "`", "." ]
[ "\"\"\"Waits until a Ray pod passes `ray health-check`.\n\n More precisely, waits until a Ray pod whose name includes the string\n `pod_name_filter` passes `ray health-check`.\n (Ensures Ray has completely started in the pod.)\n\n Use case: Wait until there is a Ray head pod with Ray running on it.\n ...
[ { "param": "pod_name_filter", "type": "str" }, { "param": "namespace", "type": "str" }, { "param": "tries", "type": null }, { "param": "backoff_s", "type": null }, { "param": "ray_container", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pod_name_filter", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namespace", "type": "str", "docstring": null, "do...
183ae73f437c0b8d47dbaefec115faaa7cf9a838
kisuke95/ray
python/ray/tests/kuberay/utils.py
[ "Apache-2.0" ]
Python
kubectl_exec
str
def kubectl_exec( command: List[str], pod: str, namespace: str, container: Optional[str] = None, ) -> str: """kubectl exec the `command` in the given `pod` in the given `namespace`. If a `container` is specified, will specify that container for kubectl. Prints and return kubectl's output as...
kubectl exec the `command` in the given `pod` in the given `namespace`. If a `container` is specified, will specify that container for kubectl. Prints and return kubectl's output as a string.
Prints and return kubectl's output as a string.
[ "Prints", "and", "return", "kubectl", "'", "s", "output", "as", "a", "string", "." ]
def kubectl_exec( command: List[str], pod: str, namespace: str, container: Optional[str] = None, ) -> str: container_option = ["-c", container] if container else [] kubectl_exec_command = ( ["kubectl", "exec", "-it", pod] + container_option + ["--"] + command ) out = subprocess.c...
[ "def", "kubectl_exec", "(", "command", ":", "List", "[", "str", "]", ",", "pod", ":", "str", ",", "namespace", ":", "str", ",", "container", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "str", ":", "container_option", "=", "[", "\...
kubectl exec the `command` in the given `pod` in the given `namespace`.
[ "kubectl", "exec", "the", "`", "command", "`", "in", "the", "given", "`", "pod", "`", "in", "the", "given", "`", "namespace", "`", "." ]
[ "\"\"\"kubectl exec the `command` in the given `pod` in the given `namespace`.\n If a `container` is specified, will specify that container for kubectl.\n\n Prints and return kubectl's output as a string.\n \"\"\"", "# Print for debugging convenience." ]
[ { "param": "command", "type": "List[str]" }, { "param": "pod", "type": "str" }, { "param": "namespace", "type": "str" }, { "param": "container", "type": "Optional[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "command", "type": "List[str]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pod", "type": "str", "docstring": null, "docstring_...
df0d953c7d46beec063613326818e024cd061fe2
kisuke95/ray
dashboard/state_aggregator.py
[ "Apache-2.0" ]
Python
list_actors
dict
async def list_actors(self, *, option: ListApiOptions) -> dict: """List all actor information from the cluster. Returns: {actor_id -> actor_data_in_dict} actor_data_in_dict's schema is in ActorState """ reply = await self._client.get_all_actor_info(timeout=option...
List all actor information from the cluster. Returns: {actor_id -> actor_data_in_dict} actor_data_in_dict's schema is in ActorState
List all actor information from the cluster.
[ "List", "all", "actor", "information", "from", "the", "cluster", "." ]
async def list_actors(self, *, option: ListApiOptions) -> dict: reply = await self._client.get_all_actor_info(timeout=option.timeout) result = [] for message in reply.actor_table_data: data = self._message_to_dict(message=message, fields_to_decode=["actor_id"]) data = fil...
[ "async", "def", "list_actors", "(", "self", ",", "*", ",", "option", ":", "ListApiOptions", ")", "->", "dict", ":", "reply", "=", "await", "self", ".", "_client", ".", "get_all_actor_info", "(", "timeout", "=", "option", ".", "timeout", ")", "result", "=...
List all actor information from the cluster.
[ "List", "all", "actor", "information", "from", "the", "cluster", "." ]
[ "\"\"\"List all actor information from the cluster.\n\n Returns:\n {actor_id -> actor_data_in_dict}\n actor_data_in_dict's schema is in ActorState\n \"\"\"", "# Sort to make the output deterministic." ]
[ { "param": "self", "type": null }, { "param": "option", "type": "ListApiOptions" } ]
{ "returns": [ { "docstring": "{actor_id -> actor_data_in_dict}\nactor_data_in_dict's schema is in ActorState", "docstring_tokens": [ "{", "actor_id", "-", ">", "actor_data_in_dict", "}", "actor_data_in_dict", "'", "s", "s...
df0d953c7d46beec063613326818e024cd061fe2
kisuke95/ray
dashboard/state_aggregator.py
[ "Apache-2.0" ]
Python
list_placement_groups
dict
async def list_placement_groups(self, *, option: ListApiOptions) -> dict: """List all placement group information from the cluster. Returns: {pg_id -> pg_data_in_dict} pg_data_in_dict's schema is in PlacementGroupState """ reply = await self._client.get_all_place...
List all placement group information from the cluster. Returns: {pg_id -> pg_data_in_dict} pg_data_in_dict's schema is in PlacementGroupState
List all placement group information from the cluster.
[ "List", "all", "placement", "group", "information", "from", "the", "cluster", "." ]
async def list_placement_groups(self, *, option: ListApiOptions) -> dict: reply = await self._client.get_all_placement_group_info(timeout=option.timeout) result = [] for message in reply.placement_group_table_data: data = self._message_to_dict( message=message, ...
[ "async", "def", "list_placement_groups", "(", "self", ",", "*", ",", "option", ":", "ListApiOptions", ")", "->", "dict", ":", "reply", "=", "await", "self", ".", "_client", ".", "get_all_placement_group_info", "(", "timeout", "=", "option", ".", "timeout", "...
List all placement group information from the cluster.
[ "List", "all", "placement", "group", "information", "from", "the", "cluster", "." ]
[ "\"\"\"List all placement group information from the cluster.\n\n Returns:\n {pg_id -> pg_data_in_dict}\n pg_data_in_dict's schema is in PlacementGroupState\n \"\"\"", "# Sort to make the output deterministic." ]
[ { "param": "self", "type": null }, { "param": "option", "type": "ListApiOptions" } ]
{ "returns": [ { "docstring": "{pg_id -> pg_data_in_dict}\npg_data_in_dict's schema is in PlacementGroupState", "docstring_tokens": [ "{", "pg_id", "-", ">", "pg_data_in_dict", "}", "pg_data_in_dict", "'", "s", "schema", ...