Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
resnet56
(pretrained: bool = False, num_classes: int = 10)
factory class of ResNet-56. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
factory class of ResNet-56. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
def resnet56(pretrained: bool = False, num_classes: int = 10) -> nn.Module: """factory class of ResNet-56. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class. """ if pretrained: ...
[ "def", "resnet56", "(", "pretrained", ":", "bool", "=", "False", ",", "num_classes", ":", "int", "=", "10", ")", "->", "nn", ".", "Module", ":", "if", "pretrained", ":", "raise", "NotImplementedError", "(", "\"resnet for cifar10 dose not have pretrained models.\""...
[ 189, 0 ]
[ 200, 65 ]
python
en
['en', 'lb', 'en']
True
resnet110
(pretrained: bool = False, num_classes: int = 10)
factory class of ResNet-110. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
factory class of ResNet-110. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
def resnet110(pretrained: bool = False, num_classes: int = 10) -> nn.Module: """factory class of ResNet-110. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class. """ if pretrained: ...
[ "def", "resnet110", "(", "pretrained", ":", "bool", "=", "False", ",", "num_classes", ":", "int", "=", "10", ")", "->", "nn", ".", "Module", ":", "if", "pretrained", ":", "raise", "NotImplementedError", "(", "\"resnet for cifar10 dose not have pretrained models.\"...
[ 203, 0 ]
[ 214, 68 ]
python
en
['en', 'lb', 'en']
True
resnet1202
(pretrained: bool = False, num_classes: int = 10)
factory class of ResNet-1202. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
factory class of ResNet-1202. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class.
def resnet1202(pretrained: bool = False, num_classes: int = 10) -> nn.Module: """factory class of ResNet-1202. Parameters ---------- pretrained : bool Rreturn pretrained model. Note: currently just raise error. num_classes : int Number of output class. """ if pretrained: ...
[ "def", "resnet1202", "(", "pretrained", ":", "bool", "=", "False", ",", "num_classes", ":", "int", "=", "10", ")", "->", "nn", ".", "Module", ":", "if", "pretrained", ":", "raise", "NotImplementedError", "(", "\"resnet for cifar10 dose not have pretrained models.\...
[ 217, 0 ]
[ 228, 71 ]
python
en
['en', 'lb', 'en']
True
Metamer._init_synthesized_signal
(self, initial_image, clamper=RangeClamper((0, 1)), clamp_each_iter=True)
initialize the synthesized image set the ``self.synthesized_signal`` attribute to be a parameter with the user-supplied data, making sure it's the right shape and calling clamper on it, if set also initialize the ``self.synthesized_representation`` attribute Parameters ...
initialize the synthesized image
def _init_synthesized_signal(self, initial_image, clamper=RangeClamper((0, 1)), clamp_each_iter=True): """initialize the synthesized image set the ``self.synthesized_signal`` attribute to be a parameter with the user-supplied data, making sure it's the right sha...
[ "def", "_init_synthesized_signal", "(", "self", ",", "initial_image", ",", "clamper", "=", "RangeClamper", "(", "(", "0", ",", "1", ")", ")", ",", "clamp_each_iter", "=", "True", ")", ":", "if", "initial_image", "is", "None", ":", "try", ":", "# then we ha...
[ 109, 4 ]
[ 146, 99 ]
python
en
['en', 'zu', 'en']
True
Metamer.synthesize
(self, initial_image=None, seed=0, max_iter=100, learning_rate=.01, scheduler=True, optimizer='SGD', optimizer_kwargs={}, swa=False, swa_kwargs={}, clamper=RangeClamper((0, 1)), clamp_each_iter=True, store_progress=False, save_progress=False, s...
r"""Synthesize a metamer This is the main method, which updates the ``initial_image`` until its representation matches that of ``base_signal``. We run this until either we reach ``max_iter`` or the change over the past ``loss_change_iter`` iterations is less than ``loss_thresh`...
r"""Synthesize a metamer
def synthesize(self, initial_image=None, seed=0, max_iter=100, learning_rate=.01, scheduler=True, optimizer='SGD', optimizer_kwargs={}, swa=False, swa_kwargs={}, clamper=RangeClamper((0, 1)), clamp_each_iter=True, store_progress=False, save_progress=False, ...
[ "def", "synthesize", "(", "self", ",", "initial_image", "=", "None", ",", "seed", "=", "0", ",", "max_iter", "=", "100", ",", "learning_rate", "=", ".01", ",", "scheduler", "=", "True", ",", "optimizer", "=", "'SGD'", ",", "optimizer_kwargs", "=", "{", ...
[ 148, 4 ]
[ 310, 81 ]
python
en
['en', 'en', 'pt']
True
Metamer.save
(self, file_path, save_model_reduced=False)
r"""save all relevant variables in .pt file Note that if store_progress is True, this will probably be very large Parameters ---------- file_path : str The path to save the metamer object to save_model_reduced : bool Whether we save the full mode...
r"""save all relevant variables in .pt file
def save(self, file_path, save_model_reduced=False): r"""save all relevant variables in .pt file Note that if store_progress is True, this will probably be very large Parameters ---------- file_path : str The path to save the metamer object to save_m...
[ "def", "save", "(", "self", ",", "file_path", ",", "save_model_reduced", "=", "False", ")", ":", "attrs", "=", "[", "'model'", ",", "'synthesized_signal'", ",", "'base_signal'", ",", "'seed'", ",", "'loss'", ",", "'base_representation'", ",", "'synthesized_repre...
[ 312, 4 ]
[ 335, 59 ]
python
en
['en', 'en', 'en']
True
Metamer.to
(self, *args, **kwargs)
r"""Moves and/or casts the parameters and buffers. This can be called as .. function:: to(device=None, dtype=None, non_blocking=False) .. function:: to(dtype, non_blocking=False) .. function:: to(tensor, non_blocking=False) Its signature is similar to :meth:`torch.Tensor.to`...
r"""Moves and/or casts the parameters and buffers.
def to(self, *args, **kwargs): r"""Moves and/or casts the parameters and buffers. This can be called as .. function:: to(device=None, dtype=None, non_blocking=False) .. function:: to(dtype, non_blocking=False) .. function:: to(tensor, non_blocking=False) Its signatur...
[ "def", "to", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "attrs", "=", "[", "'base_signal'", ",", "'base_representation'", ",", "'synthesized_signal'", ",", "'synthesized_representation'", ",", "'saved_signal'", ",", "'saved_representation'",...
[ 337, 4 ]
[ 376, 55 ]
python
en
['en', 'en', 'en']
True
Metamer.load
(cls, file_path, model_constructor=None, map_location='cpu', **state_dict_kwargs)
r"""load all relevant stuff from a .pt file We will iterate through any additional key word arguments provided and, if the model in the saved representation is a dictionary, add them to the state_dict of the model. In this way, you can replace, e.g., paths that have changed between ...
r"""load all relevant stuff from a .pt file
def load(cls, file_path, model_constructor=None, map_location='cpu', **state_dict_kwargs): r"""load all relevant stuff from a .pt file We will iterate through any additional key word arguments provided and, if the model in the saved representation is a dictionary, add them to the state_...
[ "def", "load", "(", "cls", ",", "file_path", ",", "model_constructor", "=", "None", ",", "map_location", "=", "'cpu'", ",", "*", "*", "state_dict_kwargs", ")", ":", "return", "super", "(", ")", ".", "load", "(", "file_path", ",", "'model'", ",", "model_c...
[ 379, 4 ]
[ 454, 48 ]
python
en
['en', 'en', 'en']
True
Metamer.plot_value_comparison
(self, value='representation', batch_idx=0, channel_idx=None, iteration=None, figsize=(5, 5), ax=None, func='scatter', hist2d_nbins=21, hist2d_cmap='Blues', scatter_subsample=1, **kwargs)
Plot comparison of base vs. synthesized representation or signal. Plotting representation is another way of visualizing the representation error, while plotting signal is similar to plot_image_hist, but allows you to see whether there's any pattern of individual correspondence. ...
Plot comparison of base vs. synthesized representation or signal.
def plot_value_comparison(self, value='representation', batch_idx=0, channel_idx=None, iteration=None, figsize=(5, 5), ax=None, func='scatter', hist2d_nbins=21, hist2d_cmap='Blues', scatter_subsample=1, ...
[ "def", "plot_value_comparison", "(", "self", ",", "value", "=", "'representation'", ",", "batch_idx", "=", "0", ",", "channel_idx", "=", "None", ",", "iteration", "=", "None", ",", "figsize", "=", "(", "5", ",", "5", ")", ",", "ax", "=", "None", ",", ...
[ 456, 4 ]
[ 518, 18 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check drop row policy query syntax. ```sql DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] ```
Check drop row policy query syntax.
def feature(self, node="clickhouse1"): """Check drop row policy query syntax. ```sql DROP [ROW] POLICY [IF EXISTS] name [,...] ON [database.]table [,...] [ON CLUSTER cluster_name] ``` """ node = self.context.cluster.node(node) @contextmanager def cleanup(policy, on=["default.foo"]): ...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "@", "contextmanager", "def", "cleanup", "(", "policy", ",", "on", "=", "[", "\"default.fo...
[ 9, 0 ]
[ 134, 60 ]
python
en
['en', 'en', 'en']
True
new_role
(self, server)
Check that new roles can't be assigned to any LDAP user authenticated using external user directory.
Check that new roles can't be assigned to any LDAP user authenticated using external user directory.
def new_role(self, server): """Check that new roles can't be assigned to any LDAP user authenticated using external user directory. """ node = self.context.node uid = getuid() self.context.ldap_node = self.context.cluster.node(server) users = [ {"username": f"user0_{uid}", "passwor...
[ "def", "new_role", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "self", ".", "context", ".", "ldap_node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "ser...
[ 9, 0 ]
[ 46, 101 ]
python
en
['en', 'en', 'en']
True
add_privilege
(self, server)
Check that we can add privilege to a role used in the external user directory configuration.
Check that we can add privilege to a role used in the external user directory configuration.
def add_privilege(self, server): """Check that we can add privilege to a role used in the external user directory configuration. """ node = self.context.node uid = getuid() message = "DB::Exception: {user}: Not enough privileges." exitcode = 241 self.context.ldap_node = self.context.clu...
[ "def", "add_privilege", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "message", "=", "\"DB::Exception: {user}: Not enough privileges.\"", "exitcode", "=", "241", "self", ".", "context",...
[ 52, 0 ]
[ 91, 106 ]
python
en
['en', 'en', 'en']
True
remove_privilege
(self, server)
Check that we can remove privilege from a role used in the external user directory configuration.
Check that we can remove privilege from a role used in the external user directory configuration.
def remove_privilege(self, server): """Check that we can remove privilege from a role used in the external user directory configuration. """ node = self.context.node uid = getuid() message = "DB::Exception: {user}: Not enough privileges." exitcode = 241 self.context.ldap_node = self.con...
[ "def", "remove_privilege", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "message", "=", "\"DB::Exception: {user}: Not enough privileges.\"", "exitcode", "=", "241", "self", ".", "contex...
[ 97, 0 ]
[ 137, 97 ]
python
en
['en', 'en', 'en']
True
remove_role
(self, server)
Check that when a role used in the external user directory configuration is dynamically removed then any LDAP users should still be authenticated using LDAP external user directory.
Check that when a role used in the external user directory configuration is dynamically removed then any LDAP users should still be authenticated using LDAP external user directory.
def remove_role(self, server): """Check that when a role used in the external user directory configuration is dynamically removed then any LDAP users should still be authenticated using LDAP external user directory. """ node = self.context.node uid = getuid() self.context.ldap_node = self.c...
[ "def", "remove_role", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "self", ".", "context", ".", "ldap_node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "...
[ 143, 0 ]
[ 174, 106 ]
python
en
['en', 'en', 'en']
True
remove_privilege_by_removing_role
(self, server)
Check that when the role used in the external user directory configuration is dynamically removed then privileges are removed from all LDAP users that are authenticated using external user directory.
Check that when the role used in the external user directory configuration is dynamically removed then privileges are removed from all LDAP users that are authenticated using external user directory.
def remove_privilege_by_removing_role(self, server): """Check that when the role used in the external user directory configuration is dynamically removed then privileges are removed from all LDAP users that are authenticated using external user directory. """ node = self.context.node message = "...
[ "def", "remove_privilege_by_removing_role", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "message", "=", "\"DB::Exception: {user}: Not enough privileges.\"", "exitcode", "=", "241", "uid", "=", "getuid", "(", ")", "self",...
[ 180, 0 ]
[ 217, 101 ]
python
en
['en', 'en', 'en']
True
readd_privilege_by_readding_role
(self, server)
Check that when the role used in the external user directory configuration is dynamically removed then all the privileges are removed from any LDAP users authenticated using external user directory but when the role is re-added then privileges are restored.
Check that when the role used in the external user directory configuration is dynamically removed then all the privileges are removed from any LDAP users authenticated using external user directory but when the role is re-added then privileges are restored.
def readd_privilege_by_readding_role(self, server): """Check that when the role used in the external user directory configuration is dynamically removed then all the privileges are removed from any LDAP users authenticated using external user directory but when the role is re-added then privileges are r...
[ "def", "readd_privilege_by_readding_role", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "self", ".", "context", ".", "ldap_node", "=", "self", ".", "context", ".", "cluster", ".",...
[ 223, 0 ]
[ 282, 110 ]
python
en
['en', 'en', 'en']
True
not_present_role_added
(self, server)
Check that when the role used in the external user directory configuration which was not present during LDAP user authentication is dynamically added then all the privileges granted by the role are given to all users authenticated using external LDAP user directory.
Check that when the role used in the external user directory configuration which was not present during LDAP user authentication is dynamically added then all the privileges granted by the role are given to all users authenticated using external LDAP user directory.
def not_present_role_added(self, server): """Check that when the role used in the external user directory configuration which was not present during LDAP user authentication is dynamically added then all the privileges granted by the role are given to all users authenticated using external LDAP user dir...
[ "def", "not_present_role_added", "(", "self", ",", "server", ")", ":", "node", "=", "self", ".", "context", ".", "node", "uid", "=", "getuid", "(", ")", "self", ".", "context", ".", "ldap_node", "=", "self", ".", "context", ".", "cluster", ".", "node",...
[ 288, 0 ]
[ 336, 81 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check that all the users that are authenticated using LDAP external user directory are assigned the roles specified in the configuration of the LDAP external user directory.
Check that all the users that are authenticated using LDAP external user directory are assigned the roles specified in the configuration of the LDAP external user directory.
def feature(self, node="clickhouse1"): """Check that all the users that are authenticated using LDAP external user directory are assigned the roles specified in the configuration of the LDAP external user directory. """ self.context.node = self.context.cluster.node(node) servers = { "op...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "servers", "=", "{", "\"openldap1\"", ":", "{", "\"host\"", ...
[ 343, 0 ]
[ 360, 40 ]
python
en
['en', 'en', 'en']
True
simple_get
(url)
Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None.
Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None.
def simple_get(url): """ Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None. """ try: with closing(get(url, stream=True)) as resp: if is_good_response(res...
[ "def", "simple_get", "(", "url", ")", ":", "try", ":", "with", "closing", "(", "get", "(", "url", ",", "stream", "=", "True", ")", ")", "as", "resp", ":", "if", "is_good_response", "(", "resp", ")", ":", "return", "resp", ".", "content", "else", ":...
[ 25, 0 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
is_good_response
(resp)
Returns True if the response seems to be HTML, False otherwise.
Returns True if the response seems to be HTML, False otherwise.
def is_good_response(resp): """ Returns True if the response seems to be HTML, False otherwise. """ content_type = resp.headers['Content-Type'].lower() return (resp.status_code == 200 and content_type is not None and content_type.find('html') > -1)
[ "def", "is_good_response", "(", "resp", ")", ":", "content_type", "=", "resp", ".", "headers", "[", "'Content-Type'", "]", ".", "lower", "(", ")", "return", "(", "resp", ".", "status_code", "==", "200", "and", "content_type", "is", "not", "None", "and", ...
[ 43, 0 ]
[ 50, 47 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.__init__
(self, scale_factor=1, range_constraints=())
Base class for unique cost functions. Parameters ---------- scale_factor: float The factor by which the cost should be scaled (for cost aggregation). range_constraints: tuple Minimum and maximum values for the constraint on the cumulative cost.
Base class for unique cost functions.
def __init__(self, scale_factor=1, range_constraints=()): """ Base class for unique cost functions. Parameters ---------- scale_factor: float The factor by which the cost should be scaled (for cost aggregation). range_constra...
[ "def", "__init__", "(", "self", ",", "scale_factor", "=", "1", ",", "range_constraints", "=", "(", ")", ")", ":", "self", ".", "scale_factor", "=", "scale_factor", "self", ".", "range_constraints", "=", "range_constraints", "self", ".", "normalized_constraint", ...
[ 6, 4 ]
[ 21, 39 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.scale
(self, cost)
Scales the cost Parameters ---------- cost: float Unscaled cost.
Scales the cost
def scale(self, cost): """ Scales the cost Parameters ---------- cost: float Unscaled cost. """ return cost / self.scale_factor
[ "def", "scale", "(", "self", ",", "cost", ")", ":", "return", "cost", "/", "self", ".", "scale_factor" ]
[ 30, 4 ]
[ 40, 39 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.compute_normalized_constraint
(self, constraint)
normalized constraints as a function of the true constraint. Parameters ---------- normalized_constraint: float Value in [0, 1]. Returns ------- float Value in the unit of the cost.
normalized constraints as a function of the true constraint.
def compute_normalized_constraint(self, constraint): """ normalized constraints as a function of the true constraint. Parameters ---------- normalized_constraint: float Value in [0, 1]. Returns ------- float Value in the unit of ...
[ "def", "compute_normalized_constraint", "(", "self", ",", "constraint", ")", ":", "return", "(", "constraint", "-", "self", ".", "range_constraints", "[", "0", "]", ")", "/", "(", "self", ".", "range_constraints", "[", "1", "]", "-", "self", ".", "range_co...
[ 42, 4 ]
[ 57, 113 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.compute_constraint
(self, normalized_constraint)
Return true constraints as a function of normalized constraint. Parameters ---------- normalized_constraint: float Value in [0, 1]. Returns ------- float Value in the unit of the cost.
Return true constraints as a function of normalized constraint.
def compute_constraint(self, normalized_constraint): """ Return true constraints as a function of normalized constraint. Parameters ---------- normalized_constraint: float Value in [0, 1]. Returns ------- float Value in the unit o...
[ "def", "compute_constraint", "(", "self", ",", "normalized_constraint", ")", ":", "return", "normalized_constraint", "*", "(", "self", ".", "range_constraints", "[", "1", "]", "-", "self", ".", "range_constraints", "[", "0", "]", ")", "+", "self", ".", "rang...
[ 59, 4 ]
[ 74, 122 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.check_constraint
(self, value, normalized_constraint)
Checks whether constraints are respected. Parameters ---------- values: list Values to be compared to constraints. normalized_constraints: list Normalized values of the constraints. Returns ------- over_constraints: nd.array of b...
Checks whether constraints are respected.
def check_constraint(self, value, normalized_constraint): """ Checks whether constraints are respected. Parameters ---------- values: list Values to be compared to constraints. normalized_constraints: list Normalized values of the constraints. ...
[ "def", "check_constraint", "(", "self", ",", "value", ",", "normalized_constraint", ")", ":", "constraint", "=", "self", ".", "compute_constraint", "(", "normalized_constraint", ")", "over_constraint", "=", "int", "(", "value", ">", "constraint", ")", "return", ...
[ 76, 4 ]
[ 95, 30 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.compute_cost
(self, previous_state, state, label_to_id, action, others={})
Computes cost since the last state. Parameters ---------- previous_state: 2D nd.array Previous model states (either 1D or 2D with first dimension # of states). state: 2D nd.array Current model states (either 1D or 2D with first dimension # of states). ...
Computes cost since the last state.
def compute_cost(self, previous_state, state, label_to_id, action, others={}): """ Computes cost since the last state. Parameters ---------- previous_state: 2D nd.array Previous model states (either 1D or 2D with first dimension # of states). state: 2D nd.arr...
[ "def", "compute_cost", "(", "self", ",", "previous_state", ",", "state", ",", "label_to_id", ",", "action", ",", "others", "=", "{", "}", ")", ":", "pass" ]
[ 98, 4 ]
[ 114, 12 ]
python
en
['en', 'error', 'th']
False
BaseCostFunction.compute_cumulative_cost
(self, previous_state, state, label_to_id, action, others={})
Computes cumulative costs Parameters ---------- previous_state: 2D nd.array Previous model states (either 1D or 2D with first dimension # of states). state: 2D nd.array Current model states (either 1D or 2D with first dimension # of states). labe...
Computes cumulative costs
def compute_cumulative_cost(self, previous_state, state, label_to_id, action, others={}): """ Computes cumulative costs Parameters ---------- previous_state: 2D nd.array Previous model states (either 1D or 2D with first dimension # of states). state: 2D nd.ar...
[ "def", "compute_cumulative_cost", "(", "self", ",", "previous_state", ",", "state", ",", "label_to_id", ",", "action", ",", "others", "=", "{", "}", ")", ":", "pass" ]
[ 117, 4 ]
[ 133, 12 ]
python
en
['en', 'error', 'th']
False
do_evaluation
(submission_dir, ground_truth_dir, sequences=None, num_frames=-1, start_frame=0)
Evaluate a particular image sequence :param submission_dir: location of the detections .json files (one for each sequence) :param ground_truth_dir: location of the ground-truth folders (one for each sequence). Each ground-truth folder must contain mask images (.png format) and a matching labels.json fi...
Evaluate a particular image sequence :param submission_dir: location of the detections .json files (one for each sequence) :param ground_truth_dir: location of the ground-truth folders (one for each sequence). Each ground-truth folder must contain mask images (.png format) and a matching labels.json fi...
def do_evaluation(submission_dir, ground_truth_dir, sequences=None, num_frames=-1, start_frame=0): """ Evaluate a particular image sequence :param submission_dir: location of the detections .json files (one for each sequence) :param ground_truth_dir: location of the ground-truth folders (one for each se...
[ "def", "do_evaluation", "(", "submission_dir", ",", "ground_truth_dir", ",", "sequences", "=", "None", ",", "num_frames", "=", "-", "1", ",", "start_frame", "=", "0", ")", ":", "ground_truth", "=", "gt_loader", ".", "read_ground_truth", "(", "ground_truth_dir", ...
[ 11, 0 ]
[ 45, 5 ]
python
en
['en', 'error', 'th']
False
permutations
(table_type)
Uses stress flag and table type, returns list of all permutations to run Stress test: All permutations, all tables (when stress=True) Sanity test: All permutations for MergeTree, selected permutations* for other tables
Uses stress flag and table type, returns list of all permutations to run
def permutations(table_type): """Uses stress flag and table type, returns list of all permutations to run Stress test: All permutations, all tables (when stress=True) Sanity test: All permutations for MergeTree, selected permutations* for other tables """ if current().context.stress or table_type =...
[ "def", "permutations", "(", "table_type", ")", ":", "if", "current", "(", ")", ".", "context", ".", "stress", "or", "table_type", "==", "\"MergeTree\"", ":", "return", "[", "*", "range", "(", "permutation_count", "+", "len", "(", "aliases", "[", "\"ALTER I...
[ 34, 0 ]
[ 47, 94 ]
python
en
['en', 'en', 'en']
True
alter_index_privileges
(grants: int)
Takes in an integer, and returns the corresponding set of tests to grant and not grant using the binary string. Each integer corresponds to a unique permutation of grants.
Takes in an integer, and returns the corresponding set of tests to grant and not grant using the binary string. Each integer corresponds to a unique permutation of grants.
def alter_index_privileges(grants: int): """Takes in an integer, and returns the corresponding set of tests to grant and not grant using the binary string. Each integer corresponds to a unique permutation of grants. """ note(grants) privileges = [] # Extra iteration for ALTER INDEX if g...
[ "def", "alter_index_privileges", "(", "grants", ":", "int", ")", ":", "note", "(", "grants", ")", "privileges", "=", "[", "]", "# Extra iteration for ALTER INDEX", "if", "grants", ">=", "permutation_count", ":", "privileges", ".", "append", "(", "aliases", "[", ...
[ 49, 0 ]
[ 77, 32 ]
python
en
['en', 'en', 'en']
True
alter_index_privilege_handler
(grants, table, user, node)
For all 5 subprivileges, if the privilege is granted: run test to ensure correct behavior, and if the privilege is not granted, run test to ensure correct behavior there as well.
For all 5 subprivileges, if the privilege is granted: run test to ensure correct behavior, and if the privilege is not granted, run test to ensure correct behavior there as well.
def alter_index_privilege_handler(grants, table, user, node): """For all 5 subprivileges, if the privilege is granted: run test to ensure correct behavior, and if the privilege is not granted, run test to ensure correct behavior there as well. """ # Testing ALTER INDEX and INDEX is the same as testing a...
[ "def", "alter_index_privilege_handler", "(", "grants", ",", "table", ",", "user", ",", "node", ")", ":", "# Testing ALTER INDEX and INDEX is the same as testing all subprivileges", "if", "grants", ">", "permutation_count", "-", "1", ":", "grants", "=", "permutation_count"...
[ 79, 0 ]
[ 122, 77 ]
python
en
['en', 'en', 'en']
True
check_order_by_when_privilege_is_granted
(table, user, node)
Ensures ORDER BY runs as expected when the privilege is granted to the specified user
Ensures ORDER BY runs as expected when the privilege is granted to the specified user
def check_order_by_when_privilege_is_granted(table, user, node): """Ensures ORDER BY runs as expected when the privilege is granted to the specified user """ column = "order" with Given("I run sanity check"): node.query(f"ALTER TABLE {table} MODIFY ORDER BY d", settings = [("user", user)]) ...
[ "def", "check_order_by_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "column", "=", "\"order\"", "with", "Given", "(", "\"I run sanity check\"", ")", ":", "node", ".", "query", "(", "f\"ALTER TABLE {table} MODIFY ORDER BY d\"", ",", "...
[ 124, 0 ]
[ 158, 47 ]
python
en
['en', 'en', 'en']
True
check_sample_by_when_privilege_is_granted
(table, user, node)
Ensures SAMPLE BY runs as expected when the privilege is granted to the specified user
Ensures SAMPLE BY runs as expected when the privilege is granted to the specified user
def check_sample_by_when_privilege_is_granted(table, user, node): """Ensures SAMPLE BY runs as expected when the privilege is granted to the specified user """ column = 'sample' with Given(f"I add new column {column}"): node.query(f"ALTER TABLE {table} ADD COLUMN {column} UInt32") with Whe...
[ "def", "check_sample_by_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "column", "=", "'sample'", "with", "Given", "(", "f\"I add new column {column}\"", ")", ":", "node", ".", "query", "(", "f\"ALTER TABLE {table} ADD COLUMN {column} UInt...
[ 160, 0 ]
[ 179, 47 ]
python
en
['en', 'en', 'en']
True
check_add_index_when_privilege_is_granted
(table, user, node)
Ensures ADD INDEX runs as expected when the privilege is granted to the specified user
Ensures ADD INDEX runs as expected when the privilege is granted to the specified user
def check_add_index_when_privilege_is_granted(table, user, node): """Ensures ADD INDEX runs as expected when the privilege is granted to the specified user """ index = "add" with Given(f"I add index '{index}'"): # Column x: String node.query(f"ALTER TABLE {table} ADD INDEX {index}(x) TYPE set(0...
[ "def", "check_add_index_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "index", "=", "\"add\"", "with", "Given", "(", "f\"I add index '{index}'\"", ")", ":", "# Column x: String", "node", ".", "query", "(", "f\"ALTER TABLE {table} ADD IN...
[ 181, 0 ]
[ 195, 61 ]
python
en
['en', 'en', 'en']
True
check_materialize_index_when_privilege_is_granted
(table, user, node)
Ensures MATERIALIZE INDEX runs as expected when the privilege is granted to the specified user
Ensures MATERIALIZE INDEX runs as expected when the privilege is granted to the specified user
def check_materialize_index_when_privilege_is_granted(table, user, node): """Ensures MATERIALIZE INDEX runs as expected when the privilege is granted to the specified user """ index = "materialize" with Given(f"I add index '{index}'"): node.query(f"ALTER TABLE {table} ADD INDEX {index}(x) TYPE ...
[ "def", "check_materialize_index_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "index", "=", "\"materialize\"", "with", "Given", "(", "f\"I add index '{index}'\"", ")", ":", "node", ".", "query", "(", "f\"ALTER TABLE {table} ADD INDEX {ind...
[ 197, 0 ]
[ 214, 61 ]
python
en
['en', 'en', 'en']
True
check_clear_index_when_privilege_is_granted
(table, user, node)
Ensures CLEAR INDEX runs as expected when the privilege is granted to the specified user
Ensures CLEAR INDEX runs as expected when the privilege is granted to the specified user
def check_clear_index_when_privilege_is_granted(table, user, node): """Ensures CLEAR INDEX runs as expected when the privilege is granted to the specified user """ index = "clear" with Given(f"I add index '{index}'"): # Column x: String node.query(f"ALTER TABLE {table} ADD INDEX {index}(x) TYPE...
[ "def", "check_clear_index_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "index", "=", "\"clear\"", "with", "Given", "(", "f\"I add index '{index}'\"", ")", ":", "# Column x: String", "node", ".", "query", "(", "f\"ALTER TABLE {table} AD...
[ 216, 0 ]
[ 232, 61 ]
python
en
['en', 'en', 'en']
True
check_drop_index_when_privilege_is_granted
(table, user, node)
Ensures DROP INDEX runs as expected when the privilege is granted to the specified user
Ensures DROP INDEX runs as expected when the privilege is granted to the specified user
def check_drop_index_when_privilege_is_granted(table, user, node): """Ensures DROP INDEX runs as expected when the privilege is granted to the specified user """ with When("I try to drop nonexistent index, throws exception"): exitcode, message = errors.wrong_index_name("fake_index") node.que...
[ "def", "check_drop_index_when_privilege_is_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to drop nonexistent index, throws exception\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "wrong_index_name", "(", "\"f...
[ 234, 0 ]
[ 253, 95 ]
python
en
['en', 'en', 'en']
True
check_order_by_when_privilege_is_not_granted
(table, user, node)
Ensures ORDER BY errors as expected without the required privilege for the specified user
Ensures ORDER BY errors as expected without the required privilege for the specified user
def check_order_by_when_privilege_is_not_granted(table, user, node): """Ensures ORDER BY errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user) node.que...
[ "def", "check_order_by_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", ...
[ 255, 0 ]
[ 261, 84 ]
python
en
['en', 'en', 'en']
True
check_sample_by_when_privilege_is_not_granted
(table, user, node)
Ensures SAMPLE BY errors as expected without the required privilege for the specified user
Ensures SAMPLE BY errors as expected without the required privilege for the specified user
def check_sample_by_when_privilege_is_not_granted(table, user, node): """Ensures SAMPLE BY errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user) node.q...
[ "def", "check_sample_by_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(",...
[ 263, 0 ]
[ 269, 84 ]
python
en
['en', 'en', 'en']
True
check_add_index_when_privilege_is_not_granted
(table, user, node)
Ensures ADD INDEX errors as expected without the required privilege for the specified user
Ensures ADD INDEX errors as expected without the required privilege for the specified user
def check_add_index_when_privilege_is_not_granted(table, user, node): """Ensures ADD INDEX errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user) node.q...
[ "def", "check_add_index_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(",...
[ 271, 0 ]
[ 277, 84 ]
python
en
['en', 'en', 'en']
True
check_materialize_index_when_privilege_is_not_granted
(table, user, node)
Ensures MATERIALIZE INDEX errors as expected without the required privilege for the specified user
Ensures MATERIALIZE INDEX errors as expected without the required privilege for the specified user
def check_materialize_index_when_privilege_is_not_granted(table, user, node): """Ensures MATERIALIZE INDEX errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user...
[ "def", "check_materialize_index_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges"...
[ 279, 0 ]
[ 285, 84 ]
python
en
['en', 'en', 'en']
True
check_clear_index_when_privilege_is_not_granted
(table, user, node)
Ensures CLEAR INDEX errors as expected without the required privilege for the specified user
Ensures CLEAR INDEX errors as expected without the required privilege for the specified user
def check_clear_index_when_privilege_is_not_granted(table, user, node): """Ensures CLEAR INDEX errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user) no...
[ "def", "check_clear_index_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(...
[ 287, 0 ]
[ 293, 84 ]
python
en
['en', 'en', 'en']
True
check_drop_index_when_privilege_is_not_granted
(table, user, node)
Ensures DROP INDEX errors as expected without the required privilege for the specified user
Ensures DROP INDEX errors as expected without the required privilege for the specified user
def check_drop_index_when_privilege_is_not_granted(table, user, node): """Ensures DROP INDEX errors as expected without the required privilege for the specified user """ with When("I try to use privilege that has not been granted"): exitcode, message = errors.not_enough_privileges(user) node...
[ "def", "check_drop_index_when_privilege_is_not_granted", "(", "table", ",", "user", ",", "node", ")", ":", "with", "When", "(", "\"I try to use privilege that has not been granted\"", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "("...
[ 295, 0 ]
[ 301, 84 ]
python
en
['en', 'en', 'en']
True
user_with_some_privileges
(self, table_type, node=None)
Check that user with any permutation of ALTER INDEX subprivileges is able to alter the table for privileges granted, and not for privileges not granted.
Check that user with any permutation of ALTER INDEX subprivileges is able to alter the table for privileges granted, and not for privileges not granted.
def user_with_some_privileges(self, table_type, node=None): """Check that user with any permutation of ALTER INDEX subprivileges is able to alter the table for privileges granted, and not for privileges not granted. """ if node is None: node = self.context.node table_name = f"merge_tree_{ge...
[ "def", "user_with_some_privileges", "(", "self", ",", "table_type", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "table_name", "=", "f\"merge_tree_{getuid()}\"", "user_name", "=", "f\"...
[ 304, 0 ]
[ 323, 91 ]
python
en
['en', 'en', 'en']
True
user_with_revoked_privileges
(self, table_type, node=None)
Check that user is unable to ALTER INDEX on table after ALTER INDEX privilege on that table has been revoked from the user.
Check that user is unable to ALTER INDEX on table after ALTER INDEX privilege on that table has been revoked from the user.
def user_with_revoked_privileges(self, table_type, node=None): """Check that user is unable to ALTER INDEX on table after ALTER INDEX privilege on that table has been revoked from the user. """ if node is None: node = self.context.node table_name = f"merge_tree_{getuid()}" user_name = f...
[ "def", "user_with_revoked_privileges", "(", "self", ",", "table_type", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "table_name", "=", "f\"merge_tree_{getuid()}\"", "user_name", "=", "...
[ 329, 0 ]
[ 352, 81 ]
python
en
['en', 'en', 'en']
True
role_with_some_privileges
(self, table_type, node=None)
Check that user can ALTER INDEX on a table after it is granted a role that has the ALTER INDEX privilege for that table.
Check that user can ALTER INDEX on a table after it is granted a role that has the ALTER INDEX privilege for that table.
def role_with_some_privileges(self, table_type, node=None): """Check that user can ALTER INDEX on a table after it is granted a role that has the ALTER INDEX privilege for that table. """ if node is None: node = self.context.node table_name = f"merge_tree_{getuid()}" user_name = f"user_...
[ "def", "role_with_some_privileges", "(", "self", ",", "table_type", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "table_name", "=", "f\"merge_tree_{getuid()}\"", "user_name", "=", "f\"...
[ 358, 0 ]
[ 381, 91 ]
python
en
['en', 'en', 'en']
True
user_with_revoked_role
(self, table_type, node=None)
Check that user with a role that has ALTER INDEX privilege on a table is unable to ALTER INDEX from that table after the role with privilege has been revoked from the user.
Check that user with a role that has ALTER INDEX privilege on a table is unable to ALTER INDEX from that table after the role with privilege has been revoked from the user.
def user_with_revoked_role(self, table_type, node=None): """Check that user with a role that has ALTER INDEX privilege on a table is unable to ALTER INDEX from that table after the role with privilege has been revoked from the user. """ if node is None: node = self.context.node table_name =...
[ "def", "user_with_revoked_role", "(", "self", ",", "table_type", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "table_name", "=", "f\"merge_tree_{getuid()}\"", "user_name", "=", "f\"use...
[ 384, 0 ]
[ 411, 81 ]
python
en
['en', 'en', 'en']
True
user_with_privileges_on_cluster
(self, table_type, node=None)
Check that user is able to ALTER INDEX on a table with privilege granted on a cluster.
Check that user is able to ALTER INDEX on a table with privilege granted on a cluster.
def user_with_privileges_on_cluster(self, table_type, node=None): """Check that user is able to ALTER INDEX on a table with privilege granted on a cluster. """ if node is None: node = self.context.node table_name = f"merge_tree_{getuid()}" user_name = f"user_{getuid()}" for permuta...
[ "def", "user_with_privileges_on_cluster", "(", "self", ",", "table_type", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "table_name", "=", "f\"merge_tree_{getuid()}\"", "user_name", "=", ...
[ 417, 0 ]
[ 443, 87 ]
python
en
['en', 'en', 'en']
True
train_kmeans
(x, k, ngpu, max_points_per_centroid=256)
Runs kmeans on one or several GPUs
Runs kmeans on one or several GPUs
def train_kmeans(x, k, ngpu, max_points_per_centroid=256): "Runs kmeans on one or several GPUs" d = x.shape[1] clus = faiss.Clustering(d, k) clus.verbose = True clus.niter = 20 clus.max_points_per_centroid = max_points_per_centroid if ngpu == 0: index = faiss.IndexFlatL2(d) else...
[ "def", "train_kmeans", "(", "x", ",", "k", ",", "ngpu", ",", "max_points_per_centroid", "=", "256", ")", ":", "d", "=", "x", ".", "shape", "[", "1", "]", "clus", "=", "faiss", ".", "Clustering", "(", "d", ",", "k", ")", "clus", ".", "verbose", "=...
[ 25, 0 ]
[ 61, 34 ]
python
en
['en', 'en', 'en']
True
GitLabYAMLGenerator.get_image_uri
(self, registry:str, image_name:str, version:str)
returns image uri based on registry, image name and version
returns image uri based on registry, image name and version
def get_image_uri(self, registry:str, image_name:str, version:str) -> str: ''' returns image uri based on registry, image name and version ''' if not registry: logger.error(f'Missed registry parameter, registry: {registry}') return None if not image_name:...
[ "def", "get_image_uri", "(", "self", ",", "registry", ":", "str", ",", "image_name", ":", "str", ",", "version", ":", "str", ")", "->", "str", ":", "if", "not", "registry", ":", "logger", ".", "error", "(", "f'Missed registry parameter, registry: {registry}'",...
[ 79, 4 ]
[ 93, 51 ]
python
en
['en', 'da', 'en']
True
GitLabYAMLGenerator.print_step
(self, targets:list, tag_suffix:bool=False)
print step
print step
def print_step(self, targets:list, tag_suffix:bool=False) -> None: ''' print step ''' for target in targets: # skip target if no definiton in settings file if not target.info.get('stage') in self._settings.get('stages', []): continue ...
[ "def", "print_step", "(", "self", ",", "targets", ":", "list", ",", "tag_suffix", ":", "bool", "=", "False", ")", "->", "None", ":", "for", "target", "in", "targets", ":", "# skip target if no definiton in settings file", "if", "not", "target", ".", "info", ...
[ 95, 4 ]
[ 115, 61 ]
python
en
['en', 'be', 'en']
False
GitLabYAMLGenerator.run
(self, changed_targets:list, child_targets:list)
generate GitLab CI pipeline
generate GitLab CI pipeline
def run(self, changed_targets:list, child_targets:list) -> None: ''' generate GitLab CI pipeline ''' print(TEMPLATE_PIPELINE.format( STAGES='\n- '.join( self._settings.get('stages', []) ) )) s...
[ "def", "run", "(", "self", ",", "changed_targets", ":", "list", ",", "child_targets", ":", "list", ")", "->", "None", ":", "print", "(", "TEMPLATE_PIPELINE", ".", "format", "(", "STAGES", "=", "'\\n- '", ".", "join", "(", "self", ".", "_settings", ".", ...
[ 117, 4 ]
[ 126, 63 ]
python
co
['de', 'co', 'en']
False
replace_ports
(json, substitute_ports)
In string json (which must be a valid JSON string), replace all ports in strings of the form "host:port" with ports from the list or map substitute_ports. If list, each new distinct port from the json will be replaced from the next port from the list. If map of the form (old_port: new_port), repla...
In string json (which must be a valid JSON string), replace all ports in strings of the form "host:port" with ports from the list or map substitute_ports.
def replace_ports(json, substitute_ports): """In string json (which must be a valid JSON string), replace all ports in strings of the form "host:port" with ports from the list or map substitute_ports. If list, each new distinct port from the json will be replaced from the next port from the list. ...
[ "def", "replace_ports", "(", "json", ",", "substitute_ports", ")", ":", "NORMAL", "=", "0", "STRING", "=", "1", "ESCAPE", "=", "2", "state", "=", "NORMAL", "out", "=", "\"\"", "s", "=", "\"\"", "port_map", "=", "{", "}", "for", "c", "in", "json", "...
[ 662, 0 ]
[ 704, 14 ]
python
en
['en', 'en', 'en']
True
ProcessBase.dump
(self)
dump stderr, stdout, and the log file to stdout with nice headers. This allows us to get all this information in a test failure (hidden by default) so we can debug better.
dump stderr, stdout, and the log file to stdout with nice headers. This allows us to get all this information in a test failure (hidden by default) so we can debug better.
def dump(self): """ dump stderr, stdout, and the log file to stdout with nice headers. This allows us to get all this information in a test failure (hidden by default) so we can debug better. """ try: stdout, stderr = self.proc.communicate() except Exception: ...
[ "def", "dump", "(", "self", ")", ":", "try", ":", "stdout", ",", "stderr", "=", "self", ".", "proc", ".", "communicate", "(", ")", "except", "Exception", ":", "stdout", ",", "stderr", "=", "b''", ",", "b''", "if", "hasattr", "(", "self", ",", "'log...
[ 94, 4 ]
[ 121, 64 ]
python
en
['en', 'en', 'en']
True
dict_privileges_granted_directly
(self, node=None)
Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted directly.
Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted directly.
def dict_privileges_granted_directly(self, node=None): """Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted directly. """ user_name = f"u...
[ "def", "dict_privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "f\"{...
[ 8, 0 ]
[ 25, 80 ]
python
en
['en', 'en', 'en']
True
dict_privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted via role.
Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted via role.
def dict_privileges_granted_via_role(self, node=None): """Check that a user is able to execute `USE` and `SHOW CREATE` commands on a database and see the database when they execute `SHOW DATABASES` command if and only if they have any privilege on that database granted via role. """ user_name = f"u...
[ "def", "dict_privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "...
[ 28, 0 ]
[ 49, 80 ]
python
en
['en', 'en', 'en']
True
check_privilege
(self, privilege, on, grant_target_name, user_name, db_name, node=None)
Run checks for commands that require SHOW DATABASE privilege.
Run checks for commands that require SHOW DATABASE privilege.
def check_privilege(self, privilege, on, grant_target_name, user_name, db_name, node=None): """Run checks for commands that require SHOW DATABASE privilege. """ if node is None: node = self.context.node on = on.replace("db", f"{db_name}") Suite(test=show_db)(privilege=privilege, on=on, gr...
[ "def", "check_privilege", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "db_name", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "on",...
[ 59, 0 ]
[ 70, 130 ]
python
en
['en', 'en', 'en']
True
show_db
(self, privilege, on, grant_target_name, user_name, db_name, node=None)
Check that user is only able to see a database in SHOW DATABASES when they have a privilege on that database.
Check that user is only able to see a database in SHOW DATABASES when they have a privilege on that database.
def show_db(self, privilege, on, grant_target_name, user_name, db_name, node=None): """Check that user is only able to see a database in SHOW DATABASES when they have a privilege on that database. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self....
[ "def", "show_db", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "db_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_nam...
[ 76, 0 ]
[ 123, 60 ]
python
en
['en', 'en', 'en']
True
use
(self, privilege, on, grant_target_name, user_name, db_name, node=None)
Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database.
Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database.
def use(self, privilege, on, grant_target_name, user_name, db_name, node=None): """Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: ...
[ "def", "use", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "db_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ...
[ 129, 0 ]
[ 176, 60 ]
python
en
['en', 'en', 'en']
True
show_create
(self, privilege, on, grant_target_name, user_name, db_name, node=None)
Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database.
Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database.
def show_create(self, privilege, on, grant_target_name, user_name, db_name, node=None): """Check that user is able to execute EXISTS on a database if and only if the user has SHOW DATABASE privilege on that database. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is No...
[ "def", "show_create", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "db_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user...
[ 182, 0 ]
[ 229, 60 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of SHOW DATABASES.
Check the RBAC functionality of SHOW DATABASES.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of SHOW DATABASES. """ self.context.node = self.context.cluster.node(node) Suite(run=dict_privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=dict_privileges_granted_via_role, setup=instrument_clickhou...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "dict_privileges_granted_directly", "...
[ 238, 0 ]
[ 244, 87 ]
python
en
['en', 'en', 'en']
True
Query.get_members
(self)
Get all team members for organization Returns: members: a map of members' logins to ids
Get all team members for organization
def get_members(self): '''Get all team members for organization Returns: members: a map of members' logins to ids ''' _QUERY = ''' organization(login: "{organization}") {{ team(slug: "{team}") {{ members(first: {max_page_size}...
[ "def", "get_members", "(", "self", ")", ":", "_QUERY", "=", "'''\n organization(login: \"{organization}\") {{\n team(slug: \"{team}\") {{\n members(first: {max_page_size} {next}) {{\n pageInfo {{\n hasNext...
[ 84, 4 ]
[ 126, 22 ]
python
en
['en', 'en', 'en']
True
Query.find_pull_requests
(self, label_name)
Get all pull-requests filtered by label name
Get all pull-requests filtered by label name
def find_pull_requests(self, label_name): ''' Get all pull-requests filtered by label name ''' _QUERY = ''' repository(owner: "{owner}" name: "{name}") {{ pullRequests(first: {min_page_size} labels: "{label_name}" states: OPEN) {{ nodes {{ ...
[ "def", "find_pull_requests", "(", "self", ",", "label_name", ")", ":", "_QUERY", "=", "'''\n repository(owner: \"{owner}\" name: \"{name}\") {{\n pullRequests(first: {min_page_size} labels: \"{label_name}\" states: OPEN) {{\n nodes {{\n ...
[ 161, 4 ]
[ 177, 70 ]
python
en
['en', 'error', 'th']
False
Query.get_pull_requests
(self, before_commit)
Get all merged pull-requests from the HEAD of default branch to the last commit (excluding)
Get all merged pull-requests from the HEAD of default branch to the last commit (excluding)
def get_pull_requests(self, before_commit): ''' Get all merged pull-requests from the HEAD of default branch to the last commit (excluding) ''' _QUERY = ''' repository(owner: "{owner}" name: "{name}") {{ defaultBranchRef {{ target {{ ...
[ "def", "get_pull_requests", "(", "self", ",", "before_commit", ")", ":", "_QUERY", "=", "'''\n repository(owner: \"{owner}\" name: \"{name}\") {{\n defaultBranchRef {{\n target {{\n ... on Commit {{\n ...
[ 179, 4 ]
[ 256, 28 ]
python
en
['en', 'error', 'th']
False
Query.set_label
(self, pull_request, label_name)
Set label by name to the pull request Args: pull_request: JSON object returned by `get_pull_requests()` label_name (string): label name
Set label by name to the pull request
def set_label(self, pull_request, label_name): ''' Set label by name to the pull request Args: pull_request: JSON object returned by `get_pull_requests()` label_name (string): label name ''' _GET_LABEL = ''' repository(owner: "{owner}" name: ...
[ "def", "set_label", "(", "self", ",", "pull_request", ",", "label_name", ")", ":", "_GET_LABEL", "=", "'''\n repository(owner: \"{owner}\" name: \"{name}\") {{\n labels(first: {max_page_size} {next} query: \"{label_name}\") {{\n pageInfo {{\n ...
[ 308, 4 ]
[ 361, 42 ]
python
en
['en', 'error', 'th']
False
lightning_qubit_dev
(wires)
Loads ``lightning.qubit``
Loads ``lightning.qubit``
def lightning_qubit_dev(wires): """Loads ``lightning.qubit``""" return qml.device("lightning.qubit", wires=wires)
[ "def", "lightning_qubit_dev", "(", "wires", ")", ":", "return", "qml", ".", "device", "(", "\"lightning.qubit\"", ",", "wires", "=", "wires", ")" ]
[ 25, 0 ]
[ 27, 53 ]
python
bg
['da', 'bg', 'en']
False
default_qubit_dev
(wires)
Loads ``default.qubit``
Loads ``default.qubit``
def default_qubit_dev(wires): """Loads ``default.qubit``""" return qml.device("default.qubit", wires=wires)
[ "def", "default_qubit_dev", "(", "wires", ")", ":", "return", "qml", ".", "device", "(", "\"default.qubit\"", ",", "wires", "=", "wires", ")" ]
[ 31, 0 ]
[ 33, 51 ]
python
en
['en', 'fr', 'en']
False
one_qubit_block
(wires=None)
A block containing all of the supported gates in ``lightning.qubit``
A block containing all of the supported gates in ``lightning.qubit``
def one_qubit_block(wires=None): """A block containing all of the supported gates in ``lightning.qubit``""" qml.PauliX(wires=wires) qml.PauliY(wires=wires) qml.S(wires=wires) qml.Hadamard(wires=wires) qml.PauliX(wires=wires) qml.T(wires=wires) qml.PhaseShift(-1, wires=wires) qml.Rot(...
[ "def", "one_qubit_block", "(", "wires", "=", "None", ")", ":", "qml", ".", "PauliX", "(", "wires", "=", "wires", ")", "qml", ".", "PauliY", "(", "wires", "=", "wires", ")", "qml", ".", "S", "(", "wires", "=", "wires", ")", "qml", ".", "Hadamard", ...
[ 36, 0 ]
[ 49, 27 ]
python
en
['en', 'en', 'en']
True
Git.__init__
(self, branch:str=None, tag:str=None)
Creates a git scm proxy that assumes the git repository is in the cwd by default. branch: The branch name, in most cases specified via CI system tag: The tag name, in most cases specified from CI system branch and tag paramaters are specify the current state of Git object
Creates a git scm proxy that assumes the git repository is in the cwd by default.
def __init__(self, branch:str=None, tag:str=None) -> None: """Creates a git scm proxy that assumes the git repository is in the cwd by default. branch: The branch name, in most cases specified via CI system tag: The tag name, in most cases specified from CI system branch and...
[ "def", "__init__", "(", "self", ",", "branch", ":", "str", "=", "None", ",", "tag", ":", "str", "=", "None", ")", "->", "None", ":", "self", ".", "_gitcmd", "=", "\"git\"", "self", ".", "_branch", "=", "branch", "self", ".", "_tag", "=", "tag", "...
[ 28, 4 ]
[ 50, 11 ]
python
en
['en', 'en', 'en']
True
Git.version
(self)
returns git version
returns git version
def version(self): ''' returns git version ''' return self._check_output(["version", ]).replace('git version', '').strip()
[ "def", "version", "(", "self", ")", ":", "return", "self", ".", "_check_output", "(", "[", "\"version\"", ",", "]", ")", ".", "replace", "(", "'git version'", ",", "''", ")", ".", "strip", "(", ")" ]
[ 61, 4 ]
[ 64, 83 ]
python
de
['de', 'no', 'en']
False
Git.branch_name
(self)
returns branch name
returns branch name
def branch_name(self): ''' returns branch name ''' if not self._branch: self._branch = self.git_branch_name return self._branch
[ "def", "branch_name", "(", "self", ")", ":", "if", "not", "self", ".", "_branch", ":", "self", ".", "_branch", "=", "self", ".", "git_branch_name", "return", "self", ".", "_branch" ]
[ 67, 4 ]
[ 72, 27 ]
python
en
['en', 'sl', 'en']
True
Git.git_branch_name
(self)
returns branch name from git
returns branch name from git
def git_branch_name(self): ''' returns branch name from git ''' return self._check_output(["rev-parse", "--abbrev-ref", "HEAD"])
[ "def", "git_branch_name", "(", "self", ")", ":", "return", "self", ".", "_check_output", "(", "[", "\"rev-parse\"", ",", "\"--abbrev-ref\"", ",", "\"HEAD\"", "]", ")" ]
[ 80, 4 ]
[ 83, 72 ]
python
en
['en', 'no', 'en']
True
Git.status
(self)
return current Git status
return current Git status
def status(self): ''' return current Git status ''' return { 'gitVersion': self.version, 'gitBranchName': self.git_branch_name, 'gitTargetBranch': self.get_target_branch(), 'gitCommitId': self.commit_id, 'ciBranchName': self.branch_name...
[ "def", "status", "(", "self", ")", ":", "return", "{", "'gitVersion'", ":", "self", ".", "version", ",", "'gitBranchName'", ":", "self", ".", "git_branch_name", ",", "'gitTargetBranch'", ":", "self", ".", "get_target_branch", "(", ")", ",", "'gitCommitId'", ...
[ 86, 4 ]
[ 96, 9 ]
python
en
['en', 'la', 'en']
True
Git.changed_files
(self, commit_from=None, commit_to=None, include_untracked=False)
returns the list of changed files between from_commit and to_commit
returns the list of changed files between from_commit and to_commit
def changed_files(self, commit_from=None, commit_to=None, include_untracked=False): ''' returns the list of changed files between from_commit and to_commit ''' if not commit_from: commit_from = self.get_target_branch() if not commit_to: ...
[ "def", "changed_files", "(", "self", ",", "commit_from", "=", "None", ",", "commit_to", "=", "None", ",", "include_untracked", "=", "False", ")", ":", "if", "not", "commit_from", ":", "commit_from", "=", "self", ".", "get_target_branch", "(", ")", "if", "n...
[ 98, 4 ]
[ 141, 20 ]
python
en
['en', 'en', 'en']
True
Git.get_target_branch
(self)
returns target branch name based on the name of current branch for feature/bugfix branch -> origin/devel for devel branch -> origin/master for master branch -> ""
returns target branch name based on the name of current branch
def get_target_branch(self) -> str: ''' returns target branch name based on the name of current branch for feature/bugfix branch -> origin/devel for devel branch -> origin/master for master branch -> "" ''' result = "" if RE_FEATURE_BRANCH.match(self.branch_name)...
[ "def", "get_target_branch", "(", "self", ")", "->", "str", ":", "result", "=", "\"\"", "if", "RE_FEATURE_BRANCH", ".", "match", "(", "self", ".", "branch_name", ")", "or", "RE_BUGFIX_BRANCH", ".", "match", "(", "self", ".", "branch_name", ")", ":", "result...
[ 156, 4 ]
[ 168, 21 ]
python
en
['en', 'en', 'en']
True
Git.fetch_target_branch
(self)
fetch target branch
fetch target branch
def fetch_target_branch(self): ''' fetch target branch ''' cmd = ["fetch", ] if not RE_MASTER_BRANCH.match(self.git_branch_name) and not self.tag: target_branch_name = self.get_target_branch().split("/") cmd += target_branch_name self._check_call(cmd)
[ "def", "fetch_target_branch", "(", "self", ")", ":", "cmd", "=", "[", "\"fetch\"", ",", "]", "if", "not", "RE_MASTER_BRANCH", ".", "match", "(", "self", ".", "git_branch_name", ")", "and", "not", "self", ".", "tag", ":", "target_branch_name", "=", "self", ...
[ 170, 4 ]
[ 177, 29 ]
python
en
['en', 'ht', 'en']
True
Git.get_last_tags
(self, tags:int=1, prefix:str=None)
return the list of last tags, sorted by descending tag date
return the list of last tags, sorted by descending tag date
def get_last_tags(self, tags:int=1, prefix:str=None) -> list: ''' return the list of last tags, sorted by descending tag date ''' pattern = 'refs/tags' # handling tag's prefixes if prefix: pattern += f"/{prefix}" if self._tag_prefix: pattern += f...
[ "def", "get_last_tags", "(", "self", ",", "tags", ":", "int", "=", "1", ",", "prefix", ":", "str", "=", "None", ")", "->", "list", ":", "pattern", "=", "'refs/tags'", "# handling tag's prefixes", "if", "prefix", ":", "pattern", "+=", "f\"/{prefix}\"", "if"...
[ 179, 4 ]
[ 198, 67 ]
python
en
['en', 'en', 'en']
True
privileges_granted_directly
(self, node=None)
Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted directly.
Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted directly.
def privileges_granted_directly(self, node=None): """Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(run=drop_set...
[ "def", "privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "f\"{user_...
[ 8, 0 ]
[ 22, 74 ]
python
en
['en', 'en', 'en']
True
privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted through a role.
Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted through a role.
def privileges_granted_via_role(self, node=None): """Check that a user is able to execute `DROP SETTINGS PROFILE` with privileges are granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user(node, f"{...
[ "def", "privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with"...
[ 25, 0 ]
[ 43, 74 ]
python
en
['en', 'en', 'en']
True
drop_settings_profile
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `DROP SETTINGS PROFILE` when they have the necessary privilege.
Check that user is only able to execute `DROP SETTINGS PROFILE` when they have the necessary privilege.
def drop_settings_profile(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `DROP SETTINGS PROFILE` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.conte...
[ "def", "drop_settings_profile", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", ...
[ 52, 0 ]
[ 133, 85 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of DROP SETTINGS PROFILE.
Check the RBAC functionality of DROP SETTINGS PROFILE.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of DROP SETTINGS PROFILE. """ self.context.node = self.context.cluster.node(node) Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=privileges_granted_via_role, setup=instrument_clickhouse_...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "privileges_granted_directly", ",", ...
[ 142, 0 ]
[ 148, 82 ]
python
en
['en', 'en', 'en']
True
replicated_privileges_granted_directly
(self, node=None)
Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted directly.
Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted directly.
def replicated_privileges_granted_directly(self, node=None): """Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_na...
[ "def", "replicated_privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", ...
[ 8, 0 ]
[ 22, 80 ]
python
en
['en', 'en', 'en']
True
replicated_privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted via role.
Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted via role.
def replicated_privileges_granted_via_role(self, node=None): """Check that a user is able to execute `SYSTEM FETCHES` commands if and only if the privilege has been granted via role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.n...
[ "def", "replicated_privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node...
[ 25, 0 ]
[ 43, 80 ]
python
en
['en', 'en', 'en']
True
check_replicated_privilege
(self, privilege, on, grant_target_name, user_name, node=None)
Run checks for commands that require SYSTEM FETCHES privilege.
Run checks for commands that require SYSTEM FETCHES privilege.
def check_replicated_privilege(self, privilege, on, grant_target_name, user_name, node=None): """Run checks for commands that require SYSTEM FETCHES privilege. """ if node is None: node = self.context.node Suite(test=start_replication_queues)(privilege=privilege, on=on, grant_target_name=grant...
[ "def", "check_replicated_privilege", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "Suite", "("...
[ 55, 0 ]
[ 63, 125 ]
python
en
['en', 'en', 'en']
True
start_replication_queues
(self, privilege, on, grant_target_name, user_name, node=None)
Check that user is only able to execute `SYSTEM START FETCHES` when they have privilege.
Check that user is only able to execute `SYSTEM START FETCHES` when they have privilege.
def start_replication_queues(self, privilege, on, grant_target_name, user_name, node=None): """Check that user is only able to execute `SYSTEM START FETCHES` when they have privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) table_name = f"table_name_{getuid()}" if node ...
[ "def", "start_replication_queues", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name",...
[ 66, 0 ]
[ 109, 55 ]
python
en
['en', 'en', 'en']
True
stop_replication_queues
(self, privilege, on, grant_target_name, user_name, node=None)
Check that user is only able to execute `SYSTEM STOP FETCHES` when they have privilege.
Check that user is only able to execute `SYSTEM STOP FETCHES` when they have privilege.
def stop_replication_queues(self, privilege, on, grant_target_name, user_name, node=None): """Check that user is only able to execute `SYSTEM STOP FETCHES` when they have privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) table_name = f"table_name_{getuid()}" if node is...
[ "def", "stop_replication_queues", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ...
[ 112, 0 ]
[ 155, 55 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of SYSTEM FETCHES.
Check the RBAC functionality of SYSTEM FETCHES.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of SYSTEM FETCHES. """ self.context.node = self.context.cluster.node(node) Suite(run=replicated_privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=replicated_privileges_granted_via_role, setup=instrum...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "replicated_privileges_granted_directly...
[ 164, 0 ]
[ 170, 93 ]
python
en
['en', 'en', 'en']
True
is_good_response
(resp)
Returns True if the response seems to be HTML, False otherwise.
Returns True if the response seems to be HTML, False otherwise.
def is_good_response(resp): """ Returns True if the response seems to be HTML, False otherwise. """ content_type = resp.headers['Content-Type'].lower() return (resp.status_code == 200 and content_type is not None and content_type.find('html') > -1)
[ "def", "is_good_response", "(", "resp", ")", ":", "content_type", "=", "resp", ".", "headers", "[", "'Content-Type'", "]", ".", "lower", "(", ")", "return", "(", "resp", ".", "status_code", "==", "200", "and", "content_type", "is", "not", "None", "and", ...
[ 39, 0 ]
[ 46, 47 ]
python
en
['en', 'error', 'th']
False
BaseModel.__init__
(self, internal_states_labels: list, internal_params_labels: list, range_delay=None, stochastic=False)
This is an abstract class for epidemiological models. Parameters ---------- internal_states_labels: list of str Labels for each internal state of the model. internal_params_labels: list of str Labels for each parameter of t...
This is an abstract class for epidemiological models.
def __init__(self, internal_states_labels: list, internal_params_labels: list, range_delay=None, stochastic=False): """This is an abstract class for epidemiological models. Parameters ---------- internal_states_labels: ...
[ "def", "__init__", "(", "self", ",", "internal_states_labels", ":", "list", ",", "internal_params_labels", ":", "list", ",", "range_delay", "=", "None", ",", "stochastic", "=", "False", ")", ":", "self", ".", "internal_states_labels", "=", "internal_states_labels"...
[ 6, 4 ]
[ 45, 20 ]
python
en
['en', 'en', 'en']
True
BaseModel.reset
(self, delay=None)
Resets the model parameters, and state, add delay. Parameters ---------- delay: int, optional Number of days the model should be run for before the start of the episode. Default is 0.
Resets the model parameters, and state, add delay.
def reset(self, delay=None) -> None: """Resets the model parameters, and state, add delay. Parameters ---------- delay: int, optional Number of days the model should be run for before the start of the episode. Default is 0. """ self._sample...
[ "def", "reset", "(", "self", ",", "delay", "=", "None", ")", "->", "None", ":", "self", ".", "_sample_model_params", "(", ")", "self", ".", "_sample_initial_state", "(", ")", "self", ".", "_reset_state", "(", ")", "if", "self", ".", "stochastic", ":", ...
[ 47, 4 ]
[ 64, 28 ]
python
en
['en', 'en', 'en']
True
BaseModel.reset_same_model
(self)
Resets the model to its former initial conditions with its current parameters.
Resets the model to its former initial conditions with its current parameters.
def reset_same_model(self) -> None: """ Resets the model to its former initial conditions with its current parameters. """ self._reset_model_params() self._reset_state()
[ "def", "reset_same_model", "(", "self", ")", "->", "None", ":", "self", ".", "_reset_model_params", "(", ")", "self", ".", "_reset_state", "(", ")" ]
[ 66, 4 ]
[ 72, 27 ]
python
en
['en', 'error', 'th']
False
BaseModel.delay
(self, random=True, delay=None)
Run the model for 'delay' steps before the beginning of the episode. Parameters ---------- delay: int Delay before the episode starts in days. Returns ------- 1D nd.array Latest model state
Run the model for 'delay' steps before the beginning of the episode.
def delay(self, random=True, delay=None): """ Run the model for 'delay' steps before the beginning of the episode. Parameters ---------- delay: int Delay before the episode starts in days. Returns ------- 1D nd.array Latest mod...
[ "def", "delay", "(", "self", ",", "random", "=", "True", ",", "delay", "=", "None", ")", ":", "if", "not", "random", ":", "assert", "delay", "is", "not", "None", "else", ":", "if", "self", ".", "range_delay", "is", "not", "None", ":", "delay", "=",...
[ 74, 4 ]
[ 96, 48 ]
python
en
['en', 'error', 'th']
False
BaseModel._sample_initial_state
(self)
Samples the initial state of the model (abstract)
Samples the initial state of the model (abstract)
def _sample_initial_state(self): """ Samples the initial state of the model (abstract) """ pass
[ "def", "_sample_initial_state", "(", "self", ")", ":", "pass" ]
[ 100, 4 ]
[ 105, 12 ]
python
en
['en', 'error', 'th']
False
BaseModel._sample_model_params
(self)
Samples parameters of the model (abstract)
Samples parameters of the model (abstract)
def _sample_model_params(self): """ Samples parameters of the model (abstract) """ pass
[ "def", "_sample_model_params", "(", "self", ")", ":", "pass" ]
[ 108, 4 ]
[ 113, 12 ]
python
en
['en', 'error', 'th']
False
BaseModel.run_n_steps
(self, current_state=None, n=1)
Runs the model for n steps. Parameters ---------- current_state: 1D nd.array Current state of the model. n: int Number of steps the model should be run for. Returns ------- new_state: 2D nd.array Retu...
Runs the model for n steps.
def run_n_steps(self, current_state=None, n=1): """ Runs the model for n steps. Parameters ---------- current_state: 1D nd.array Current state of the model. n: int Number of steps the model should ...
[ "def", "run_n_steps", "(", "self", ",", "current_state", "=", "None", ",", "n", "=", "1", ")", ":", "pass" ]
[ 116, 4 ]
[ 135, 12 ]
python
en
['en', 'error', 'th']
False
BaseModel._reset_model_params
(self)
Resets model parameters to their initial values.
Resets model parameters to their initial values.
def _reset_model_params(self) -> None: """ Resets model parameters to their initial values. """ self.current_internal_params = self.initial_internal_params.copy()
[ "def", "_reset_model_params", "(", "self", ")", "->", "None", ":", "self", ".", "current_internal_params", "=", "self", ".", "initial_internal_params", ".", "copy", "(", ")" ]
[ 137, 4 ]
[ 142, 74 ]
python
en
['en', 'error', 'th']
False
BaseModel._get_model_params
(self)
Get current parameters of the model Returns ------- tuple tuple of the model parameters in the order of the list of labels
Get current parameters of the model
def _get_model_params(self) -> tuple: """ Get current parameters of the model Returns ------- tuple tuple of the model parameters in the order of the list of labels """ return tuple([self.current_internal_params[k] for k in self.internal_params_labels...
[ "def", "_get_model_params", "(", "self", ")", "->", "tuple", ":", "return", "tuple", "(", "[", "self", ".", "current_internal_params", "[", "k", "]", "for", "k", "in", "self", ".", "internal_params_labels", "]", ")" ]
[ 144, 4 ]
[ 153, 92 ]
python
en
['en', 'error', 'th']
False
BaseModel._reset_state
(self)
Resets model state to initial state.
Resets model state to initial state.
def _reset_state(self): """ Resets model state to initial state. """ self.current_state = dict(zip(self.internal_states_labels, np.array([self.initial_state['{}0'.format(s)] for s in self.internal_states_labels])))
[ "def", "_reset_state", "(", "self", ")", ":", "self", ".", "current_state", "=", "dict", "(", "zip", "(", "self", ".", "internal_states_labels", ",", "np", ".", "array", "(", "[", "self", ".", "initial_state", "[", "'{}0'", ".", "format", "(", "s", ")"...
[ 155, 4 ]
[ 159, 153 ]
python
en
['en', 'error', 'th']
False
BaseModel._get_current_state
(self)
Get current state in the order of state labels.
Get current state in the order of state labels.
def _get_current_state(self): """ Get current state in the order of state labels. """ return np.array([self.current_state['{}'.format(s)] for s in self.internal_states_labels])
[ "def", "_get_current_state", "(", "self", ")", ":", "return", "np", ".", "array", "(", "[", "self", ".", "current_state", "[", "'{}'", ".", "format", "(", "s", ")", "]", "for", "s", "in", "self", ".", "internal_states_labels", "]", ")" ]
[ 161, 4 ]
[ 167, 98 ]
python
en
['en', 'error', 'th']
False
BaseModel._set_current_state
(self, current_state)
Set current state to given values. Parameters ---------- current_state: 1D nd.array State the current state should be set to.
Set current state to given values.
def _set_current_state(self, current_state): """ Set current state to given values. Parameters ---------- current_state: 1D nd.array State the current state should be set to. """ self.current_state = dict(zip(self.internal_states_labels, c...
[ "def", "_set_current_state", "(", "self", ",", "current_state", ")", ":", "self", ".", "current_state", "=", "dict", "(", "zip", "(", "self", ".", "internal_states_labels", ",", "current_state", ")", ")" ]
[ 169, 4 ]
[ 179, 82 ]
python
en
['en', 'error', 'th']
False