code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def get_running_path(self, filename: str) -> str: """Get the file path in the running directory.""" name, ext = os.path.splitext(filename) return os.path.join(self.running_dirpath, f"{name}-{self.timestamp}{ext}")
Get the file path in the running directory.
get_running_path
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/output.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/output.py
Apache-2.0
def get_running_job_path(self, filename: str) -> str: """Get the file path in the running job directory.""" name, ext = os.path.splitext(filename) return os.path.join(self.running_job_dirpath, f"{name}-{self.timestamp}{ext}")
Get the file path in the running job directory.
get_running_job_path
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/output.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/output.py
Apache-2.0
def is_all_set(self) -> bool: """Check if the path configuration is all set. Returns: `bool`: Whether the path configuration is all set. """ fields = get_fields(self) for f in fields: if not getattr(self, f.name): return Fa...
Check if the path configuration is all set. Returns: `bool`: Whether the path configuration is all set.
is_all_set
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def is_all_empty(self) -> bool: """Check if the path configuration is all empty. Returns: `bool`: Whether the path configuration is all empty. """ fields = get_fields(self) for f in fields: if getattr(self, f.name): return ...
Check if the path configuration is all empty. Returns: `bool`: Whether the path configuration is all empty.
is_all_empty
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def clone(self) -> tp.Self: """Clone the path configuration. Returns: `Self`: The cloned path configuration. """ fields = get_fields(self) return self.__class__(**{f.name: getattr(self, f.name) for f in fields})
Clone the path configuration. Returns: `Self`: The cloned path configuration.
clone
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def add_parent_dirs(self, *parent_dirs: str) -> tp.Self: """Add the parent directories to the paths. Args: parent_dirs (`str`): The parent directories. """ fields = get_fields(self) for f in fields: path = getattr(self, f.name) ...
Add the parent directories to the paths. Args: parent_dirs (`str`): The parent directories.
add_parent_dirs
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def add_children(self, *children: str) -> tp.Self: """Add the children to the paths. Args: children (`str`): The children paths. """ fields = get_fields(self) for f in fields: path = getattr(self, f.name) if path: ...
Add the children to the paths. Args: children (`str`): The children paths.
add_children
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def to_dirpath(self) -> tp.Self: """Convert the paths to directory paths.""" fields = get_fields(self) for f in fields: path = getattr(self, f.name) if path: setattr(self, f.name, os.path.dirname(path)) return self
Convert the paths to directory paths.
to_dirpath
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def apply(self, fn: tp.Callable) -> tp.Self: """Apply the function to the paths. Args: fn (`Callable`): The function to apply. """ fields = get_fields(self) for f in fields: path = getattr(self, f.name) if path: ...
Apply the function to the paths. Args: fn (`Callable`): The function to apply.
apply
python
mit-han-lab/deepcompressor
deepcompressor/utils/config/path.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/config/path.py
Apache-2.0
def pre_forward( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any] ) -> None: """Pre-forward function. Args: module (nn.Module): Module. input_args (tuple[torch.Tensor, ...]): Input arguments. input_kwargs (dic...
Pre-forward function. Args: module (nn.Module): Module. input_args (tuple[torch.Tensor, ...]): Input arguments. input_kwargs (dict[str, tp.Any]): Input keyword arguments.
pre_forward
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/branch.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/branch.py
Apache-2.0
def post_forward( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any], output: tuple[torch.Tensor, ...], ) -> tp.Any: """Post-forward function. Args: module (nn.Module): Module. input_args (tu...
Post-forward function. Args: module (nn.Module): Module. input_args (tuple[torch.Tensor, ...]): Input arguments. input_kwargs (dict[str, tp.Any]): Input keyword arguments. output (tuple[torch.Tensor, ...]): Output.
post_forward
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/branch.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/branch.py
Apache-2.0
def __init__(self, *, pre: bool, post: bool) -> None: """Initialize the hook. Args: pre (`bool`): Whether the hook should be called before the forward pass. post (`bool`): Whether the hook should be called after the forward pass. Raises: ...
Initialize the hook. Args: pre (`bool`): Whether the hook should be called before the forward pass. post (`bool`): Whether the hook should be called after the forward pass. Raises: AssertionError: If both `pre` and `po...
__init__
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def pre_forward( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any] ) -> tp.Any: """Pre-forward function. Args: module (`nn.Module`): Module to process. input_args (`tuple[torch.Tensor, ...]`): ...
Pre-forward function. Args: module (`nn.Module`): Module to process. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[str, tp.Any]`): Input keyword arguments.
pre_forward
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def post_forward( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any], output: tuple[torch.Tensor, ...], ) -> tp.Any: """Post-forward function. Args: module (`nn.Module`): Module to proces...
Post-forward function. Args: module (`nn.Module`): Module to process. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[str, tp.Any]`): Input keyword arguments. output (`tuple[torch.Tenso...
post_forward
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def register( self, module: nn.Module | tp.Iterable[nn.Module], prepend: bool | tuple[bool, bool] = False, always_call: bool = False, ) -> tp.Self: """Register the hook to the module(s). Args: module (`nn.Module` or `Iterable[nn.Module]`): ...
Register the hook to the module(s). Args: module (`nn.Module` or `Iterable[nn.Module]`): The module(s). prepend (`bool` or `tuple[bool, bool]`, *optional*, defaults to `False`): Whether to prepend the hook. If a tuple, the first element is...
register
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def remove(self, module: nn.Module | tp.Iterable[nn.Module] | None = None) -> tp.Self: """Remove the hook from the module(s). Args: module (`nn.Module` or `Iterable[nn.Module]`, *optional*, defaults to `None`): The module(s) to remove the hook from. If `None`, remove the hoo...
Remove the hook from the module(s). Args: module (`nn.Module` or `Iterable[nn.Module]`, *optional*, defaults to `None`): The module(s) to remove the hook from. If `None`, remove the hook from all modules.
remove
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def __init__( self, *, pre: bool, post: bool, input_packager: BaseInputPackager | None = None, output_packager: BaseOutputPackager | None = None, ): """Initialize the IO hook. Args: pre (`bool`): Whether the hook should be ...
Initialize the IO hook. Args: pre (`bool`): Whether the hook should be called before the forward pass. post (`bool`): Whether the hook should be called after the forward pass. input_packager (`BaseInputPackager`, *optional*, defaults to `None`...
__init__
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/hook.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/hook.py
Apache-2.0
def unpack( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any] ) -> dict[int | str, torch.Tensor]: """Unpack inputs in inputs packager. Args: module (`nn.Module`): Module. input_args (`tuple[torch.Tensor, .....
Unpack inputs in inputs packager. Args: module (`nn.Module`): Module. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[str, tp.Any]`): Input keyword arguments. Returns: `dict[in...
unpack
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/packager.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/packager.py
Apache-2.0
def repack( self, tensors: dict[int | str, torch.Tensor], module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any], ) -> tuple[tuple[torch.Tensor, ...], dict[str, tp.Any]]: """Repack inputs in inputs packager. Args: ...
Repack inputs in inputs packager. Args: tensors (`dict[int | str, torch.Tensor]`): The input tensors. module (`nn.Module`): Module. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[str, ...
repack
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/packager.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/packager.py
Apache-2.0
def unpack( self, module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any], output: tp.Any, ) -> dict[int | str, torch.Tensor]: """Unpack outputs in outputs packager. Args: module (`nn.Module`): Modu...
Unpack outputs in outputs packager. Args: module (`nn.Module`): Module. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[str, tp.Any]`): Input keyword arguments. output (`Any`): ...
unpack
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/packager.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/packager.py
Apache-2.0
def repack( self, tensors: dict[int | str, torch.Tensor], module: nn.Module, input_args: tuple[torch.Tensor, ...], input_kwargs: dict[str, tp.Any], output: tp.Any, ) -> tp.Any: """Repack outputs in outputs packager. Args: tensors (`dict[in...
Repack outputs in outputs packager. Args: tensors (`dict[int | str, torch.Tensor]`): The output tensors. module (`nn.Module`): Module. input_args (`tuple[torch.Tensor, ...]`): Input arguments. input_kwargs (`dict[st...
repack
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/packager.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/packager.py
Apache-2.0
def as_hook( self, func: tp.Callable[[torch.Tensor], torch.Tensor] | None = None, *, is_output: bool = False ) -> "ProcessHook": """Convert the processor to a hook. Args: func (`Callable[[torch.Tensor], torch.Tensor]` or `None`, *optional*, defaults to `None`): F...
Convert the processor to a hook. Args: func (`Callable[[torch.Tensor], torch.Tensor]` or `None`, *optional*, defaults to `None`): Function to process the tensors. is_output (`bool`, *optional*, defaults to `False`): Whether to process the output tensors. ...
as_hook
python
mit-han-lab/deepcompressor
deepcompressor/utils/hooks/processor.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/hooks/processor.py
Apache-2.0
def _matmul_hadU(X: torch.Tensor, hadamard_K: torch.Tensor | None, K: int) -> torch.Tensor: """Apply Hadamard matrix to the input tensor.""" n = X.shape[-1] input = X.clone().view(-1, n, 1) output = input.clone() while input.shape[1] > K: input = input.view(input.shape[0], input.shape[1] // ...
Apply Hadamard matrix to the input tensor.
_matmul_hadU
python
mit-han-lab/deepcompressor
deepcompressor/utils/math/hadamard.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/math/hadamard.py
Apache-2.0
def random_hadamard_matrix(size: int) -> torch.Tensor: """Generate a random Hadamard matrix of size `size`.""" # See https://cornell-relaxml.github.io/quip-sharp/ , Section "Randomized Hadamard Transformation" Q = torch.randint(low=0, high=2, size=(size,)).to(torch.float64) Q = Q * 2 - 1 Q = torch.d...
Generate a random Hadamard matrix of size `size`.
random_hadamard_matrix
python
mit-han-lab/deepcompressor
deepcompressor/utils/math/hadamard.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/math/hadamard.py
Apache-2.0
def get( n: int, *, scale: bool, dtype: torch.dtype = torch.float32, device: torch.device | str = "cpu" ) -> tuple[torch.Tensor, torch.Tensor, int]: """Get the Hadamard matrix and left-hand-size dimension for a given input size.""" device = torch.device(device) key = (n, scale, dtype...
Get the Hadamard matrix and left-hand-size dimension for a given input size.
get
python
mit-han-lab/deepcompressor
deepcompressor/utils/math/hadamard.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/math/hadamard.py
Apache-2.0
def get_lhs(n: int) -> tuple[torch.FloatTensor, int]: """Get the Hadamard matrix (left-hand-side) and its dimension for a given input size.""" for k in [172, 156, 140, 108, 60, 52, 36, 28, 40, 20, 12]: if n % k == 0: assert is_pow2(n // k) return HadamardMatri...
Get the Hadamard matrix (left-hand-side) and its dimension for a given input size.
get_lhs
python
mit-han-lab/deepcompressor
deepcompressor/utils/math/hadamard.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/math/hadamard.py
Apache-2.0
def log(level: int, msg: str, logger: logging.Logger | None = None) -> None: """Log a message with the given level. Args: level (`int`): The logging level. msg (`str`): The message to log. logger (`logging.Logger` or `None`, *optional*, defaults to `None`): The logger to use...
Log a message with the given level. Args: level (`int`): The logging level. msg (`str`): The message to log. logger (`logging.Logger` or `None`, *optional*, defaults to `None`): The logger to use. If `None`, the root logger is used.
log
python
mit-han-lab/deepcompressor
deepcompressor/utils/tools/logging.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/tools/logging.py
Apache-2.0
def format(self, record: logging.LogRecord) -> str: """Format the record. Args: record (`logging.LogRecord`): The log record. Returns: str: The formatted record. """ record.message = " " * self.indent + record.getMessage() if self.usesTime(): ...
Format the record. Args: record (`logging.LogRecord`): The log record. Returns: str: The formatted record.
format
python
mit-han-lab/deepcompressor
deepcompressor/utils/tools/logging.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/tools/logging.py
Apache-2.0
def setup( path: str | None = None, level: int = logging.DEBUG, format: str = "%(asctime)s | %(levelname).1s | %(message)s", datefmt: str = "%y-%m-%d %H:%M:%S", **kwargs, ) -> None: """Setup the default logging configuration. Args: path (`str` | `None`, *optional*, defaults to `None...
Setup the default logging configuration. Args: path (`str` | `None`, *optional*, defaults to `None`): The path to the log file. If `None`, only the console is used. level (`int`, *optional*, defaults to `logging.DEBUG`): The logging level. format (`str`, *optional*, defaults to ...
setup
python
mit-han-lab/deepcompressor
deepcompressor/utils/tools/logging.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/tools/logging.py
Apache-2.0
def get_max_memory_map(ratio: float = 0.9) -> dict[str, str]: """Get maximum memory map. Args: ratio (`float`, *optional*, defaults to `0.9`): The ratio of the maximum memory to use. Returns: `dict[str, str]`: Maximum memory map. """ gpu_capacity_list = _get_visible_gpu_capacity_li...
Get maximum memory map. Args: ratio (`float`, *optional*, defaults to `0.9`): The ratio of the maximum memory to use. Returns: `dict[str, str]`: Maximum memory map.
get_max_memory_map
python
mit-han-lab/deepcompressor
deepcompressor/utils/tools/sys.py
https://github.com/mit-han-lab/deepcompressor/blob/master/deepcompressor/utils/tools/sys.py
Apache-2.0
def set_draft_status_of_pull_request(self, number: int, *, target_draft_status: bool) -> bool: """Returns true if PR had a different draft status, and draft status has been toggled. Returns false if PR already had the desired draft status, and hence draft status has NOT been toggled."""
Returns true if PR had a different draft status, and draft status has been toggled. Returns false if PR already had the desired draft status, and hence draft status has NOT been toggled.
set_draft_status_of_pull_request
python
VirtusLab/git-machete
git_machete/code_hosting.py
https://github.com/VirtusLab/git-machete/blob/master/git_machete/code_hosting.py
MIT
def __get_remote_name_for_org_and_repo(self, domain: str, org_and_repo: OrganizationAndRepository) -> Optional[str]: """ Check if the given remote (as identified by `remote_url`) is already added to local git remotes, because it may happen that the local git remote's name is different from the n...
Check if the given remote (as identified by `remote_url`) is already added to local git remotes, because it may happen that the local git remote's name is different from the name of organization on code hosting site.
__get_remote_name_for_org_and_repo
python
VirtusLab/git-machete
git_machete/client/with_code_hosting.py
https://github.com/VirtusLab/git-machete/blob/master/git_machete/client/with_code_hosting.py
MIT
def __get_downwards_tree_excluding_pr(self, original_pr: PullRequest) -> List[Tuple[PullRequest, int]]: """Returns pairs of (PR, depth below the given PR)""" visited_head_branches: Set[str] = set([]) def reverse_pr_dfs(pr: PullRequest, depth: int) -> Iterator[Tuple[PullRequest, int]]: ...
Returns pairs of (PR, depth below the given PR)
__get_downwards_tree_excluding_pr
python
VirtusLab/git-machete
git_machete/client/with_code_hosting.py
https://github.com/VirtusLab/git-machete/blob/master/git_machete/client/with_code_hosting.py
MIT
def mock__run_cmd_and_forward_stdout(cmd: str, *args: str, **kwargs: Any) -> int: """Execute command in the new subprocess but capture together process's stdout and print it into sys.stdout. This sys.stdout is later being redirected via the `redirect_stdout` in `launch_command()` and gets returned by this funct...
Execute command in the new subprocess but capture together process's stdout and print it into sys.stdout. This sys.stdout is later being redirected via the `redirect_stdout` in `launch_command()` and gets returned by this function. Below is shown the chain of function calls that presents this mechanism: 1. ...
mock__run_cmd_and_forward_stdout
python
VirtusLab/git-machete
tests/mockers.py
https://github.com/VirtusLab/git-machete/blob/master/tests/mockers.py
MIT
def test_add_check_out_remote_branch(self, mocker: MockerFixture) -> None: """ Verify the behaviour of a 'git machete add' command in the special case when a remote branch is checked out locally. """ create_repo_with_remote() new_branch("master") commit("master commit.")...
Verify the behaviour of a 'git machete add' command in the special case when a remote branch is checked out locally.
test_add_check_out_remote_branch
python
VirtusLab/git-machete
tests/test_add.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_add.py
MIT
def test_advance_for_a_few_possible_downstream_branches_and_yes_option(self, mocker: MockerFixture) -> None: """ Verify that 'git machete advance -y' raises an error when current branch has more than one synchronized downstream branch and option '-y' is passed. """ create_repo_wi...
Verify that 'git machete advance -y' raises an error when current branch has more than one synchronized downstream branch and option '-y' is passed.
test_advance_for_a_few_possible_downstream_branches_and_yes_option
python
VirtusLab/git-machete
tests/test_advance.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_advance.py
MIT
def test_anno(self) -> None: """ Verify behaviour of a 'git machete anno' command. """ create_repo_with_remote() new_branch("master") commit("master commit.") new_branch("develop") commit("develop commit.") new_branch("feature") commit("fe...
Verify behaviour of a 'git machete anno' command.
test_anno
python
VirtusLab/git-machete
tests/test_anno.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_anno.py
MIT
def test_file(self) -> None: """ Verify behaviour of a 'git machete file' command. """ create_repo() new_branch("master") commit("master commit.") new_branch("develop") commit("develop commit.") new_branch("feature") commit("feature commit...
Verify behaviour of a 'git machete file' command.
test_file
python
VirtusLab/git-machete
tests/test_file.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_file.py
MIT
def test_go_up(self) -> None: """Verify behaviour of a 'git machete go up' command. Verify that 'git machete go up' performs 'git checkout' to the parent/upstream branch of the current branch. """ create_repo() new_branch("level-0-branch") commit() new_b...
Verify behaviour of a 'git machete go up' command. Verify that 'git machete go up' performs 'git checkout' to the parent/upstream branch of the current branch.
test_go_up
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_down(self, mocker: MockerFixture) -> None: """Verify behaviour of a 'git machete go down' command. Verify that 'git machete go down' performs 'git checkout' to the child/downstream branch of the current branch. """ create_repo() new_branch("level-0-branch") ...
Verify behaviour of a 'git machete go down' command. Verify that 'git machete go down' performs 'git checkout' to the child/downstream branch of the current branch.
test_go_down
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_first_root_with_downstream(self) -> None: """Verify behaviour of a 'git machete go first' command. Verify that 'git machete go first' performs 'git checkout' to the first downstream branch of a root branch in the config file if root branch has any downstream branches. ...
Verify behaviour of a 'git machete go first' command. Verify that 'git machete go first' performs 'git checkout' to the first downstream branch of a root branch in the config file if root branch has any downstream branches.
test_go_first_root_with_downstream
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_first_root_without_downstream(self) -> None: """Verify behaviour of a 'git machete go first' command. Verify that 'git machete go first' set current branch to root if root branch has no downstream. """ create_repo() new_branch("level-0-branch") commit...
Verify behaviour of a 'git machete go first' command. Verify that 'git machete go first' set current branch to root if root branch has no downstream.
test_go_first_root_without_downstream
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_last(self) -> None: """Verify behaviour of a 'git machete go last' command. Verify that 'git machete go last' performs 'git checkout' to the last downstream branch of a root branch if root branch has any downstream branches. """ create_repo() new_bran...
Verify behaviour of a 'git machete go last' command. Verify that 'git machete go last' performs 'git checkout' to the last downstream branch of a root branch if root branch has any downstream branches.
test_go_last
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_next_successor_exists(self) -> None: """Verify behaviour of a 'git machete go next' command. Verify that 'git machete go next' performs 'git checkout' to the branch right after the current one in the config file when successor branch exists within the root tree. """...
Verify behaviour of a 'git machete go next' command. Verify that 'git machete go next' performs 'git checkout' to the branch right after the current one in the config file when successor branch exists within the root tree.
test_go_next_successor_exists
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_next_successor_on_another_root_tree(self) -> None: """Verify behaviour of a 'git machete go next' command. Verify that 'git machete go next' can checkout to branch that doesn't share root with the current branch. """ create_repo() new_branch("level-0-branch"...
Verify behaviour of a 'git machete go next' command. Verify that 'git machete go next' can checkout to branch that doesn't share root with the current branch.
test_go_next_successor_on_another_root_tree
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_prev_successor_exists(self) -> None: """Verify behaviour of a 'git machete go prev' command. Verify that 'git machete go prev' performs 'git checkout' to the branch right before the current one in the config file when predecessor branch exists within the root tree. "...
Verify behaviour of a 'git machete go prev' command. Verify that 'git machete go prev' performs 'git checkout' to the branch right before the current one in the config file when predecessor branch exists within the root tree.
test_go_prev_successor_exists
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_prev_successor_on_another_root_tree(self) -> None: """Verify behaviour of a 'git machete go prev' command. Verify that 'git machete go prev' raises an error when predecessor branch doesn't exist. """ create_repo() new_branch("level-0-branch") commit(...
Verify behaviour of a 'git machete go prev' command. Verify that 'git machete go prev' raises an error when predecessor branch doesn't exist.
test_go_prev_successor_on_another_root_tree
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_go_root(self) -> None: """Verify behaviour of a 'git machete go root' command. Verify that 'git machete go root' performs 'git checkout' to the root of the current branch. """ create_repo() new_branch("level-0-branch") commit() new_branch("level...
Verify behaviour of a 'git machete go root' command. Verify that 'git machete go root' performs 'git checkout' to the root of the current branch.
test_go_root
python
VirtusLab/git-machete
tests/test_go.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_go.py
MIT
def test_is_managed(self) -> None: """ Verify behaviour of a 'git machete is-managed' command. """ create_repo() new_branch("master") commit("master commit.") new_branch("develop") commit("develop commit.") new_branch("feature") commit("fe...
Verify behaviour of a 'git machete is-managed' command.
test_is_managed
python
VirtusLab/git-machete
tests/test_is_managed.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_is_managed.py
MIT
def test_list(self) -> None: """ Verify behaviour of a 'git machete list' command. """ create_repo_with_remote() new_branch("master") commit("master commit.") new_branch("develop") commit("develop commit.") new_branch("feature_0") commit("...
Verify behaviour of a 'git machete list' command.
test_list
python
VirtusLab/git-machete
tests/test_list.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_list.py
MIT
def test_reapply(self) -> None: """ Verify that 'git machete reapply' performs 'git rebase' to the fork point of the current branch. """ create_repo() with fixed_author_and_committer_date_in_past(): new_branch("level-0-branch") commit("Basic commi...
Verify that 'git machete reapply' performs 'git rebase' to the fork point of the current branch.
test_reapply
python
VirtusLab/git-machete
tests/test_reapply.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_reapply.py
MIT
def test_show_up(self) -> None: """Verify behaviour of a 'git machete show up' command. Verify that 'git machete show up' displays name of a parent/upstream branch one above current one in the config file from within current root tree. """ create_repo() new_branc...
Verify behaviour of a 'git machete show up' command. Verify that 'git machete show up' displays name of a parent/upstream branch one above current one in the config file from within current root tree.
test_show_up
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_down(self) -> None: """Verify behaviour of a 'git machete show down' command. Verify that 'git machete show down' displays name of a child/downstream branch one below current one. """ create_repo() new_branch("level-0-branch") commit() new_b...
Verify behaviour of a 'git machete show down' command. Verify that 'git machete show down' displays name of a child/downstream branch one below current one.
test_show_down
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_first(self) -> None: """Verify behaviour of a 'git machete show first' command. Verify that 'git machete show first' displays name of the first downstream branch of a root branch of the current branch in the config file if root branch has any downstream branches. "...
Verify behaviour of a 'git machete show first' command. Verify that 'git machete show first' displays name of the first downstream branch of a root branch of the current branch in the config file if root branch has any downstream branches.
test_show_first
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_last(self) -> None: """Verify behaviour of a 'git machete show last' command. Verify that 'git machete show last' displays name of the last downstream branch of a root branch of the current branch in the config file if root branch has any downstream branches. """ ...
Verify behaviour of a 'git machete show last' command. Verify that 'git machete show last' displays name of the last downstream branch of a root branch of the current branch in the config file if root branch has any downstream branches.
test_show_last
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_next(self) -> None: """Verify behaviour of a 'git machete show next' command. Verify that 'git machete show next' displays name of a branch right after the current one in the config file when successor branch exists within the root tree. """ create_repo() ...
Verify behaviour of a 'git machete show next' command. Verify that 'git machete show next' displays name of a branch right after the current one in the config file when successor branch exists within the root tree.
test_show_next
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_prev(self) -> None: """Verify behaviour of a 'git machete show prev' command. Verify that 'git machete show prev' displays name of a branch right before the current one in the config file when predecessor branch exists within the root tree. """ create_repo...
Verify behaviour of a 'git machete show prev' command. Verify that 'git machete show prev' displays name of a branch right before the current one in the config file when predecessor branch exists within the root tree.
test_show_prev
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_show_root(self) -> None: """Verify behaviour of a 'git machete show root' command. Verify that 'git machete show root' displays name of the root of the current branch. """ create_repo() new_branch("level-0-branch") commit() new_branch("level-1a-b...
Verify behaviour of a 'git machete show root' command. Verify that 'git machete show root' displays name of the root of the current branch.
test_show_root
python
VirtusLab/git-machete
tests/test_show.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_show.py
MIT
def test_reset_to_remote_after_rebase(self) -> None: """Very unlikely case; can happen only in case of divergence of clocks between local and remote (which is simulated in this test).""" create_repo_with_remote() new_branch("branch-0") commit() push() new_branch("...
Very unlikely case; can happen only in case of divergence of clocks between local and remote (which is simulated in this test).
test_reset_to_remote_after_rebase
python
VirtusLab/git-machete
tests/test_traverse.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_traverse.py
MIT
def test_update_with_fork_point_not_specified(self) -> None: """ Verify that 'git machete update --no-interactive-rebase' performs 'git rebase' to the parent branch of the current branch. """ create_repo() new_branch("level-0-branch") commit("Basic commit.") ...
Verify that 'git machete update --no-interactive-rebase' performs 'git rebase' to the parent branch of the current branch.
test_update_with_fork_point_not_specified
python
VirtusLab/git-machete
tests/test_update.py
https://github.com/VirtusLab/git-machete/blob/master/tests/test_update.py
MIT
def __init__(self, exec_config, cwd, cluster=None): """ exec_config must be of type ConfigNode because we depend on safe_get(self, key) to correctly handle optional exec provider config parameters. """ for key in ['command', 'apiVersion']: if key not in exec_c...
exec_config must be of type ConfigNode because we depend on safe_get(self, key) to correctly handle optional exec provider config parameters.
__init__
python
kubernetes-client/python
kubernetes/base/config/exec_provider.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/exec_provider.py
Apache-2.0
def load_incluster_config(client_configuration=None, try_refresh_token=True): """ Use the service account kubernetes gives to pods to connect to kubernetes cluster. It's intended for clients that expect to be running inside a pod running on kubernetes. It will raise an exception if called from a process...
Use the service account kubernetes gives to pods to connect to kubernetes cluster. It's intended for clients that expect to be running inside a pod running on kubernetes. It will raise an exception if called from a process not running in a kubernetes environment.
load_incluster_config
python
kubernetes-client/python
kubernetes/base/config/incluster_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/incluster_config.py
Apache-2.0
def as_file(self): """If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].""" use_data_if_no_file = not self._file and self._data if use_data_if_no_file: if self._base64_file_content: ...
If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].
as_file
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def as_data(self): """If obj[%data_key_name] exists, Return obj[%data_key_name] otherwise base64 encoded string of obj[%file_key_name] file content.""" use_file_if_no_data = not self._data and self._file if use_file_if_no_data: with open(self._file) as f: if s...
If obj[%data_key_name] exists, Return obj[%data_key_name] otherwise base64 encoded string of obj[%file_key_name] file content.
as_data
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def _load_authentication(self): """Read authentication from kube-config user section if exists. This function goes through various authentication methods in user section of kube-config and stops if it finds a valid authentication method. The order of authentication methods is: ...
Read authentication from kube-config user section if exists. This function goes through various authentication methods in user section of kube-config and stops if it finds a valid authentication method. The order of authentication methods is: 1. auth-provider (gcp, azure, oidc) ...
_load_authentication
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def load_kube_config(config_file=None, context=None, client_configuration=None, persist_config=True, temp_file_path=None): """Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration. ...
Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration. :param config_file: Name of the kube-config file. :param context: set the active context. If is set to None, current_context from config file will be used. :param client_config...
load_kube_config
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def load_kube_config_from_dict(config_dict, context=None, client_configuration=None, persist_config=True, temp_file_path=None): """Loads authentication and cluster information from config_dict file and stores them in ku...
Loads authentication and cluster information from config_dict file and stores them in kubernetes.client.configuration. :param config_dict: Takes the config file as a dict. :param context: set the active context. If is set to None, current_context from config file will be used. :param client_con...
load_kube_config_from_dict
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def new_client_from_config( config_file=None, context=None, persist_config=True, client_configuration=None): """ Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with ...
Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.
new_client_from_config
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def new_client_from_config_dict( config_dict=None, context=None, persist_config=True, temp_file_path=None, client_configuration=None): """ Loads configuration the same as load_kube_config_from_dict but returns an ApiClient to be used with any API object. This will all...
Loads configuration the same as load_kube_config_from_dict but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.
new_client_from_config_dict
python
kubernetes-client/python
kubernetes/base/config/kube_config.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/kube_config.py
Apache-2.0
def load_config(**kwargs): """ Wrapper function to load the kube_config. It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists If neither exists, it will fall back to load_incluster_config and inform the user accordingly. :param ...
Wrapper function to load the kube_config. It will initially try to load_kube_config from provided path, then check if the KUBE_CONFIG_DEFAULT_LOCATION exists If neither exists, it will fall back to load_incluster_config and inform the user accordingly. :param kwargs: A combination of all possi...
load_config
python
kubernetes-client/python
kubernetes/base/config/__init__.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/config/__init__.py
Apache-2.0
def meta_request(func): """ Handles parsing response structure and translating API Exceptions """ def inner(self, *args, **kwargs): serialize_response = kwargs.pop('serialize', True) serializer = kwargs.pop('serializer', ResourceInstance) try: resp = func(self, *args, **kwarg...
Handles parsing response structure and translating API Exceptions
meta_request
python
kubernetes-client/python
kubernetes/base/dynamic/client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py
Apache-2.0
def serialize_body(self, body): """Serialize body to raw dict so apiserver can handle it :param body: kubernetes resource body, current support: Union[Dict, ResourceInstance] """ # This should match any `ResourceInstance` instances if callable(getattr(body, 'to_dict', None)): ...
Serialize body to raw dict so apiserver can handle it :param body: kubernetes resource body, current support: Union[Dict, ResourceInstance]
serialize_body
python
kubernetes-client/python
kubernetes/base/dynamic/client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py
Apache-2.0
def watch(self, resource, namespace=None, name=None, label_selector=None, field_selector=None, resource_version=None, timeout=None, watcher=None, allow_watch_bookmarks=None): """ Stream events for a resource from the Kubernetes API :param resource: The API resource object that will be used to q...
Stream events for a resource from the Kubernetes API :param resource: The API resource object that will be used to query the API :param namespace: The namespace to query :param name: The name of the resource instance to query :param label_selector: The label selector with which...
watch
python
kubernetes-client/python
kubernetes/base/dynamic/client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py
Apache-2.0
def validate(self, definition, version=None, strict=False): """validate checks a kubernetes resource definition Args: definition (dict): resource definition version (str): version of kubernetes to validate against strict (bool): whether unexpected additional properti...
validate checks a kubernetes resource definition Args: definition (dict): resource definition version (str): version of kubernetes to validate against strict (bool): whether unexpected additional properties should be considered errors Returns: warnings (...
validate
python
kubernetes-client/python
kubernetes/base/dynamic/client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/client.py
Apache-2.0
def parse_api_groups(self, request_resources=False, update=False): """ Discovers all API groups present in the cluster """ if not self._cache.get('resources') or update: self._cache['resources'] = self._cache.get('resources', {}) groups_response = self.client.request('GET', '/{}'...
Discovers all API groups present in the cluster
parse_api_groups
python
kubernetes-client/python
kubernetes/base/dynamic/discovery.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/discovery.py
Apache-2.0
def get_resources_for_api_version(self, prefix, group, version, preferred): """ returns a dictionary of resources associated with provided (prefix, group, version)""" resources = defaultdict(list) subresources = {} path = '/'.join(filter(None, [prefix, group, version])) try: ...
returns a dictionary of resources associated with provided (prefix, group, version)
get_resources_for_api_version
python
kubernetes-client/python
kubernetes/base/dynamic/discovery.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/discovery.py
Apache-2.0
def get(self, **kwargs): """ Same as search, but will throw an error if there are multiple or no results. If there are multiple results and only one is an exact match on api_version, that resource will be returned. """ results = self.search(**kwargs) # If there ar...
Same as search, but will throw an error if there are multiple or no results. If there are multiple results and only one is an exact match on api_version, that resource will be returned.
get
python
kubernetes-client/python
kubernetes/base/dynamic/discovery.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/discovery.py
Apache-2.0
def search(self, **kwargs): """ Takes keyword arguments and returns matching resources. The search will happen in the following order: prefix: The api prefix for a resource, ie, /api, /oapi, /apis. Can usually be ignored group: The api group of a resource. Will also b...
Takes keyword arguments and returns matching resources. The search will happen in the following order: prefix: The api prefix for a resource, ie, /api, /oapi, /apis. Can usually be ignored group: The api group of a resource. Will also be extracted from api_version if it is p...
search
python
kubernetes-client/python
kubernetes/base/dynamic/discovery.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/discovery.py
Apache-2.0
def api_exception(e): """ Returns the proper Exception class for the given kubernetes.client.rest.ApiException object https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#success-codes """ _, _, exc_traceback = sys.exc_info() tb = '\n'.join(traceback.format_t...
Returns the proper Exception class for the given kubernetes.client.rest.ApiException object https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#success-codes
api_exception
python
kubernetes-client/python
kubernetes/base/dynamic/exceptions.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/exceptions.py
Apache-2.0
def _items_to_resources(self, body): """ Takes a List body and return a dictionary with the following structure: { 'api_version': str, 'kind': str, 'items': [{ 'resource': Resource, 'name': str, ...
Takes a List body and return a dictionary with the following structure: { 'api_version': str, 'kind': str, 'items': [{ 'resource': Resource, 'name': str, 'namespace': str, }] ...
_items_to_resources
python
kubernetes-client/python
kubernetes/base/dynamic/resource.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/resource.py
Apache-2.0
def test_resource_field(self): """`ResourceField` is a special type which overwrites `__getattr__` method to return `None` when a non-existent attribute was accessed. which means it can pass any `hasattr(...)` tests. """ params = { "foo": "bar", "self": True ...
`ResourceField` is a special type which overwrites `__getattr__` method to return `None` when a non-existent attribute was accessed. which means it can pass any `hasattr(...)` tests.
test_resource_field
python
kubernetes-client/python
kubernetes/base/dynamic/test_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/dynamic/test_client.py
Apache-2.0
def __init__(self, name, namespace, identity): """ :param name: name of the lock :param namespace: namespace :param identity: A unique identifier that the candidate is using """ self.api_instance = client.CoreV1Api() self.leader_electionrecord_annotationkey = 'con...
:param name: name of the lock :param namespace: namespace :param identity: A unique identifier that the candidate is using
__init__
python
kubernetes-client/python
kubernetes/base/leaderelection/resourcelock/configmaplock.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/leaderelection/resourcelock/configmaplock.py
Apache-2.0
def get(self, name, namespace): """ :param name: Name of the configmap object information to get :param namespace: Namespace in which the configmap object is to be searched :return: 'True, election record' if object found else 'False, exception response' """ try: ...
:param name: Name of the configmap object information to get :param namespace: Namespace in which the configmap object is to be searched :return: 'True, election record' if object found else 'False, exception response'
get
python
kubernetes-client/python
kubernetes/base/leaderelection/resourcelock/configmaplock.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/leaderelection/resourcelock/configmaplock.py
Apache-2.0
def create(self, name, namespace, election_record): """ :param electionRecord: Annotation string :param name: Name of the configmap object to be created :param namespace: Namespace in which the configmap object is to be created :return: 'True' if object is created else 'False' if...
:param electionRecord: Annotation string :param name: Name of the configmap object to be created :param namespace: Namespace in which the configmap object is to be created :return: 'True' if object is created else 'False' if failed
create
python
kubernetes-client/python
kubernetes/base/leaderelection/resourcelock/configmaplock.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/leaderelection/resourcelock/configmaplock.py
Apache-2.0
def update(self, name, namespace, updated_record): """ :param name: name of the lock to be updated :param namespace: namespace the lock is in :param updated_record: the updated election record :return: True if update is successful False if it fails """ try: ...
:param name: name of the lock to be updated :param namespace: namespace the lock is in :param updated_record: the updated election record :return: True if update is successful False if it fails
update
python
kubernetes-client/python
kubernetes/base/leaderelection/resourcelock/configmaplock.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/leaderelection/resourcelock/configmaplock.py
Apache-2.0
def _websocket_request(websocket_request, force_kwargs, api_method, *args, **kwargs): """Override the ApiClient.request method with an alternative websocket based method and call the supplied Kubernetes API method with that in place.""" if force_kwargs: for kwarg, value in force_kwargs.items(): ...
Override the ApiClient.request method with an alternative websocket based method and call the supplied Kubernetes API method with that in place.
_websocket_request
python
kubernetes-client/python
kubernetes/base/stream/stream.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/stream.py
Apache-2.0
def __init__(self, configuration, url, headers, capture_all, binary=False): """A websocket client with support for channels. Exec command uses different channels for different streams. for example, 0 is stdin, 1 is stdout and 2 is stderr. Some other API calls like port forwarding ca...
A websocket client with support for channels. Exec command uses different channels for different streams. for example, 0 is stdin, 1 is stdout and 2 is stderr. Some other API calls like port forwarding can forward different pods' streams to different channels.
__init__
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def peek_channel(self, channel, timeout=0): """Peek a channel and return part of the input, empty string otherwise.""" self.update(timeout=timeout) if channel in self._channels: return self._channels[channel] return ""
Peek a channel and return part of the input, empty string otherwise.
peek_channel
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def read_all(self): """Return buffered data received on stdout and stderr channels. This is useful for non-interactive call where a set of command passed to the API call and their result is needed after the call is concluded. Should be called after run_forever() or update() TODO...
Return buffered data received on stdout and stderr channels. This is useful for non-interactive call where a set of command passed to the API call and their result is needed after the call is concluded. Should be called after run_forever() or update() TODO: Maybe we can process this and...
read_all
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def update(self, timeout=0): """Update channel buffers with at most one complete frame of input.""" if not self.is_open(): return if not self.sock.connected: self._connected = False return # The options here are: # select.select() - this will ...
Update channel buffers with at most one complete frame of input.
update
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def run_forever(self, timeout=None): """Wait till connection is closed or timeout reached. Buffer any input received during this time.""" if timeout: start = time.time() while self.is_open() and time.time() - start < timeout: self.update(timeout=(timeout -...
Wait till connection is closed or timeout reached. Buffer any input received during this time.
run_forever
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def returncode(self): """ The return code, A None value indicates that the process hasn't terminated yet. """ if self.is_open(): return None else: if self._returncode is None: err = self.read_channel(ERROR_CHANNEL) e...
The return code, A None value indicates that the process hasn't terminated yet.
returncode
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def __init__(self, websocket, ports): """A websocket client with support for port forwarding. Port Forward command sends on 2 channels per port, a read/write data channel and a read only error channel. Both channels are sent an initial frame containing the port number that channel is as...
A websocket client with support for port forwarding. Port Forward command sends on 2 channels per port, a read/write data channel and a read only error channel. Both channels are sent an initial frame containing the port number that channel is associated with.
__init__
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def websocket_proxycare(connect_opt, configuration, url, headers): """ An internal function to be called in api-client when a websocket create is requested. """ if configuration.no_proxy: connect_opt.update({ 'http_no_proxy': configuration.no_proxy.split(',') }) if configuration.proxy: ...
An internal function to be called in api-client when a websocket create is requested.
websocket_proxycare
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def websocket_call(configuration, _method, url, **kwargs): """An internal function to be called in api-client when a websocket connection is required. method, url, and kwargs are the parameters of apiClient.request method.""" url = get_websocket_url(url, kwargs.get("query_params")) headers = kwargs...
An internal function to be called in api-client when a websocket connection is required. method, url, and kwargs are the parameters of apiClient.request method.
websocket_call
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def portforward_call(configuration, _method, url, **kwargs): """An internal function to be called in api-client when a websocket connection is required for port forwarding. args and kwargs are the parameters of apiClient.request method.""" query_params = kwargs.get("query_params") ports = [] f...
An internal function to be called in api-client when a websocket connection is required for port forwarding. args and kwargs are the parameters of apiClient.request method.
portforward_call
python
kubernetes-client/python
kubernetes/base/stream/ws_client.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/stream/ws_client.py
Apache-2.0
def stream(self, func, *args, **kwargs): """Watch an API resource and stream the result back via a generator. Note that watching an API resource can expire. The method tries to resume automatically once from the last result, but if that last result is too old as well, an `ApiException` ...
Watch an API resource and stream the result back via a generator. Note that watching an API resource can expire. The method tries to resume automatically once from the last result, but if that last result is too old as well, an `ApiException` exception will be thrown with ``code`` 410. ...
stream
python
kubernetes-client/python
kubernetes/base/watch/watch.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/base/watch/watch.py
Apache-2.0
def auth_settings(self): """Gets Auth Settings dict for api client. :return: The Auth Settings information dict. """ auth = {} if 'authorization' in self.api_key: auth['BearerToken'] = { 'type': 'api_key', 'in': 'header', ...
Gets Auth Settings dict for api client. :return: The Auth Settings information dict.
auth_settings
python
kubernetes-client/python
kubernetes/client/configuration.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/client/configuration.py
Apache-2.0
def get_api_group(self, **kwargs): # noqa: E501 """get_api_group # noqa: E501 get information of a group # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_api_group(async...
get_api_group # noqa: E501 get information of a group # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_api_group(async_req=True) >>> result = thread.get() :param...
get_api_group
python
kubernetes-client/python
kubernetes/client/api/admissionregistration_api.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api/admissionregistration_api.py
Apache-2.0
def get_api_group_with_http_info(self, **kwargs): # noqa: E501 """get_api_group # noqa: E501 get information of a group # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_...
get_api_group # noqa: E501 get information of a group # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_api_group_with_http_info(async_req=True) >>> result = thread.get() ...
get_api_group_with_http_info
python
kubernetes-client/python
kubernetes/client/api/admissionregistration_api.py
https://github.com/kubernetes-client/python/blob/master/kubernetes/client/api/admissionregistration_api.py
Apache-2.0