text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> r = requests.get(opts['url'], headers=opts['headers'], params=opts['params'], timeout=30) if r.status_code != 200: logging.warning(opts['url'] + " returned status " + str(r.status_code)) return None try: jval = json.loads(r.text, parse_float=decimal.Decimal) # jval = json.loads(r.text) ex...
code_fim
medium
{ "lang": "python", "repo": "CryptoGodfatherVA4/arbot", "path": "/httputil.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: randName/50.008-Project path: /shop/views.py from json import loads from django.http import Http404 from django.shortcuts import render from django.core.exceptions import PermissionDenied from django.views.decorators.csrf import ensure_csrf_cookie from common.db import sql, count, page from com...
code_fim
hard
{ "lang": "python", "repo": "randName/50.008-Project", "path": "/shop/views.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if request.method == 'POST': if not request.user.is_authenticated: raise PermissionDenied(NOT_LOGGED_IN) uid = request.user.id s = """INSERT INTO feedback (user_id, item_id, score, review, made_on) VALUES (%s, %s, %s, %s, NOW())""" try: ...
code_fim
hard
{ "lang": "python", "repo": "randName/50.008-Project", "path": "/shop/views.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: netbox-community/netbox path: /netbox/utilities/tests/test_utils.py from django.http import QueryDict from django.test import TestCase from utilities.utils import deepmerge, dict_to_filter_params, normalize_querydict class DictToFilterParamsTest(TestCase): """ Validate the operation of...
code_fim
hard
{ "lang": "python", "repo": "netbox-community/netbox", "path": "/netbox/utilities/tests/test_utils.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """ Validate the behavior of the deepmerge() utility. """ def test_deepmerge(self): dict1 = { 'active': True, 'foo': 123, 'fruits': { 'orange': 1, 'apple': 2, 'pear': 3, }, ...
code_fim
hard
{ "lang": "python", "repo": "netbox-community/netbox", "path": "/netbox/utilities/tests/test_utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if isinstance(add_config, configparser.ConfigParser): add_config = config_to_dict(add_config) base_config.read_dict(add_config) return base_config def reverse_data(data_config): for section in data_config: for option in data_config[section]: value = parse(data_...
code_fim
hard
{ "lang": "python", "repo": "THUNLP-MT/Mask-Align", "path": "/thualign/utils/config.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: THUNLP-MT/Mask-Align path: /thualign/utils/config.py # coding=utf-8 # Copyright 2021-Present The THUAlign Authors from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import json import configparser import logging def parse(valu...
code_fim
hard
{ "lang": "python", "repo": "THUNLP-MT/Mask-Align", "path": "/thualign/utils/config.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> return json.dumps(self._params, sort_keys=True) @classmethod def read(cls, cfg, base=None, data=None, model=None, exp='DEFAULT'): curdir = os.path.dirname(__file__) if not os.path.exists(cfg): cfg = os.path.join(curdir, \ '../configs/user/{}.con...
code_fim
hard
{ "lang": "python", "repo": "THUNLP-MT/Mask-Align", "path": "/thualign/utils/config.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: FedML-AI/FedML path: /python/fedml/data/reddit/data_loader.py import os import logging import numpy as np import torch import torch.utils.data as data import torchvision.transforms as transforms from torch.nn.utils.rnn import pad_sequence from .datasets import Reddit_dataset from .divide_data ...
code_fim
hard
{ "lang": "python", "repo": "FedML-AI/FedML", "path": "/python/fedml/data/reddit/data_loader.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> filter_client_idx = 0 num_clients = len(training_sets.partitions) for client_idx in range(num_clients): client_data = select_dataset(client_idx, training_sets, batch_size=args.batch_size, args=args, collat...
code_fim
hard
{ "lang": "python", "repo": "FedML-AI/FedML", "path": "/python/fedml/data/reddit/data_loader.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: yennicks/kirby path: /tests/tests_api/test_api_context.py import datetime import multiprocessing import os import pytest from kirby.api.context import ContextManager from kirby.api.queue import Queue def _load_config(q): from kirby.api.context import ctx assert ctx.HELLO == "WORLD" ...
code_fim
hard
{ "lang": "python", "repo": "yennicks/kirby", "path": "/tests/tests_api/test_api_context.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> offset = datetime.timedelta(seconds=5) with kafka_topic_factory("kirby-test-integration"): q = Queue("kirby-test-integration") start = datetime.datetime.now() q.append("too early", submitted=start - offset) q.append("hello world", submitted=start + offset) ...
code_fim
hard
{ "lang": "python", "repo": "yennicks/kirby", "path": "/tests/tests_api/test_api_context.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.unit == 'tile': df_idx = np.where((idx < self.df['n_tiles_end']) & (idx >= self.df['n_tiles_start']))[0][0] elif self.unit == 'slide': df_idx = idx cancer = self.df.loc[df_idx, 'Type'] basename = self.df.loc[df_idx, 'basename'] ...
code_fim
hard
{ "lang": "python", "repo": "chsher/CAML", "path": "/caml/datasets/tcga.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: chsher/CAML path: /caml/datasets/tcga.py import os import sys from os.path import dirname, realpath sys.path.append(dirname(realpath(__file__))) from caml.datasets import data_utils import numpy as np import pandas as pd import torch import torch.nn as nn import torch.nn.functional as F import ...
code_fim
hard
{ "lang": "python", "repo": "chsher/CAML", "path": "/caml/datasets/tcga.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.apply_filter: self.df = data_utils.filter_df(self.df, self.min_tiles, self.cancers, n_pts=self.n_pts, random_seed=self.random_seed) idxs = np.arange(self.df.shape[0]) np.random.shuffle(idxs) self.df = self.df.iloc[idxs, :] self.df.reset_...
code_fim
hard
{ "lang": "python", "repo": "chsher/CAML", "path": "/caml/datasets/tcga.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>F-707-1-X-X-1", "npGsmRegistration"), ("DKSF-707-1-X-X-1", "npGsmStrength")) if mibBuilder.loadTexts: npGsmTrap.setStatus('current') npReboot = MibIdentifier((1, 3, 6, 1, 4, 1, 25728, 911)) npSoftReboot = MibScalar((1, 3, 6, 1, 4, 1, 25728, 911, 1), Integer32()).setMaxAccess("readwrite") if mibBuilder.loa...
code_fim
hard
{ "lang": "python", "repo": "agustinhenze/mibs.snmplabs.com", "path": "/pysnmp/DKSF-707-1-X-X-1.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/DKSF-707-1-X-X-1.py # # PySNMP MIB module DKSF-707-1-X-X-1 (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DKSF-707-1-X-X-1 # Produced by pysmi-0.3.4 at Mon Apr 29 18:32:32 2019 # On host DAVWANG4-M-1475 pla...
code_fim
hard
{ "lang": "python", "repo": "agustinhenze/mibs.snmplabs.com", "path": "/pysnmp/DKSF-707-1-X-X-1.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>barX = [] for i in range(N+1): count = sum([r == i for r in X_t]) barX.append(count) plt.plot(barX) plt.savefig('kmr0_frequency.png') plt.show() SD = mc_compute_stationary(P) plt.hist(SD) plt.savefig('kmr0_hist.png') plt.show()<|fim_prefix|># repo: yohanashima/stochevolution path: /kmr.py # -*- ...
code_fim
medium
{ "lang": "python", "repo": "yohanashima/stochevolution", "path": "/kmr.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yohanashima/stochevolution path: /kmr.py # -*- coding: utf-8 -*- from __future__ import division import matplotlib.pyplot as plt from random import randint import numpy as np from scipy.stats import binom from discrete_rv import DiscreteRV from mc_tools.py import mc_compute_stationary, mc_sampl...
code_fim
hard
{ "lang": "python", "repo": "yohanashima/stochevolution", "path": "/kmr.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def mk_matrix1(N, ep, p): #同時改訂 P = np.empty((N+1, N+1)) for i in range(N): if i/N < p: pro = ep/2 elif i/N == p: pro = 1/2 else: pro = 1-ep/2 P[i] = binom.pmf(range(N+1), N, pro) return P #変数 N = 15 #人数 T = 1000 #試行回数 ep = 0...
code_fim
hard
{ "lang": "python", "repo": "yohanashima/stochevolution", "path": "/kmr.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: PavlidisLab/rnaseq-pipeline path: /rnaseq_pipeline/gemma.py from getpass import getpass import os from os.path import join import subprocess import luigi from luigi.contrib.external_program import ExternalProgramTask import requests from requests.auth import HTTPBasicAuth from .config import rn...
code_fim
hard
{ "lang": "python", "repo": "PavlidisLab/rnaseq-pipeline", "path": "/rnaseq_pipeline/gemma.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> @property def reference_id(self): try: return {'human': gemma_cfg.human_reference_id, 'mouse': gemma_cfg.mouse_reference_id, 'rat': gemma_cfg.rat_reference_id}[self.taxon] except KeyError: raise ValueError('Unsupported Gemma taxon {}.'.format(self.taxon)) ...
code_fim
hard
{ "lang": "python", "repo": "PavlidisLab/rnaseq-pipeline", "path": "/rnaseq_pipeline/gemma.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> def datasets(self, experiment_id): return self._query_api(join('datasets', experiment_id)) def samples(self, experiment_id): return self._query_api(join('datasets', experiment_id, 'samples')) def platforms(self, experiment_id): return self._query_api(join('datasets', ...
code_fim
hard
{ "lang": "python", "repo": "PavlidisLab/rnaseq-pipeline", "path": "/rnaseq_pipeline/gemma.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #import the example submission file for its stucture submit = pd.read_csv('C:/Users/Laurens/Documents/TeamGreaterThanBrains/Scripts/Ensembles/SubmissionFormat.csv',sep=',') filename='128linearSubmission.csv' #input for this has to be an array in the order of the testbusinesses in the submissionfile #...
code_fim
hard
{ "lang": "python", "repo": "LHagendoorn/TeamGreaterThanBrains", "path": "/Project1/Scripts/Clustering (HBOW-EM)/MBKMtoPrediction.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LHagendoorn/TeamGreaterThanBrains path: /Project1/Scripts/Clustering (HBOW-EM)/MBKMtoPrediction.py # -*- coding: utf-8 -*- """ Created on Mon Apr 11 16:03:55 2016 @author: Laurens Takes a minibatch kmeans cluster and generates both the verification set prediction as well as the prediction for t...
code_fim
hard
{ "lang": "python", "repo": "LHagendoorn/TeamGreaterThanBrains", "path": "/Project1/Scripts/Clustering (HBOW-EM)/MBKMtoPrediction.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> data = pd.read_csv('C:/Users/Laurens/Documents/uni/MLP/data/features/caffe_features_test.csv', header=None, sep=',', engine='c', dtype={c: np.float64 for c in np.ones(4096)}) photoToBiz = pd.read_csv('C:/Users/Laurens/Documents/uni/MLP/data/test_photo_to_biz.csv', sep=',') testBizIds = photoToBiz.bu...
code_fim
hard
{ "lang": "python", "repo": "LHagendoorn/TeamGreaterThanBrains", "path": "/Project1/Scripts/Clustering (HBOW-EM)/MBKMtoPrediction.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kevjeong/CSE450 path: /rply/lexer.py from .errors import LexingError from .token import SourcePosition, Token class Lexer(object): tokens = ( "WHATEVR", "VISIBLE", "KTHXBAI", "GIMME", "MKAY", "HAS", "HAI", "ITZ", "OF", ...
code_fim
hard
{ "lang": "python", "repo": "kevjeong/CSE450", "path": "/rply/lexer.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.lexer = lexer self.s = s self.idx = 0 self._lineno = 1 def __iter__(self): return self def _update_pos(self, match): self.idx = match.end self._lineno += self.s.count("\n", match.start, match.end) last_nl = self.s.rfind("\n", ...
code_fim
hard
{ "lang": "python", "repo": "kevjeong/CSE450", "path": "/rply/lexer.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> E501 from tf_keras_vis.activation_maximization.callbacks import \ GifGenerator2D # noqa: F401 E402 from tf_keras_vis.activation_maximization.callbacks import \ GifGenerator2D as GifGenerator # noqa: F401 E402 from tf_keras_vis.activation_maximization.callbacks import \ PrintLogger as Print ...
code_fim
medium
{ "lang": "python", "repo": "ZNHU-Forks/tf-keras-vis", "path": "/tf_keras_vis/utils/callbacks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ZNHU-Forks/tf-keras-vis path: /tf_keras_vis/utils/callbacks.py import warnings warnings.warn(('`tf_keras_vis.utils.callbacks` module is deprecated. ' 'Please use `tf_keras_vis.activation_maximization.callbacks<|fim_suffix|>t \ GifGenerator2D as GifGenerator # noqa: F401 E402 ...
code_fim
hard
{ "lang": "python", "repo": "ZNHU-Forks/tf-keras-vis", "path": "/tf_keras_vis/utils/callbacks.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t \ GifGenerator2D as GifGenerator # noqa: F401 E402 from tf_keras_vis.activation_maximization.callbacks import \ PrintLogger as Print # noqa: F401 E402<|fim_prefix|># repo: ZNHU-Forks/tf-keras-vis path: /tf_keras_vis/utils/callbacks.py import warnings warnings.warn(('`tf_keras_vis.utils.callb...
code_fim
medium
{ "lang": "python", "repo": "ZNHU-Forks/tf-keras-vis", "path": "/tf_keras_vis/utils/callbacks.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> cipher_text += chr(pos) else: cipher_text += i return cipher_text s = "www.abc.xy" k = 87 print(caesarCipher(s, k))<|fim_prefix|># repo: DiyorbekAzimqulov/ProblemSolving path: /ceaserCipher.py # https://www.hackerrank.com/challenges/caesar-cipher-1/problem def cae...
code_fim
hard
{ "lang": "python", "repo": "DiyorbekAzimqulov/ProblemSolving", "path": "/ceaserCipher.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: DiyorbekAzimqulov/ProblemSolving path: /ceaserCipher.py # https://www.hackerrank.com/challenges/caesar-cipher-1/problem def caesarCipher(s: str, k: int): k %= 26 cipher_text = '' for i in s: if i.isalpha(): if i.isupper(): pos = ord(i) + k ...
code_fim
hard
{ "lang": "python", "repo": "DiyorbekAzimqulov/ProblemSolving", "path": "/ceaserCipher.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: polmes/hackcu path: /justcaptionthis/justcaptionthis/listener.py import tweepy import requests from utils import ocr, tweetsplitter class MentionListener(tweepy.StreamListener): def __init__(self, api, deepai): self.api = api self.key = deepai['key'] def on_status(self, status, firstcall...
code_fim
hard
{ "lang": "python", "repo": "polmes/hackcu", "path": "/justcaptionthis/justcaptionthis/listener.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Add OCR text if detected if text is not None: cap = 'The image shows ' + cap + ' and it says ' + text caption.append(cap) if caption: # Build tweet if len(caption) == 1: tweet = caption[0] else: tweet = '' for i, c in enumerate(caption): tweet +...
code_fim
hard
{ "lang": "python", "repo": "polmes/hackcu", "path": "/justcaptionthis/justcaptionthis/listener.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Tweet (reply) the response if len(tweet) <= 280: self.api.update_status(tweet, in_reply_to_status_id=self.id, auto_populate_reply_metadata=True) else: tweets = tweetsplitter(tweet) prev = self.id for t in tweets: latest = self.api.update_status(t, in_reply_to_status...
code_fim
hard
{ "lang": "python", "repo": "polmes/hackcu", "path": "/justcaptionthis/justcaptionthis/listener.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> ''' Hold a NumPy array ''' a = np.arange(1,n) f = np.frompyfunc(lambda s, x: ((s + x) if (x % 2 == 0) else s), 2, 1) return f.reduce(a, initial=0, dtype=np.int) if __name__ == "__main__": n=1000001 print((1 + ((n - 1) // 2)) * ((n - 1) // 2)) print(hold_a_lis...
code_fim
hard
{ "lang": "python", "repo": "zettsu-t/cPlusPlusFriend", "path": "/scripts/stock_price/memory_profile_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zettsu-t/cPlusPlusFriend path: /scripts/stock_price/memory_profile_list.py #!/usr/bin/python3 # coding: utf-8 ''' Compare memory footprints. Based on https://twitter.com/uuyr112/status/1160375090090876930 ''' <|fim_suffix|>if __name__ == "__main__": n=1000001 print((1 + ((n - ...
code_fim
hard
{ "lang": "python", "repo": "zettsu-t/cPlusPlusFriend", "path": "/scripts/stock_price/memory_profile_list.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>@profile def use_a_np_array(n): ''' Hold a NumPy array ''' a = np.arange(1,n) f = np.frompyfunc(lambda s, x: ((s + x) if (x % 2 == 0) else s), 2, 1) return f.reduce(a, initial=0, dtype=np.int) if __name__ == "__main__": n=1000001 print((1 + ((n - 1) // 2)) * ((n...
code_fim
hard
{ "lang": "python", "repo": "zettsu-t/cPlusPlusFriend", "path": "/scripts/stock_price/memory_profile_list.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: data61/landshark path: /landshark/dataprocess.py """Process training and query data.""" # Copyright 2019 CSIRO (Data61) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at...
code_fim
hard
{ "lang": "python", "repo": "data61/landshark", "path": "/landshark/dataprocess.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # # Functions for reading hdf5 query data directy # def _islice_batched(it: Iterator[np.ndarray], n: int) -> Iterator[np.ndarray]: """Slice an iterator which comes in batches.""" while n > 0: arr: np.ndarray = next(it) k = arr.shape[0] yield arr[:n, :] n -= k d...
code_fim
hard
{ "lang": "python", "repo": "data61/landshark", "path": "/landshark/dataprocess.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> """Read feature data from HDF5 file.""" def __init__( self, hdf5_file: str, halfwidth: int = 0, nworkers: int = 1, batch_mb: float = 1000, ) -> None: self.file = hdf5_file self.meta = read_feature_metadata(hdf5_file) self.meta.ha...
code_fim
hard
{ "lang": "python", "repo": "data61/landshark", "path": "/landshark/dataprocess.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> if seq1 == seq2: return True else: return False def _inorderTraverse(self, node, seq, val): # exit condition if node is None: seq.append(val) return # in-order traversing self._inorderTraverse(node.left, ...
code_fim
medium
{ "lang": "python", "repo": "solomonovum/algorithms", "path": "/leetcode/872_Leaf-Similar Trees.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: solomonovum/algorithms path: /leetcode/872_Leaf-Similar Trees.py # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: <|fim_suffix|> # exit condition if nod...
code_fim
hard
{ "lang": "python", "repo": "solomonovum/algorithms", "path": "/leetcode/872_Leaf-Similar Trees.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print("測試資料 x:") print(prediction['input_data_x']) print("測試資料 y:") print(prediction['input_data_y']) print("預測結果:") print(prediction['prediction']) print("W 平均錯誤率(Ein):") print(best_model.calculate_avg_error(best_model.train_X, best_model.tr...
code_fim
hard
{ "lang": "python", "repo": "gogobook/fuku-ml", "path": "/test_fuku_ml.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> svm_bc = svm.BinaryClassifier() svm_bc.load_train_data(input_train_data_file) svm_bc.set_feature_transform('legendre', 3) svm_bc.load_test_data(input_test_data_file) svm_bc.set_param(svm_kernel='primal_hard_margin') svm_bc.init_W() W = svm_bc.train()...
code_fim
hard
{ "lang": "python", "repo": "gogobook/fuku-ml", "path": "/test_fuku_ml.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: gogobook/fuku-ml path: /test_fuku_ml.py 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0...
code_fim
hard
{ "lang": "python", "repo": "gogobook/fuku-ml", "path": "/test_fuku_ml.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: GowthamBA/Voice-Assistant path: /testingVoice.py recording = sr.Recognizer() with sr.Microphone() as source: recording.adjust_for_ambient_noise(source) print("Please Say something:"<|fim_suffix|> recording.recognize_google(audio)) except Exception as e: print(e)<|fim_middle|>) au...
code_fim
medium
{ "lang": "python", "repo": "GowthamBA/Voice-Assistant", "path": "/testingVoice.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>) audio = recording.listen(source) try: print("You said: \n" + recording.recognize_google(audio)) except Exception as e: print(e)<|fim_prefix|># repo: GowthamBA/Voice-Assistant path: /testingVoice.py recording = sr.Recognizer() with sr.Microphone() as source: recor<|fim_middle|>ding.adju...
code_fim
medium
{ "lang": "python", "repo": "GowthamBA/Voice-Assistant", "path": "/testingVoice.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> recording.recognize_google(audio)) except Exception as e: print(e)<|fim_prefix|># repo: GowthamBA/Voice-Assistant path: /testingVoice.py recording = sr.Recognizer() with sr.Microphone() as source: recor<|fim_middle|>ding.adjust_for_ambient_noise(source) print("Please Say something:") au...
code_fim
medium
{ "lang": "python", "repo": "GowthamBA/Voice-Assistant", "path": "/testingVoice.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: jellyear/niy path: /examples/colorizing_photos/model_b/get_sample.py import os, glob import numpy as np import matplotlib.pyplot as plt from PIL import Image IMG_WIDTH = 64 IMG_HEIGHT = 64 def get_train_sample(filepath): with Image.open(filepath) as img_color: img_gray = img_color.convert('...
code_fim
hard
{ "lang": "python", "repo": "jellyear/niy", "path": "/examples/colorizing_photos/model_b/get_sample.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>paths = [] paths += glob.glob('files/Train/group1/64/*.png') paths += glob.glob('files/Train/group2/64/*.png') paths += glob.glob('files/Train/group3/64/*.png') paths += glob.glob('files/Train/group4/64/*.png') paths += glob.glob('files/Train/group5/64/*.png') paths += glob.glob('files/Train/group6/64/*.p...
code_fim
hard
{ "lang": "python", "repo": "jellyear/niy", "path": "/examples/colorizing_photos/model_b/get_sample.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: tgsnopec/pysegyutils path: /pysegyutils/ops/negation.py import segyio from ..core import is_segy_valid, SegyFile from ..core.file_copy_utils import fast_copy def negate_file(input_file, output_file, iline=9, xline=21): <|fim_suffix|> try: fast_copy(input_file, output_file) excep...
code_fim
hard
{ "lang": "python", "repo": "tgsnopec/pysegyutils", "path": "/pysegyutils/ops/negation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> try: fast_copy(input_file, output_file) except OSError as o: # TODO raise o output_segy_file = segyio.open(output_file, mode='r+', ignore_geometry=True, strict=False, iline=iline, xline=xline) for it in range(output_segy_file.tr...
code_fim
hard
{ "lang": "python", "repo": "tgsnopec/pysegyutils", "path": "/pysegyutils/ops/negation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for it in range(output_segy_file.tracecount): output_segy_file.trace[it] *= -1 output_segy_file.close()<|fim_prefix|># repo: tgsnopec/pysegyutils path: /pysegyutils/ops/negation.py import segyio from ..core import is_segy_valid, SegyFile from ..core.file_copy_utils import fast_copy...
code_fim
hard
{ "lang": "python", "repo": "tgsnopec/pysegyutils", "path": "/pysegyutils/ops/negation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))<|fim_prefix|># repo: schferbe/glucometerutils path: /test/__init__.py # -*- coding: utf-8 -*- # # SPDX-License-Identifier: MIT """Add the top-level module to the PYTHONPATH.""" <|fim_middle|>import os import sys
code_fim
easy
{ "lang": "python", "repo": "schferbe/glucometerutils", "path": "/test/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: schferbe/glucometerutils path: /test/__init__.py # -*- coding: utf-8 -*- # # SPDX-License-Identifier: MIT """Add the top-level module to the PYTHONPATH.""" <|fim_suffix|>sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))<|fim_middle|>import os import sys
code_fim
easy
{ "lang": "python", "repo": "schferbe/glucometerutils", "path": "/test/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Here we test the examples in the documentation automatically using doctest. We set up an environment which is similar to what a rule writer might see - a 'sshd_config' variable that has been passed in as a parameter to the rule declaration. This saves doing this setup in the ...
code_fim
hard
{ "lang": "python", "repo": "eduardocerqueira/insights-core", "path": "/docs/examples/parsers/tests/test_secure_shell.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: eduardocerqueira/insights-core path: /docs/examples/parsers/tests/test_secure_shell.py from insights.parsers.secure_shell import SshDConfig from insights.parsers import secure_shell from insights.tests import context_wrap import doctest SSHD_CONFIG_INPUT = """ # $OpenBSD: sshd_config,v 1.93 2...
code_fim
hard
{ "lang": "python", "repo": "eduardocerqueira/insights-core", "path": "/docs/examples/parsers/tests/test_secure_shell.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> uuid = models.UUIDField(default=uuid4, primary_key=True) name = models.TextField(null=False) type = models.TextField(null=False) provider = models.ForeignKey("api.Provider", on_delete=models.CASCADE, null=True) class SubsLastProcessed(models.Model): """A model for storing last proces...
code_fim
medium
{ "lang": "python", "repo": "project-koku/koku", "path": "/koku/reporting/provider/models.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: project-koku/koku path: /koku/reporting/provider/models.py # # Copyright 2023 Red Hat Inc. # SPDX-License-Identifier: Apache-2.0 # """Models for provider management.""" from uuid import uuid4 from django.db import models class TenantAPIProvider(models.Model): <|fim_suffix|>class SubsLastProces...
code_fim
hard
{ "lang": "python", "repo": "project-koku/koku", "path": "/koku/reporting/provider/models.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> source_uuid = models.ForeignKey( "reporting.TenantAPIProvider", on_delete=models.CASCADE, unique=False, null=False, db_column="source_uuid" ) year = models.CharField(null=False, max_length=4) month = models.CharField(null=False, max_length=2) latest_processed_time = models.Date...
code_fim
hard
{ "lang": "python", "repo": "project-koku/koku", "path": "/koku/reporting/provider/models.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Return ------ str Return the URI of destination. """ source = _normalize_uri(source) dest = _normalize_uri(dest) parsed_source = urlparse(source) if dest and dest.endswith("/"): dest = join(dest, basename(parsed_source.path)) parsed_dest = urlparse(dest)...
code_fim
hard
{ "lang": "python", "repo": "adRise/rikai", "path": "/python/rikai/io.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: adRise/rikai path: /python/rikai/io.py # Copyright 2020 Rikai Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-...
code_fim
hard
{ "lang": "python", "repo": "adRise/rikai", "path": "/python/rikai/io.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> attribute_filter = AttributeFilter.from_model(UserREST(), False) attribute_filter.first_name = True adapted_users = sqlalchemy.adapt_persistent_collection(users, UserREST, attribute_filter) self.assertEqual(adapted_users[0].first_name, "James") self.assertIsNone(ad...
code_fim
hard
{ "lang": "python", "repo": "anomaly/prestans", "path": "/tests/issues/test_issue84.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def test_correct_adaption_collection(self): user = UserPersistent() user.first_name = "James" user.last_name = "Hetfield" users = [user] attribute_filter = AttributeFilter.from_model(UserREST(), False) attribute_filter.first_name = True adapt...
code_fim
hard
{ "lang": "python", "repo": "anomaly/prestans", "path": "/tests/issues/test_issue84.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: anomaly/prestans path: /tests/issues/test_issue84.py from prestans.ext.data import adapters from prestans.ext.data.adapters import sqlalchemy from prestans.parser.attribute_filter import AttributeFilter from prestans import types import unittest class UserPersistent(object): first_name = "...
code_fim
hard
{ "lang": "python", "repo": "anomaly/prestans", "path": "/tests/issues/test_issue84.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: JosemyDuarte/aws_python_terraform_poc path: /downloader/downloader.py import requests def handler(event, context): <|fim_suffix|> print("Downloading page from [{}] ...".format(path)) return requests.get(path).content<|fim_middle|> print("Starting request with event [{}] and context [{...
code_fim
medium
{ "lang": "python", "repo": "JosemyDuarte/aws_python_terraform_poc", "path": "/downloader/downloader.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> print("Downloading page from [{}] ...".format(path)) return requests.get(path).content<|fim_prefix|># repo: JosemyDuarte/aws_python_terraform_poc path: /downloader/downloader.py import requests def handler(event, context): <|fim_middle|> print("Starting request with event [{}] and context [{...
code_fim
medium
{ "lang": "python", "repo": "JosemyDuarte/aws_python_terraform_poc", "path": "/downloader/downloader.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> app.conf.beat_schedule = { 'update-feeds-and-items': { 'task': 'rss_feed.feeds.tasks.periodic_update_feeds_and_items', 'schedule': crontab(minute='*/30'), # every 30 minutes } }<|fim_prefix|># repo: MahmoudFarid/rss_feed path: /config/celery_beat.py from c...
code_fim
easy
{ "lang": "python", "repo": "MahmoudFarid/rss_feed", "path": "/config/celery_beat.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: MahmoudFarid/rss_feed path: /config/celery_beat.py from celery.schedules import crontab <|fim_suffix|> app.conf.beat_schedule = { 'update-feeds-and-items': { 'task': 'rss_feed.feeds.tasks.periodic_update_feeds_and_items', 'schedule': crontab(minute='*/30'), # ...
code_fim
easy
{ "lang": "python", "repo": "MahmoudFarid/rss_feed", "path": "/config/celery_beat.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Write header writer.writerow(HEURISTICS_CSV_HEADERS) # Run experiments for experiment in experiments: try: # Log logger.info( 'Starting experiment timeout={} dataset={}' .format(*experi...
code_fim
hard
{ "lang": "python", "repo": "TheoryInPractice/practical-oct", "path": "/experiments/heuristic/cplex.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: TheoryInPractice/practical-oct path: /experiments/heuristic/cplex.py """Run cplex experiments.""" # Imports from experiments import ( logger, SNAP_DATA_DIR, SNAP_DATA_EXT, PREPROCESSING_TIMEOUTS ) from experiments.datasets import preprocessed from experiments.heuristic import ( ...
code_fim
hard
{ "lang": "python", "repo": "TheoryInPractice/practical-oct", "path": "/experiments/heuristic/cplex.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def display(self): puts(bold + uline, "Issues in Repo:") clear() nl() for issue in self.data: SingleIssueDisplayObject(issue).display() putln(black, '=' * CONSOLE_WIDTH) nl() class SingleLongIssueDisplayObject(DisplayObject): de...
code_fim
hard
{ "lang": "python", "repo": "elunico/guppy", "path": "/issue_display.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def display(self): SingleIssueDisplayObject(self.data).display() puts(' ') putln(uline + bold, 'Body:') clear() body = self.data['body'] LongTextDisplayObject(body, CONSOLE_WIDTH - 4, 4).display(magenta) clear() nl() class SingleIssueD...
code_fim
hard
{ "lang": "python", "repo": "elunico/guppy", "path": "/issue_display.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: elunico/guppy path: /issue_display.py from colors import * import requests from utils import * from repo_display import * from display import * from caching import * def fetch_issue(repo, issue, issues_url, caching=CACHING_ACTIVE): """ Retrieves an issue for a partiular repo either from...
code_fim
hard
{ "lang": "python", "repo": "elunico/guppy", "path": "/issue_display.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> with h5py.File(h5file, "r") as f: data = f[vid_name]['data'][:] length = data.shape[0] start_idx = length//2 - 30//2 end_idx = length//2 + 30//2 cliped = data[start_idx:end_idx] print(cliped.shape) return cliped name = "/home/butlely/PycharmPro...
code_fim
hard
{ "lang": "python", "repo": "songys96/yolact", "path": "/convertToNpy.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: songys96/yolact path: /convertToNpy.py import os import time import h5py import numpy as np import cv2 def run(): src = '/home/butlely/Desktop/Dataset/aihub/source_7/20201024_cat-grooming-000052.mp4' image_list = os.listdir(src) image_list = sorted(image_list, key=lambda x: int(x.sp...
code_fim
hard
{ "lang": "python", "repo": "songys96/yolact", "path": "/convertToNpy.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Detect faces face_ids = [] faces = face_client.face.detect_with_stream(image) for face in faces: face_ids.append(face.face_id) # Identify faces results = face_client.face.identify(face_ids, PERSON_GROUP_ID) print('Identifying faces in {}'.format(os.path.basename(image.name))) if not results: pr...
code_fim
hard
{ "lang": "python", "repo": "pjgpetecodes/mscognitive", "path": "/pythonface/pyface-group.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pjgpetecodes/mscognitive path: /pythonface/pyface-group.py from azure.cognitiveservices.vision.face import FaceClient from msrest.authentication import CognitiveServicesCredentials from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person import os import uuid import glob...
code_fim
hard
{ "lang": "python", "repo": "pjgpetecodes/mscognitive", "path": "/pythonface/pyface-group.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def deleteNode(self, data): p = self.root while p.ptr and p.ptr.data != data: p = p.ptr if p.ptr: sleep(1) print("Deleting {} from linked list...".format(data)) temp = p.ptr p.ptr = p.ptr.ptr temp = None ...
code_fim
hard
{ "lang": "python", "repo": "AamirAnwar/PythonLab", "path": "/linkedList.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def testLinkedList(): ll = LinkedList() data = [random.randint(1, 1000) for x in range(10)] for i in data: ll.addNode(i) for i in range(len(data)): randIndex = random.randint(0, len(data) - 1) ll.deleteNode(data[randIndex]) print(ll)<|fim_prefix|># repo: Aami...
code_fim
hard
{ "lang": "python", "repo": "AamirAnwar/PythonLab", "path": "/linkedList.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AamirAnwar/PythonLab path: /linkedList.py '''Linked list data structure using lists''' from time import sleep # Linked list node structure class Node: def __init__(self, data, ptr): self.ptr = ptr self.data = data class LinkedList: def __init__(self): self.root ...
code_fim
hard
{ "lang": "python", "repo": "AamirAnwar/PythonLab", "path": "/linkedList.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: collector-m/DI-store path: /di_store/storage/storage_server_pb2.py # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: storage_server.proto """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf imp...
code_fim
hard
{ "lang": "python", "repo": "collector-m/DI-store", "path": "/di_store/storage/storage_server_pb2.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>FetchResponse = _reflection.GeneratedProtocolMessageType('FetchResponse', (_message.Message,), { 'DESCRIPTOR' : _FETCHRESPONSE, '__module__' : 'storage_server_pb2' # @@protoc_insertion_point(class_scope:di_store.storage_server.FetchResponse) }) _sym_db.RegisterMessage(FetchResponse) GetRequest = ...
code_fim
hard
{ "lang": "python", "repo": "collector-m/DI-store", "path": "/di_store/storage/storage_server_pb2.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>_GETRESPONSE = _descriptor.Descriptor( name='GetResponse', full_name='di_store.storage_server.GetResponse', filename=None, file=DESCRIPTOR, containing_type=None, create_key=_descriptor._internal_create_key, fields=[ _descriptor.FieldDescriptor( name='not_found', full_name='di_store...
code_fim
hard
{ "lang": "python", "repo": "collector-m/DI-store", "path": "/di_store/storage/storage_server_pb2.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> super(OrganizationPeriodicUsage, self).__init__(item, **kwargs) self.unit_of_measure = item.get('unitOfMeasure', None) self.metric = item.get('metric', None) self.usage = item.get('usage', None) self.usage_per_day = item.get('usagePerDay', None) self.date_r...
code_fim
hard
{ "lang": "python", "repo": "contentful/contentful-management.py", "path": "/contentful_management/organization_periodic_usage.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: contentful/contentful-management.py path: /contentful_management/organization_periodic_usage.py from .resource import Resource """ contentful_management.organization_periodic_usage ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This module implements the OrganizationPeriodicUsage class. AP...
code_fim
hard
{ "lang": "python", "repo": "contentful/contentful-management.py", "path": "/contentful_management/organization_periodic_usage.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if self.format != 'html': raise Exception('URL can only be obtained for an html report') request = requests.get(str(self)) return '{0}{1}'.format(self.PRESTIFY_SERVICE_URL, request.headers['Location']) def __str__(self): return '{0}/reports/{1}?{2}'.format( self.PRESTIFY_SERVICE_URL, s...
code_fim
hard
{ "lang": "python", "repo": "omarkhd/prestify-client-py", "path": "/prestify/client.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: omarkhd/prestify-client-py path: /prestify/client.py # -*- coding: utf-8 -*- import base64 import json try: from urllib.parse import urlencode except ImportError: from urllib import urlencode import requests class Report(object): PRESTIFY_SERVICE_URL = None _VALID_FORMATS = ('pdf', 'rtf', ...
code_fim
medium
{ "lang": "python", "repo": "omarkhd/prestify-client-py", "path": "/prestify/client.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def collect_itsm_status(self, collect_config_id): collect_config = CollectorConfig.objects.get(collector_config_id=collect_config_id) ret = { "collect_itsm_status": collect_config.itsm_ticket_status, "collect_itsm_status_display": CollectItsmStatus.get_choice_la...
code_fim
hard
{ "lang": "python", "repo": "jiazhizhong/bk-log", "path": "/apps/log_databus/handlers/itsm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jiazhizhong/bk-log path: /apps/log_databus/handlers/itsm.py # -*- coding: utf-8 -*- """ Tencent is pleased to support the open source community by making BK-LOG 蓝鲸日志平台 available. Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. BK-LOG 蓝鲸日志平台 is licensed under the MIT L...
code_fim
hard
{ "lang": "python", "repo": "jiazhizhong/bk-log", "path": "/apps/log_databus/handlers/itsm.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> collector_process = CollectorConfig.objects.get(itsm_ticket_sn=ticket_info.get("sn")) ticket_detail_info = self.ticket_info(ticket_info.get("sn")) collector_process.set_can_use_es_cluster(self._get_can_use_es_cluster(ticket_detail_info)) if self._ticket_is_finish(ticket_inf...
code_fim
hard
{ "lang": "python", "repo": "jiazhizhong/bk-log", "path": "/apps/log_databus/handlers/itsm.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def get_queryset(self, request): return Declaration.objects.all_with_deleted() admin.site.register(Report, ReportAdmin) admin.site.register(Resolution, ResolutionAdmin) admin.site.register(Declaration, DeclarationAdmin)<|fim_prefix|># repo: un-project/un-project.org path: /web/declarations/...
code_fim
medium
{ "lang": "python", "repo": "un-project/un-project.org", "path": "/web/declarations/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class DeclarationAdmin(admin.ModelAdmin): list_display = ("text", "resolution", "is_deleted") list_filter = ("is_deleted",) def get_queryset(self, request): return Declaration.objects.all_with_deleted() admin.site.register(Report, ReportAdmin) admin.site.register(Resolution, Resolu...
code_fim
hard
{ "lang": "python", "repo": "un-project/un-project.org", "path": "/web/declarations/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: un-project/un-project.org path: /web/declarations/admin.py from django.contrib import admin from django.db import models from django.db.models import Count from django.forms import Textarea from declarations.models import Resolution, Declaration, Report class ReportAdmin(admin.ModelAdmin): ...
code_fim
hard
{ "lang": "python", "repo": "un-project/un-project.org", "path": "/web/declarations/admin.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># Force sending of all messages producer.flush()<|fim_prefix|># repo: drednout/site_checker path: /src/scripts/kafka_producer.py from kafka import KafkaProducer producer = KafkaProducer( bootstrap_servers="kafka-aiven-site-checker-drednout-7f62.aivencloud.com:14798", security_protocol="SSL", ...
code_fim
medium
{ "lang": "python", "repo": "drednout/site_checker", "path": "/src/scripts/kafka_producer.py", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: drednout/site_checker path: /src/scripts/kafka_producer.py from kafka import KafkaProducer producer = KafkaProducer( bootstrap_servers="kafka-aiven-site-checker-drednout-7f62.aivencloud.com:14798", security_protocol="SSL", ssl_cafile="ca.pem", ssl_certfile="service.cert", ss...
code_fim
medium
{ "lang": "python", "repo": "drednout/site_checker", "path": "/src/scripts/kafka_producer.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> while True: key = random.randint(0,10) value = ''.join([random.choice(string.ascii_letters) for _ in range(10)]) if random.choice([0,1]): await dhash.read(key) else: await dhash.write(key, value) if __name__ == '__main__': loop = asyncio.get_event_loop() dhash = ASyncDHash() tasks = [ ...
code_fim
hard
{ "lang": "python", "repo": "lightning-pro/dhash", "path": "/asdhash.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lightning-pro/dhash path: /asdhash.py import asyncio import time import random import string class ASyncDHash(object): def __init__(self): self.nodes = [ASyncNodes('#1'), ASyncNodes('#2')] <|fim_suffix|>class ASyncNodes(object): def __init__(self, name): self.name = name self.storage =...
code_fim
hard
{ "lang": "python", "repo": "lightning-pro/dhash", "path": "/asdhash.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }