query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Function to create a discrete node split.
def get_discrete_node ( self, feature_matrix, target_array, feature_column, feature_value, node ): # Get the unique values for the X poitns unique_x_vals = self.discrete_value_maps [ feature_column ] # Create the node with an empty child for each x value node.updateTreeValues ( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_split(cls, op, op_t):\n node = cls._common_singa_tensor_to_onnx_node(op, op_t)\n\n node.attribute.extend([\n helper.make_attribute('axis', op.axis),\n helper.make_attribute('split', op.parts),\n ])\n return node", "def create_split(self) -> NoReturn:\...
[ "0.6879672", "0.66267234", "0.65676033", "0.6179339", "0.6152159", "0.5976991", "0.5958041", "0.5940135", "0.5805374", "0.57914776", "0.57853085", "0.5728951", "0.56534255", "0.5645786", "0.56177664", "0.5589983", "0.5586557", "0.5562353", "0.55578905", "0.55205125", "0.54881...
0.5515158
20
Function to get the next split in the decision tree
def get_next_split ( self, feature_matrix: np.ndarray, target_array: np.ndarray, tree_split: TreeSplits): # If only 1 y value, make a leaf node if len ( set ( target_array ) ) == 1: tree_split.updateTreeValues ( feature_column = None, feature_value = None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nextSplit(self):\n pass", "def split_next(self):\n # Consider the node with the highest loss reduction (a.k.a. gain)\n node = heappop(self.splittable_nodes)\n\n tic = time()\n (sample_indices_left,\n sample_indices_right,\n right_child_pos) = self.splitter.s...
[ "0.72422147", "0.6587546", "0.6098902", "0.607232", "0.60684705", "0.60498345", "0.6005773", "0.59968233", "0.59107053", "0.5817029", "0.5778859", "0.5776043", "0.5758599", "0.5738114", "0.5722309", "0.5722309", "0.5703586", "0.56686014", "0.5667164", "0.5667024", "0.5664685"...
0.6345202
2
Function to fit the decision tree
def fit ( self, feature_matrix: np.ndarray, target_array: np.ndarray): # Create the root node self.root = TreeSplits() # Get all possible values for discrete valued columns # Necessary so each split can handle unique X values that # were not in the training set. self.dis...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fit_decision_tree(model, x_train, y_train):\r\n model.fit(x_train, y_train)\r\n score = model.score(x_train, y_train)\r\n importance = model.feature_importances_\r\n return score, importance", "def train_decision_tree():\n train_model(DecisionTreeRegressor(max_depth=3, random_state=42),\n ...
[ "0.77766097", "0.7377799", "0.729431", "0.72421414", "0.71106946", "0.70728546", "0.69706905", "0.6933395", "0.692453", "0.68938357", "0.6887726", "0.6838739", "0.6834463", "0.6828714", "0.6772153", "0.6772153", "0.6662862", "0.6650102", "0.65992475", "0.6572775", "0.6558867"...
0.0
-1
Function to get all the target values of leaves for a subtree. Used for postpruning
def collect_children ( node: TreeSplits ): if node.nodes is None or len ( node.nodes ) == 0: return node.children # Recursively get all the children and concatenate them return np.concatenate ( [ BaseTree.collect_children ( child_node ) fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leaves(tree):\n if is_leaf(tree):\n return [label(tree)]\n else:\n return sum([leaves(b) for b in branches(tree)], [])", "def get_leaves(tree):\n if tree.is_leaf:\n return [tree.indices]\n else:\n return get_leaves(tree.left_child) + get_leaves(tree.right_child)", "d...
[ "0.64149165", "0.6268147", "0.6199293", "0.60760117", "0.5998846", "0.5984824", "0.592592", "0.5859059", "0.58194226", "0.58169144", "0.5734021", "0.57295066", "0.57267654", "0.5701329", "0.56755906", "0.5645248", "0.5631038", "0.5622244", "0.55899423", "0.5583704", "0.558262...
0.0
-1
Function gets the prediction by treating a subtree as a leaf.
def predict_from_all_children ( self, node: TreeSplits ): # Collect the children children_values = BaseTree.collect_children ( node ) # Aggregate the leaf values return self.agg_function ( children_values ) # End predict_from_all_children
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _predict(self, treenode, X):\n if treenode.is_leaf:\n return treenode.leaf_score\n elif pd.isnull(X[1][treenode.feature]):\n if treenode.nan_direction == 0:\n return self._predict(treenode.left_child, X)\n else:\n return self._predict...
[ "0.73726535", "0.7305055", "0.72884184", "0.68872315", "0.6845775", "0.6741382", "0.67383456", "0.67291856", "0.67155856", "0.664063", "0.66377825", "0.65606916", "0.65345055", "0.6481487", "0.6466333", "0.64396113", "0.6425822", "0.641785", "0.64166534", "0.6359143", "0.6341...
0.6237798
25
Function which makes predictions based on a subtree
def predict_node ( self, feature_matrix: np.ndarray, node: TreeSplits ): # If leaf, return children target values if node.children is not None and len ( node.children ): return node.children # If continuous, split appropriately, and make recursive call if node.node_type == "...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_example(x, tree):\r\n\r\n # INSERT YOUR CODE HERE. NOTE: THIS IS A RECURSIVE FUNCTION.\r\n \r\n for branching_value, subtree in tree.items():\r\n attr_index = branching_value[0]\r\n attr_value = branching_value[1]\r\n split_decision = branching_value[2]\r\n\r\n if s...
[ "0.7251586", "0.7180416", "0.7117868", "0.7090114", "0.7047164", "0.7041305", "0.7013195", "0.69450426", "0.6935808", "0.6813366", "0.68088096", "0.68065083", "0.6770708", "0.6596798", "0.6544427", "0.6533072", "0.65033436", "0.6477702", "0.6445264", "0.6400186", "0.6392303",...
0.61561775
40
Function to make predictions over an X matrix
def predict ( self, feature_matrix: np.ndarray, node: TreeSplits = None ): node = self.root if not node else node if feature_matrix.ndim == 1: # If just one row, predict return self.agg_function ( self.predict_node ( feature_matrix = feature_matrix, node = node ) ) # If ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, X):", "def predict(self, X):", "def predict(self, X):\n ...", "def predict(self, X):\n ...", "def predict(self, X):\n ...", "def predict(self, x):\n \n\n return predictions", "def predict(self,X): \n return self._predict(X)", "def predict(se...
[ "0.8184807", "0.8184807", "0.80694795", "0.80694795", "0.80694795", "0.79561454", "0.7893413", "0.78499883", "0.78499883", "0.78499883", "0.7741521", "0.7699846", "0.7668127", "0.7650042", "0.75861543", "0.75762063", "0.75502324", "0.7527598", "0.752281", "0.7517701", "0.7517...
0.0
-1
Function to test a subtree for pruning.
def tag_node_from_pruning ( self, tree, node, feature_matrix, target_array ): # If is a leaf, return False if node.nodes is None or len ( node.nodes ) == 0: return False # Score predictions from whole tree predictions = tree.predict ( feature_matrix ) whole_tree_scor...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _prune( tree, impurity_crit, dataSet, treeSeq ):\n\n\t\tsaved = {}\n\n\t\ttotal_leaf_impurity, num_leaves = DecisionTree._fetch(tree, impurity_crit, dataSet, saved)\n\n\t\tnodes, sets, G = saved['node'], saved['set'], saved['G']\n\n\t\t# choose TreeNode such that g is minimum to prune\n\t\tmin_g_ind = np.argmi...
[ "0.6757538", "0.65374196", "0.6457873", "0.6327665", "0.6244245", "0.6157366", "0.61086893", "0.60678625", "0.60539806", "0.5990413", "0.59583294", "0.5913224", "0.5904743", "0.5879302", "0.58372855", "0.5814479", "0.5754499", "0.5735543", "0.56741375", "0.56655", "0.56423604...
0.51750505
65
Function to prune a given node
def prune_node (self, tree: BaseTree, node: TreeSplits): # Prune node, get if change change_made = self.tag_node_from_pruning ( tree = tree, node = node, feature_matrix = self.X_validation, target_array = self.y_validation ) # If change not made and it's not a leaf i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_prune(self, function_graph, node, reason):", "def prune(self, node, exclude=None):\n for child in node.children:\n if exclude and exclude.id != child.id:\n self.prune(child, exclude)\n\n self.nodes[node.id] = None\n del self.nodes[node.id]", "def prune_node...
[ "0.7823959", "0.75583607", "0.6794292", "0.66370064", "0.6618599", "0.6538975", "0.6535095", "0.6478751", "0.6396522", "0.6379691", "0.6367987", "0.6344035", "0.6319461", "0.62772906", "0.6246157", "0.62271076", "0.6200702", "0.61402917", "0.61102575", "0.6105385", "0.6104484...
0.69929415
2
Function to prune a tree.
def prune_tree ( self ): tree = copy.deepcopy ( self.tree ) change_made = True # As long as changes are made, recursively prune from the root node. while change_made: change_made = self.prune_node ( tree, tree.root ) return tree # End prune_tree()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prune_tree(self):\n tree = copy.deepcopy(self.tree)\n change_made = True\n # As long as changes are made, recursively prune from the root node.\n while change_made:\n change_made = self.prune_node(tree, tree.root)\n return tree", "def prune(self, n_leaves):\n ...
[ "0.76428306", "0.757985", "0.74307483", "0.7363779", "0.73275864", "0.732632", "0.7228591", "0.72047454", "0.7031705", "0.6908371", "0.6862588", "0.6833638", "0.676064", "0.67177105", "0.67132443", "0.6611636", "0.6551961", "0.65180445", "0.65033764", "0.64932555", "0.6482528...
0.77864975
0
Function to run classification experiment
def run_classification_experiment ( feature_matrix, target_array, colmap ): np.random.seed ( 7062020 ) # Due date # Split off validation set and cross-validation set X_validation = feature_matrix [ : feature_matrix.shape [ 0 ] // 10 ] X_cross_validation = feature_matrix [ feature_matrix.shape [ 0 ] //...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_classification_experiment(data_set_path, learner, positive_class_name, data_type=float):\n print(\"Running {0} Experiment with positive class = {1}\".format(data_set_path, positive_class_name))\n\n # Network structure.\n print(\"Number of Hidden Layers: {}\".format(len(learner.weights)-1))\n pr...
[ "0.7555303", "0.71173567", "0.70545274", "0.70258445", "0.69593644", "0.6909916", "0.6901521", "0.6863415", "0.68557537", "0.6821653", "0.67475575", "0.67457944", "0.6727784", "0.67036206", "0.67031395", "0.67025673", "0.67003846", "0.669516", "0.6651564", "0.6640094", "0.663...
0.69589823
5
Function to run regression experiment
def run_regression_experiment ( feature_matrix, target_array, early_stopping_values ): np.random.seed ( 7062020 ) # Due date X_validation = feature_matrix [ : feature_matrix.shape [ 0 ] // 10 ] X_cross_validation = feature_matrix [ feature_matrix.shape [ 0 ] // 10 : ] y_validation = target_array [ : fea...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run_regressions(test_data, model):\n answer = model._Run_Regressions(\n test_data,\n 100,\n forecasts={\"arima\", \"holtwinters\", \"prophet\", \"arima_r\", \"sarima_r\"}\n )", "def run():\n\n df = read_input() # the parameters\n df = add_time_period(df) # a feature\n ...
[ "0.7170951", "0.7053031", "0.6840249", "0.6774338", "0.6767782", "0.67024475", "0.66778004", "0.6634623", "0.65704435", "0.6561046", "0.6554445", "0.64907575", "0.6428488", "0.64265656", "0.6409631", "0.64052933", "0.6398685", "0.6391104", "0.6386898", "0.6347162", "0.6340198...
0.0
-1
Function obtains indices of length of rows in feature matrix X
def get_indices ( self, feature_matrix ): # Shuffle if `self.shuffle` is true. nrows = feature_matrix.shape [ 0 ] return ( np.random.permutation ( np.arange ( nrows ) ) # Shuffle the rows if `self.shuffle` if self.shuffle e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feature_to_index(feature, dims):\n p = 0\n for j, k in enumerate(feature):\n print(\"j:\", \"k:\", k, \"dims\", dims[:j])\n p += int(np.prod(dims[:j])) * k\n return p", "def get_num_features(self):\r\n \r\n return len(self[0]['x'])", "def __len__(self):\n return ...
[ "0.68508416", "0.6607199", "0.6558984", "0.62764865", "0.61540145", "0.6143088", "0.61092424", "0.6106243", "0.6093235", "0.6086436", "0.60840034", "0.60784405", "0.6062819", "0.604969", "0.6011112", "0.6004441", "0.5983271", "0.5979516", "0.5979018", "0.59567195", "0.5944685...
0.6091677
9
Given the split indices, function obtains one of the training splits
def _get_one_split ( split_indices, number_of_split ): # Given the split indices, get the `number_of_split` element of the indices. return ( np.delete ( np.concatenate ( split_indices ), split_indices [ number_of_split ] ), # Drops the test from the train split_indices [ number_of_spli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def indices_of_split(self, split_name='train'):\n return self.indices_of('split', split_name)", "def train_valid_index_split(all_index, train_size = None, valid_split = 0.3):\n\tall_index = np.arange(all_index) if isinstance(all_index, int) else np.array(all_index)\n\ttrain_size = len(all_index) if train_size...
[ "0.6946859", "0.680867", "0.6726826", "0.66065216", "0.62583315", "0.6195574", "0.6195574", "0.61884665", "0.618018", "0.61747795", "0.6159418", "0.61322176", "0.61260164", "0.60440093", "0.6012981", "0.6004573", "0.5996648", "0.5986898", "0.59850836", "0.59788764", "0.593213...
0.80875164
1
Function splits the indices by the number of folds
def _get_indices_split ( indices, number_of_folds ): # Split the indicies by the number of folds return np.array_split ( indices, indices_or_sections = number_of_folds ) # End get_indices_split()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fold(nb_splits, dataset):\r\n index = np.arange(np.shape(dataset)[0])\r\n splits = np.split(index, nb_splits)\r\n\r\n index = []\r\n\r\n for n_fold in np.arange(nb_splits):\r\n index.append((splits[n_fold].tolist(),(np.concatenate([x for i,x in enumerate(splits) if i!=n_fold])).tolist()))\r\...
[ "0.78790355", "0.7600039", "0.71495384", "0.7104353", "0.6637206", "0.6535842", "0.6340548", "0.6302971", "0.6302251", "0.62954754", "0.62954754", "0.62938744", "0.6240823", "0.62392235", "0.6203992", "0.6193665", "0.6119545", "0.61134005", "0.60917705", "0.6089957", "0.60720...
0.8309637
1
Function creates a generator of train/test splits from feature matrix X
def split ( self, feature_matrix: np.ndarray, target_array: np.ndarray = None ): # Split the indices into `number_of_folds` subarray indices = self.get_indices ( feature_matrix ) split_indices = KFoldCV._get_indices_split ( indices = indices, number_of_folds = self.number_of_folds ) for ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split(self,X,y=None):\n all_idx = pd.Series(np.arange(X.shape[0])) \n mbrg = int(X.shape[0]*self.embargo_pct)\n test_starts=[(i[0],i[-1]+1) for i in np.array_split(all_idx.values,self.n_splits)]\n for i, j in test_starts:\n t0 = all_idx.index[i] # start of test set\n ...
[ "0.7445462", "0.7317444", "0.7171339", "0.6934437", "0.6873336", "0.6599626", "0.65487504", "0.65389675", "0.6490598", "0.6489834", "0.64814985", "0.64605737", "0.64358217", "0.6416908", "0.6387303", "0.63864625", "0.6376802", "0.6374079", "0.63144904", "0.6305631", "0.630481...
0.6842673
5
Function adds new column called "split"
def add_split_col ( self, feature_array ): feature_array = feature_array if not self.shuffle else np.random.permutation ( feature_array ) n = len ( feature_array ) k = int ( np.ceil ( n / self.number_of_folds ) ) return pd.DataFrame ( { "index": feature_array, "split": np.til...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def FE_split_add_column(dft, col, splitter=',', action='add'):\r\n dft = copy.deepcopy(dft)\r\n new_col = col + '_split_apply'\r\n print('Creating column = %s using split_add feature engineering...' %new_col)\r\n if action in ['+','-','*','/','add','subtract','multiply','divide']:\r\n if action ...
[ "0.70793533", "0.6979426", "0.6646522", "0.6312934", "0.6276767", "0.6180665", "0.60511595", "0.58757806", "0.58685505", "0.58671844", "0.5830357", "0.5812464", "0.5775889", "0.5757142", "0.5717239", "0.56658155", "0.56388277", "0.56223357", "0.55786914", "0.54897255", "0.548...
0.5971428
7
Function takes an array of classes, and creates train/test splits with proportional examples for each group.
def split ( self, target_array, feature_matrix = None ): # Make sure y is an array target_array = np.array ( target_array ) if isinstance ( target_array, list ) else target_array # Groupby y and add integer indices. df_with_split = ( pd.DataFrame ( { "y": target_array, "inde...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitData(groupList, trainSize):\r\n from sklearn.model_selection import StratifiedShuffleSplit\r\n\r\n groupList[0]['text'] = cleanRealTexts(list(groupList[0]['text']))\r\n\r\n classLabels = np.array([])\r\n for i, group in enumerate(groupList):\r\n classLabels = np.append(classLabels, np.r...
[ "0.69671094", "0.6935927", "0.68803024", "0.67468333", "0.65711087", "0.6552346", "0.65297866", "0.6526746", "0.6494246", "0.63984704", "0.6372851", "0.6314143", "0.6303204", "0.6303204", "0.6286704", "0.628164", "0.6279098", "0.6203552", "0.61877185", "0.6187187", "0.6186407...
0.0
-1
Function creates a mapping of arguments to values to grid search over.
def create_param_grid ( param_grid: Dict ): return ( dict ( zip ( param_grid.keys(), instance ) ) for instance in product ( * param_grid.values() ) ) # End create_param_grid
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_grid(parameters):\n grid = {}\n for c_name, c_type, c_vals in parameters:\n if c_type == \"choice\":\n grid[c_name] = c_vals\n elif c_type == \"fixed\":\n grid[c_name] = [c_vals]\n else:\n raise ValueError(\"GridSearch can only use categorical...
[ "0.6630265", "0.6563484", "0.60290205", "0.59737265", "0.59663725", "0.5853442", "0.5811071", "0.57477045", "0.570582", "0.5683749", "0.5681522", "0.5669857", "0.56621957", "0.56388795", "0.5599613", "0.559585", "0.5566635", "0.5566635", "0.55430984", "0.5477576", "0.5477576"...
0.6079484
3
Function runs a model fit and a validation step.
def get_single_fitting_iteration ( self, feature_matrix: np.ndarray, target_array: np.ndarray, model ): scores = [] if self.cv_object: # Create train/test splits for train, test in self.cv_object.split ( feature_matrix = feature_matrix, target_array = target_arr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _evaluate_during_fit(self, test_loader, epoch):", "def _fit(self, x_train, y_train, x_valid, y_valid, regressor_callback=None):", "def fit(epochs, model, loss_func, opt, train_dl, valid_dl):\n def train():\n \"\"\"Train model for one epoch.\"\"\"\n model.train()\n for batch_index, (...
[ "0.71327233", "0.7107278", "0.70992154", "0.7027115", "0.699485", "0.6873614", "0.68706995", "0.683266", "0.68170667", "0.67857736", "0.67634565", "0.6738605", "0.6716458", "0.6715485", "0.6705056", "0.6692423", "0.6687187", "0.66685694", "0.6666301", "0.6655238", "0.66347945...
0.0
-1
Function runs the grid search across the parameter grid.
def get_cv_scores ( self, feature_matrix: np.ndarray, target_array: np.ndarray ): # Create the parameter grid param_grid = list ( GridSearchCV.create_param_grid ( self.param_grid ) ) # Zip the grid to the results from a single fit return zip ( param_grid, [ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grid_search(self, params):\n train_X, train_y, dev_X, dev_y = self.extract_train_dev_data()\n clf = self.classifiers[0]\n pred_y = clf.grid_search(params, train_X, train_y, dev_X)\n logger.info(classification_report(dev_y, pred_y))", "def FindGrid(self, p_float=..., p_float=..., p...
[ "0.73994136", "0.724876", "0.7212698", "0.70302624", "0.69863653", "0.69728756", "0.6971818", "0.6971692", "0.6942894", "0.6706154", "0.66942745", "0.6680439", "0.6678906", "0.6663483", "0.6650619", "0.66011894", "0.659441", "0.65446216", "0.6542018", "0.65298516", "0.6524632...
0.0
-1
Function to get classifier accuracy
def accuracy ( actuals, predictions ): return np.mean ( actuals == predictions ) # End accuracy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accuracy(self):", "def accuracy(self):\r\n # Load tarined model using intent id.\r\n clf = joblib.load(filename=self.intention_id+'.pkl')\r\n # Compute accuracy for hole training data and return.\r\n return clf.score(X=self.training_data, y=self.target_data)", "def accuracy(clf,...
[ "0.8496106", "0.8096605", "0.801635", "0.8007906", "0.8000073", "0.79757977", "0.7973719", "0.78371614", "0.7820705", "0.77562433", "0.77545613", "0.77506614", "0.7692017", "0.7687957", "0.76814085", "0.7674037", "0.7672642", "0.7662792", "0.76614755", "0.7658593", "0.7611567...
0.7498263
31
Function to get MSE
def mean_squared_error ( actuals, predictions ): return np.mean ( ( actuals - predictions ) ** 2 ) # End mean_squared_error()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_MSE(e):\n\n return 1/2*np.mean(e**2)", "def calculate_mse(e):\r\n return 1/2*np.mean(e**2)", "def calculate_mse(e):\n return 1/2*np.mean(e.dot(e))", "def _mse(self):\n error = self._input * self._weights - self._label\n sum_ = 0.0\n for i in range(self._input.shape[0...
[ "0.8160725", "0.78669804", "0.7640311", "0.75215", "0.75183463", "0.7489461", "0.74785423", "0.74559116", "0.74378157", "0.72474", "0.70897496", "0.70897496", "0.7059256", "0.7040443", "0.7005932", "0.69923854", "0.69908667", "0.69908667", "0.6931149", "0.6910345", "0.6901799...
0.0
-1
Function to use crossvalidation to choose a value of k
def choose_k ( feature_matrix, target_array, model_call, param_grid, scoring_func = accuracy, cv = KFoldStratifiedCV ( number_of_folds = 3 ), ): grid_search_cv = GridSearchCV ( model_callable = model_call, param_grid = param_grid, scoring_func = scoring_func, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_validation(self, k=5):\n test_errors, train_errors = [], []\n\n # For leave out cross validation k = n\n if k == -1:\n k = len(data)\n\n for _ in range(k):\n shuffled_data = data.copy()\n\n # Do not shuffle data for leave one out cross validati...
[ "0.7224282", "0.7093413", "0.70916903", "0.70881224", "0.70334035", "0.7002712", "0.6994055", "0.69897985", "0.69870645", "0.6966804", "0.6940088", "0.6907635", "0.6839479", "0.67935413", "0.6744706", "0.6740456", "0.6682505", "0.66799736", "0.6622509", "0.65909576", "0.65484...
0.676675
14
HTTP 404 custom handler.
def custom_404(request, exception=None): return render(request, "404.html", {"exception": exception})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handler404(request, *args, **argv):\n response = render_to_response('404.html', {})\n response.status_code = 404\n return response", "def handleStatus_404(self):\n log.err('HTTP Error 404')", "def handler404(request):\n response = render_to_response('404.html', {})\n response.status_c...
[ "0.85132957", "0.8353488", "0.8330883", "0.81509715", "0.8048861", "0.80313754", "0.786501", "0.77363306", "0.7723717", "0.7723717", "0.76770884", "0.7660519", "0.76588506", "0.76477534", "0.76434803", "0.76398075", "0.7615034", "0.7605221", "0.75976616", "0.75976616", "0.759...
0.75459987
33
HTTP 500 custom handler.
def custom_500(request, exception=None): return render(request, "500.html", {"exception": exception})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handler500(request, *args, **argv):\n response = render_to_response('500.html', {})\n response.status_code = 500\n return response", "def handler500(request):\n response = render_to_response('500.html', {}, RequestContext(request))\n response.status_code = 500\n return response", "def han...
[ "0.86234283", "0.8478117", "0.82295", "0.786497", "0.7826512", "0.7707343", "0.7634453", "0.7619125", "0.75892836", "0.75564367", "0.7447762", "0.73859936", "0.7378208", "0.73606354", "0.7347734", "0.7283436", "0.72626084", "0.725488", "0.72149926", "0.72052675", "0.7164875",...
0.77075195
5
>>> s = Solution() >>> s.numSpecial([[1,0,0],[0,0,1],[1,0,0]]) 1
def numSpecial(self, mat: list[list[int]]) -> int: ans = 0 col_cache = {} for row in mat: # print(row) ones = [] for i, n in enumerate(row): if n == 1: ones.append(i) # print(ones) if len(ones) == 1: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nits(self):", "def J (self, n):", "def __len__(self):\n if self.solution is None:\n return 0\n elif isinstance(self.solution, list):\n return len(self.solution)\n else:\n return 1", "def double_nums(num_list):", "def __init__(self, nums):\n d...
[ "0.5634397", "0.533418", "0.52352107", "0.5177232", "0.50461686", "0.50198936", "0.50171566", "0.5002507", "0.49893063", "0.49433863", "0.49368918", "0.49326292", "0.49240553", "0.4905042", "0.48826474", "0.485887", "0.4855875", "0.48495466", "0.48342177", "0.48332715", "0.48...
0.6581576
0
get frame process frame handle result of processing process output
def run(self): last_mean = 0 st = time.time() sframe = 0 while True: if time.time()-1 > st: st = time.time() #print 'fps', self.frame_counter - sframe sframe = self.frame_counter self.frame_counter += 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_frame(self, frame):\n\t\treturn frame", "def process_frame():\n return \"OK\"", "def process_results(process_object):\n (stdout, stderr)=process_object.communicate()\n return (process_object.returncode, stdout, stderr)", "def _get_output(self):\n return self.__output", "def _get_out...
[ "0.665789", "0.65517163", "0.607196", "0.6038569", "0.6038569", "0.6038569", "0.6038569", "0.6038569", "0.6038569", "0.59761804", "0.5886538", "0.5737582", "0.5724387", "0.572208", "0.572208", "0.5645779", "0.5604923", "0.5576578", "0.5565851", "0.5554697", "0.55533904", "0...
0.0
-1
Retrieve experiment specific phoneme information
def get_experiment_phn_info(): phone_list = ['##', 'aa', 'ae', 'ao', 'aw', 'ax', 'ay', 'bb', 'br', 'ch', 'dd', 'dh', 'eh', 'er', 'ey', 'ff', 'gg', 'hh', 'ih', 'iy', 'jh', 'kk', 'll', 'mm', 'ng', 'nn', 'ow', 'oy', 'pp', 'rr', 'sh', 'sp', 'ss', 'th', 'tt', 'uh', '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getexperimentinfo(expid):\n rdata = {}\n rdata['expId'] = expid\n res = requests.get(scbd_server_address + '/experiments/get_details', json=rdata)\n if res.status_code == 200:\n outstr = ''\n for cres in res.json()['details']:\n outstr += cres[0] + ':' + cres[1] + '<br>'\n ...
[ "0.5790809", "0.5501423", "0.5499727", "0.5498819", "0.54900473", "0.54471534", "0.53917515", "0.5380888", "0.5365359", "0.53366756", "0.5317841", "0.52648", "0.5258462", "0.52435106", "0.5186929", "0.5146196", "0.5093818", "0.50938", "0.50878394", "0.50823444", "0.5073125", ...
0.6426803
0
return a tuple containing all the experiment specific speaker related information
def get_experiment_speaker_info(db_root): seen_speakers = ['VCTK-speaker-p225-female', 'VCTK-speaker-p226-male', 'VCTK-speaker-p227-male', 'VCTK-speaker-p228-female', 'VCTK-speaker-p229-female', 'VCTK-speaker-p230-female', 'VCTK-speaker-p231-female', 'VCTK-speaker-p232-male', 'VCTK-speaker-p233-female', 'V...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def speaker_list(self):\n return \", \".join(str(speaker.person) for speaker in self.speakers.all())", "def extract_speaker_data(self, X, y):\r\n\r\n speaker_names = []\r\n global_idx = 0\r\n curr_speaker_num = -1\r\n old_speaker = ''\r\n\r\n # Crawl the base and all sub...
[ "0.6471933", "0.6339277", "0.63172996", "0.629798", "0.61967725", "0.60992134", "0.60636175", "0.5926962", "0.580786", "0.575381", "0.5750333", "0.5709002", "0.5697383", "0.56863433", "0.564128", "0.55814594", "0.5512268", "0.54673225", "0.54642814", "0.5446318", "0.5411513",...
0.72033405
0
sort `regions` in a descending order self The object regions A list of region which is in tuple form `regions` in a descending order.
def reverse_sort_regions(self, regions): return sorted(regions, key=lambda region: region[0], reverse=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concatregions(in_regions):\n out_regions = []\n if len(in_regions) == 0: # if no regions, then return empty\n return np.asarray(out_regions)\n for strand in [0,1]:\n # sort by left position\n on_strand = in_regions[in_regions[:,0] == strand]\n if len(on_strand) <= 1: # if 0...
[ "0.5818421", "0.5711712", "0.55216634", "0.54087275", "0.537096", "0.5370231", "0.5354793", "0.5290695", "0.51466596", "0.5135079", "0.5049498", "0.49889728", "0.49651736", "0.495241", "0.49407768", "0.49245477", "0.4892419", "0.48727", "0.48430598", "0.48423144", "0.48328733...
0.8506791
0
called after changes have been made to a view self The object view The view True if a replacement happened, False otherwise.
def on_modified(self, view): v = sublime.active_window().active_view() # fix the issue that breaks functionality for undo/soft_undo historyCmd = v.command_history(1) # this is from the redo stack if historyCmd[0] == PLUGIN_CMD: return False print(v.command_history...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replaceView(self, modeId, newView):\n oldView = None\n for view in self.__views:\n if view.modeId() == modeId:\n oldView = view\n break\n elif isinstance(view, _CompositeDataView):\n # recurse\n hooks = self.getHook...
[ "0.6698093", "0.6566338", "0.63016355", "0.62604386", "0.61732435", "0.60758954", "0.5874421", "0.5849249", "0.5848018", "0.5837404", "0.57142", "0.5711947", "0.5706732", "0.56667256", "0.56494045", "0.562875", "0.5618073", "0.55706793", "0.5516057", "0.5492775", "0.5480724",...
0.5966791
6
get the syntax file name and the syntax name which is on the bottomright corner of ST self The object view The view The current syntax.
def get_current_syntax(self, view): syntaxFile = view.settings().get('syntax') if syntaxFile not in syntaxInfos: syntaxInfos[syntaxFile] = { 'fileName' : os.path.splitext(os.path.basename(syntaxFile))[0], 'syntaxName' : self.find_syntax_name(syntaxFile), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_syntax_name(self, syntaxFile):\n\n content = sublime.load_resource(syntaxFile).strip()\n\n # .tmLanguage (XML)\n if content.startswith('<'):\n matches = self.nameXmlRegex.search(content)\n # .sublime-syntax (YAML)\n else:\n matches = self.nameYamlRe...
[ "0.60397613", "0.59165514", "0.5733196", "0.57180023", "0.57087535", "0.5576404", "0.5452801", "0.5322473", "0.5300614", "0.5289165", "0.5253225", "0.52486515", "0.5197351", "0.5190645", "0.5080132", "0.5079527", "0.50793636", "0.4998947", "0.4986166", "0.49765286", "0.494739...
0.69336903
0
find the name section in the give syntax file path self The object syntaxFile The path of a syntax file The syntax name of `syntaxFile` or None.
def find_syntax_name(self, syntaxFile): content = sublime.load_resource(syntaxFile).strip() # .tmLanguage (XML) if content.startswith('<'): matches = self.nameXmlRegex.search(content) # .sublime-syntax (YAML) else: matches = self.nameYamlRegex.search(con...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getSyntaxBySourceFileName(self, name, formatConverterFunction):\n for regExp, xmlFileName in self._extensionToXmlFileName.items():\n if regExp.match(name):\n return self._getSyntaxByXmlFileName(xmlFileName, formatConverterFunction)\n else:\n raise KeyError(\"...
[ "0.62873906", "0.6136943", "0.5446002", "0.5399976", "0.53163207", "0.5222896", "0.52083194", "0.5134081", "0.5114007", "0.5108348", "0.50795096", "0.5013631", "0.5010836", "0.5007915", "0.49805075", "0.49515027", "0.49298373", "0.49222234", "0.49050725", "0.48783788", "0.487...
0.7932906
0
set employee name and salary
def __init__(self,fname,lname,salary): self.first_name = fname self.last_name = lname self.salary = salary
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_salaried(self,salary,name):\n id = self.find_employee_id(name)\n if id in self.clsf:\n self.emp_dict[id][5] = \"2\"\n print(\"{}{}\".format(name,\" was successfully changed to be a salaried employee\"))\n self.emp_dict[id][7] = salary\n self.classi...
[ "0.72247374", "0.66080004", "0.6537093", "0.64817953", "0.64773196", "0.64633507", "0.637234", "0.6360494", "0.6305041", "0.6234114", "0.6188405", "0.6122401", "0.59281445", "0.5886777", "0.57775176", "0.5758939", "0.5757083", "0.5713785", "0.571265", "0.56920433", "0.5691727...
0.5555704
28
give $5000 raise as default or raise as per inout
def give_raise(self,amount=5000): self.salary += amount
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def give_raise(self, increase = 5000):\n\t\tself.increase = increase \n\t\tself.salary += increase", "def give_raise(self, amount=5000):\n\t\tself.annual_salary += amount", "def give_raise(self, amount=5000):\n self.salary += amount", "def apply_raise(self):\n self.pay = int(self.pay * self.rai...
[ "0.66732913", "0.6612099", "0.6555888", "0.6327619", "0.6268917", "0.6259644", "0.62239206", "0.6026449", "0.5994266", "0.5977445", "0.59706587", "0.5913774", "0.58989495", "0.58105314", "0.57626814", "0.57234055", "0.56761575", "0.5651629", "0.5606309", "0.5548258", "0.55305...
0.6504534
3
This files 'pass', register them as such and move their snapshots to the reference snapshots folder
def update_3(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ : Snapshots inspected, 'pass' test/test_accel_amplitude.py test/test_accel_deccel_amplitude.py test/test_acceldeccel.py test/test_accelerate.py test/test_accelerate_speed.py ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveSnapshot(self, filename): \n\t\tpass", "def syncfolder():", "def register_artifacts(self, which_pass):\n\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_INDEX_TABLE, which_pass\n )\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_STORE, which_pas...
[ "0.5904011", "0.58413935", "0.57848144", "0.56511885", "0.56056577", "0.56036234", "0.55917174", "0.5542068", "0.5518935", "0.5510767", "0.5492488", "0.5471138", "0.54641044", "0.5460884", "0.54597145", "0.5448846", "0.5443123", "0.5436103", "0.5423372", "0.5380155", "0.53798...
0.5158686
37
This files 'pass', register them as such and move their snapshots to the reference snapshots folder
def update_6(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ : Snapshots inspected, 'pass' test/test_cocosz.py test/test_delay.py test/test_draw.py test/test_liquid_16_x_16.py test/test_move_corner_down.py test/test_move_corner_up.py...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveSnapshot(self, filename): \n\t\tpass", "def syncfolder():", "def register_artifacts(self, which_pass):\n\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_INDEX_TABLE, which_pass\n )\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_STORE, which_pas...
[ "0.59056723", "0.58410805", "0.57843566", "0.5651954", "0.56048363", "0.5604114", "0.5592725", "0.5542086", "0.5518854", "0.5509179", "0.5492142", "0.54697585", "0.54642814", "0.54608977", "0.545977", "0.5447512", "0.5442904", "0.54362696", "0.5422522", "0.5379201", "0.534108...
0.5380971
19
This files 'pass', register them as such and move their snapshots to the reference snapshots folder
def update_9(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ test/test_action_non_interval.py test/test_all_collisions.py : puede no ser representativo; agregado z para ver si cuadrado rinde test/test_draw_resolution.py test/test_interpreter_layer.py : weak ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveSnapshot(self, filename): \n\t\tpass", "def syncfolder():", "def register_artifacts(self, which_pass):\n\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_INDEX_TABLE, which_pass\n )\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_STORE, which_pas...
[ "0.59056723", "0.58410805", "0.57843566", "0.5651954", "0.56048363", "0.5604114", "0.5592725", "0.5542086", "0.5518854", "0.5509179", "0.5492142", "0.54697585", "0.54642814", "0.54608977", "0.545977", "0.5447512", "0.5442904", "0.54362696", "0.5422522", "0.5380971", "0.537920...
0.0
-1
This files 'pass', register them as such and move their snapshots to the reference snapshots folder
def update_19(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ test/test_aspect_16_9_to_fullscreen.py test/test_aspect_4_3_to_fullscreen.py test/test_aspect_ratio_on_resize.py test/test_coords.py test/test_custom_on_resize.py test/test_entry_m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveSnapshot(self, filename): \n\t\tpass", "def syncfolder():", "def register_artifacts(self, which_pass):\n\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_INDEX_TABLE, which_pass\n )\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_STORE, which_pas...
[ "0.59038097", "0.58405656", "0.5784711", "0.5651934", "0.5604398", "0.5604276", "0.55919385", "0.5542104", "0.55189013", "0.5510264", "0.54917127", "0.54698503", "0.5464448", "0.5460157", "0.5460076", "0.5447427", "0.5442345", "0.54360855", "0.54222316", "0.53805226", "0.5378...
0.0
-1
This files 'pass', register them as such and move their snapshots to the reference snapshots folder
def update_21(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ test/test_label_changing.py test/test_batch2.py test/test_scalexy.py test/test_shader_examples.py """ candidates = doers.scripts_names_from_text(text, end_mark=':') checked_in, unknown...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def saveSnapshot(self, filename): \n\t\tpass", "def syncfolder():", "def register_artifacts(self, which_pass):\n\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_INDEX_TABLE, which_pass\n )\n artifact_manager.register_temp_file(\n config.MIRROR_NODES_STORE, which_pas...
[ "0.5904011", "0.58413935", "0.57848144", "0.56511885", "0.56056577", "0.56036234", "0.55917174", "0.5542068", "0.5518935", "0.5510767", "0.5492488", "0.5471138", "0.54641044", "0.5460884", "0.54597145", "0.5448846", "0.5443123", "0.5436103", "0.5423372", "0.5380155", "0.53798...
0.0
-1
Enter testrun info 'fail' or 'error' for some tests
def update_22(db, filename_persist, snapshots_dir, snapshots_reference_dir): data = { # 'fail' 'test/test_pyglet_vb.py' : { 'st': 'fail', 'diag': 'incomplete grossini rendition at first frame'}, # 'error' 'test/test_text_movement.py' : { 'st': 'error', 'diag': 'posit...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_start(self):\n self.fail(\"write a test\")", "def test_case_01(self):\n if True:\n self.fail()", "def failed( self, mesg ):\n self.tests_failed += 1\n print \"fail: \" + mesg.rstrip()", "def _test_run_with_short_error_msg(self, task_class):\r\n task_entr...
[ "0.6509504", "0.64223963", "0.6414181", "0.6359421", "0.6322421", "0.6320431", "0.63138866", "0.63009924", "0.62677574", "0.6245532", "0.6233363", "0.6229177", "0.6223931", "0.6205429", "0.62039953", "0.6189725", "0.61890954", "0.6184349", "0.61788744", "0.61643875", "0.61274...
0.0
-1
This files 'pass', register them as such and move their snapshots to the reference snapshots folder (but the second script should be updated for better autotest)
def update_23(db, filename_persist, snapshots_dir, snapshots_reference_dir): text = """ test/test_fadeto.py test/test_draw_elbows2.py """ candidates = doers.scripts_names_from_text(text, end_mark=':') checked_in, unknown, move_failed = hl.update_testrun__pass(db, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_6(db, filename_persist, snapshots_dir, snapshots_reference_dir):\n text = \"\"\"\n : Snapshots inspected, 'pass'\n\n test/test_cocosz.py\n test/test_delay.py\n test/test_draw.py\n test/test_liquid_16_x_16.py\n test/test_move_corner_down.py\n test/test_...
[ "0.6359054", "0.62082005", "0.61056006", "0.59230334", "0.5728174", "0.5716799", "0.56549895", "0.5625936", "0.5621173", "0.5597403", "0.5585399", "0.5543149", "0.5535106", "0.55044854", "0.54968536", "0.54944915", "0.5480739", "0.5479904", "0.5454584", "0.54531294", "0.54304...
0.53809464
27
get_aws_iam returns a dict with id and secret
def test_get_aws_iam(mock_system): config = voithos.lib.config.DEFAULT_CONFIG config["license"] = "11111111111111111111-2222222222222222222222222222222222222222" mock_system.get_file_contents.return_value = json.dumps(config) iam = aws.get_aws_iam() assert "id" in iam assert "secret" in iam ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_aws_secret(role):\n global AWS_ID\n AWS_ID += 1\n request.data\n return jsonify({\n \"request_id\": f\"a-request-id-{AWS_ID}\",\n \"lease_id\": f\"aws/creds/{role}/a-lease-id-{AWS_ID}\",\n \"renewable\": True,\n \"lease_duration\": 3600,\n \"data\": {\n ...
[ "0.725023", "0.6431359", "0.6358747", "0.6328489", "0.63060457", "0.6280029", "0.6222176", "0.61839336", "0.61627704", "0.61163086", "0.609", "0.60536736", "0.6049167", "0.6023562", "0.6014561", "0.6012974", "0.587488", "0.5873585", "0.5872633", "0.58578235", "0.578888", "0...
0.7496777
0
Fit model with MCMC, starting from MAP as initial value, and plot results
def fit_model(model): print "Fitting vars:" print model.vars.describe() import time start_time = time.time() model.map = mc.MAP(model.vars) model.map.fit(method='fmin_powell', verbose=1) model.mcmc = mc.MCMC(model.vars) model.mcmc.use_step_method(mc.AdaptiveMetropolis, mode...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def robust_lin_reg(df, var_map, \n steps=2000, mcmc='metropolis',\n plot_trace=True, plot_vars=True):\n import pymc3 as pm\n import pandas as pd\n import matplotlib.pyplot as plt\n import numpy as np\n import theano \n \n # Get cols\n df = df[var_map.valu...
[ "0.64326185", "0.6002663", "0.59082", "0.5907472", "0.5891982", "0.58877134", "0.5886521", "0.58731794", "0.57898426", "0.5746489", "0.5707085", "0.5540485", "0.5530723", "0.55105585", "0.5510401", "0.54991907", "0.54921657", "0.5474497", "0.53770715", "0.5369792", "0.5352105...
0.62368906
1
Return a string response to a request
def serve(self) -> str: return self._render()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, request):\r\n data = {\r\n 'results': 'THIS IS THE PROTECTED STRING FROM SERVER',\r\n }\r\n return Response(data, status=status.HTTP_200_OK)", "def return_response_string(self):\n response = \"{} {}\\r\\n\".format(self.protocol, self.code)\n str_headers...
[ "0.74981505", "0.7350811", "0.7167688", "0.71017843", "0.6830472", "0.67458236", "0.6614951", "0.66047513", "0.65713", "0.6560834", "0.64871925", "0.64846617", "0.64349794", "0.6416181", "0.6400384", "0.63373923", "0.6288346", "0.6281628", "0.6238544", "0.6194683", "0.6193233...
0.0
-1
Return a string rendering of this view
def _render(self) -> str: html = self._template.render(self._transient_context) self._transient_context = None return html
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render(self):\n return render_to_string(\n self.template_name, self.get_context_data(), request=self.request\n )", "def __str__(self):\n t = Template(\n \"\"\"\n <h4>$title</h4>\n $imgs\n $footnotes\n <hr/>\"\"\")\n ...
[ "0.80261445", "0.7637391", "0.7607511", "0.74145526", "0.7372933", "0.7351635", "0.7343746", "0.73345333", "0.73166084", "0.7243189", "0.7200906", "0.7183523", "0.71555793", "0.71239877", "0.7080639", "0.7080639", "0.7080639", "0.7080639", "0.7080639", "0.7080639", "0.7047732...
0.71599025
12
Return a transient context for use in rendering the view
def generate_context(self) -> Context: self._transient_context = Context() return self._transient_context
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_context(self):\n return self.context.generate()", "def context():\n return dict()", "def get_context(self):\n return {}", "def context(self) -> CONTEXT:", "def get_context(self):\n return {\"request\": self.request, \"format\": self.format_kwarg, \"view\": self}", "def get...
[ "0.77184707", "0.7593439", "0.75010717", "0.7317102", "0.72651404", "0.7169451", "0.70651585", "0.70517874", "0.6991241", "0.695222", "0.695222", "0.695222", "0.695222", "0.695222", "0.695222", "0.695222", "0.6935061", "0.6920173", "0.69052017", "0.69001997", "0.6891732", "...
0.75156814
2
Configure wrapper to use SPI.
def use_spi(): _LIB.oled_click_use_spi()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SPIsetup(self):\n self.writecmd(0x01,0x10,0,self.data); #SPI/SETUP", "def _init_config(self, width, height, spi=None, spiMosi= None, spiDC=None, spiCS=None, spiReset=None, spiClk=None):\n self._spi = spi\n self._spi_mosi = spiMosi\n self._spi_dc = spiDC\n self._spi_cs = spi...
[ "0.64581645", "0.60692745", "0.57994145", "0.5797513", "0.5785946", "0.57624316", "0.57624316", "0.57624316", "0.57624316", "0.575913", "0.5678284", "0.5665971", "0.56648326", "0.56648326", "0.56648326", "0.563461", "0.563461", "0.5623664", "0.5560134", "0.55506355", "0.54671...
0.63154364
1
Configure wrapper to use I2C.
def use_i2c(): _LIB.oled_click_use_i2c()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, machine):\n super().__init__(machine)\n self.features['has_i2c'] = True", "def __init__(self, machine):\n super().__init__(machine)\n self.features['has_i2c'] = True", "def ensureI2C(i2c=None):\n if i2c is None:\n logger.info('Initializing I2C.')\n ...
[ "0.66162145", "0.66162145", "0.65949684", "0.63167465", "0.6111046", "0.6078323", "0.58250207", "0.5788781", "0.5767513", "0.5689637", "0.5681065", "0.55661315", "0.5519384", "0.55006874", "0.5482283", "0.5454556", "0.5420815", "0.5417926", "0.53746414", "0.53718674", "0.5340...
0.7479867
0
Enable the OLED click.
def enable(mikrobus_index): ret = _LIB.oled_click_enable(mikrobus_index) if ret < 0: raise Exception("oled click enable failed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _led_enable():\n # type: () -> None\n GPIO.output(LED_nOE, GPIO.LOW)", "def turn_on(self):\n GPIO.output(self.gpio, True) # turn on light", "def enable(self):\n self.switch.enable()\n self._enabled = True", "def enable():\n ret = _LIB.led_matrix_click_enable()\n if ret <...
[ "0.7803562", "0.71197575", "0.71039397", "0.69039017", "0.67663074", "0.6755123", "0.6752181", "0.6694265", "0.6667028", "0.6605703", "0.6582292", "0.6561643", "0.6561643", "0.6537502", "0.65163743", "0.64581394", "0.6453925", "0.64473325", "0.6443345", "0.64403516", "0.64364...
0.74189276
1
Write a pixel buffer on the Oled display. Each bit of the array represents the state of a pixel. The first 96 bytes represent the first page (96x8 pixels), the following 96 bytes represent the second page...
def raw_write(data): buf = (ctypes.c_uint8 * 384)(*data) ret = _LIB.oled_click_raw_write(buf) if ret < 0: raise Exception("oled click raw write failed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bitmap(arr, dc):\n wiringPy.digital_write(pin_DC, dc)\n wiringPy.digital_write_serial_array(0, struct.pack('B'*len(arr), *arr))", "def set_pixel(self, x, y, r, g, b, a):\n\t\t\n\t\ti = 4 * (y * self.width + x)\n\t\tself.buffer[i : i + 4] = array.array('f', struct.pack('ffff', r, g, b, a))", "def _sav...
[ "0.6251184", "0.6223932", "0.61893326", "0.60717803", "0.6011565", "0.600209", "0.5915968", "0.5871335", "0.58328456", "0.5809756", "0.5783888", "0.5709632", "0.57080525", "0.56664234", "0.5656356", "0.56479025", "0.562347", "0.55849427", "0.557958", "0.5566176", "0.55603415"...
0.52128667
46
Write some text on the Oled display.
def write_text(text): ret = _LIB.oled_click_write_text(ctypes.c_char_p(text.encode('utf-8'))) if ret < 0: raise Exception("oled click write text failed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_text(self, text):\n self.write_to_serial(':DISP:TEXT \\'' + text + '\\'')", "def WriteText(self, text):\n print(text)", "def printt(self, data):\r\n self.text_ctrl_output.AppendText(data)", "def Print(self,text = \"\"):\n self.Bus.Write_String(self.Address,0x00, text)", ...
[ "0.8052281", "0.73763824", "0.71736574", "0.70968753", "0.7006892", "0.6958783", "0.6950346", "0.69271636", "0.6902415", "0.6863863", "0.68558705", "0.6836492", "0.683297", "0.68294656", "0.68263483", "0.68179524", "0.68005294", "0.67513156", "0.6740279", "0.67395735", "0.672...
0.6721604
21
Convert a character into an array of 22 bytes.
def get_char(c): data = (ctypes.c_uint8 * 22)() ret = _LIB.oled_click_get_char(c, ctypes.byref(data)) if ret < 0: raise Exception("oled click get char failed") return [data[i] for i in range(22)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bytes_as_char_array(b):\n return \"{ \" + \", \".join(\"0x%02x\" % x for x in b) + \" }\"", "def to_char_array(s):\n if type(s) != bytes:\n raise ValueError('Input to to_char_array function should be in bytes')\n char_array = []\n tokens = s.split(b' ')\n for token in tokens:\n c...
[ "0.6772518", "0.64857394", "0.6455129", "0.6275554", "0.6080935", "0.6075504", "0.6041937", "0.6011441", "0.6011441", "0.60084045", "0.5997307", "0.59810466", "0.59715194", "0.59327745", "0.5909544", "0.5848634", "0.58313006", "0.58160806", "0.5803004", "0.5797645", "0.578704...
0.57538843
23
Disable the OLED click.
def disable(): ret = _LIB.oled_click_disable() if ret < 0: raise Exception("oled click disable failed")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _led_disable():\n # type: () -> None\n GPIO.output(LED_nOE, GPIO.HIGH)", "def disable():\n ret = _LIB.led_matrix_click_disable()\n if ret < 0:\n raise Exception(\"led matrix click disable failed\")", "def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light", "def t...
[ "0.809518", "0.7531012", "0.7469522", "0.72568923", "0.7174813", "0.71696955", "0.71069515", "0.71025395", "0.70688444", "0.70502096", "0.704196", "0.70280635", "0.70278597", "0.6998497", "0.6984781", "0.6962407", "0.69579947", "0.6957407", "0.6956076", "0.6949486", "0.694127...
0.8671251
0
Pump until there is no more input or output. Returns whether any data was moved.
def flush(self, debug=False): result = False for x in range(1000): if self.pump(debug): result = True else: break else: assert 0, "Too long" return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_until_stop(self):\n while self.commands[self.pointer] != END:\n # Get the cmd\n cmd = self.commands[self.pointer]\n opcode = cmd % 100\n modes = cmd // 100\n \n vals, locs, self.pointer = get_vals_and_locs(opcode, modes, self.pointer, self.co...
[ "0.5977106", "0.57480776", "0.56906104", "0.5683975", "0.5607149", "0.558183", "0.55323035", "0.5428544", "0.54132", "0.5409012", "0.5401055", "0.5396786", "0.53637314", "0.535892", "0.5358188", "0.53309345", "0.53243923", "0.53135455", "0.52789587", "0.52524316", "0.52387816...
0.5209061
23
Move data back and forth. Returns whether any data was moved.
def pump(self, debug=False): if self.debug or debug: print '-- GLUG --' sData = self.serverIO.getOutBuffer() cData = self.clientIO.getOutBuffer() self.clientIO._checkProducer() self.serverIO._checkProducer() if self.debug or debug: print '.' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move(self) -> bool:\n pass", "def move_down(self):\n if self.pointer < (len(self._contents)-1):\n logging.debug(\"moved down\")\n self.pointer += 1 \n self.refresh() \n return True\n else: \n return False", "def has_moved(self)...
[ "0.6548814", "0.59832346", "0.59732103", "0.58637434", "0.5830981", "0.5820136", "0.57540244", "0.5660683", "0.56401706", "0.56389946", "0.5632333", "0.56197184", "0.5614149", "0.56067765", "0.5605793", "0.55919355", "0.55858994", "0.55379903", "0.5512463", "0.5510148", "0.54...
0.0
-1
Returns a list of valid words. Words are strings of lowercase letters. Depending on the size of the word list, this function may take a while to finish.
def loadWords(): print "Loading word list from file..." # inFile: file inFile = open(WORDLIST_FILENAME, 'r', 0) # wordList: list of strings wordList = [] for line in inFile: wordList.append(line.strip().lower()) print " ", len(wordList), "words loaded." return wordList
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_words(f: str, letters: List[str]) -> List[str]:\r\n forbidden_letters = [i for i in string.ascii_lowercase]\r\n for i in letters:\r\n try:\r\n forbidden_letters.remove(i)\r\n except:\r\n pass\r\n words_file = open(f)\r\n word_list = []\r\n letstr = \"\"\r\...
[ "0.7713766", "0.717011", "0.7087718", "0.6993999", "0.69623536", "0.6962017", "0.69448495", "0.6917324", "0.6899307", "0.68871945", "0.6885995", "0.68723124", "0.6845915", "0.68409246", "0.6833867", "0.6833511", "0.6822346", "0.68203837", "0.6806308", "0.6800549", "0.673057",...
0.6601317
34
Returns a dictionary where the keys are elements of the sequence and the values are integer counts, for the number of times that an element is repeated in the sequence.
def getFrequencyDict(sequence): # freqs: dictionary (element_type -> int) freq = {} for x in sequence: freq[x] = freq.get(x,0) + 1 return freq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def counts(sequence):\n # initialize the countainer\n count = defaultdict(int)\n # iterates through sequence elements\n for item in sequence:\n # if element not in counts add 0\n # else add 1\n count[item] = count.get(item, 0) + 1\n return dict(count)", "def count_elements(seq...
[ "0.88433635", "0.8707861", "0.8707861", "0.8238257", "0.81628364", "0.78431886", "0.7644035", "0.762158", "0.7452036", "0.7337739", "0.7311011", "0.6998471", "0.68835694", "0.68639237", "0.6829713", "0.6818011", "0.67900753", "0.67836136", "0.6756537", "0.6749939", "0.6742152...
0.8210399
5
Returns the score for a word. Assumes the word is a valid word. The score for a word is the sum of the points for letters in the word, multiplied by the length of the word, PLUS 50 points if all n letters are used on the first turn. Letters are scored as in Scrabble; A is worth 1, B is worth 3, C is worth 3, D is worth...
def getWordScore(word, n): score = 0 for letters in word: if letters in SCRABBLE_LETTER_VALUES: score += SCRABBLE_LETTER_VALUES[letters] if len(word) == n: return (score * len(word)) + 50 else: return score * len(word)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getWordScore(word, n):\n score = 0\n for letter in word:\n score += SCRABBLE_LETTER_VALUES[letter]\n score *= len(word)\n if len(word) == n:\n score += 50\n return score", "def get_word_score(word, n=7):\n score = 0\n\n for i in word:\n score += SCRABBLE_LETTER_VALUE...
[ "0.84181976", "0.82934874", "0.8220061", "0.8052078", "0.8041427", "0.7843509", "0.7650167", "0.7636099", "0.7610513", "0.75861526", "0.7409019", "0.7204724", "0.70169866", "0.70130014", "0.6928664", "0.6779603", "0.67548424", "0.67543375", "0.67239964", "0.66737604", "0.6667...
0.8374879
1
Displays the letters currently in the hand.
def displayHand(hand): for letter in hand.keys(): for j in range(hand[letter]): print letter, # print all on the same line print # print an empty line
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def displayHand(hand: d_si) -> None:\n for letter in hand.keys():\n for _ in range(hand[letter]):\n print(letter,end=\" \")\n print()", "def displayHand(hand):\r\n for letter in hand.keys():\r\n for j in range(hand[letter]):\r\n print(letter,end=\" \") # print ...
[ "0.76924473", "0.76908666", "0.7630516", "0.7603937", "0.70320636", "0.69698924", "0.68899405", "0.68821144", "0.6802938", "0.674929", "0.6746151", "0.67160624", "0.6569305", "0.6542722", "0.6519904", "0.6488587", "0.648419", "0.6351849", "0.6351849", "0.6351849", "0.62965095...
0.75768644
4
Returns a random hand containing n lowercase letters. At least n/3 the letters in the hand should be VOWELS. Hands are represented as dictionaries. The keys are letters and the values are the number of times the particular letter is repeated in that hand.
def dealHand(n): hand={} numVowels = n / 3 for i in range(numVowels): x = VOWELS[random.randrange(0,len(VOWELS))] hand[x] = hand.get(x, 0) + 1 for i in range(numVowels, n): x = CONSONANTS[random.randrange(0,len(CONSONANTS))] hand[x] = hand.get(x, 0) + 1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deal_hand(n):\n hand = {}\n num_vowels = n // 3\n\n for i in range(num_vowels):\n x = VOWELS[random.randrange(0, len(VOWELS))]\n hand[x] = hand.get(x, 0) + 1\n\n for i in range(num_vowels, n):\n x = CONSONANTS[random.randrange(0, len(CONSONANTS))]\n hand[x] =...
[ "0.78006905", "0.7678525", "0.7669588", "0.74499804", "0.6461991", "0.6153672", "0.60777944", "0.60667515", "0.60564005", "0.5998895", "0.59673965", "0.59573287", "0.59163105", "0.59163105", "0.59163105", "0.5879762", "0.58750254", "0.584636", "0.5825631", "0.58003813", "0.57...
0.76973146
1
Assumes that 'hand' has all the letters in word. In other words, this assumes that however many times a letter appears in 'word', 'hand' has at least as many of that letter in it.
def updateHand(hand, word): tempHand = hand.copy() for letters in word: if letters in tempHand: tempHand[letters] -= 1 return tempHand
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isValidWord(word, hand, wordList):\n myHand = hand.copy() \n for letter in word:\n if letter not in hand or myHand[letter] <= 0:\n return False\n else:\n myHand[letter] -= 1 \n if word not in wordList:\n return False\n else:\n return T...
[ "0.7523692", "0.73815393", "0.72896904", "0.72852725", "0.72229683", "0.7206578", "0.7138506", "0.71194625", "0.7096104", "0.70616984", "0.6982035", "0.69689786", "0.69662434", "0.69557613", "0.6898297", "0.6891437", "0.6696662", "0.66834134", "0.6676677", "0.66196877", "0.65...
0.69068694
14
Returns True if word is in the wordList and is entirely composed of letters in the hand. Otherwise, returns False. Does not mutate hand or wordList.
def isValidWord(word, hand, wordList): tempHand = hand.copy() if len(word) > 0 and word in wordList: for letter in word: if letter not in tempHand or tempHand[letter] <= 0: return False else: tempHand[letter] = tempHand.get(letter, 0) - 1 r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isValidWord(word, hand, wordList):\r\n \r\n \r\n if type(word) != str:\r\n return False\r\n \r\n if word not in wordList:\r\n return False\r\n \r\n for letter in word:\r\n if letter not in hand:\r\n return False\r\n \r\n updatedHand = hand.copy()\r\n ...
[ "0.81876624", "0.8107502", "0.7984113", "0.7944561", "0.79433525", "0.7854562", "0.7823658", "0.77725965", "0.7753029", "0.77365476", "0.77109057", "0.7666229", "0.76648957", "0.74651563", "0.735434", "0.730834", "0.7299409", "0.7229836", "0.7229836", "0.7229836", "0.7094772"...
0.7918604
5
Returns the length (number of letters) in the current hand.
def calculateHandlen(hand): return sum(hand.itervalues())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_length(self):\r\n return len(self.hand)", "def calculate_handlen(hand):\n handlen = len(hand)\n return handlen", "def get_length(self):\r\n return len(self.deck)", "def handsize(self):\n return self._handsize", "def get_length(self):\n return len(self.cards)", "d...
[ "0.8455392", "0.7924513", "0.75295866", "0.73232204", "0.7322879", "0.7170316", "0.71048033", "0.70595866", "0.70591575", "0.703998", "0.703998", "0.70157504", "0.70006496", "0.6982251", "0.6982251", "0.69610137", "0.69566923", "0.69514513", "0.69469476", "0.6931802", "0.6922...
0.728664
5
Allow the user to play an arbitrary number of hands. 1) Asks the user to input 'n' or 'r' or 'e'. If the user inputs 'n', let the user play a new (random) hand. If the user inputs 'r', let the user play the last hand again. If the user inputs 'e', exit the game. If the user inputs anything else, tell them their input w...
def playGame(wordList): hand = None while True: selection = raw_input("Enter n to deal a new hand, r to replay the last hand, or e to end game:") if selection == 'n': hand = dealHand(HAND_SIZE) playHand(hand, wordList, HAND_SIZE) print eli...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_game(word_list):\n # TO DO ...\n\n hand = deal_hand(HAND_SIZE) # random init\n\n while True:\n cmd = input('Enter n to deal a new hand, r to replay the last hand, or e to end game: ')\n\n if cmd == 'n':\n hand = deal_hand(HAND_SIZE)\n play_hand(hand.copy(), wo...
[ "0.77609646", "0.76356065", "0.7516967", "0.75046504", "0.7053985", "0.69752824", "0.6643235", "0.6316062", "0.6228966", "0.61934215", "0.61589503", "0.6122529", "0.6072859", "0.60151553", "0.6011535", "0.6007752", "0.6001467", "0.5992759", "0.5989423", "0.5976205", "0.596974...
0.7623381
2
Generates a JWT token valid for 10 minutes using the private key.
def generate_jwt_token(private_pem: bytes, app_id: int) -> str: private_key = jwcrypto.jwk.JWK.from_pem(private_pem) payload = {"iss": app_id} duration = datetime.timedelta(minutes=10) return python_jwt.generate_jwt(payload, private_key, "RS256", duration)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_jwt_token(self):\n import jwt\n from datetime import datetime, timedelta\n from django.conf import settings\n\n dt = datetime.now() + timedelta(days=60)\n\n token = jwt.encode({\n 'id': self.pk,\n 'username': self.username,\n 'exp': ...
[ "0.7184967", "0.7133718", "0.6737407", "0.67275083", "0.6704615", "0.65334314", "0.6511841", "0.64169765", "0.64080316", "0.6331098", "0.62940425", "0.62615675", "0.6237678", "0.621826", "0.6174233", "0.6108475", "0.60688114", "0.6027714", "0.6024385", "0.59928554", "0.595844...
0.7318258
0
Generates an installation access token using a JWT token and an installation id. An installation access token is valid for 1 hour.
def generate_installation_access_token(jwt_token: str, installation_id) -> str: headers = { "Authorization": f"Bearer {jwt_token}", "Accept": "application/vnd.github.machine-man-preview+json", "User-Agent": USER_AGENT, } url = f"https://api.github.com/app/installations/{installation_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_access_token():\n return do_build_access_token(tenant_id='intility_tenant_id')", "def get_token(app_id, installation_id):\n token_url = f\"{API_BASE_URL}/app/installations/{installation_id}/access_tokens\"\n temp_state = str(uuid.uuid4())\n private_key = get_private_key()\n\n # Required ...
[ "0.6996901", "0.6979113", "0.6809183", "0.67003566", "0.6534887", "0.6493192", "0.6465398", "0.6324435", "0.6281636", "0.62720484", "0.6217066", "0.62050366", "0.61707485", "0.6150757", "0.61372226", "0.60964096", "0.6017347", "0.6011306", "0.592635", "0.59209037", "0.5904168...
0.8433338
0
Reads a private PEM file from an S3 bucket.
def get_pem(bucket_name: str, bucket_key: str) -> bytes: s3 = boto3.resource("s3") s3.Bucket(bucket_name).download_file(bucket_key, "/tmp/key.pem") with open("/tmp/key.pem", "rb") as f: return f.read()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_s3_file(bucket, key):\r\n try:\r\n s_3 = boto3.client('s3')\r\n file = s_3.get_object(Bucket=bucket, Key=key)\r\n file_body = file['Body'].read().decode(\"utf-8\")\r\n return file_body\r\n\r\n except (FileNotFoundError, IndexError, SystemExit, OSError, IOError) as err:\r\...
[ "0.7351964", "0.7110344", "0.70346", "0.6955667", "0.69070524", "0.6842378", "0.6714841", "0.6691865", "0.6596183", "0.6484976", "0.6464774", "0.62390226", "0.62254405", "0.62190664", "0.62123066", "0.6198812", "0.616393", "0.61633474", "0.6101623", "0.60783464", "0.60682744"...
0.74012285
0
Checks if the MAC (message authentication code) sent in the request is really from GitHub.
def authenticate_request(shared_secret: str, body: str, signature: str) -> bool: if signature is None: return False sha_body = hmac.new( shared_secret.encode("utf8"), body.encode("utf8"), hashlib.sha1 ).hexdigest() _, sha_github = signature.split("=") return hmac.compare_digest(sha_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _identify_mac(self, request):\n params = parse_authz_header(request, None)\n if params is None:\n return None\n if params.get(\"scheme\") != \"MAC\":\n return None\n # Check that various parameters are as expected.\n token = params.get(\"id\")\n i...
[ "0.62339866", "0.57387596", "0.5716142", "0.5713359", "0.5712786", "0.56901765", "0.5681487", "0.5649187", "0.55427325", "0.5540321", "0.55339146", "0.55098766", "0.54962564", "0.5493968", "0.54877156", "0.545417", "0.5438969", "0.54327047", "0.54191214", "0.5394371", "0.5342...
0.56696975
7
Sets the learning rate to the initial LR decayed by 0.2 every steep step
def pt_adjust_learning_rate(epoch, opt, optimizer): # if epoch < 2: # for param_group in optimizer.param_groups: # param_group['lr'] = 1e-7 # return 0 # print(epoch) # print(np.asarray(opt.pt_lr_decay_epochs)) steps = np.sum(epoch > np.asarray(opt.pt_lr_decay_epochs)) if ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_learning_rate(self):\n\n if (self.FLAGS.learning_rate_decay is \"exponential\"):\n self.learning_rate = tf.train.exponential_decay(\n self.FLAGS.learning_rate,\n self.global_step,\n self....
[ "0.79089844", "0.7856753", "0.7856753", "0.76767546", "0.75567615", "0.75240135", "0.75000376", "0.7454447", "0.7426672", "0.74171114", "0.7404257", "0.7401694", "0.7386987", "0.73657304", "0.7329806", "0.73260325", "0.73156565", "0.7304068", "0.73000455", "0.7264402", "0.725...
0.0
-1
Sets the learning rate to the initial LR decayed by 10 every 30 epochs
def ft_adjust_learning_rate(optimizer, intial_lr, epoch, lr_steps): decay = 0.3 ** (sum(epoch >= np.array(lr_steps))) lr = intial_lr * decay for param_group in optimizer.param_groups: param_group['lr'] = lr
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr", "def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l...
[ "0.79140896", "0.7908034", "0.7850816", "0.7776915", "0.7735598", "0.7732588", "0.7723862", "0.77235436", "0.77208304", "0.7710736", "0.76948273", "0.7675381", "0.76670265", "0.76670265", "0.76670265", "0.7657111", "0.76431805", "0.7640621", "0.7639109", "0.76275903", "0.7625...
0.7563326
36
Function to parse features from GeoDataFrame in such a manner that rasterio wants them
def getFeatures(gdf): import json features = [json.loads(gdf.to_json())['features'][0]['geometry']] return features
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0]['geometry']]", "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0]['geometry']]", "def getFeatures(gdf):\n import json\n return [json.loads(gdf.to_json())['features'][0][...
[ "0.70252776", "0.70252776", "0.70252776", "0.70073014", "0.7006912", "0.66584796", "0.6582383", "0.6436205", "0.6337286", "0.6247641", "0.6246245", "0.6210641", "0.6190014", "0.61856955", "0.6074713", "0.605977", "0.60548824", "0.60548824", "0.6047158", "0.6041518", "0.602713...
0.6990803
5
Converts node to a string
def __str__(self): return str(self._key) + ", " + str(self._value[0]) + ", " + str(self._value[1])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeToString(cls, node):\n return lxml.etree.tostring(node, method='html').decode()", "def as_str(node):\n node_string = ' '.join(k for k, _ in node.leaves())\n return u' '.join(node_string.split())", "def test_node_to_str(self):\n f = lws.node_to_str\n # normal\n ...
[ "0.8387049", "0.82369703", "0.75747645", "0.7456867", "0.7450837", "0.73087424", "0.70796245", "0.70432127", "0.70348823", "0.69631356", "0.69130164", "0.68732697", "0.6834229", "0.6753791", "0.674325", "0.6713926", "0.6698366", "0.6690693", "0.6684852", "0.6667392", "0.66580...
0.0
-1
Initializes the priority heap
def __init__(self, g): self._data = [] self.graph = g self.pqLocator = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.min_heap = []\n self.max_heap = []\n self.size_max, self.size_min = 0, 0", "def __init__(self):\n self.min_heap = []\n self.max_heap = []", "def __init__(self):\n self.__max_heap = []\n self.__min_heap = []", "def __init__(self):\n ...
[ "0.7895022", "0.78730625", "0.78242964", "0.7812003", "0.7795688", "0.77610606", "0.7727318", "0.7712711", "0.77093875", "0.7683902", "0.7657671", "0.764797", "0.76411146", "0.76411146", "0.76411146", "0.76315606", "0.76188815", "0.75978863", "0.75660425", "0.756221", "0.7523...
0.0
-1
Converts the priority heap to a string
def __str__(self): return '\n\n'.join(str(item) for item in self._data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return str(self._heap)", "def __str__(self) -> str:\n return 'HEAP ' + str(self.heap)", "def __str__(self) -> str:\n return 'HEAP ' + str(self.heap)", "def __str__(self):\n\n string = \"[\"\n for i in range(1, self.i , 1):\n try:\n ...
[ "0.7485955", "0.7094816", "0.7094816", "0.67488325", "0.6633048", "0.62878686", "0.6045484", "0.59887344", "0.5947995", "0.5898321", "0.5829193", "0.57599413", "0.5745034", "0.5654975", "0.56530416", "0.5631066", "0.5626237", "0.56002146", "0.55961776", "0.55735004", "0.55630...
0.0
-1
Finds if heap is empty
def empty(self): return True if len(self) == 0 else False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty(heap):\n return size(heap) == 0", "def is_empty(self):\n return self.heap_size <= 0", "def is_empty(self):\n return len(self.__heap) == 0", "def is_empty(self) -> bool:\n return self.heap.length() == 0", "def is_empty(self) -> bool:\n return self.heap.length() == 0"...
[ "0.87432164", "0.8080125", "0.80508566", "0.7974598", "0.7974598", "0.78623253", "0.7857394", "0.7734315", "0.7480083", "0.71097034", "0.69872475", "0.6981132", "0.6887114", "0.6812178", "0.67947066", "0.67928696", "0.6768594", "0.67281306", "0.6711304", "0.6684485", "0.66307...
0.0
-1
Minimum value in the min heap
def top(self): # if not empty if not self.empty(): return self._data[0].get_value()[1].course # if empty return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min(self):\n return self.heap[1]", "def get_min(h: Heap) -> Node:\n prev, curr = _min(h)\n return curr", "def find_min_in_max_heap(self):\n min_number = None\n last_parent = (self.size - 1) // 2\n first_leaf = last_parent + 1\n # Shortcut to find first_leaf:\n ...
[ "0.80066824", "0.79924774", "0.7953096", "0.7922488", "0.7861636", "0.7807199", "0.773033", "0.7653231", "0.7630557", "0.7614359", "0.76007307", "0.74046606", "0.7337545", "0.72455674", "0.7219387", "0.72004133", "0.71765816", "0.7166307", "0.7158743", "0.7147012", "0.7126886...
0.0
-1
Adds an element to the heap
def push(self, key, val): # create new node and add to data new_ele = Node(key, val) self._data.append(new_ele) # percolate number into correct place self.percolate_up(len(self)-1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, element):\n # add element to the heap\n self.heap.append(element)\n\n # get index of added element and parent of added element\n index = len(self.heap) - 1\n parentIndex = (index - 1) // 2\n\n # swap parents and childs while needed\n while index >= 1 a...
[ "0.83968014", "0.8395562", "0.83507353", "0.80548006", "0.7984432", "0.7979835", "0.7967062", "0.7937237", "0.79159236", "0.7915377", "0.789867", "0.786664", "0.7776185", "0.7742011", "0.7721637", "0.7721637", "0.7709229", "0.76871336", "0.7682712", "0.7673222", "0.76684994",...
0.0
-1
Removes minimum element of the heap
def pop(self): # if not empty if not self.empty(): # swap min element with last and pop from data popped = self._data[0] self.swap(0, len(self)-1) # swap elements self._data.pop() # move swapped node to correct place self.percolate...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_min(self):\n #The length is 1 because the heap list was initialized with 0\n if len(self.heap_list) == 1:\n return \"Empty heap.\"\n\n #Store the min value of the heap\n top = self.heap_list[1]\n\n #Move the last value of the heap to the top\n self.he...
[ "0.83863187", "0.8268813", "0.8243556", "0.8172819", "0.8009114", "0.7942755", "0.7838469", "0.7836379", "0.7799861", "0.77351683", "0.76470023", "0.7637858", "0.7591406", "0.7585167", "0.75569344", "0.7526615", "0.74768615", "0.7413565", "0.7364462", "0.725336", "0.7238196",...
0.0
-1
Finds the minimum child of the index
def max_child(self, index): # left and right child left = self._data[(index*2)+1] if (index*2)+1 < len(self) else None right = self._data[(index*2)+2] if (index*2)+2 < len(self) else None # if has both children if left and right: if left < right: retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_child(self, index):\n if self.empty():\n return None\n if self._has_left(index):\n left = self._left(index)\n small_child = left\n if self._has_right(index):\n right = self._right(index)\n if self._data[right] < self._d...
[ "0.80425453", "0.791862", "0.7847695", "0.7785256", "0.75363547", "0.7435741", "0.7424413", "0.73639077", "0.71918046", "0.71815383", "0.70990807", "0.7095202", "0.70832723", "0.70796996", "0.70733607", "0.7018999", "0.6948961", "0.69062304", "0.68996906", "0.6890181", "0.686...
0.67524004
26
Moves node at index up to correct position in it's branch
def percolate_up(self, index): # reached root if index == 0: return p_ind = (index-1)//2 # swap if parent is greater than current and continue percolating if self._data[p_ind] > self._data[index]: self.swap(p_ind, index) self.percolate_up(p_in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shift_item_up(self, index):\n while index > 0:\n parent_index = index // 2\n if parent_index > 0 and self.heaplist[parent_index] < self.heaplist[index]:\n self.heaplist[parent_index], self.heaplist[index] = self.heaplist[index], self.heaplist[parent_index]\n ...
[ "0.7009742", "0.67257226", "0.67239445", "0.6688178", "0.65012705", "0.64163274", "0.64070076", "0.6321453", "0.62840545", "0.6257231", "0.6249017", "0.6238124", "0.620318", "0.6138193", "0.6126185", "0.6125101", "0.6112156", "0.6093909", "0.6091938", "0.60718596", "0.6055841...
0.65998065
4
Moves node down to correct position in tree
def percolate_down(self, index): child = self.max_child(index) # swap if child is less than than current and continue percolating if child and self._data[child] < self._data[index]: self.swap(child, index) self.percolate_down(child)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_node(self,node):\n path=self.get_path(self.current_node,node)\n self.move_to(path)", "def move_down(self):\n\n next_sibling = self.get_next_sibling()\n if next_sibling!=None: \n self.move_to(next_sibling,'right')\n self.save()", "def move_up(self):\...
[ "0.72382915", "0.7134786", "0.7060045", "0.69184643", "0.68837345", "0.68561095", "0.6826683", "0.679074", "0.6742192", "0.664455", "0.6588179", "0.6588179", "0.6588179", "0.6588179", "0.65466446", "0.64491093", "0.64305204", "0.6385504", "0.63706255", "0.63670796", "0.634902...
0.0
-1
Changes the key of the node at index
def change_priority(self, index, new_key): # if index is within array if index < len(self): old_key = self._data[index].get_key() self._data[index].set_key(new_key) # if new key greater percolate down if new_key > old_key: self.percolate_d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_key(self, i, key):\n self.__keys[i] = key\n self.__swim(self.__qp[i])\n self.__sink(self.__qp[i])", "def _key_generated(self, key, index):\n self.keys[self.get_address(key)] = key\n self.last_generated_index = index", "def transfer_key_counter_clockwise(self, index...
[ "0.6950654", "0.6736145", "0.67204005", "0.6658157", "0.65645784", "0.6562288", "0.6557089", "0.65253705", "0.64411515", "0.6421411", "0.6420965", "0.64163303", "0.6392428", "0.63772845", "0.6363883", "0.6359659", "0.6347571", "0.63453865", "0.6337254", "0.63109064", "0.63013...
0.6091664
38
Swapping item at index x and y
def swap(self, x, y): self._data[x], self._data[y] = self._data[y], self._data[x]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap(ix, jx, ax, ay):\n tempx, tempy = ax[ix], ay[ix]\n ax[ix] = ax[jx]\n ay[ix] = ay[jx]\n ax[jx] = tempx\n ay[jx] = tempy", "def _swap(self, i, j):\n self._data[i], self._data[j] = self._data[j], self._data[i]", "def _swap(self, i, j):\n self._data[i], self._data[j] = self._data[j], ...
[ "0.76685715", "0.75711036", "0.75711036", "0.7535092", "0.7397885", "0.73663235", "0.73580956", "0.7349034", "0.7334804", "0.7314467", "0.72962046", "0.7253714", "0.7218827", "0.71823746", "0.7175004", "0.71747667", "0.71580243", "0.71521693", "0.71480864", "0.71342266", "0.7...
0.73140013
10
Add `self` to the current session and optionally commits
def save(self, commit=True): db.session.add(self) if commit: db.session.commit() logger.info( '{} {} saved'.format(self.__class__.__name__, self.id)) return self
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit(self):\n db.session.add(self)\n db.session.commit()", "def add(self):\n with managed_session() as session:\n session.add(self)\n session.flush()\n session.refresh(self)\n session.expunge(self)", "def save(self):\r\n s = self.get...
[ "0.7331662", "0.7142118", "0.70269156", "0.6803673", "0.6794338", "0.6794338", "0.6736462", "0.6722512", "0.6670579", "0.6655404", "0.6650521", "0.65264803", "0.65223646", "0.6519931", "0.64977217", "0.64977217", "0.64977217", "0.64977217", "0.64977217", "0.64977217", "0.6497...
0.6096156
40
Removes `self` to the current session and optionally commits
def delete(self, commit=True): db.session.delete(self) if commit: db.session.commit() logger.info( '{} {} deleted'.format(self.__class__.__name__, self.id)) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(self):\n with managed_session() as session:\n session.delete(self)", "def remove(self):\n db.session.delete(self)\n db.session.commit()", "def delete(self):\r\n s = self.get_session()\r\n s.delete(self)\r\n s.commit()", "def remove_data(self):\n...
[ "0.72724396", "0.7219021", "0.7042429", "0.6749172", "0.66947454", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6635438", "0.6613953", "0.64947295", "0.64789134", "0.6435805", "0.6435805", "0.6383086", "0.63283646"...
0.57677335
66
Returns the maximum number of kubernetes jobs
def get_maximum_number_of_allowed_k8s_jobs(dry_run: bool = False) -> int: retval = 5000 JSON_PATH = r"'{.spec.hard.count/jobs\.batch}'" cmd = f'kubectl get resourcequota gke-resource-quotas -o=jsonpath={JSON_PATH}' if not dry_run: try: p = safe_exec(cmd) if p.stdout: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jobserver_max_jobs():\n\n if _MakeJobServer._singleton is not None:\n return _MakeJobServer._singleton.num_jobs\n else:\n return 0", "def maximum_number_of_workers(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"maximum_number_of_workers\")", "def maximum_number_of_worke...
[ "0.78179955", "0.75503117", "0.7508189", "0.73179954", "0.7272363", "0.7165923", "0.7165923", "0.7165923", "0.7165923", "0.7165923", "0.70873964", "0.69605875", "0.6936822", "0.6898711", "0.6891758", "0.6864941", "0.6856878", "0.68284523", "0.6810833", "0.6802255", "0.6756869...
0.8028468
0
Return a list of persistent volume ids for a kubernetes cluster. Kubeconfig file determines the cluster that will be contacted.
def get_persistent_volumes(k8s_ctx: str) -> List[str]: cmd = f'kubectl --context={k8s_ctx} get pv -o json' p = safe_exec(cmd) try: dvols = json.loads(p.stdout.decode()) except Exception as err: raise RuntimeError('Error when parsing listing of Kubernetes persistent volumes ' + str(err)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_persistent_disks(k8s_ctx: str, dry_run: bool = False) -> List[str]:\n cmd = f'kubectl --context={k8s_ctx} get pv -o json'\n if dry_run:\n logging.info(cmd)\n else:\n p = safe_exec(cmd)\n if p.stdout:\n pds = json.loads(p.stdout.decode())\n return [i['spec...
[ "0.66107404", "0.6445898", "0.5872532", "0.5834013", "0.57105106", "0.57075375", "0.5590087", "0.5556461", "0.55296147", "0.5528321", "0.5513306", "0.5472359", "0.54522735", "0.54383785", "0.54374796", "0.542925", "0.53947073", "0.53806466", "0.5363869", "0.5344736", "0.53418...
0.69992113
0
Return a list of persistent disks for a kubernetes cluster. Kubeconfig file determines the cluster that will be contacted.
def get_persistent_disks(k8s_ctx: str, dry_run: bool = False) -> List[str]: cmd = f'kubectl --context={k8s_ctx} get pv -o json' if dry_run: logging.info(cmd) else: p = safe_exec(cmd) if p.stdout: pds = json.loads(p.stdout.decode()) return [i['spec']['csi']['vo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_ceph_disk():\n disks = []\n for srv in get_srv_list():\n cfg = get_srv_config(srv)\n for key in ['osd_data', 'osd_journal', 'mds_data', 'mon_data']:\n mnt_point = cfg[key]\n disk = get_disk_by_mountpoint(find_mount_point(mnt_point))\n if disk not in disk...
[ "0.69804466", "0.65357673", "0.62569875", "0.6242567", "0.6178439", "0.6145541", "0.61331636", "0.61212426", "0.61172605", "0.6103872", "0.6091794", "0.6074201", "0.6053231", "0.597123", "0.5810261", "0.57258034", "0.5673861", "0.56392694", "0.5635887", "0.55451983", "0.55267...
0.73454463
0
Retry kubernetes job submissions with the parameters specified in the decorator
def submit_jobs_with_retries(k8s_ctx: str, path: pathlib.Path, dry_run=False) -> List[str]: return submit_jobs(k8s_ctx, path, dry_run)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retry_job(\n self,\n ) -> Callable[[cloud_deploy.RetryJobRequest], cloud_deploy.RetryJobResponse]:\n # Generate a \"stub function\" on-the-fly which will actually make\n # the request.\n # gRPC handles serialization and deserialization, so we just need\n # to pass in the f...
[ "0.69828594", "0.6794983", "0.6765454", "0.66975325", "0.6523476", "0.6380863", "0.63713455", "0.6340863", "0.6169279", "0.61630946", "0.6125724", "0.6113218", "0.6111197", "0.60778093", "0.60651016", "0.6061368", "0.6057735", "0.60167474", "0.60050476", "0.5981546", "0.59133...
0.59404534
20
Submit kubernetes jobs using yaml files in the provided path.
def submit_jobs(k8s_ctx: str, path: pathlib.Path, dry_run=False) -> List[str]: retval = list() if not path.exists(): raise RuntimeError(f'Path with kubernetes jobs "{path}" does not exist') if path.is_dir(): num_files = len(os.listdir(str(path))) if num_files == 0 and not dry_run: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def submit_jobs_with_retries(k8s_ctx: str, path: pathlib.Path, dry_run=False) -> List[str]:\n return submit_jobs(k8s_ctx, path, dry_run)", "def main():\n parser = argparse.ArgumentParser()\n parser.add_argument('--file', '-f',\n type=argparse.FileType('r'),\n ...
[ "0.6221261", "0.5811291", "0.5430136", "0.54265577", "0.53359383", "0.52959836", "0.5294317", "0.52891713", "0.52890307", "0.5270789", "0.52489644", "0.52117705", "0.5200493", "0.5173163", "0.5100042", "0.5079487", "0.5079471", "0.5078372", "0.5067541", "0.50371045", "0.50299...
0.72203076
0
Delete all kubernetes jobs, persistent volume claims, and persistent volumes.
def delete_all(k8s_ctx: str, dry_run: bool = False) -> List[str]: commands1 = [f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=setup', f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=blast'] commands2 = [f'kubectl --context={k8s_ctx} delete pvc -...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_jobs(self):\n jobs = self.get_jobs(self.age)\n print('Jobs queued for delete: ', jobs)\n for job in jobs:\n try: \n body = k_client.V1DeleteOptions(propagation_policy='Background')\n self.kube_v1_batch_client.delete_namespaced_job(job, body=b...
[ "0.7011506", "0.6865935", "0.6693092", "0.66884226", "0.66858184", "0.6641274", "0.65057886", "0.64343244", "0.642385", "0.6397125", "0.63845754", "0.6333038", "0.6206506", "0.61990374", "0.6195", "0.6106106", "0.61037713", "0.60304976", "0.60248446", "0.6022556", "0.59941286...
0.75015736
0
Run the commands in the argument list and return the names of the relevant k8s objects. This function is specific to delete_all.
def run_commands(commands: List[str], dry_run: bool) -> List[str]: result = [] for cmd in commands: if dry_run: logging.info(cmd) else: p = safe_exec(cmd) if p.stdout: for line in p.stdout.decode().split('\n'): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_all(k8s_ctx: str, dry_run: bool = False) -> List[str]:\n commands1 = [f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=setup',\n f'kubectl --context={k8s_ctx} delete jobs --ignore-not-found=true -l app=blast']\n commands2 = [f'kubectl --context={k8s_ctx} dele...
[ "0.78953844", "0.6110259", "0.6092635", "0.608586", "0.6070033", "0.60426444", "0.59926337", "0.5909514", "0.58847016", "0.5745861", "0.5739375", "0.5739248", "0.573826", "0.5714165", "0.5710907", "0.5709907", "0.5706169", "0.5691667", "0.5688918", "0.5684755", "0.5675016", ...
0.6005288
6
Delete finalizers to ensure PV and PVC get deleted
def delete_finalizers(k8s_ctx: str, dry_run: bool = False): cmd = f'kubectl --context={k8s_ctx} get pv,pvc -o=NAME' for storage_obj in run_commands([cmd], dry_run): cmd = f'kubectl --context={k8s_ctx} patch {storage_obj} -p ' cmd += '{"metadata":{"finalizers":null}}' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finalizer():\n for resource_type in pods, pvcs, storageclasses, secrets:\n for resource in resource_type:\n resource.delete()\n resource.ocp.wait_for_delete(resource.name)\n if pools:\n # Delete only the RBD pool\n pools[0].delete()\n...
[ "0.78778726", "0.68315476", "0.639127", "0.63186175", "0.62764853", "0.6226027", "0.6223201", "0.61615956", "0.61301416", "0.612153", "0.6120431", "0.6120431", "0.6120431", "0.6109426", "0.6105209", "0.60924125", "0.60924125", "0.60924125", "0.6078456", "0.6068378", "0.606651...
0.7561303
1
Retrieve information about PV and PVC from kubectl and log it for debugging purposes.
def inspect_storage_objects_for_debugging(k8s_ctx: str, dry_run: bool = False): cmd = f'kubectl --context={k8s_ctx} get pv,pvc -o=NAME' for storage_obj in run_commands([cmd], dry_run): cmd = f'kubectl --context={k8s_ctx} describe {storage_obj}' if dry_run: logging...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_pv_by_pvc_name_description(namespace, k8s_cli, retries):\n pv_output = \"\"\n error_template = \"Namespace '{}': Failed to get {} resource: {{}}.\".format(namespace, \"PersistentVolumeClaim\")\n volumes_names = get_pv_names(k8s_cli, namespace, error_template)\n for volume in volumes_names:\...
[ "0.61853266", "0.5792927", "0.5758242", "0.57081366", "0.5688722", "0.5639404", "0.55854255", "0.5542733", "0.55318034", "0.5493715", "0.5396289", "0.53871465", "0.53501064", "0.5298621", "0.5275156", "0.5263584", "0.5230812", "0.5208932", "0.51616544", "0.5160978", "0.515081...
0.6945199
0
Delete all volume snapshots associated with the kubernetes cluster
def delete_volume_snapshots(k8s_ctx: str, dry_run: bool = False): # We are not using --force=true here to do a graceful deletion. Volume # snapshot does not need to wait for any pod or job to be deleted and it # is fine if deletion takes some time. --ignore-not-found defaults to true # if --all is used....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snap_delete_all(mnode):\n cmd = \"gluster snapshot delete all --mode=script\"\n return g.run(mnode, cmd)", "def delete_volume_snapshot(volume_snapshots):\n if type(volume_snapshots) is not list:\n volumes = [volume_snapshots]\n command = 'cinder snapshot-delete %s' % \\\n \" \...
[ "0.72916466", "0.694778", "0.6632236", "0.66130334", "0.6478083", "0.6477406", "0.63046324", "0.62845635", "0.62041503", "0.6171982", "0.6118543", "0.6096079", "0.6044555", "0.60432434", "0.60415065", "0.6008003", "0.59782016", "0.5899641", "0.5896192", "0.5867627", "0.586752...
0.8123454
0
Return a list of kubernetes jobs
def get_jobs(k8s_ctx: str, selector: Optional[str] = None, dry_run: bool = False) -> List[str]: cmd = 'kubectl --context={k8s_ctx} get jobs -o json' if selector is not None: cmd += f' -l {selector}' if dry_run: logging.info(cmd) return list() p = safe_exec(cmd) if not p.stdo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_jobs():\n\n name_to_job_details = redis_controller.get_name_to_job_details()\n return list(name_to_job_details.values())", "def jobs():\n result = []\n out = subprocess.check_output([\"/bin/launchctl\", \"list\"]).decode()\n for row in out.splitlines()[1:]:\n result.append(Job(row)...
[ "0.79306775", "0.7741598", "0.7518071", "0.7471795", "0.7458499", "0.74025124", "0.73712224", "0.7338191", "0.7267556", "0.72309756", "0.72155577", "0.72155577", "0.72001016", "0.7166212", "0.706977", "0.70534074", "0.7034029", "0.7031616", "0.70106757", "0.69732976", "0.6967...
0.84486145
0
Wait for the job to return successfully or raise a TimeoutError after specified number of attempts
def _wait_for_job(k8s_ctx: str, job_file: pathlib.Path, attempts: int = 30, secs2wait: int = 60, dry_run: bool = False) -> None: for counter in range(attempts): if _job_succeeded(k8s_ctx, job_file, dry_run): break time.sleep(secs2wait) else: raise TimeoutError(f'{job_file} t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def _wait_retry(self) -> None:\n # Sleep 2^tries + 0…tries*3 seconds between retries\n self.retry_task = asyncio.create_task(\n asyncio.sleep(2 ** min(9, self.tries) + random.randint(0, self.tries * 3))\n )\n await self.retry_task\n self.retry_task = None", "de...
[ "0.6805994", "0.67427564", "0.66825926", "0.6454168", "0.6368625", "0.6354731", "0.63537157", "0.63452667", "0.63171816", "0.6291563", "0.62773556", "0.6274619", "0.6184791", "0.61747164", "0.6170765", "0.6160677", "0.6152056", "0.6144066", "0.61388767", "0.61302525", "0.6112...
0.7734525
0
Checks whether the job file passed in as an argument has succeeded or not. Returns true if the job succeeded, false otherwise. If the job failed, a RuntimeError is raised.
def _job_succeeded(k8s_ctx: str, k8s_job_file: pathlib.Path, dry_run: bool = False) -> bool: if not k8s_job_file.exists(): raise FileNotFoundError(str(k8s_job_file)) cmd = f'kubectl --context={k8s_ctx} get -f {k8s_job_file} -o json' if dry_run: logging.info(cmd) return True p ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isJobRunning ( self ):\n #cmd = \"qstat \" + str(self.jobid)\n \n #magicString='Unknown Job Id' ### magicString _might_ need to be changed if Torque version changes\n #(output, error) = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()\...
[ "0.67143625", "0.66477233", "0.6379032", "0.6379032", "0.6247778", "0.62245816", "0.6209879", "0.6126895", "0.6095487", "0.60941005", "0.60333455", "0.60249513", "0.6003191", "0.5996906", "0.59792376", "0.59495425", "0.5948564", "0.5945208", "0.5917747", "0.590241", "0.588247...
0.6971786
0