id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
11,100 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.EnvironmentSetupError | from ray_release.result import ExitCode
class EnvironmentSetupError(ReleaseTestError):
exit_code = ExitCode.CLUSTER_STARTUP_ERROR |
class EnvironmentSetupError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,101 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.FetchResultError | from ray_release.result import ExitCode
class FetchResultError(FileManagerError):
exit_code = ExitCode.FETCH_RESULT_ERROR |
class FetchResultError(FileManagerError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,102 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.FileDownloadError | class FileDownloadError(FileManagerError):
pass | class FileDownloadError(FileManagerError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 6 | 0 | 0 |
11,103 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.FileManagerError | class FileManagerError(ReleaseTestError):
pass | class FileManagerError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 5 | 0 | 0 |
11,104 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.FileUploadError | class FileUploadError(FileManagerError):
pass | class FileUploadError(FileManagerError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 6 | 0 | 0 |
11,105 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobBrokenError | from ray_release.result import ExitCode
class JobBrokenError(ReleaseTestError):
exit_code = ExitCode.ANYSCALE_ERROR |
class JobBrokenError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,106 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobNoLogsError | from ray_release.result import ExitCode
class JobNoLogsError(ReleaseTestError):
exit_code = ExitCode.ANYSCALE_ERROR |
class JobNoLogsError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,107 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobOutOfRetriesError | from ray_release.result import ExitCode
class JobOutOfRetriesError(ReleaseTestError):
exit_code = ExitCode.ANYSCALE_ERROR |
class JobOutOfRetriesError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,108 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobStartupFailed | class JobStartupFailed(ClusterStartupFailed):
pass | class JobStartupFailed(ClusterStartupFailed):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 7 | 0 | 0 |
11,109 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobStartupTimeout | class JobStartupTimeout(ClusterStartupTimeout):
pass | class JobStartupTimeout(ClusterStartupTimeout):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 7 | 0 | 0 |
11,110 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobTerminatedBeforeStartError | from ray_release.result import ExitCode
class JobTerminatedBeforeStartError(ReleaseTestError):
exit_code = ExitCode.CLUSTER_STARTUP_TIMEOUT |
class JobTerminatedBeforeStartError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,111 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.JobTerminatedError | from ray_release.result import ExitCode
class JobTerminatedError(ReleaseTestError):
exit_code = ExitCode.ANYSCALE_ERROR |
class JobTerminatedError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,112 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.LocalEnvSetupError | from ray_release.result import ExitCode
class LocalEnvSetupError(EnvironmentSetupError):
exit_code = ExitCode.LOCAL_ENV_SETUP_ERROR |
class LocalEnvSetupError(EnvironmentSetupError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,113 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.LogsError | class LogsError(CommandError):
pass | class LogsError(CommandError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 6 | 0 | 0 |
11,114 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.PrepareCommandError | from ray_release.result import ExitCode
class PrepareCommandError(CommandError):
exit_code = ExitCode.PREPARE_ERROR |
class PrepareCommandError(CommandError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,115 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.PrepareCommandTimeout | from ray_release.result import ExitCode
class PrepareCommandTimeout(CommandTimeout):
exit_code = ExitCode.CLUSTER_WAIT_TIMEOUT |
class PrepareCommandTimeout(CommandTimeout):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,116 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.RayWheelsError | from ray_release.result import ExitCode
class RayWheelsError(ReleaseTestError):
exit_code = ExitCode.CLI_ERROR |
class RayWheelsError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 5 | 0 | 0 |
11,117 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.RayWheelsTimeoutError | from ray_release.result import ExitCode
class RayWheelsTimeoutError(RayWheelsError):
exit_code = ExitCode.RAY_WHEELS_TIMEOUT |
class RayWheelsTimeoutError(RayWheelsError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,118 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.RayWheelsUnspecifiedError | from ray_release.result import ExitCode
class RayWheelsUnspecifiedError(RayWheelsError):
exit_code = ExitCode.CLI_ERROR |
class RayWheelsUnspecifiedError(RayWheelsError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,119 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ReleaseTestCLIError | from ray_release.result import ExitCode
class ReleaseTestCLIError(ReleaseTestPackageError):
exit_code = ExitCode.CLI_ERROR |
class ReleaseTestCLIError(ReleaseTestPackageError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,120 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ReleaseTestConfigError | from ray_release.result import ExitCode
class ReleaseTestConfigError(ReleaseTestPackageError):
exit_code = ExitCode.CONFIG_ERROR |
class ReleaseTestConfigError(ReleaseTestPackageError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,121 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ReleaseTestError | from ray_release.result import ExitCode
class ReleaseTestError(RuntimeError):
exit_code = ExitCode.UNSPECIFIED |
class ReleaseTestError(RuntimeError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 13 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 4 | 0 | 0 |
11,122 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ReleaseTestPackageError | class ReleaseTestPackageError(ReleaseTestError):
pass | class ReleaseTestPackageError(ReleaseTestError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 3 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 5 | 0 | 0 |
11,123 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ReleaseTestSetupError | from ray_release.result import ExitCode
class ReleaseTestSetupError(ReleaseTestPackageError):
exit_code = ExitCode.SETUP_ERROR |
class ReleaseTestSetupError(ReleaseTestPackageError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,124 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.RemoteEnvSetupError | from ray_release.result import ExitCode
class RemoteEnvSetupError(EnvironmentSetupError):
exit_code = ExitCode.REMOTE_ENV_SETUP_ERROR |
class RemoteEnvSetupError(EnvironmentSetupError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,125 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.ResultsAlert | from ray_release.result import ExitCode
class ResultsAlert(CommandError):
exit_code = ExitCode.COMMAND_ALERT |
class ResultsAlert(CommandError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,126 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.TestCommandError | from ray_release.result import ExitCode
class TestCommandError(CommandError):
exit_code = ExitCode.COMMAND_ERROR |
class TestCommandError(CommandError):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,127 | ray-project/ray | release/ray_release/exception.py | release.ray_release.exception.TestCommandTimeout | from ray_release.result import ExitCode
class TestCommandTimeout(CommandTimeout):
exit_code = ExitCode.COMMAND_TIMEOUT |
class TestCommandTimeout(CommandTimeout):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 11 | 2 | 0 | 2 | 2 | 1 | 0 | 2 | 2 | 1 | 0 | 6 | 0 | 0 |
11,128 | ray-project/ray | release/ray_release/file_manager/file_manager.py | release.ray_release.file_manager.file_manager.FileManager | import abc
from typing import Optional
from ray_release.cluster_manager.cluster_manager import ClusterManager
class FileManager(abc.ABC):
def __init__(self, cluster_manager: ClusterManager):
self.cluster_manager = cluster_manager
def upload(self, source: Optional[str]=None, target: Optional[str]=None... |
class FileManager(abc.ABC):
def __init__(self, cluster_manager: ClusterManager):
pass
def upload(self, source: Optional[str]=None, target: Optional[str]=None):
'''Upload source to target.
Infers target dir from basename if not stated.
'''
pass
def download(self, s... | 4 | 2 | 4 | 0 | 2 | 1 | 1 | 0.57 | 1 | 3 | 1 | 3 | 3 | 1 | 3 | 23 | 14 | 3 | 7 | 5 | 3 | 4 | 7 | 5 | 3 | 1 | 4 | 0 | 3 |
11,129 | ray-project/ray | release/ray_release/file_manager/job_file_manager.py | release.ray_release.file_manager.job_file_manager.JobFileManager | import os
from ray_release.job_manager import JobManager
import tempfile
from ray_release.aws import RELEASE_AWS_BUCKET
from ray_release.util import exponential_backoff_retry, generate_tmp_cloud_storage_path, S3_CLOUD_STORAGE, GS_CLOUD_STORAGE, GS_BUCKET
from ray_release.exception import FileDownloadError, FileUploadEr... |
class JobFileManager(FileManager):
def __init__(self, cluster_manager: ClusterManager):
pass
def _run_with_retry(self, f, initial_retry_delay_s: int=10):
pass
def _generate_tmp_cloud_storage_path(self):
pass
def download_from_cloud(self, key: str, target: str, delete_after_d... | 12 | 0 | 17 | 1 | 15 | 1 | 3 | 0.06 | 1 | 10 | 4 | 0 | 10 | 6 | 10 | 33 | 185 | 22 | 154 | 40 | 139 | 9 | 89 | 36 | 76 | 4 | 5 | 2 | 29 |
11,130 | ray-project/ray | release/ray_release/file_manager/remote_task.py | release.ray_release.file_manager.remote_task.RemoteTaskFileManager | from ray_release.file_manager.file_manager import FileManager
from typing import Optional
class RemoteTaskFileManager(FileManager):
def upload(self, source: Optional[str]=None, target: Optional[str]=None):
send_dir_to_head(source, target)
def download(self, source: str, target: str):
fetch_di... |
class RemoteTaskFileManager(FileManager):
def upload(self, source: Optional[str]=None, target: Optional[str]=None):
pass
def download(self, source: str, target: str):
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 2 | 0 | 2 | 25 | 6 | 1 | 5 | 3 | 2 | 0 | 5 | 3 | 2 | 1 | 5 | 0 | 2 |
11,131 | ray-project/ray | release/ray_release/job_manager/anyscale_job_manager.py | release.ray_release.job_manager.anyscale_job_manager.AnyscaleJobManager | import anyscale
from ray_release.exception import CommandTimeout, JobStartupTimeout, JobStartupFailed
from ray_release.signal_handling import register_handler, unregister_handler
from contextlib import contextmanager
from ray_release.util import exponential_backoff_retry, anyscale_job_url, format_link
from ray_release.... |
class AnyscaleJobManager:
def __init__(self, cluster_manager: ClusterManager):
pass
def _run_job(self, cmd_to_run: str, env_vars: Dict[str, Any], working_dir: Optional[str]=None, upload_path: Optional[str]=None, pip: Optional[List[str]]=None) -> None:
pass
@property
def sdk(self):
... | 26 | 2 | 15 | 1 | 12 | 1 | 2 | 0.08 | 0 | 12 | 4 | 0 | 16 | 7 | 16 | 16 | 269 | 36 | 215 | 66 | 174 | 18 | 132 | 42 | 114 | 9 | 0 | 4 | 40 |
11,132 | ray-project/ray | release/ray_release/job_manager/job_manager.py | release.ray_release.job_manager.job_manager.JobManager | import time
from ray_release.util import ANYSCALE_HOST, exponential_backoff_retry
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple
import os
from ray_release.logger import logger
from ray_release.exception import CommandTimeout
from ray_release.cluster_manager.cluster_manager import ClusterManager
class Jo... |
class JobManager:
def __init__(self, cluster_manager: ClusterManager):
pass
def _get_job_client(self) -> 'JobSubmissionClient':
pass
def _run_job(self, cmd_to_run: str, env_vars: Dict[str, Any], working_dir: Optional[str]=None) -> int:
pass
def _get_job_status_with_retry(sel... | 8 | 0 | 14 | 1 | 12 | 1 | 2 | 0.06 | 0 | 10 | 4 | 0 | 7 | 6 | 7 | 7 | 105 | 14 | 88 | 43 | 67 | 5 | 61 | 32 | 51 | 6 | 0 | 2 | 14 |
11,133 | ray-project/ray | release/ray_release/log_aggregator.py | release.ray_release.log_aggregator.LogAggregator | from typing import List
import re
class LogAggregator:
def __init__(self, log: str):
self.log = log
def compute_crash_pattern(self) -> str:
stack_trace = LogAggregator._compute_stack_trace(self.log.splitlines())
return LogAggregator._compute_signature(stack_trace)[:4000]
@staticm... |
class LogAggregator:
def __init__(self, log: str):
pass
def compute_crash_pattern(self) -> str:
pass
@staticmethod
def _compute_signature(stack_trace: List[str]) -> str:
'''
Compute signature pattern from stack trace, by remove factors such as date,
time, temp ... | 7 | 2 | 23 | 1 | 13 | 9 | 4 | 0.63 | 0 | 1 | 0 | 0 | 2 | 1 | 4 | 4 | 97 | 6 | 56 | 17 | 49 | 35 | 51 | 15 | 46 | 11 | 0 | 3 | 17 |
11,134 | ray-project/ray | release/ray_release/reporter/artifacts.py | release.ray_release.reporter.artifacts.ArtifactsReporter | from ray_release.logger import logger
from ray_release.reporter.reporter import Reporter
from ray_release.result import Result
from ray_release.test import Test
import os
import gzip
import json
class ArtifactsReporter(Reporter):
"""This is called on on buildkite runners."""
def __init__(self, artifacts_dir: ... |
class ArtifactsReporter(Reporter):
'''This is called on on buildkite runners.'''
def __init__(self, artifacts_dir: str=DEFAULT_ARTIFACTS_DIR):
pass
def report_result(self, test: Test, result: Result):
pass | 3 | 1 | 14 | 3 | 12 | 0 | 2 | 0.04 | 1 | 3 | 2 | 0 | 2 | 1 | 2 | 4 | 32 | 7 | 24 | 10 | 21 | 1 | 20 | 9 | 17 | 3 | 1 | 2 | 4 |
11,135 | ray-project/ray | release/ray_release/reporter/db.py | release.ray_release.reporter.db.DBReporter | import time
from ray_release.reporter.reporter import Reporter
from ray_release.test import Test
from ray_release.log_aggregator import LogAggregator
import os
from botocore.config import Config
from ray_release.result import Result
import boto3
from ray_release.logger import logger
import json
class DBReporter(Report... |
class DBReporter(Reporter):
def __init__(self):
pass
def report_result(self, test: Test, result: Result):
pass | 3 | 0 | 23 | 2 | 20 | 1 | 2 | 0.05 | 1 | 5 | 3 | 0 | 2 | 1 | 2 | 4 | 48 | 5 | 41 | 5 | 38 | 2 | 13 | 5 | 10 | 2 | 1 | 1 | 3 |
11,136 | ray-project/ray | release/ray_release/reporter/log.py | release.ray_release.reporter.log.LogReporter | from ray_release.logger import logger
from ray_release.reporter.reporter import Reporter
from ray_release.result import Result
from ray_release.test import Test
from ray_release.util import format_link
class LogReporter(Reporter):
def report_result(self, test: Test, result: Result):
logger.info(f"Test {te... |
class LogReporter(Reporter):
def report_result(self, test: Test, result: Result):
pass | 2 | 0 | 33 | 4 | 29 | 0 | 5 | 0 | 1 | 2 | 2 | 0 | 1 | 0 | 1 | 3 | 34 | 4 | 30 | 5 | 28 | 0 | 16 | 5 | 14 | 5 | 1 | 2 | 5 |
11,137 | ray-project/ray | release/ray_release/reporter/reporter.py | release.ray_release.reporter.reporter.Reporter | from ray_release.logger import logger
from ray_release.test import Test
from ray_release.result import Result
class Reporter:
"""Reporter interface"""
def report_result(self, test: Test, result: Result):
try:
self.report_result(test, result)
except Exception as e:
logge... |
class Reporter:
'''Reporter interface'''
def report_result(self, test: Test, result: Result):
pass
def report_result_ex(self, test: Test, result: Result):
pass | 3 | 1 | 4 | 0 | 4 | 0 | 2 | 0.13 | 0 | 5 | 2 | 5 | 2 | 0 | 2 | 2 | 11 | 2 | 8 | 4 | 5 | 1 | 8 | 3 | 5 | 2 | 0 | 1 | 3 |
11,138 | ray-project/ray | release/ray_release/result.py | release.ray_release.result.ExitCode | import enum
class ExitCode(enum.Enum):
SUCCESS = 0
UNCAUGHT = 1
UNSPECIFIED = 2
UNKNOWN = 3
CLI_ERROR = 10
CONFIG_ERROR = 11
SETUP_ERROR = 12
CLUSTER_RESOURCE_ERROR = 13
CLUSTER_ENV_BUILD_ERROR = 14
CLUSTER_STARTUP_ERROR = 15
LOCAL_ENV_SETUP_ERROR = 16
REMOTE_ENV_SETUP_E... |
class ExitCode(enum.Enum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0.3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 32 | 4 | 23 | 23 | 22 | 7 | 23 | 23 | 22 | 0 | 4 | 0 | 0 |
11,139 | ray-project/ray | release/ray_release/result.py | release.ray_release.result.Result | from typing import Optional, Dict, Tuple
from dataclasses import dataclass
@dataclass
class Result:
results: Optional[Dict] = None
status: str = ResultStatus.UNKNOWN.value
return_code: int = 0
last_logs: Optional[str] = None
runtime: Optional[float] = None
stable: bool = True
smoke_test: bo... | @dataclass
class Result:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0.06 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 24 | 6 | 17 | 17 | 16 | 1 | 17 | 17 | 16 | 0 | 0 | 0 | 0 |
11,140 | ray-project/ray | release/ray_release/result.py | release.ray_release.result.ResultStatus | import enum
class ResultStatus(enum.Enum):
"""
Overall status of the result test run
"""
SUCCESS = 'success'
UNKNOWN = 'unknown'
RUNTIME_ERROR = 'runtime_error'
TRANSIENT_INFRA_ERROR = 'transient_infra_error'
INFRA_ERROR = 'infra_error'
INFRA_TIMEOUT = 'infra_timeout'
ERROR = 'e... |
class ResultStatus(enum.Enum):
'''
Overall status of the result test run
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 13 | 1 | 9 | 9 | 8 | 3 | 9 | 9 | 8 | 0 | 4 | 0 | 0 |
11,141 | ray-project/ray | release/ray_release/template.py | release.ray_release.template.TestEnvironment | class TestEnvironment(dict):
pass | class TestEnvironment(dict):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 27 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
11,142 | ray-project/ray | release/ray_release/util.py | release.ray_release.util.DeferredEnvVar | from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
import os
class DeferredEnvVar:
def __init__(self, var: str, default: Optional[str]=None):
self._var = var
self._default = default
def __str__(self):
return os.environ.get(self._var, self._default) |
class DeferredEnvVar:
def __init__(self, var: str, default: Optional[str]=None):
pass
def __str__(self):
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 2 | 2 | 2 | 2 | 7 | 1 | 6 | 5 | 3 | 0 | 6 | 5 | 3 | 1 | 0 | 0 | 2 |
11,143 | ray-project/ray | doc/source/rllib/doc_code/replay_buffer_demo.py | replay_buffer_demo.LessSampledReplayBuffer | from ray.rllib.utils.annotations import override
from ray.rllib.utils.replay_buffers import ReplayBuffer, StorageUnit
import random
from ray.rllib.utils.typing import SampleBatchType
from typing import Optional
import numpy as np
class LessSampledReplayBuffer(ReplayBuffer):
@override(ReplayBuffer)
def sample(... |
class LessSampledReplayBuffer(ReplayBuffer):
@override(ReplayBuffer)
def sample(self, num_items: int, evict_sampled_more_then: int=30, **kwargs) -> Optional[SampleBatchType]:
'''Evicts experiences that have been sampled > evict_sampled_more_then times.'''
pass | 3 | 1 | 19 | 3 | 15 | 1 | 2 | 0.06 | 1 | 5 | 0 | 0 | 1 | 1 | 1 | 1 | 21 | 3 | 17 | 10 | 12 | 1 | 10 | 7 | 8 | 2 | 1 | 1 | 2 |
11,144 | ray-project/ray | doc/source/serve/doc_code/fault_tolerance/replica_health_check.py | replica_health_check.MyDeployment | from ray import serve
@serve.deployment(health_check_period_s=10, health_check_timeout_s=30)
class MyDeployment:
def __init__(self, db_addr: str):
self._my_db_connection = connect_to_db(db_addr)
def __call__(self, request):
return self._do_something_cool()
def check_health(self):
... | @serve.deployment(health_check_period_s=10, health_check_timeout_s=30)
class MyDeployment:
def __init__(self, db_addr: str):
pass
def __call__(self, request):
pass
def check_health(self):
pass | 5 | 0 | 3 | 0 | 2 | 0 | 1 | 0.25 | 0 | 2 | 0 | 0 | 3 | 1 | 3 | 3 | 12 | 2 | 8 | 5 | 4 | 2 | 8 | 5 | 4 | 2 | 0 | 1 | 4 |
11,145 | ray-project/ray | doc/source/serve/doc_code/monitoring/request_id.py | request_id.Model | from ray import serve
@serve.deployment
class Model:
def __call__(self) -> int:
return 1 | @serve.deployment
class Model:
def __call__(self) -> int:
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,146 | ray-project/ray | doc/source/serve/doc_code/resnet50_example.py | resnet50_example.Model | from io import BytesIO
from ray import serve
from torchvision import transforms
from PIL import Image
import starlette.requests
import torch
import torchvision.models as models
import requests
from torchvision.models import ResNet50_Weights
@serve.deployment(ray_actor_options={'num_cpus': 1}, num_replicas='auto')
clas... | @serve.deployment(ray_actor_options={'num_cpus': 1}, num_replicas='auto')
class Model:
def __init__(self):
pass
async def __call__(self, request: starlette.requests.Request) -> str:
pass | 4 | 0 | 15 | 1 | 14 | 1 | 1 | 0.03 | 0 | 1 | 0 | 0 | 2 | 3 | 2 | 2 | 32 | 2 | 29 | 14 | 26 | 1 | 16 | 14 | 13 | 1 | 0 | 1 | 2 |
11,147 | ray-project/ray | release/serve_tests/workloads/resnet_50.py | resnet_50.Model | import starlette.requests
from concurrent.futures import ThreadPoolExecutor, TimeoutError
from torchvision.models import ResNet50_Weights
import torch
from io import BytesIO
from ray import serve
from PIL import Image
import PIL
import requests
from torchvision import transforms
import torchvision.models as models
@se... | @serve.deployment
class Model:
def __init__(self):
pass
async def __call__(self, request: starlette.requests.Request) -> str:
pass
def run_model():
pass | 5 | 0 | 21 | 2 | 20 | 1 | 3 | 0.03 | 0 | 1 | 0 | 0 | 2 | 4 | 2 | 2 | 44 | 4 | 40 | 16 | 37 | 1 | 24 | 15 | 21 | 3 | 0 | 1 | 5 |
11,148 | ray-project/ray | doc/source/ray-core/doc_code/resources.py | resources.Actor | import ray
@ray.remote(num_cpus=0, num_gpus=1)
class Actor:
pass | @ray.remote(num_cpus=0, num_gpus=1)
class Actor:
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
11,149 | ray-project/ray | doc/source/ray-core/doc_code/resources.py | resources.IOActor | import ray
@ray.remote(num_gpus=0.5)
class IOActor:
def ping(self):
import os
print(f"CUDA_VISIBLE_DEVICES: {os.environ['CUDA_VISIBLE_DEVICES']}") | @ray.remote(num_gpus=0.5)
class IOActor:
def ping(self):
pass | 3 | 0 | 4 | 1 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 5 | 1 | 4 | 3 | 1 | 0 | 4 | 3 | 1 | 1 | 0 | 0 | 1 |
11,150 | ray-project/ray | doc/source/serve/doc_code/model_composition/response_to_object_ref_example.py | response_to_object_ref_example.Ingress | from ray import serve
import ray
from ray.serve.handle import DeploymentHandle, DeploymentResponse
@serve.deployment
class Ingress:
def __init__(self, say_hi: DeploymentHandle):
self._say_hi = say_hi
async def __call__(self):
response: DeploymentResponse = self._say_hi.remote()
respon... | @serve.deployment
class Ingress:
def __init__(self, say_hi: DeploymentHandle):
pass
async def __call__(self):
pass | 4 | 0 | 5 | 0 | 4 | 1 | 1 | 0.25 | 0 | 2 | 2 | 0 | 2 | 1 | 2 | 2 | 11 | 1 | 8 | 7 | 5 | 2 | 8 | 7 | 5 | 1 | 0 | 0 | 2 |
11,151 | ray-project/ray | doc/source/serve/doc_code/model_composition/response_to_object_ref_example.py | response_to_object_ref_example.SayHi | from ray import serve
@serve.deployment
class SayHi:
def __call__(self) -> str:
return 'Hi from Serve deployment' | @serve.deployment
class SayHi:
def __call__(self) -> str:
pass | 3 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 3 | 0 | 3 | 2 | 1 | 0 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
11,152 | ray-project/ray | rllib/algorithms/algorithm.py | rllib.algorithms.algorithm.Algorithm | import importlib
from ray.rllib.core.rl_module.rl_module import RLModule, RLModuleSpec
import gymnasium as gym
from ray.rllib.core.rl_module import validate_module_id
from ray.rllib.utils.annotations import DeveloperAPI, ExperimentalAPI, OldAPIStack, override, OverrideToImplementCustomLogic, OverrideToImplementCustomLo... | @PublicAPI
class Algorithm(Checkpointable, Trainable):
'''An RLlib algorithm responsible for training one or more neural network models.
You can write your own Algorithm classes by sub-classing from `Algorithm`
or any of its built-in subclasses.
Override the `training_step` method to implement your own ... | 158 | 43 | 48 | 4 | 32 | 12 | 5 | 0.36 | 3 | 33 | 9 | 0 | 53 | 16 | 64 | 65 | 3,832 | 398 | 2,528 | 567 | 2,186 | 913 | 1,117 | 321 | 1,034 | 32 | 1 | 4 | 383 |
11,153 | ray-project/ray | rllib/algorithms/algorithm.py | rllib.algorithms.algorithm.TrainIterCtx | import time
from ray.rllib.utils.metrics import AGGREGATOR_ACTOR_RESULTS, ALL_MODULES, DATASET_NUM_ITERS_EVALUATED, ENV_RUNNER_RESULTS, ENV_RUNNER_SAMPLING_TIMER, EPISODE_LEN_MEAN, EPISODE_RETURN_MEAN, EVALUATION_ITERATION_TIMER, EVALUATION_RESULTS, FAULT_TOLERANCE_STATS, LEARNER_RESULTS, LEARNER_UPDATE_TIMER, NUM_AGEN... |
class TrainIterCtx:
def __init__(self, algo: Algorithm):
pass
def __enter__(self):
pass
def __exit__(self, *args):
pass
def get_time_taken_sec(self) -> float:
'''Returns the time we spent in the context in seconds.'''
pass
def should_stop(self, results):... | 6 | 1 | 26 | 1 | 23 | 2 | 2 | 0.1 | 0 | 3 | 1 | 0 | 5 | 11 | 5 | 5 | 134 | 7 | 115 | 20 | 109 | 12 | 48 | 20 | 42 | 7 | 0 | 2 | 12 |
11,154 | ray-project/ray | rllib/algorithms/algorithm_config.py | rllib.algorithms.algorithm_config.AlgorithmConfig | from typing import Any, Callable, Collection, Dict, List, Optional, Tuple, Type, TYPE_CHECKING, Union
from ray.rllib.env.multi_agent_env import MultiAgentEnv
from ray.rllib.utils.test_utils import check
import sys
from ray.rllib.env import INPUT_ENV_SPACES, INPUT_ENV_SINGLE_SPACES
import math
from ray.rllib.utils.seria... | null | 215 | 68 | 42 | 3 | 24 | 15 | 5 | 0.62 | 1 | 18 | 2 | 0 | 121 | 226 | 128 | 149 | 5,630 | 459 | 3,198 | 904 | 2,580 | 1,997 | 1,617 | 459 | 1,472 | 47 | 5 | 7 | 648 |
11,155 | ray-project/ray | rllib/algorithms/algorithm_config.py | rllib.algorithms.algorithm_config.TorchCompileWhatToCompile | from enum import Enum
class TorchCompileWhatToCompile(str, Enum):
"""Enumerates schemes of what parts of the TorchLearner can be compiled.
This can be either the entire update step of the learner or only the forward
methods (and therein the forward_train method) of the RLModule.
.. note::
- t... |
class TorchCompileWhatToCompile(str, Enum):
'''Enumerates schemes of what parts of the TorchLearner can be compiled.
This can be either the entire update step of the learner or only the forward
methods (and therein the forward_train method) of the RLModule.
.. note::
- torch.compiled code can b... | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 5.33 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 115 | 22 | 3 | 3 | 3 | 2 | 16 | 3 | 3 | 2 | 0 | 4 | 0 | 0 |
11,156 | ray-project/ray | rllib/algorithms/appo/appo.py | rllib.algorithms.appo.appo.APPO | from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
from ray.rllib.utils.annotations import override
from typing import Optional, Type
from ray.rllib.algorithms.impala.impala import IMPALA, IMPALAConfig
from ray.rllib.utils.metrics import LEARNER_STATS_KEY
from ray.rllib.policy.policy import ... |
class APPO(IMPALA):
def __init__(self, config, *args, **kwargs):
'''Initializes an APPO instance.'''
pass
@override(IMPALA)
def training_step(self) -> None:
pass
def update(pi, pi_id):
pass
@classmethod
@override(IMPALA)
... | 11 | 1 | 19 | 2 | 14 | 3 | 3 | 0.19 | 1 | 3 | 1 | 0 | 2 | 0 | 4 | 4 | 89 | 14 | 63 | 19 | 47 | 12 | 38 | 14 | 29 | 5 | 1 | 2 | 14 |
11,157 | ray-project/ray | rllib/algorithms/appo/appo.py | rllib.algorithms.appo.appo.APPOConfig | from typing_extensions import Self
from typing import Optional, Type
from ray.rllib.algorithms.impala.impala import IMPALA, IMPALAConfig
from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
from ray._common.deprecation import DEPRECATED_VALUE, deprecation_warning
from ray.rllib.core.rl_module.... |
class APPOConfig(IMPALAConfig):
'''Defines a configuration class from which an APPO Algorithm can be built.
.. testcode::
from ray.rllib.algorithms.appo import APPOConfig
config = (
APPOConfig()
.training(lr=0.01, grad_clip=30.0, train_batch_size_per_learner=50)
... | 13 | 3 | 41 | 3 | 27 | 14 | 5 | 0.71 | 1 | 6 | 1 | 0 | 6 | 36 | 6 | 6 | 305 | 30 | 166 | 72 | 129 | 118 | 91 | 44 | 82 | 15 | 1 | 2 | 27 |
11,158 | ray-project/ray | rllib/algorithms/appo/appo_learner.py | rllib.algorithms.appo.appo_learner.APPOLearner | from ray.rllib.utils.lambda_defaultdict import LambdaDefaultDict
from ray.rllib.utils.annotations import override
from typing import Any, Dict, Optional
from ray.rllib.core.learner.learner import Learner
from ray.rllib.algorithms.appo.appo import APPOConfig
from ray.rllib.core.rl_module.rl_module import RLModuleSpec
fr... |
class APPOLearner(IMPALALearner):
'''Adds KL coeff updates via `after_gradient_based_update()` to IMPALA logic.
Framework-specific subclasses must override `_update_module_kl_coeff()`.
'''
@override(IMPALALearner)
def build(self):
pass
@override(Learner)
def add_module(self, *, ... | 14 | 3 | 17 | 1 | 13 | 3 | 2 | 0.26 | 1 | 5 | 0 | 0 | 5 | 2 | 6 | 6 | 121 | 15 | 84 | 30 | 63 | 22 | 31 | 16 | 24 | 5 | 1 | 3 | 11 |
11,159 | ray-project/ray | rllib/algorithms/appo/appo_torch_policy.py | rllib.algorithms.appo.appo_torch_policy.APPOTorchPolicy | from ray.rllib.models.torch.torch_modelv2 import TorchModelV2
from ray.rllib.models.modelv2 import ModelV2
from ray.rllib.algorithms.impala.impala_torch_policy import make_time_major, VTraceOptimizer
from ray.rllib.policy.torch_policy_v2 import TorchPolicyV2
import gymnasium as gym
import ray.rllib.algorithms.impala.vt... |
class APPOTorchPolicy(VTraceOptimizer, LearningRateSchedule, EntropyCoeffSchedule, KLCoeffMixin, ValueNetworkMixin, TargetNetworkMixin, TorchPolicyV2):
'''PyTorch policy class used with APPO.'''
def __init__(self, observation_space, action_space, config):
pass
@override(TorchPolicyV2)
def init... | 20 | 3 | 30 | 4 | 22 | 4 | 2 | 0.18 | 7 | 6 | 0 | 0 | 9 | 2 | 9 | 9 | 355 | 56 | 254 | 92 | 208 | 45 | 130 | 58 | 118 | 11 | 1 | 2 | 26 |
11,160 | ray-project/ray | rllib/algorithms/appo/default_appo_rl_module.py | rllib.algorithms.appo.default_appo_rl_module.DefaultAPPORLModule | from ray.rllib.algorithms.ppo.default_ppo_rl_module import DefaultPPORLModule
from ray.util.annotations import DeveloperAPI
from ray.rllib.core.rl_module.apis import TARGET_NETWORK_ACTION_DIST_INPUTS, TargetNetworkAPI
from ray.rllib.core.models.base import ACTOR, ENCODER_OUT
from ray.rllib.utils.typing import NetworkTy... | @DeveloperAPI
class DefaultAPPORLModule(DefaultPPORLModule, TargetNetworkAPI, abc.ABC):
'''Default RLModule used by APPO, if user does not specify a custom RLModule.
Users who want to train their RLModules with APPO may implement any RLModule
(or TorchRLModule) subclass as long as the custom class also impl... | 11 | 1 | 5 | 0 | 4 | 1 | 1 | 0.45 | 3 | 3 | 0 | 0 | 4 | 2 | 4 | 24 | 37 | 5 | 22 | 14 | 12 | 10 | 14 | 10 | 9 | 1 | 4 | 0 | 4 |
11,161 | ray-project/ray | rllib/algorithms/appo/torch/appo_torch_learner.py | rllib.algorithms.appo.torch.appo_torch_learner.APPOTorchLearner | from ray.rllib.utils.annotations import override
from ray.rllib.utils.numpy import convert_to_numpy
from typing import Dict
from ray.rllib.utils.typing import ModuleID, TensorType
from ray.rllib.core.rl_module.apis import TARGET_NETWORK_ACTION_DIST_INPUTS, TargetNetworkAPI, ValueFunctionAPI
from ray.rllib.algorithms.ap... |
class APPOTorchLearner(APPOLearner, IMPALATorchLearner):
'''Implements APPO loss / update logic on top of IMPALATorchLearner.'''
@override(IMPALATorchLearner)
def compute_loss_for_module(self, *, module_id: ModuleID, config: APPOConfig, batch: Dict, fwd_out: Dict[str, TensorType]) -> TensorType:
pa... | 5 | 1 | 95 | 9 | 75 | 13 | 3 | 0.18 | 2 | 2 | 0 | 0 | 2 | 0 | 2 | 2 | 195 | 19 | 152 | 46 | 140 | 27 | 49 | 37 | 46 | 3 | 1 | 1 | 5 |
11,162 | ray-project/ray | rllib/algorithms/appo/torch/default_appo_torch_rl_module.py | rllib.algorithms.appo.torch.default_appo_torch_rl_module.DefaultAPPOTorchRLModule | from ray.rllib.algorithms.appo.default_appo_rl_module import DefaultAPPORLModule
from ray.util.annotations import DeveloperAPI
from ray.rllib.algorithms.ppo.torch.default_ppo_torch_rl_module import DefaultPPOTorchRLModule
@DeveloperAPI
class DefaultAPPOTorchRLModule(DefaultPPOTorchRLModule, DefaultAPPORLModule):
p... | @DeveloperAPI
class DefaultAPPOTorchRLModule(DefaultPPOTorchRLModule, DefaultAPPORLModule):
pass | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 1 | 0 | 0 |
11,163 | ray-project/ray | rllib/algorithms/appo/utils.py | rllib.algorithms.appo.utils.CircularBuffer | import threading
from collections import deque
import numpy as np
import time
class CircularBuffer:
"""A circular batch-wise buffer as described in [1] for APPO.
The buffer holds at most N batches, which are sampled at random (uniformly).
If full and a new batch is added, the oldest batch is discarded. Al... |
class CircularBuffer:
'''A circular batch-wise buffer as described in [1] for APPO.
The buffer holds at most N batches, which are sampled at random (uniformly).
If full and a new batch is added, the oldest batch is discarded. Also, each batch
currently in the buffer can be sampled at most K times (afte... | 7 | 3 | 16 | 2 | 10 | 3 | 3 | 0.43 | 0 | 1 | 0 | 0 | 4 | 5 | 4 | 4 | 74 | 14 | 42 | 14 | 37 | 18 | 40 | 14 | 35 | 5 | 0 | 2 | 10 |
11,164 | ray-project/ray | rllib/algorithms/bc/bc.py | rllib.algorithms.bc.bc.BC | from ray.rllib.utils.annotations import override
from ray.rllib.algorithms.marwil.marwil import MARWIL, MARWILConfig
class BC(MARWIL):
"""Behavioral Cloning (derived from MARWIL).
Uses MARWIL with beta force-set to 0.0.
"""
@classmethod
@override(MARWIL)
def get_default_config(cls) -> BCConfi... |
class BC(MARWIL):
'''Behavioral Cloning (derived from MARWIL).
Uses MARWIL with beta force-set to 0.0.
'''
@classmethod
@override(MARWIL)
def get_default_config(cls) -> BCConfig:
pass | 4 | 1 | 2 | 0 | 2 | 0 | 1 | 0.6 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 1 | 10 | 2 | 5 | 3 | 1 | 3 | 3 | 2 | 1 | 1 | 1 | 0 | 1 |
11,165 | ray-project/ray | rllib/algorithms/bc/bc.py | rllib.algorithms.bc.bc.BCConfig | from ray.rllib.algorithms.marwil.marwil import MARWIL, MARWILConfig
from ray.rllib.utils.annotations import override
from ray.rllib.utils.typing import RLModuleSpecType
from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
from ray.rllib.core.rl_module.rl_module import RLModuleSpec
class BCConfig(MARWILCon... |
class BCConfig(MARWILConfig):
'''Defines a configuration class from which a new BC Algorithm can be built
.. testcode::
:skipif: True
from ray.rllib.algorithms.bc import BCConfig
# Run this from the ray directory root.
config = BCConfig().training(lr=0.00001, gamma=0.99)
... | 8 | 1 | 13 | 2 | 9 | 2 | 2 | 1.21 | 1 | 3 | 1 | 0 | 4 | 4 | 4 | 4 | 101 | 15 | 39 | 21 | 23 | 47 | 21 | 11 | 15 | 2 | 1 | 1 | 6 |
11,166 | ray-project/ray | rllib/algorithms/bc/bc_catalog.py | rllib.algorithms.bc.bc_catalog.BCCatalog | from ray.rllib.core.models.configs import FreeLogStdMLPHeadConfig, MLPHeadConfig
import gymnasium as gym
from ray.rllib.algorithms.ppo.ppo_catalog import _check_if_diag_gaussian
from ray.rllib.utils.annotations import OverrideToImplementCustomLogic
from ray.rllib.core.models.base import Model
from ray.rllib.core.models... |
class BCCatalog(Catalog):
'''The Catalog class used to build models for BC.
BCCatalog provides the following models:
- Encoder: The encoder used to encode the observations.
- Pi Head: The head used for the policy logits.
The default encoder is chosen by RLlib dependent on the observation sp... | 4 | 3 | 38 | 4 | 23 | 11 | 2 | 0.81 | 1 | 3 | 0 | 0 | 2 | 5 | 2 | 2 | 99 | 14 | 47 | 18 | 38 | 38 | 16 | 10 | 13 | 3 | 1 | 1 | 4 |
11,167 | ray-project/ray | rllib/algorithms/bc/torch/default_bc_torch_rl_module.py | rllib.algorithms.bc.torch.default_bc_torch_rl_module.DefaultBCTorchRLModule | from typing import Any, Dict
from ray.rllib.core.rl_module.rl_module import RLModule
from ray.rllib.core.columns import Columns
from ray.util.annotations import DeveloperAPI
from ray.rllib.core.rl_module.torch.torch_rl_module import TorchRLModule
from ray.rllib.core.models.base import ENCODER_OUT
import abc
from ray.rl... | null | 7 | 2 | 6 | 0 | 5 | 1 | 1 | 0.59 | 2 | 3 | 0 | 0 | 3 | 2 | 3 | 23 | 32 | 5 | 17 | 10 | 11 | 10 | 13 | 8 | 9 | 2 | 4 | 1 | 4 |
11,168 | ray-project/ray | rllib/algorithms/cql/cql.py | rllib.algorithms.cql.cql.CQL | from typing import Optional, Type, Union
from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
from ray.rllib.execution.train_ops import multi_gpu_train_one_step, train_one_step
from ray.rllib.utils.metrics import LEARNER_RESULTS, LEARNER_UPDATE_TIMER, LAST_TARGET_UPDATE_TS, NUM_AGENT_STEPS_SAM... |
class CQL(SAC):
'''CQL (derived from SAC).'''
@classmethod
@override(SAC)
def get_default_config(cls) -> CQLConfig:
pass
@classmethod
@override(SAC)
def get_default_policy_class(cls, config: AlgorithmConfig) -> Optional[Type[Policy]]:
pass
@override(SAC)
def training... | 11 | 1 | 21 | 2 | 14 | 5 | 3 | 0.3 | 1 | 2 | 1 | 0 | 2 | 0 | 4 | 4 | 95 | 12 | 64 | 19 | 51 | 19 | 38 | 13 | 33 | 5 | 1 | 2 | 11 |
11,169 | ray-project/ray | rllib/algorithms/cql/cql.py | rllib.algorithms.cql.cql.CQLConfig | from ray.rllib.algorithms.sac.sac import SAC, SACConfig
from ray.rllib.utils.framework import try_import_tf, try_import_tfp
from ray.rllib.core.rl_module.rl_module import RLModuleSpec
from typing import Optional, Type, Union
from ray.rllib.utils.annotations import OldAPIStack, override
from ray._common.deprecation impo... |
class CQLConfig(SACConfig):
'''Defines a configuration class from which a CQL can be built.
.. testcode::
:skipif: True
from ray.rllib.algorithms.cql import CQLConfig
config = CQLConfig().training(gamma=0.9, lr=0.01)
config = config.resources(num_gpus=0)
config = config.... | 16 | 2 | 25 | 3 | 17 | 5 | 3 | 0.36 | 1 | 7 | 1 | 0 | 8 | 17 | 8 | 8 | 226 | 32 | 143 | 55 | 106 | 51 | 71 | 29 | 59 | 8 | 1 | 2 | 25 |
11,170 | ray-project/ray | rllib/algorithms/cql/cql_tf_policy.py | rllib.algorithms.cql.cql_tf_policy.ActorCriticOptimizerMixin | from ray.rllib.algorithms.sac.sac_tf_policy import apply_gradients as sac_apply_gradients, compute_and_clip_gradients as sac_compute_and_clip_gradients, get_distribution_inputs_and_class, _get_dist_class, build_sac_model, postprocess_trajectory, setup_late_mixins, stats, validate_spaces, ActorCriticOptimizerMixin as SA... |
class ActorCriticOptimizerMixin(SACActorCriticOptimizerMixin):
def __init__(self, config):
pass | 2 | 0 | 13 | 0 | 11 | 2 | 3 | 0.17 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 14 | 0 | 12 | 3 | 10 | 2 | 7 | 3 | 5 | 3 | 1 | 2 | 3 |
11,171 | ray-project/ray | rllib/algorithms/cql/torch/cql_torch_learner.py | rllib.algorithms.cql.torch.cql_torch_learner.CQLTorchLearner | from typing import Dict
from ray.rllib.utils.annotations import override
from ray.rllib.utils.typing import ModuleID, ParamDict, TensorType
from ray.rllib.core.learner.learner import POLICY_LOSS_KEY
from ray.rllib.algorithms.sac.sac_learner import LOGPS_KEY, QF_LOSS_KEY, QF_MEAN_KEY, QF_MAX_KEY, QF_MIN_KEY, QF_PREDS, Q... |
class CQLTorchLearner(SACTorchLearner):
@override(SACTorchLearner)
def compute_loss_for_module(self, *, module_id: ModuleID, config: CQLConfig, batch: Dict, fwd_out: Dict[str, TensorType]) -> TensorType:
pass
@override(SACTorchLearner)
def compute_gradients(self, loss_per_module: Dict[ModuleID... | 5 | 0 | 122 | 11 | 79 | 34 | 7 | 0.42 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 2 | 247 | 22 | 160 | 39 | 146 | 68 | 51 | 28 | 48 | 9 | 1 | 2 | 14 |
11,172 | ray-project/ray | rllib/algorithms/cql/torch/default_cql_torch_rl_module.py | rllib.algorithms.cql.torch.default_cql_torch_rl_module.DefaultCQLTorchRLModule | from ray.rllib.algorithms.sac.sac_learner import QF_PREDS, QF_TWIN_PREDS
from ray.rllib.algorithms.sac.torch.default_sac_torch_rl_module import DefaultSACTorchRLModule
from ray.rllib.utils.annotations import override
import tree
from ray.rllib.core.models.base import ENCODER_OUT
from ray.rllib.utils.typing import Tenso... |
class DefaultCQLTorchRLModule(DefaultSACTorchRLModule):
def __init__(self, *args, **kwargs):
pass
@override(DefaultSACTorchRLModule)
def _forward_train(self, batch: Dict) -> Dict[str, Any]:
pass
def _repeat_tensor(self, tensor: TensorType, repeat: int) -> TensorType:
'''Genera... | 6 | 2 | 45 | 3 | 26 | 16 | 3 | 0.59 | 1 | 5 | 0 | 0 | 4 | 0 | 4 | 4 | 186 | 16 | 107 | 28 | 99 | 63 | 52 | 25 | 47 | 4 | 1 | 1 | 10 |
11,173 | ray-project/ray | rllib/algorithms/dqn/default_dqn_rl_module.py | rllib.algorithms.dqn.default_dqn_rl_module.DefaultDQNRLModule | from ray.rllib.core.rl_module.apis import QNetAPI, InferenceOnlyAPI, TargetNetworkAPI
import abc
from ray.rllib.core.rl_module.rl_module import RLModule
from ray.rllib.core.learner.utils import make_target_network
from typing import Any, Dict, List, Tuple, Union
from ray.rllib.utils.typing import NetworkType, TensorTyp... | @DeveloperAPI
class DefaultDQNRLModule(RLModule, InferenceOnlyAPI, TargetNetworkAPI, QNetAPI):
@override(RLModule)
def setup(self):
pass
@override(InferenceOnlyAPI)
def get_non_inference_attributes(self) -> List[str]:
pass
@override(TargetNetworkAPI)
def make_target_networks(sel... | 19 | 3 | 13 | 1 | 7 | 5 | 2 | 0.58 | 4 | 6 | 0 | 0 | 12 | 12 | 12 | 12 | 178 | 22 | 99 | 42 | 68 | 57 | 39 | 25 | 26 | 3 | 1 | 1 | 22 |
11,174 | ray-project/ray | rllib/algorithms/dqn/distributional_q_tf_model.py | rllib.algorithms.dqn.distributional_q_tf_model.DistributionalQTFModel | from ray.rllib.models.tf.tf_modelv2 import TFModelV2
from typing import List
from ray.rllib.models.tf.layers import NoisyLayer
from ray.rllib.utils.typing import ModelConfigDict, TensorType
from ray.rllib.utils.annotations import OldAPIStack
import gymnasium as gym
@OldAPIStack
class DistributionalQTFModel(TFModelV2):... | @OldAPIStack
class DistributionalQTFModel(TFModelV2):
'''Extension of standard TFModel to provide distributional Q values.
It also supports options for noisy nets and parameter space noise.
Data flow:
obs -> forward() -> model_out
model_out -> get_q_value_distributions() -> Q(s, a) atoms
... | 8 | 4 | 43 | 3 | 33 | 7 | 3 | 0.44 | 1 | 6 | 0 | 0 | 3 | 3 | 3 | 3 | 175 | 20 | 108 | 40 | 86 | 47 | 53 | 25 | 46 | 8 | 1 | 3 | 18 |
11,175 | ray-project/ray | rllib/algorithms/dqn/dqn.py | rllib.algorithms.dqn.dqn.DQN | from collections import defaultdict
from ray.rllib.utils.replay_buffers.utils import sample_min_n_steps_from_buffer
from ray.rllib.algorithms.dqn.dqn_torch_policy import DQNTorchPolicy
from ray.rllib.utils.typing import ResultDict
from ray.rllib.execution.train_ops import train_one_step, multi_gpu_train_one_step
from r... |
class DQN(Algorithm):
@classmethod
@override(Algorithm)
def get_default_config(cls) -> DQNConfig:
pass
@classmethod
@override(Algorithm)
def get_default_policy_class(cls, config: AlgorithmConfig) -> Optional[Type[Policy]]:
pass
@override(Algorithm)
def setup(self, confi... | 13 | 2 | 49 | 5 | 33 | 10 | 4 | 0.31 | 1 | 5 | 1 | 0 | 3 | 4 | 5 | 5 | 253 | 31 | 170 | 35 | 157 | 52 | 73 | 26 | 67 | 9 | 1 | 6 | 22 |
11,176 | ray-project/ray | rllib/algorithms/dqn/dqn.py | rllib.algorithms.dqn.dqn.DQNConfig | from ray.rllib.utils.annotations import override
from typing_extensions import Self
from ray.rllib.utils import deep_update
from ray.rllib.utils.replay_buffers.utils import update_priorities_in_episode_replay_buffer, update_priorities_in_replay_buffer, validate_buffer_config
from ray.rllib.policy.sample_batch import Mu... |
class DQNConfig(AlgorithmConfig):
'''Defines a configuration class from which a DQN Algorithm can be built.
.. testcode::
from ray.rllib.algorithms.dqn.dqn import DQNConfig
config = (
DQNConfig()
.environment("CartPole-v1")
.training(replay_buffer_config={
... | 15 | 3 | 61 | 3 | 37 | 21 | 6 | 0.69 | 1 | 11 | 1 | 0 | 7 | 38 | 7 | 7 | 491 | 41 | 267 | 92 | 213 | 184 | 130 | 50 | 119 | 24 | 1 | 3 | 45 |
11,177 | ray-project/ray | rllib/algorithms/dqn/dqn_catalog.py | rllib.algorithms.dqn.dqn_catalog.DQNCatalog | from ray.rllib.core.models.catalog import Catalog
from ray.rllib.utils.annotations import ExperimentalAPI, override, OverrideToImplementCustomLogic
from ray.rllib.core.distribution.torch.torch_distribution import TorchCategorical
from ray.rllib.core.models.base import Model
import gymnasium as gym
from ray.rllib.core.m... | @ExperimentalAPI
class DQNCatalog(Catalog):
'''The catalog class used to build models for DQN Rainbow.
`DQNCatalog` provides the following models:
- Encoder: The encoder used to encode the observations.
- Target_Encoder: The encoder used to encode the observations
for the target netw... | 11 | 5 | 26 | 3 | 12 | 10 | 1 | 1.1 | 1 | 6 | 0 | 0 | 5 | 4 | 5 | 5 | 165 | 24 | 67 | 20 | 51 | 74 | 17 | 9 | 11 | 2 | 1 | 1 | 6 |
11,178 | ray-project/ray | rllib/algorithms/dqn/dqn_learner.py | rllib.algorithms.dqn.dqn_learner.DQNLearner | from typing import Any, Dict, Optional
from ray.rllib.core.rl_module.multi_rl_module import MultiRLModuleSpec
from ray.rllib.core.rl_module.rl_module import RLModuleSpec
from ray.rllib.utils.typing import ModuleID, ShouldModuleBeUpdatedFn
from ray.rllib.connectors.common.add_observations_from_episodes_to_batch import A... |
class DQNLearner(Learner):
@OverrideToImplementCustomLogic_CallToSuperRecommended
@override(Learner)
def build(self) -> None:
pass
@override(Learner)
def add_module(self, *, module_id: ModuleID, module_spec: RLModuleSpec, config_overrides: Optional[Dict]=None, new_should_module_be_updated:... | 11 | 1 | 17 | 1 | 14 | 3 | 2 | 0.18 | 1 | 5 | 0 | 0 | 3 | 0 | 4 | 4 | 79 | 7 | 61 | 23 | 43 | 11 | 23 | 11 | 18 | 4 | 1 | 3 | 8 |
11,179 | ray-project/ray | rllib/algorithms/dqn/dqn_tf_policy.py | rllib.algorithms.dqn.dqn_tf_policy.ComputeTDErrorMixin | from ray.rllib.policy.sample_batch import SampleBatch
from ray.rllib.utils.tf_utils import huber_loss, l2_loss, make_tf_callable, minimize_and_clip, reduce_mean_ignore_inf
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class ComputeTDErrorMixin:
"""Assign the `compute_td_error` method to the DQNT... | @OldAPIStack
class ComputeTDErrorMixin:
'''Assign the `compute_td_error` method to the DQNTFPolicy
This allows us to prioritize on the worker side.
'''
def __init__(self):
pass
@make_tf_callable(self.get_session(), dynamic_shape=True)
def compute_td_error(obs_t, act_t, rew_t, ob... | 5 | 1 | 21 | 2 | 19 | 1 | 1 | 0.19 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 29 | 4 | 21 | 7 | 15 | 4 | 6 | 4 | 3 | 1 | 0 | 0 | 2 |
11,180 | ray-project/ray | rllib/algorithms/dqn/dqn_tf_policy.py | rllib.algorithms.dqn.dqn_tf_policy.QLoss | from ray.rllib.utils.typing import AlgorithmConfigDict, ModelGradients, TensorType
from ray.rllib.utils.tf_utils import huber_loss, l2_loss, make_tf_callable, minimize_and_clip, reduce_mean_ignore_inf
from ray.rllib.utils.annotations import OldAPIStack
@OldAPIStack
class QLoss:
def __init__(self, q_t_selected: Te... | @OldAPIStack
class QLoss:
def __init__(self, q_t_selected: TensorType, q_logits_t_selected: TensorType, q_tp1_best: TensorType, q_dist_tp1_best: TensorType, importance_weights: TensorType, rewards: TensorType, done_mask: TensorType, gamma: float=0.99, n_step: int=1, num_atoms: int=1, v_min: float=-10.0, v_max: flo... | 3 | 0 | 77 | 7 | 60 | 12 | 2 | 0.2 | 0 | 2 | 0 | 0 | 1 | 3 | 1 | 1 | 78 | 7 | 61 | 33 | 44 | 12 | 26 | 18 | 24 | 2 | 0 | 1 | 2 |
11,181 | ray-project/ray | rllib/algorithms/dqn/dqn_torch_model.py | rllib.algorithms.dqn.dqn_torch_model.DQNTorchModel | import gymnasium as gym
from ray.rllib.utils.typing import ModelConfigDict
from ray.rllib.models.torch.modules.noisy_layer import NoisyLayer
from typing import Sequence
from ray.rllib.utils.annotations import OldAPIStack
from ray.rllib.models.torch.misc import SlimFC
from ray.rllib.models.torch.torch_modelv2 import Tor... | @OldAPIStack
class DQNTorchModel(TorchModelV2, nn.Module):
'''Extension of standard TorchModelV2 to provide dueling-Q functionality.'''
def __init__(self, obs_space: gym.spaces.Space, action_space: gym.spaces.Space, num_outputs: int, model_config: ModelConfigDict, name: str, *, q_hiddens: Sequence[int]=(256,),... | 5 | 4 | 52 | 4 | 34 | 13 | 4 | 0.38 | 2 | 6 | 0 | 0 | 3 | 7 | 3 | 3 | 160 | 16 | 104 | 38 | 83 | 40 | 46 | 21 | 42 | 9 | 1 | 3 | 12 |
11,182 | ray-project/ray | rllib/algorithms/dqn/dqn_torch_policy.py | rllib.algorithms.dqn.dqn_torch_policy.ComputeTDErrorMixin | from ray.rllib.algorithms.dqn.dqn_tf_policy import PRIO_WEIGHTS, Q_SCOPE, Q_TARGET_SCOPE, postprocess_nstep_and_prio
from ray.rllib.utils.annotations import OldAPIStack
from ray.rllib.policy.sample_batch import SampleBatch
@OldAPIStack
class ComputeTDErrorMixin:
"""Assign the `compute_td_error` method to the DQNTo... | @OldAPIStack
class ComputeTDErrorMixin:
'''Assign the `compute_td_error` method to the DQNTorchPolicy
This allows us to prioritize on the worker side.
'''
def __init__(self):
pass
def compute_td_error(obs_t, act_t, rew_t, obs_tp1, terminateds_mask, importance_weights):
... | 4 | 1 | 16 | 3 | 12 | 1 | 1 | 0.29 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 23 | 5 | 14 | 7 | 9 | 4 | 12 | 5 | 9 | 1 | 0 | 0 | 2 |
11,183 | ray-project/ray | rllib/algorithms/dqn/dqn_torch_policy.py | rllib.algorithms.dqn.dqn_torch_policy.QLoss | from ray.rllib.utils.typing import TensorType, AlgorithmConfigDict
from ray.rllib.utils.annotations import OldAPIStack
from ray.rllib.utils.torch_utils import apply_grad_clipping, concat_multi_gpu_td_errors, FLOAT_MIN, huber_loss, l2_loss, reduce_mean_ignore_inf, softmax_cross_entropy_with_logits
@OldAPIStack
class QL... | @OldAPIStack
class QLoss:
def __init__(self, q_t_selected: TensorType, q_logits_t_selected: TensorType, q_tp1_best: TensorType, q_probs_tp1_best: TensorType, importance_weights: TensorType, rewards: TensorType, done_mask: TensorType, gamma=0.99, n_step=1, num_atoms=1, v_min=-10.0, v_max=10.0, loss_fn=huber_loss):
... | 3 | 0 | 69 | 7 | 50 | 12 | 2 | 0.24 | 0 | 1 | 0 | 0 | 1 | 3 | 1 | 1 | 70 | 7 | 51 | 33 | 34 | 12 | 26 | 18 | 24 | 2 | 0 | 1 | 2 |
11,184 | ray-project/ray | rllib/algorithms/dqn/torch/default_dqn_torch_rl_module.py | rllib.algorithms.dqn.torch.default_dqn_torch_rl_module.DefaultDQNTorchRLModule | from ray.rllib.utils.typing import TensorType, TensorStructType
from ray.rllib.algorithms.dqn.default_dqn_rl_module import DefaultDQNRLModule, ATOMS, QF_LOGITS, QF_NEXT_PREDS, QF_PREDS, QF_PROBS, QF_TARGET_NEXT_PREDS, QF_TARGET_NEXT_PROBS
from ray.rllib.core.rl_module.apis.q_net_api import QNetAPI
from ray.rllib.core.r... | @DeveloperAPI
class DefaultDQNTorchRLModule(TorchRLModule, DefaultDQNRLModule):
def __init__(self, *args, **kwargs):
pass
@override(RLModule)
def _forward_inference(self, batch: Dict[str, TensorType]) -> Dict[str, TensorType]:
pass
@override(RLModule)
def _forward_exploration(self, ... | 13 | 1 | 47 | 4 | 27 | 16 | 4 | 0.58 | 2 | 5 | 0 | 0 | 6 | 1 | 6 | 6 | 299 | 30 | 170 | 59 | 146 | 99 | 100 | 42 | 93 | 10 | 1 | 2 | 22 |
11,185 | ray-project/ray | rllib/algorithms/dqn/torch/dqn_torch_learner.py | rllib.algorithms.dqn.torch.dqn_torch_learner.DQNTorchLearner | from typing import Dict
from ray.rllib.utils.typing import ModuleID, TensorType
from ray.rllib.utils.annotations import override
from ray.rllib.core.columns import Columns
from ray.rllib.algorithms.dqn.dqn_learner import ATOMS, DQNLearner, QF_LOSS_KEY, QF_LOGITS, QF_MEAN_KEY, QF_MAX_KEY, QF_MIN_KEY, QF_NEXT_PREDS, QF_T... |
class DQNTorchLearner(DQNLearner, TorchLearner):
'''Implements `torch`-specific DQN Rainbow loss logic on top of `DQNLearner`
This ' Learner' class implements the loss in its
`self.compute_loss_for_module()` method.
'''
@override(TorchLearner)
def compute_loss_for_module(self, *, module_id: Mod... | 6 | 1 | 69 | 5 | 45 | 20 | 3 | 0.48 | 2 | 2 | 0 | 0 | 1 | 0 | 1 | 1 | 266 | 20 | 168 | 38 | 155 | 80 | 52 | 30 | 47 | 7 | 1 | 2 | 12 |
11,186 | ray-project/ray | rllib/algorithms/dreamerv3/dreamerv3.py | rllib.algorithms.dreamerv3.dreamerv3.DreamerV3 | import gymnasium as gym
from ray.rllib.algorithms.dreamerv3.utils import do_symlog_obs
from ray.rllib.utils.metrics import ENV_RUNNER_RESULTS, LEARN_ON_BATCH_TIMER, LEARNER_RESULTS, NUM_ENV_STEPS_SAMPLED_LIFETIME, NUM_ENV_STEPS_TRAINED_LIFETIME, NUM_GRAD_UPDATES_LIFETIME, NUM_SYNCH_WORKER_WEIGHTS, REPLAY_BUFFER_RESULTS... |
class DreamerV3(Algorithm):
'''Implementation of the model-based DreamerV3 RL algorithm described in [1].'''
@override(Algorithm)
def compute_single_action(self, *args, **kwargs):
pass
@classmethod
@override(Algorithm)
def get_default_config(cls) -> DreamerV3Config:
pass
@ov... | 14 | 3 | 45 | 3 | 30 | 12 | 3 | 0.41 | 1 | 4 | 1 | 0 | 5 | 4 | 6 | 6 | 289 | 26 | 187 | 28 | 173 | 76 | 65 | 19 | 58 | 8 | 1 | 3 | 16 |
11,187 | ray-project/ray | rllib/algorithms/dreamerv3/dreamerv3.py | rllib.algorithms.dreamerv3.dreamerv3.DreamerV3Config | from ray.rllib.core.rl_module.rl_module import RLModuleSpec
from ray.rllib.utils import deep_update
from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
from ray.rllib.utils.typing import LearningRateOrSchedule
from ray.rllib.connectors.common import AddStatesFromEpisodesToBatch
from typing im... |
class DreamerV3Config(AlgorithmConfig):
'''Defines a configuration class from which a DreamerV3 can be built.
.. testcode::
from ray.rllib.algorithms.dreamerv3 import DreamerV3Config
config = (
DreamerV3Config()
.environment("CartPole-v1")
.training(
... | 19 | 5 | 39 | 2 | 23 | 15 | 5 | 0.76 | 1 | 9 | 1 | 0 | 9 | 36 | 9 | 9 | 407 | 35 | 214 | 94 | 156 | 162 | 126 | 49 | 114 | 23 | 1 | 1 | 42 |
11,188 | ray-project/ray | rllib/algorithms/dreamerv3/dreamerv3_catalog.py | rllib.algorithms.dreamerv3.dreamerv3_catalog.DreamerV3Catalog | import gymnasium as gym
import numpy as np
from ray.rllib.algorithms.dreamerv3.utils import do_symlog_obs, get_gru_units, get_num_z_classes, get_num_z_categoricals
from ray.rllib.core.models.catalog import Catalog
from ray.rllib.utils import override
from ray.rllib.core.models.base import Encoder, Model
class DreamerV... |
class DreamerV3Catalog(Catalog):
'''The Catalog class used to build all the models needed for DreamerV3 training.'''
def __init__(self, observation_space: gym.Space, action_space: gym.Space, model_config_dict: dict):
'''Initializes a DreamerV3Catalog instance.
Args:
observation_spa... | 9 | 4 | 21 | 3 | 15 | 3 | 2 | 0.27 | 1 | 4 | 0 | 0 | 3 | 3 | 3 | 3 | 73 | 12 | 48 | 23 | 28 | 13 | 22 | 11 | 14 | 3 | 1 | 1 | 7 |
11,189 | ray-project/ray | rllib/algorithms/dreamerv3/dreamerv3_learner.py | rllib.algorithms.dreamerv3.dreamerv3_learner.DreamerV3Learner | from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic_CallToSuperRecommended
from ray.rllib.core.learner.learner import Learner
class DreamerV3Learner(Learner):
"""DreamerV3 specific Learner class.
Only implements the `after_gradient_based_update()` method to define the logic
fo... |
class DreamerV3Learner(Learner):
'''DreamerV3 specific Learner class.
Only implements the `after_gradient_based_update()` method to define the logic
for updating the critic EMA-copy after each training step.
'''
@OverrideToImplementCustomLogic_CallToSuperRecommended
@override(Learner)
def a... | 4 | 1 | 6 | 1 | 4 | 1 | 2 | 0.71 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 15 | 3 | 7 | 4 | 3 | 5 | 5 | 3 | 3 | 2 | 1 | 1 | 2 |
11,190 | ray-project/ray | rllib/algorithms/dreamerv3/dreamerv3_rl_module.py | rllib.algorithms.dreamerv3.dreamerv3_rl_module.DreamerV3RLModule | from ray.rllib.utils.annotations import override
from ray.util.annotations import DeveloperAPI
from ray.rllib.algorithms.dreamerv3.torch.models.world_model import WorldModel
from typing import Dict
from ray.rllib.algorithms.dreamerv3.torch.models.actor_network import ActorNetwork
import abc
from ray.rllib.core.rl_modul... | @DeveloperAPI(stability='alpha')
class DreamerV3RLModule(RLModule, abc.ABC):
@override(RLModule)
def setup(self):
pass
@override(RLModule)
def get_initial_state(self) -> Dict:
pass | 6 | 0 | 23 | 1 | 20 | 2 | 2 | 0.1 | 2 | 3 | 0 | 0 | 5 | 9 | 5 | 25 | 125 | 11 | 104 | 30 | 93 | 10 | 36 | 23 | 30 | 4 | 4 | 2 | 8 |
11,191 | ray-project/ray | rllib/algorithms/dreamerv3/utils/debugging.py | rllib.algorithms.dreamerv3.utils.debugging.CartPoleDebug | import numpy as np
import gymnasium as gym
from gymnasium.envs.classic_control.cartpole import CartPoleEnv
class CartPoleDebug(CartPoleEnv):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
low = np.concatenate([np.array([0.0]), self.observation_space.low])
high = np.... |
class CartPoleDebug(CartPoleEnv):
def __init__(self, *args, **kwargs):
pass
def reset(self, *, seed=None, options=None):
pass
def step(self, action):
pass | 4 | 0 | 9 | 2 | 7 | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 3 | 4 | 3 | 3 | 30 | 7 | 23 | 15 | 19 | 0 | 23 | 15 | 19 | 2 | 1 | 0 | 4 |
11,192 | ray-project/ray | rllib/algorithms/impala/impala.py | rllib.algorithms.impala.impala.IMPALA | from ray.rllib.policy.policy import Policy
import ray
from ray import ObjectRef
from ray.rllib.execution.buffers.mixin_replay_buffer import MixInMultiAgentReplayBuffer
import copy
from ray.rllib.utils.replay_buffers.multi_agent_replay_buffer import ReplayMode
from ray.rllib.utils.replay_buffers.replay_buffer import _AL... |
class IMPALA(Algorithm):
'''Importance weighted actor/learner architecture (IMPALA) Algorithm
== Overview of data flow in IMPALA ==
1. Policy evaluation in parallel across `num_env_runners` actors produces
batches of size `rollout_fragment_length * num_envs_per_env_runner`.
2. If enabled, the re... | 31 | 7 | 38 | 4 | 27 | 8 | 4 | 0.3 | 1 | 11 | 1 | 0 | 14 | 8 | 16 | 16 | 751 | 89 | 509 | 137 | 449 | 155 | 240 | 95 | 217 | 9 | 1 | 3 | 69 |
11,193 | ray-project/ray | rllib/algorithms/impala/impala.py | rllib.algorithms.impala.impala.IMPALAConfig | from ray.rllib.algorithms.algorithm_config import AlgorithmConfig, NotProvided
from typing_extensions import Self
from ray.rllib.utils.schedules.scheduler import Scheduler
from ray.rllib.connectors.learner import AddOneTsToEpisodesAndTruncate, NumpyToTensor
from typing import Dict, List, Optional, Set, Tuple, Type, Uni... |
class IMPALAConfig(AlgorithmConfig):
'''Defines a configuration class from which an Impala can be built.
.. testcode::
from ray.rllib.algorithms.impala import IMPALAConfig
config = (
IMPALAConfig()
.environment("CartPole-v1")
.env_runners(num_env_runners=1)
... | 15 | 5 | 54 | 3 | 36 | 18 | 7 | 0.59 | 1 | 7 | 1 | 0 | 7 | 39 | 7 | 7 | 430 | 34 | 259 | 95 | 204 | 154 | 135 | 49 | 125 | 27 | 1 | 2 | 48 |
11,194 | ray-project/ray | rllib/algorithms/impala/impala_learner.py | rllib.algorithms.impala.impala_learner.IMPALALearner | from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic_CallToSuperRecommended
from ray.rllib.algorithms.appo.utils import CircularBuffer
from typing import Any, Dict, Union
import threading
from ray.rllib.utils.typing import ModuleID, ResultDict
from ray.rllib.utils.lambda_defaultdict import L... |
class IMPALALearner(Learner):
@override(Learner)
def build(self) -> None:
pass
@override(Learner)
def update(self, training_data: TrainingData, *, timesteps: Dict[str, Any], return_state: bool=False, **kwargs) -> ResultDict:
'''
Args:
batch:
timesteps:
... | 12 | 1 | 22 | 2 | 16 | 4 | 2 | 0.2 | 1 | 9 | 2 | 0 | 4 | 7 | 5 | 5 | 120 | 14 | 88 | 30 | 69 | 18 | 37 | 16 | 30 | 4 | 1 | 2 | 12 |
11,195 | ray-project/ray | rllib/algorithms/impala/impala_learner.py | rllib.algorithms.impala.impala_learner._GPULoaderThread | from ray.rllib.utils.metrics import ALL_MODULES, NUM_ENV_STEPS_SAMPLED_LIFETIME
from collections import deque
import threading
from ray.rllib.algorithms.appo.utils import CircularBuffer
import queue
from ray.rllib.utils.metrics.metrics_logger import MetricsLogger
class _GPULoaderThread(threading.Thread):
def __in... |
class _GPULoaderThread(threading.Thread):
def __init__(self, *, in_queue: queue.Queue, out_queue: deque, device: torch.device, metrics_logger: MetricsLogger):
pass
def run(self) -> None:
pass
def _step(self) -> None:
pass | 4 | 0 | 13 | 1 | 11 | 1 | 2 | 0.09 | 1 | 3 | 1 | 0 | 3 | 6 | 3 | 28 | 41 | 5 | 33 | 20 | 22 | 3 | 21 | 13 | 17 | 2 | 1 | 1 | 5 |
11,196 | ray-project/ray | rllib/algorithms/impala/impala_learner.py | rllib.algorithms.impala.impala_learner._LearnerThread | from collections import deque
from ray.rllib.core.learner.training_data import TrainingData
from typing import Any, Dict, Union
from ray.rllib.utils.metrics import ALL_MODULES, NUM_ENV_STEPS_SAMPLED_LIFETIME
from ray.rllib.algorithms.appo.utils import CircularBuffer
import threading
import time
class _LearnerThread(th... |
class _LearnerThread(threading.Thread):
def __init__(self, *, update_method, in_queue: Union[deque, CircularBuffer], learner):
pass
def run(self) -> None:
pass
def step(self):
pass
@staticmethod
def enqueue(learner_queue: deque, batch, metrics):
pass | 6 | 0 | 17 | 1 | 11 | 5 | 2 | 0.48 | 1 | 1 | 0 | 0 | 3 | 5 | 4 | 29 | 72 | 7 | 44 | 19 | 31 | 21 | 26 | 12 | 20 | 3 | 1 | 3 | 8 |
11,197 | ray-project/ray | rllib/algorithms/impala/impala_tf_policy.py | rllib.algorithms.impala.impala_tf_policy.VTraceClipGradients | from ray.rllib.utils.typing import LocalOptimizer, ModelGradients, TensorType, TFPolicyV2Type
from ray.rllib.utils import force_list
class VTraceClipGradients:
"""VTrace version of gradient computation logic."""
def __init__(self):
"""No special initialization required."""
pass
def comput... |
class VTraceClipGradients:
'''VTrace version of gradient computation logic.'''
def __init__(self):
'''No special initialization required.'''
pass
def compute_gradients_fn(self, optimizer: LocalOptimizer, loss: TensorType) -> ModelGradients:
pass | 3 | 2 | 18 | 1 | 15 | 2 | 3 | 0.13 | 0 | 2 | 0 | 1 | 2 | 1 | 2 | 2 | 39 | 4 | 31 | 16 | 26 | 4 | 24 | 14 | 21 | 5 | 0 | 4 | 6 |
11,198 | ray-project/ray | rllib/algorithms/impala/impala_tf_policy.py | rllib.algorithms.impala.impala_tf_policy.VTraceLoss | from ray.rllib.algorithms.impala import vtrace_tf as vtrace
class VTraceLoss:
def __init__(self, actions, actions_logp, actions_entropy, dones, behaviour_action_logp, behaviour_logits, target_logits, discount, rewards, values, bootstrap_value, dist_class, model, valid_mask, config, vf_loss_coeff=0.5, entropy_coef... |
class VTraceLoss:
def __init__(self, actions, actions_logp, actions_entropy, dones, behaviour_action_logp, behaviour_logits, target_logits, discount, rewards, values, bootstrap_value, dist_class, model, valid_mask, config, vf_loss_coeff=0.5, entropy_coeff=0.01, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0):
... | 2 | 1 | 97 | 8 | 54 | 35 | 2 | 0.64 | 0 | 0 | 0 | 0 | 1 | 10 | 1 | 1 | 98 | 8 | 55 | 37 | 32 | 35 | 19 | 16 | 17 | 2 | 0 | 1 | 2 |
11,199 | ray-project/ray | rllib/algorithms/impala/impala_tf_policy.py | rllib.algorithms.impala.impala_tf_policy.VTraceOptimizer | from typing import Dict, List, Optional, Type, Union
class VTraceOptimizer:
"""Optimizer function for VTrace policies."""
def __init__(self):
pass
def optimizer(self) -> Union['tf.keras.optimizers.Optimizer', List['tf.keras.optimizers.Optimizer']]:
config = self.config
if config['... |
class VTraceOptimizer:
'''Optimizer function for VTrace policies.'''
def __init__(self):
pass
def optimizer(self) -> Union['tf.keras.optimizers.Optimizer', List['tf.keras.optimizers.Optimizer']]:
pass | 3 | 1 | 16 | 1 | 15 | 0 | 4 | 0.1 | 0 | 1 | 0 | 1 | 2 | 0 | 2 | 2 | 38 | 4 | 31 | 7 | 26 | 3 | 19 | 5 | 16 | 7 | 0 | 3 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.