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
Random orthogonal weights Used by norm_weights(below), in which case, we are ensuring that the rows are orthogonal (i.e W = U \Sigma V, U has the same of rows, V has the same of cols)
def ortho_weight(ndim): W = numpy.random.randn(ndim, ndim) u, s, v = numpy.linalg.svd(W) return u.astype('float32')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ortho_weight(ndim):\n W = rng_np.randn(ndim, ndim)\n u, _, _ = np.linalg.svd(W)\n return u.astype('float32')", "def orthogonal_weight_tensor(shape):\n if len(shape) == 2 :\n if shape[0] == shape[1] :\n M = rng_np.randn(*shape).astype(np.float32)\n Q, R = np.linalg.qr(...
[ "0.72828364", "0.6974768", "0.68845916", "0.66035664", "0.659437", "0.65169877", "0.64774096", "0.64329475", "0.64217156", "0.6396008", "0.6323675", "0.6312961", "0.6248349", "0.6240783", "0.6206433", "0.6184517", "0.6155063", "0.61467236", "0.6141991", "0.6136662", "0.610007...
0.7145966
1
Random weights drawn from a Gaussian
def norm_weight(nin, nout=None, scale=0.01, ortho=True): if nout is None: nout = nin if nout == nin and ortho: W = ortho_weight(nin) else: W = scale * numpy.random.randn(nin, nout) return W.astype('float32')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_gaussian_random(self):\n u1 = generateRandom()\n u2 = generateRandom()\n if u1 < 1e-6:\n u1 = 1e-6\n return sqrt(-2 * log(u1)) * cos(2 * pi * u2)", "def randomizeWeights(self, rand_distr):\n raise NotImplementedError", "def _random_weight_initialization(se...
[ "0.69253546", "0.6907757", "0.6906672", "0.6900726", "0.6889791", "0.6867258", "0.6847343", "0.6796425", "0.67804855", "0.6768728", "0.67305326", "0.6666161", "0.6633314", "0.66207737", "0.65838647", "0.65782684", "0.655484", "0.65189344", "0.65089655", "0.6487783", "0.647785...
0.0
-1
Builds the entire computational graph used for trainning
def build_model(options,worddicts): opt_ret=dict() params=dict() word_xr1_mask=tf.reverse(word_x1_mask,[1]) word_xr2_mask = tf.reverse(word_x2_mask, [1]) #embedding layer word_embedding = norm_weight(options['n_words'], options['dim_word']) if options['embedding']: with open(optio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_graph(self):\n\t\tself._create_placeholders()\n\t\tself._create_embedding()\n\t\tself._create_recurrent_layers()\n\t\tself._create_de_embedding()\n\t\tself._create_loss()\n\t\tself._create_optimizer()\n\t\tself._create_summaries()", "def build_graph(self):\n self._build_model()\n if self....
[ "0.8359795", "0.8300458", "0.8242923", "0.821802", "0.8132827", "0.8082611", "0.80549866", "0.80473834", "0.8021888", "0.79827213", "0.7915069", "0.7886922", "0.78594065", "0.77312005", "0.77268434", "0.77254844", "0.77219415", "0.76770824", "0.7657952", "0.76496536", "0.7644...
0.0
-1
Connect to a running Quicken. Exits if unable to connect.
def connect(quicken_path: str = QUICKEN_EXE) -> Application: print("Connecting to Quicken", end="") tries = 0 while tries < MAX_TRIES: try: print(".", end="", flush=True) quicken = Application().connect(path=quicken_path) except ProcessNotFoundError: tries...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self) -> None:\n self.terminate()\n self._new_client().connect(\n hostname=self.ip,\n port=self.port,\n username=self.username,\n password=self.password,\n look_for_keys=False,\n allow_agent=False)", "def connect(self):\n...
[ "0.66176707", "0.6467609", "0.63279045", "0.6277428", "0.6249217", "0.6218416", "0.6204633", "0.6191149", "0.6153156", "0.61359715", "0.6128265", "0.61268306", "0.61261153", "0.61195517", "0.6083524", "0.6077736", "0.6041318", "0.6038033", "0.6034769", "0.60110307", "0.600610...
0.75798625
0
Convert a downloaded investment transacton from Bought to BoughtX.
def switch_to_boughtx(window: WindowSpecification, account: str): PAUSE_TIME = .1 window.type_keys("{TAB}") window.type_keys("boughtx") # Tab to transfer field. import time for i in range(7): time.sleep(PAUSE_TIME) window.type_keys("{TAB}") time.sleep(PAUSE_TIME) window...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to(self,Ttyp):\n\t\tself.Ttyp = Ttyp\n\t\t# Set up API query\n\t\tquery = {'a': str(self.amount), 'from': self.typ, 'to': self.Ttyp}\n\t\tr = requests.get('https://www.google.com/finance/converter', params=query)\n\n\t\t# Search HTML for conversion result\n\t\tsearchObj = re.search(r'(?:div id=currency...
[ "0.56667024", "0.50495255", "0.4845267", "0.47580725", "0.47404823", "0.46964607", "0.4660823", "0.4660823", "0.46399745", "0.46127456", "0.45958185", "0.45786473", "0.45572513", "0.45539337", "0.45170918", "0.45087653", "0.44872877", "0.44859233", "0.44562316", "0.4449798", ...
0.44296724
22
Print help for interactive mode.
def print_interact_help(): print("Commands:") print("\tj - up") print("\tk - down") print("\t<Space> - switch Bought to BoughtX") print("\t<Enter> - send Enter to Quicken") print("\t<Escape> - quit")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printhelp():", "def print_help():\n\tprint(\"Help text\")", "def print_help(self):\n print self.get_help()", "def print_help():\n parser = parsersetup()\n parser.print_help()", "def help():\n print \"Help comes to those who ask\"", "def help():\n print(UI.HELP)", "def print_h...
[ "0.828621", "0.8249688", "0.81687295", "0.804865", "0.79219943", "0.78759795", "0.7852676", "0.77997595", "0.7799676", "0.7796095", "0.77595407", "0.76376337", "0.7617434", "0.7551285", "0.75171584", "0.7516465", "0.7511863", "0.7472519", "0.74565256", "0.74167585", "0.741298...
0.75909936
13
Pass select inputs to Quicken.
def interact(qwauto_window, window: WindowSpecification, account: str): print_interact_help() while True: key = getch() if key == bytes("\x1b", "utf-8") or key == bytes("\x03", "utf-8"): return elif key == bytes("j", "utf-8"): window.type_keys("{DOWN}") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select(*args):", "def select(*args):", "def select(self):\r\n pass", "def select(self):\n pass", "def select(self):\n pass", "def _select_datagrams(self, params):", "def __call__(self, waveforms, telid, selected_gain_channel):", "def run_select_examples():\n table = \"acto...
[ "0.6518565", "0.6518565", "0.58254296", "0.57892376", "0.57892376", "0.55605894", "0.5523021", "0.54676974", "0.54561675", "0.5415206", "0.541219", "0.541219", "0.535727", "0.5280271", "0.5219809", "0.5214467", "0.51719767", "0.516225", "0.50569713", "0.5022268", "0.5017095",...
0.0
-1
Parse command line arguments.
def parse() -> Namespace: parser = ArgumentParser() parser.add_argument( "--config", "-c", default="qwauto.cfg", help="Config file. Defaults to qwauto.cfg.", ) return parser.parse_args()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_arguments(args):", "def parse_command_line(self, argv):\n from optparse import OptionParser\n usage = \"usage: %prog [options]\"\n parser = OptionParser(usage)\n\n (options, args) = parser.parse_args(argv)", "def parseArguments(self):\n iterator = iter(sys.argv[1:])...
[ "0.807208", "0.74767", "0.73985106", "0.73932225", "0.73173845", "0.72599804", "0.7232453", "0.7222555", "0.713585", "0.7102058", "0.71020466", "0.7096281", "0.7093058", "0.70890576", "0.7080071", "0.70745754", "0.70641047", "0.70633066", "0.70568484", "0.7051162", "0.7048470...
0.0
-1
Takes a DNA sequence and transforms it into a RNA sequence.
def to_rna(seq): seq=seq.replace('A','U') seq=seq.replace('T','A') seq=seq.replace('C',"P") seq=seq.replace('G','C') seq=seq.replace('P','G') return seq
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_rna(dna):\r\n return dna.translate(str.maketrans('ATGC','UACG'))", "def translate_sequence(rna_sequence, genetic_code):\n #Crate an empty list to store AA sequence:\n AA_list = []\n # Convert all rna_sequence to upper case:\n rna_sequence=rna_sequence.upper()\n # Convert all rna_sequence...
[ "0.7669018", "0.75413525", "0.7380885", "0.7314864", "0.7216778", "0.71945727", "0.71105105", "0.70800424", "0.69325453", "0.6911802", "0.69019145", "0.6812737", "0.67335016", "0.6728875", "0.67027515", "0.66922444", "0.6666653", "0.6590273", "0.6528604", "0.6417373", "0.6373...
0.79545945
0
Returns full filter name using information from name and filter_path provided.
def _get_full_filter_name(name, filter_path): filename = os.path.basename(filter_path) file_only = os.path.splitext(filename)[0] filter_name = "{}.{}".format(file_only, name) return filter_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_filter_name(self):\n pass", "async def get_filter(self, **kwargs: Any) -> str:\n return self._telescope.filter_name", "def name(self) -> StringFilter:\n return self.__name", "def get_exact_filter_by_name(self, name):\n for entry in self.filters:\n if (entry['typ...
[ "0.7273906", "0.6495935", "0.6320404", "0.60196054", "0.5943108", "0.5935446", "0.59197485", "0.5804569", "0.5769412", "0.57038975", "0.56500113", "0.5647518", "0.5580368", "0.55199283", "0.5509952", "0.5478552", "0.54714257", "0.54514235", "0.5424941", "0.5420056", "0.541518...
0.83885926
0
Convert string to datetime object.
def _get_datetime(dt_value): result = None if result is None: result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%M:%S.%f %z") if result is None: result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%M:%S.%f") if result is None: result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def str_to_datetime(str):\n\n\treturn (datetime.strptime(str, \"%Y-%m-%dT%H:%M:%S.%fZ\"))", "def str2date(s):\n return datetime.strptime(s.decode(), \"%Y-%m-%d %H:%M:%S\")", "def str_to_datetime(str):\n if not str:\n return str\n return datetime.datetime.strptime(str.split(\".\")[0], DEFAUL...
[ "0.78559595", "0.7806504", "0.76967424", "0.76847774", "0.7623683", "0.7548493", "0.7525062", "0.7456067", "0.744933", "0.7443482", "0.743952", "0.7422947", "0.73081374", "0.7255298", "0.72483724", "0.7230942", "0.72260016", "0.722573", "0.7221167", "0.72035706", "0.71921664"...
0.0
-1
Convert value provided into datetime object or None if not successful. The purpose of this method is to attempt to convert the value provided using the datetime format string also provided into a datetime object. If the value provided doesn't correspond to the datetime format provided then the datetime strptime method ...
def _get_datetime_from_format(dt_value, dt_format): result = None try: result = datetime.datetime.strptime(dt_value, dt_format) except ValueError: pass return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_datetime(datetime_str: Text) -> datetime.datetime:\n for str_format in cfg.datetime_str_formats:\n try:\n datetime_object = datetime.datetime.strptime(datetime_str, str_format)\n return datetime_object\n except ValueError:\n continue", "def try_strptime...
[ "0.6947664", "0.6938862", "0.6867406", "0.66824174", "0.66588503", "0.66575724", "0.66326183", "0.65770185", "0.65647686", "0.6552498", "0.65447265", "0.64434665", "0.6437222", "0.64192605", "0.63708764", "0.633034", "0.6298367", "0.62121534", "0.6170873", "0.61637217", "0.61...
0.74563617
0
Returns event data matching the event label specified or None.
def _get_last_event(device_event_file_path, event_label, timeout=1.0): result = None timedout = False file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path, timeout) if not file_exists: timedout = True return result, timedou...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _getData(self, label):\n\n try:\n return self._data[label]\n except KeyError:\n try:\n field = ATOMIC_FIELDS[label]\n except KeyError:\n return None\n else:\n return getattr(self, '_get' + field.meth_pl)()", ...
[ "0.6986888", "0.6744777", "0.6611872", "0.6522634", "0.6315734", "0.6216993", "0.6191255", "0.5773424", "0.57695127", "0.57607955", "0.5585442", "0.55435276", "0.55417466", "0.54313314", "0.54313314", "0.5372679", "0.535484", "0.53264093", "0.5309692", "0.5295486", "0.5274525...
0.51357186
32
Returns list of event data history matching event_labels provided.
def _get_events_from_json_output(json_events, event_labels=None): result = [] for json_object in json_events: if json_object: try: event_dict = json.loads(json_object) except ValueError as err: logger.info( "Failed to parse event log line; skipping. Err: {!r}".format(err)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_history(self, event_labels=None, count=None, timeout=10.0):\n if event_labels:\n self.verify_event_labels(\n event_labels,\n error_message=\"{} get_event_history failed.\".format(\n self._device_name))\n timedout = False\n try:\n if count:\n hi...
[ "0.694545", "0.69158", "0.61652684", "0.6104302", "0.6035385", "0.5999904", "0.58629555", "0.57623726", "0.56984925", "0.5656778", "0.5638675", "0.5638675", "0.558742", "0.55852455", "0.55213106", "0.5489068", "0.5484949", "0.5478935", "0.54677135", "0.5459749", "0.545879", ...
0.59801936
6
Returns list of event history matching event labels specified.
def _get_all_event_history(device_event_file_path, event_labels, timeout=10.0): result = [] timedout = False file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path, timeout) if not file_exists: timedout = True return result, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_history(self, event_labels=None, count=None, timeout=10.0):\n if event_labels:\n self.verify_event_labels(\n event_labels,\n error_message=\"{} get_event_history failed.\".format(\n self._device_name))\n timedout = False\n try:\n if count:\n hi...
[ "0.6621818", "0.6082841", "0.6029266", "0.59327793", "0.5852928", "0.57673913", "0.5739131", "0.5739131", "0.56805325", "0.5663487", "0.5648216", "0.56215566", "0.56196284", "0.56168085", "0.5608801", "0.55719745", "0.5566846", "0.5565052", "0.554374", "0.5525908", "0.5512215...
0.64784175
1
Returns count of event history matching event label specified.
def _get_event_history_count(device_event_file_path, event_label, timeout=10.0): result = 0 timedout = False file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path, timeout) if not file_exists: timedout = True return result, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_history_count(self, event_label, timeout=10.0):\n\n self.verify_event_labels(\n [event_label],\n error_message=\"%s get_event_history_count failed.\" % self._device_name)\n\n try:\n count, timedout = _get_event_history_count(\n self.event_file_path, event_label, time...
[ "0.7249028", "0.6927206", "0.6022322", "0.5747557", "0.57219446", "0.5649946", "0.5648868", "0.5637877", "0.56110364", "0.55659515", "0.5556555", "0.5548814", "0.55457515", "0.5541466", "0.54923534", "0.54807", "0.547581", "0.5464675", "0.5451758", "0.54230654", "0.5416428", ...
0.6786222
2
Returns list of event history matching event labels specified.
def _get_limited_event_history(device_event_file_path, event_labels, limit, timeout=10.0): result = [] timedout = False file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_history(self, event_labels=None, count=None, timeout=10.0):\n if event_labels:\n self.verify_event_labels(\n event_labels,\n error_message=\"{} get_event_history failed.\".format(\n self._device_name))\n timedout = False\n try:\n if count:\n hi...
[ "0.6621429", "0.64784956", "0.60835177", "0.60297257", "0.5932725", "0.5853597", "0.5767491", "0.5739707", "0.5739707", "0.5680975", "0.566357", "0.5648749", "0.56219274", "0.5620122", "0.5609168", "0.55721635", "0.55673176", "0.5565304", "0.5544214", "0.5526404", "0.5512362"...
0.56169987
14
Wait up to the timeout period for the event file to be created.
def _wait_for_event_file(event_file_path, timeout): start_time = time.time() end_time = start_time + timeout while True: timeout_remaining = end_time - time.time() if timeout_remaining <= 0: return (False, 0) elif os.path.exists(event_file_path): return (True, timeout_remaining) else...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def heartbeat(self):\n timeout_at = time.time() + self.timeout\n\n try:\n os.utime(self.filename, (timeout_at, timeout_at))\n\n except OSError as err:\n if err.errno == errno.ENOENT:\n _LOGGER.warning('Lost lease file: %r', self.file...
[ "0.608407", "0.5938035", "0.5922863", "0.5837459", "0.5825981", "0.57994986", "0.57297707", "0.571166", "0.5705782", "0.5664646", "0.5608379", "0.56036955", "0.5554165", "0.5551678", "0.55417126", "0.5517896", "0.54916334", "0.5488666", "0.5487971", "0.5443709", "0.54428506",...
0.71993464
0
Initializes the log event parser.
def __init__(self, filters, event_file_path, device_name): super().__init__(device_name=device_name) self._filters_dict = {} self.event_file_path = event_file_path self.load_filters(filters)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\r\n super(LogParser, self).__init__([CmdQueryHandler(),\r\n UpdateQueryHandler(),\r\n StandardQueryHandler(),\r\n TimeLineHandler()])", "def _init():\n global logg...
[ "0.72418875", "0.64059067", "0.63440645", "0.6343518", "0.6340042", "0.62899333", "0.62823147", "0.62781703", "0.62678313", "0.626728", "0.62312514", "0.62240434", "0.61479896", "0.61318773", "0.60906297", "0.608568", "0.60841614", "0.6065981", "0.60550433", "0.60322374", "0....
0.0
-1
r"""Returns up to count elements of event data matching given list of event labels.
def get_event_history(self, event_labels=None, count=None, timeout=10.0): if event_labels: self.verify_event_labels( event_labels, error_message="{} get_event_history failed.".format( self._device_name)) timedout = False try: if count: history_results, t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _count_level_events(count_list):\r\n if not len(count_list):\r\n return 0, 0, None\r\n number_events = 0\r\n number_multiple = 0\r\n max_multiple = count_list[0]\r\n for index, count in enumerate(count_list):\r\n if count_list[index] > 0:\r\n ...
[ "0.61019707", "0.59583163", "0.58984214", "0.5834445", "0.581567", "0.57963496", "0.5795657", "0.57817817", "0.57711196", "0.5687446", "0.5591363", "0.5493502", "0.54926115", "0.5460798", "0.545492", "0.54505557", "0.5433916", "0.54291666", "0.540299", "0.5402683", "0.5393978...
0.0
-1
Returns count of event history matching event label specified.
def get_event_history_count(self, event_label, timeout=10.0): self.verify_event_labels( [event_label], error_message="%s get_event_history_count failed." % self._device_name) try: count, timedout = _get_event_history_count( self.event_file_path, event_label, timeout=timeout) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_count_by_label(self, label=None):\n if label is None:\n return len(self.data)\n else:\n return sum(1 for d in self.data if d.pred == label)", "def _get_event_history_count(device_event_file_path, event_label, timeout=10.0):\n result = 0\n timedout = False\n\n file_e...
[ "0.6927206", "0.6786222", "0.6022322", "0.5747557", "0.57219446", "0.5649946", "0.5648868", "0.5637877", "0.56110364", "0.55659515", "0.5556555", "0.5548814", "0.55457515", "0.5541466", "0.54923534", "0.54807", "0.547581", "0.5464675", "0.5451758", "0.54230654", "0.5416428", ...
0.7249028
0
Takes an event label pattern, and returns a dictionary of matching event labels.
def get_event_label_dict(self, pattern=None): if pattern is None: return {key: value.pattern for key, value in self._filters_dict.items()} else: try: result_dict = {} regex = re.compile(pattern) for event_label in list(filter(regex.match, list(self._filters_dict))): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_labels(self, pattern=None):\n\n if pattern is None:\n return list(self._filters_dict.keys())\n else:\n try:\n regex = re.compile(pattern)\n return list(filter(regex.match, list(self._filters_dict.keys())))\n except Exception as err:\n raise errors.ParserError...
[ "0.705301", "0.5967765", "0.56136435", "0.54736334", "0.5449883", "0.5353754", "0.53004324", "0.5285208", "0.522042", "0.5197204", "0.50947785", "0.5073371", "0.49641836", "0.49383032", "0.4924246", "0.491624", "0.49161154", "0.4893664", "0.4855615", "0.48546898", "0.481552",...
0.8060473
0
Takes an event label pattern, and returns a list of matching event labels.
def get_event_labels(self, pattern=None): if pattern is None: return list(self._filters_dict.keys()) else: try: regex = re.compile(pattern) return list(filter(regex.match, list(self._filters_dict.keys()))) except Exception as err: raise errors.ParserError( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_event_label_dict(self, pattern=None):\n\n if pattern is None:\n return {key: value.pattern for key, value in self._filters_dict.items()}\n else:\n try:\n result_dict = {}\n regex = re.compile(pattern)\n for event_label in list(filter(regex.match, list(self._filters_dict...
[ "0.62472373", "0.5896674", "0.5756939", "0.56767726", "0.56703365", "0.5641349", "0.5620617", "0.5609375", "0.55089414", "0.5484202", "0.53388613", "0.53148586", "0.5300112", "0.52978414", "0.5287111", "0.52725494", "0.5258854", "0.52532655", "0.523032", "0.52248114", "0.5203...
0.8007184
0
r"""Returns the most recent matching event for each item in the list of event labels.
def get_last_event(self, event_labels=None, timeout=1.0): if event_labels is None: event_labels = [None] else: self.verify_event_labels( event_labels, error_message="%s get_last_event failed." % self._device_name) results = [] any_timed_out = False try: for ev...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_event_labels(event_list):\n\n if isinstance(event_list, dcase_util.containers.MetaDataContainer):\n return event_list.unique_event_labels\n\n else:\n labels = []\n for event in event_list:\n if 'event_label' in event and event['event_label'] not in labels:\n ...
[ "0.60390705", "0.5920253", "0.5658713", "0.56303453", "0.55317956", "0.53718317", "0.5366211", "0.534492", "0.5342187", "0.5305846", "0.5221964", "0.5214762", "0.51907045", "0.51822054", "0.5040197", "0.50265944", "0.50078565", "0.500767", "0.50071764", "0.5002304", "0.49976"...
0.5869022
2
r"""Return the matching group of the event label regex if one is found.
def get_last_event_state(self, event_label, event_name=None, raise_error=False, timeout=1.0, group_index=0): if not event_name: event_name = event_label result = self.get_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group(self, group_num):\n if self.rematch is None:\n return None\n else:\n return self.rematch.group(group_num)", "def _reg_catch(reg_ex, text, group_id=1):\n\n\tmatch = re.search(reg_ex, text)\n\tif match:\n\t\treturn match.group(group_id)\n\telse:\n\t\treturn None", "d...
[ "0.6243117", "0.60847455", "0.6034069", "0.60160875", "0.5840702", "0.5764992", "0.56929356", "0.56208205", "0.5490368", "0.5478569", "0.5462098", "0.5397177", "0.53950393", "0.53933126", "0.53859985", "0.5336552", "0.5291058", "0.52490413", "0.5186651", "0.5180022", "0.51639...
0.5116134
27
Device's event file is used to identify unmatched reboot events.
def get_unexpected_reboots(self): _, remaining_bootups = self.get_unmatched_events( event_cause_label="basic.reboot_trigger", event_effect_label="basic.bootup") return remaining_bootups
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_events_split(self):\n command = \\\n '{0} -g --min-length 0'.format(\n os.path.join(self.datadir, 'monol_testB.evt'))\n hen.read_events.main(command.split())\n new_filename = os.path.join(self.datadir,\n 'monol_testB_nu...
[ "0.5753642", "0.54424083", "0.5393087", "0.5320064", "0.5308535", "0.5210652", "0.51933116", "0.51693404", "0.51566905", "0.51518387", "0.51013607", "0.50530034", "0.50432056", "0.50353235", "0.5020813", "0.5017145", "0.50081027", "0.49828738", "0.49710074", "0.49652424", "0....
0.5340216
3
Device's event file is used to identify unmatched events.
def get_unmatched_events(self, event_cause_label="basic.reboot_trigger", event_effect_label="basic.bootup"): event_cause_list = [] # Cause events matching event_cause_label event_match_list = [ ] # EventMatch objects holding events matched together bas...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_load_events_split(self):\n command = \\\n '{0} -g --min-length 0'.format(\n os.path.join(self.datadir, 'monol_testB.evt'))\n hen.read_events.main(command.split())\n new_filename = os.path.join(self.datadir,\n 'monol_testB_nu...
[ "0.623223", "0.6196645", "0.6019667", "0.5771392", "0.5714897", "0.56999695", "0.5675953", "0.5658694", "0.5624671", "0.5622697", "0.56063", "0.5586675", "0.55478656", "0.55121064", "0.54880583", "0.5487537", "0.547829", "0.5458272", "0.54574615", "0.54206586", "0.5417131", ...
0.0
-1
Load JSON filter file specified.
def load_filter_file(self, filter_path): logger.debug("Adding filter file {}", filter_path) try: with open(filter_path, "r") as filter_file: try: json_filter_data = json.load(filter_file) except Exception as err: msg = "Unable to parse filter file {} as a json file. {!r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_filter_directory(self, filter_path):\n try:\n logger.debug(\"Adding filters from directory {}\", filter_path)\n for filter_file in os.listdir(filter_path):\n if filter_file.endswith(\".json\"):\n filter_file_path = os.path.join(filter_path, filter_file)\n self.load_f...
[ "0.6793281", "0.66293055", "0.6573929", "0.63865566", "0.63719606", "0.6308072", "0.62924355", "0.6278985", "0.62667835", "0.61862415", "0.6185541", "0.61825424", "0.61428314", "0.6138989", "0.61013216", "0.6093863", "0.60882455", "0.60664535", "0.6053399", "0.60379034", "0.6...
0.7409831
0
Parser line against filters and write JSON result to event_file provided.
def process_line(self, event_file, raw_log_line, header_length=29, log_filename=""): event_data = {} for filter_name, regex in self._filters_dict.items(): match = regex.search(raw_log_line) if match: match_data = ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_filter_spec(filters, filename):\n data = export_filters(filters)\n with open(filename, 'w') as fp:\n json.dump(data, fp, indent = 4)", "def filter_json_file(filename, filters_list):\n filename = filename.replace(\" \", \"\")\n print(\"Filters List {}\".format(filters_list))\n if i...
[ "0.61318433", "0.59134746", "0.5879075", "0.5599995", "0.5580844", "0.5461981", "0.54279864", "0.5343064", "0.5231513", "0.52051693", "0.51518404", "0.51461333", "0.51446676", "0.51235896", "0.506409", "0.50508374", "0.5050683", "0.5035986", "0.5034059", "0.5006907", "0.49897...
0.70475507
0
Verifies event_labels in correct format and exist.
def verify_event_labels(self, event_labels, error_message=""): if event_labels is not None and not isinstance(event_labels, list): raise errors.ParserError("{} Expecting event_labels to be a list " "or None but received {} instead.".format( err...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_validity_label(labels):\n # Event is None -> All other values are None\n if labels[3] == 0:\n for i in xrange(5):\n if labels[i] != 0:\n return False\n return True\n \n # If two roles have the same object return False\n for i in xrange(3):\n f...
[ "0.6702047", "0.64607334", "0.63460994", "0.6305003", "0.6098443", "0.60897875", "0.6071821", "0.59971875", "0.5907106", "0.58770484", "0.5840349", "0.5821878", "0.58109576", "0.58091444", "0.58057487", "0.57937926", "0.57756233", "0.57385564", "0.5728577", "0.5722915", "0.57...
0.78669137
0
Waits up to timeout seconds for event labels to appear in device logs.
def wait_for_event_labels(self, event_labels, raise_error=False, timeout=20.0, start_datetime=None): self.verify_event_labels( event_labels, error_message="{} wait_for_event_labels failed....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wait_for_event_timeout(event):\n received = event.wait(2)\n name = threading.current_thread().getName()\n print \"Waited with timeout, got {}, name {}\".format(received, name)", "def listen(self, timeout=2):\n start = time.monotonic()\n while (time.monotonic()-start) < timeout:\n ...
[ "0.6301212", "0.585833", "0.5724939", "0.56652474", "0.55515707", "0.5549659", "0.5532575", "0.54798186", "0.5474939", "0.54436684", "0.53312016", "0.5307921", "0.5296047", "0.5280927", "0.527302", "0.52095646", "0.5194303", "0.51938176", "0.5153732", "0.51507413", "0.514181"...
0.69714695
0
Adds filter dictionary expression from filter_path specified.
def _add_filter(self, filter_list, filter_path): if "name" not in filter_list: raise errors.ParserError( "Loading filter-file {} failed. " "Missing 'name' key in filter object '{!r}'.".format( filter_path, filter_list)) if "regex_match" not in filter_list: raise err...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_filter(self, filter):\n self._filters.append(filter.as_dict())", "def add_filter(self, name: str, value: any):\n self.filters[name] = value", "def _add_filters(self, filter_list, filter_path):\n if not isinstance(filter_list, list):\n raise errors.ParserError(\n \"Loading...
[ "0.6170425", "0.6151738", "0.59039634", "0.5895332", "0.58122355", "0.56957275", "0.56685686", "0.554609", "0.5538691", "0.55265987", "0.5505833", "0.5505171", "0.5495749", "0.54955846", "0.5494427", "0.54883003", "0.5422577", "0.53739333", "0.5323809", "0.51964414", "0.51853...
0.67896575
0
Adds filters loaded from file_name to list of filters to use.
def _add_filters(self, filter_list, filter_path): if not isinstance(filter_list, list): raise errors.ParserError( "Loading filter-file {} failed. " "Expecting value of 'filter_list' entry to be a list " "but instead its a {}.".format(filter_path, type(filter_list))) for cur_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_filters(self, names, interp=True, lamb=None, filterLib=None):\n with self as s:\n filters = [s._load_filter(fname, interp=interp, lamb=lamb)\n for fname in names]\n return(filters)", "def load_filters(self, names, interp=True, lamb=None, filterLib=None):\n ...
[ "0.6986275", "0.6970435", "0.6918564", "0.6674499", "0.65343827", "0.65334064", "0.65036386", "0.630778", "0.6270512", "0.61921537", "0.6088287", "0.60821855", "0.60370624", "0.59813523", "0.59784156", "0.59227353", "0.5910277", "0.59046036", "0.59046036", "0.59046036", "0.58...
0.7120908
0
Loads every .json file found in filter_path specified.
def _load_filter_directory(self, filter_path): try: logger.debug("Adding filters from directory {}", filter_path) for filter_file in os.listdir(filter_path): if filter_file.endswith(".json"): filter_file_path = os.path.join(filter_path, filter_file) self.load_filter_file(filt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_json_files(self, filter_fn=None):\n def filter_function(f):\n return f is not None and f.endswith(\".json\")\n if not filter_fn:\n filter_fn = filter_function\n files = self.filter_files(None,filter_fn)\n dicts = []\n for f in files:\n w...
[ "0.73628515", "0.6963622", "0.6615014", "0.6268389", "0.6248232", "0.62429833", "0.6187038", "0.617747", "0.6000327", "0.59399736", "0.58981717", "0.5885145", "0.5863954", "0.58593535", "0.58425856", "0.5793319", "0.5789873", "0.57630044", "0.571526", "0.57100266", "0.5706684...
0.7727016
0
Load JSON filter files or directories specified.
def load_filters(self, filters): if not filters: return if not isinstance(filters, list): raise errors.ParserError("Expecting 'filters' value to be a list " "but instead its a {}.".format(type(filters))) for filter_path in filters: if not os.path.exists(filte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_filter_directory(self, filter_path):\n try:\n logger.debug(\"Adding filters from directory {}\", filter_path)\n for filter_file in os.listdir(filter_path):\n if filter_file.endswith(\".json\"):\n filter_file_path = os.path.join(filter_path, filter_file)\n self.load_f...
[ "0.75228626", "0.7294747", "0.6376279", "0.6365132", "0.6188679", "0.61364406", "0.60583746", "0.6027795", "0.5960382", "0.59213805", "0.59065545", "0.59002966", "0.5861516", "0.58332425", "0.58193207", "0.5805523", "0.57714075", "0.57449955", "0.5655958", "0.564419", "0.5624...
0.65141755
2
Locates a datetime.datetime closest to target datetime.
def _nearest_datetime(self, datetime_list, target_datetime): if not datetime_list: raise errors.ParserError( "Input parameter datetime_list length is zero. Required" " parameters: [datetime.datetime], datetime.datetime") work_list = [entry for entry in datetime_list if entry < target_d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _closest_date(target_dt, date_list, before_target=None) -> datetime.date | None:\n\n def time_before(d):\n return target_dt - d if d <= target_dt else datetime.timedelta.max\n\n def time_after(d):\n return d - target_dt if d >= target_dt else datetime.timedelta.max\n\n def any_time(d):\n...
[ "0.6702089", "0.6500694", "0.64598507", "0.585127", "0.57860357", "0.56574386", "0.5651094", "0.56321347", "0.56310844", "0.55818236", "0.5565437", "0.554823", "0.54743797", "0.5420503", "0.5417901", "0.526718", "0.52564967", "0.52448344", "0.52256316", "0.5214709", "0.519476...
0.7585258
0
Ask a yes/no question via raw_input() and return their answer. "question" is a string that is presented to the user. "default" is the presumed answer if the user just hits . It must be "yes" (the default), "no" or None (meaning an answer is required of the user). The "answer" return value is one of "yes" or "no".
def query_yes_no(question, default="yes"): valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False} if default is None: prompt = " [y/n] " elif default == "yes": prompt = " [Y/n] " elif default == "no": prompt = " [y/N] " else: raise ValueErr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_yes_no(question, default=\"yes\"):\n valid = {\"yes\":\"yes\", \"y\":\"yes\", \"ye\":\"yes\",\n \"no\":\"no\", \"n\":\"no\"}\n if default == None:\n prompt = \" [y/n] \"\n elif default == \"yes\":\n prompt = \" [Y/n] \"\n elif default == \"no\":\n promp...
[ "0.85728776", "0.85720545", "0.8546383", "0.85399234", "0.8515463", "0.8507957", "0.85060245", "0.85055596", "0.8505435", "0.8505435", "0.8505435", "0.8505435", "0.8505435", "0.85020584", "0.8500583", "0.8498423", "0.8496705", "0.8496254", "0.8496254", "0.8489677", "0.8488822...
0.8503884
19
Helper function used to make symlinks. Will delete existing folder/file/folder tree in the destination location
def make_symlink(dst, src, silently_move=False): dst_dir = os.path.dirname(dst.rstrip(os.path.sep)) if not os.path.isdir(dst_dir): os.makedirs(dst_dir) # get a temporary directory if os.path.exists(dst): if silently_move or (((os.path.isfile(dst) or (os.path.isdir(dst)) and ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_symlinks(target_dir: os.PathLike, symlinks_to_create: List[os.PathLike]):\n for src_path in symlinks_to_create:\n trg_path = os.path.join(target_dir, os.path.basename(src_path))\n\n if os.path.islink(src_path):\n # Let's not create symlinks to symlinks\n # Since dr...
[ "0.6967626", "0.6624714", "0.6522659", "0.6467656", "0.63707364", "0.63626695", "0.6314641", "0.6309487", "0.62151253", "0.62142515", "0.6165706", "0.6114075", "0.6099955", "0.6079026", "0.6061869", "0.60418844", "0.60241526", "0.5999441", "0.5954477", "0.5945246", "0.5912213...
0.5949081
19
Function that creates wiki pages from a template by looking at teams that are registered for a challenge. The teams that have a wiki made for them Are stored into a trackerTable that has columns wikiSynId, and teamId
def create_team_wikis(syn, synid, templateid, tracker_table_synid): challenge_ent = syn.get(synid) challenge_obj = utils.get_challenge(challenge_ent) registered_teams = syn._GET_paginated( "/challenge/{}/challengeTeam".format(challenge_obj['id'])) for i in registered_teams: submitted_te...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def team_wiki_index_page(request):\n if isinstance(request.group, Team):\n # Find wiki index.\n try:\n page = request.group.content_objects(WikiPage).get(slug=DEFAULT_INDEX)\n except WikiPage.DoesNotExist:\n page = None\n return {\n 'team_wiki_index_p...
[ "0.59659106", "0.5459703", "0.5446284", "0.5292902", "0.5168371", "0.51078725", "0.5103085", "0.5090617", "0.5079518", "0.507277", "0.50709975", "0.5061508", "0.505984", "0.5059186", "0.50466794", "0.50433093", "0.5030929", "0.50159186", "0.4994493", "0.49905354", "0.49869752...
0.8026079
0
Archive the submissions for the given evaluation queue and store them in the destination synapse folder.
def archive_writeup(syn, evaluation, stat="VALIDATED", reArchive=False): if type(evaluation) != synapseclient.Evaluation: evaluation = syn.getEvaluation(evaluation) print("\n\nArchiving", evaluation.id, evaluation.name) print("-" * 60) for sub, status in syn.getSubmissionBundles(evaluation, st...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def store(self, results):\n filename = self.get_archive_file_path(results)\n results.dump(filename)", "def _archive(self,pools=['backup','archive'],verbose=True,dry_run=False):\n\t\tif type(pools) is not list:\n\t\t\tpools = [pools]\n\n\t\t_start = datetime.today()\n\t\tself.archive_bytes = 0\n\t\t...
[ "0.5692195", "0.56353605", "0.5609163", "0.5514673", "0.5481283", "0.546587", "0.5450681", "0.54277956", "0.5391405", "0.5389693", "0.5242145", "0.5174583", "0.5116506", "0.5114481", "0.5114352", "0.51136255", "0.51075226", "0.5086116", "0.50756234", "0.50755244", "0.50661904...
0.6239523
0
Return the API server status. Return "Alive!" if this API server is online.
def get(self): # Return a plain text response return self.plain_text_response("Alive!", 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_status(self):\n if self.status:\n print(f\"Server '{self.server_name}' is online\")\n else:\n print(f\"Server '{self.server_name}' is offline\")", "def server_status(self):\n return self._server_status", "def server_status(self, timeout=None):\n return ...
[ "0.7915326", "0.74814963", "0.7172331", "0.71697026", "0.7054023", "0.70453274", "0.7006416", "0.6952428", "0.69252586", "0.68447316", "0.68376654", "0.68072945", "0.67782044", "0.6771794", "0.6770531", "0.67591166", "0.6724188", "0.67120594", "0.67039037", "0.6622279", "0.66...
0.0
-1
This function verifies that the core connection information (Base URL and API credentials) has been defined.
def verify_core_connection(): if not base_url or not api_credentials: retrieve_connection_info() return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def check_config(self) -> None:\n try:\n await self._check_api()\n except aiohttp.ClientError as e:\n raise ConnectionError(str(e))", "def _check_settings(self):\n if self.api_key is None:\n raise ImproperlyConfigured(\"You must provide an API key.\")",...
[ "0.7091963", "0.691162", "0.6798902", "0.6735169", "0.6727152", "0.6715415", "0.6694974", "0.65938854", "0.6511822", "0.64764845", "0.64648366", "0.64648366", "0.6392897", "0.6391157", "0.63395435", "0.6293454", "0.6261399", "0.6242068", "0.6227387", "0.6191004", "0.61778796"...
0.87422466
1
This function initializes and defines the global variables for the connection information.
def retrieve_connection_info(): # Define the global variables at this module level global base_url global api_credentials base_url, api_credentials = core.get_connection_info() return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n\n\t\tself.connection = self.get_connection()", "def init_connection(self, connection):", "def initialize():\n\t\tDBHelper.con = mdb.connect('localhost', 'root', 'sensepass', 'sensecambrowser')", "def __init__(self):\n self.connections = {}", "def initialize(self):\n if n...
[ "0.7339458", "0.71884817", "0.69318736", "0.68917626", "0.6795007", "0.6791531", "0.6775468", "0.67656016", "0.6697627", "0.66974974", "0.6696093", "0.6673183", "0.6663659", "0.6634123", "0.663047", "0.662494", "0.65886277", "0.6583204", "0.6544304", "0.6533463", "0.65145475"...
0.6480596
24
This function retrieves a value for a specific field from the JSON data for a user.
def get_json_field(json_data, field_names): field_value = None if isinstance(field_names, str): field_value = json_data.get(field_names) elif isinstance(field_names, tuple) or isinstance(field_names, list): if len(field_names) == 2: field_one, field_two = field_names ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username(self):\n return json_loads(self.user_json).get('username')", "def _getValue(self, field):\n if self._contents.has_key(field):\n return self._contents[field]\n else:\n return None", "def user_id(self):\n return json_loads(self.user_json).get('id')", "def ...
[ "0.639812", "0.6305945", "0.62547666", "0.6247458", "0.62376595", "0.6212003", "0.6189185", "0.61481035", "0.60158163", "0.59962857", "0.598345", "0.5971689", "0.59642", "0.59490067", "0.59454596", "0.59374005", "0.5929378", "0.59204847", "0.5918454", "0.59127593", "0.5897378...
0.6090247
8
This function populates a dictionary with the user information retrieved from the API response.
def parse_user_fields(json_data): # Populate the fields user_info = {} for db_field, json_field in Users.UserJSON.fields.items(): try: user_info[db_field] = get_json_field(json_data, json_field) if db_field == 'user_address_street': user_info[db_field] = user_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_details(self, response):\n fullname, first_name, last_name = self.get_user_names(\n response.get(\"fullName\"),\n response.get(\"firstName\"),\n response.get(\"lastName\"),\n )\n return {\n \"username\": response.get(\"username\"),\n ...
[ "0.75237215", "0.731564", "0.73052174", "0.7186673", "0.7064081", "0.7058256", "0.7032413", "0.7027056", "0.69960225", "0.6938776", "0.6933388", "0.6848777", "0.6825046", "0.6807867", "0.6727831", "0.6707013", "0.6707013", "0.6672453", "0.6665079", "0.6633706", "0.660671", ...
0.5837845
95
This function obtains the User ID for a user by querying the API against the user's email address or username.
def get_user_id(lookup_value, lookup_type='email'): lookup_type = _validate_lookup_type(lookup_type) if '@' not in lookup_value: exception_msg = f"The lookup type is 'email' but '{lookup_value}' is not a valid email address." raise errors.exceptions.LookupMismatchError(exception_msg) user_da...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user(self, user_id):\n uri = 'users/' + user_id\n return self.make_request(uri)", "def get_user_id(self, name):\n if '@' in name:\n params = {\n 'method': 'flickr.people.findByEmail',\n 'find_email': name\n }\n else:\n par...
[ "0.7441939", "0.74166447", "0.7410997", "0.7257471", "0.72548115", "0.72228175", "0.7203332", "0.7200153", "0.71400255", "0.7136", "0.71150976", "0.71053267", "0.71034515", "0.70817196", "0.70784605", "0.70483553", "0.70483553", "0.70483553", "0.7043418", "0.7042949", "0.7037...
0.6876447
49
This function validates a lookup type to ensure that it is acceptable to the primary function call.
def _validate_lookup_type(_lookup_type, _retrieval_value='id'): _accepted_lookup_values = { 'id': ('email', 'username'), 'username': ('id', 'email'), 'email': ('id', 'username') } if _retrieval_value == "id": if _lookup_type not in _accepted_lookup_values.get(_retrieval_value...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CheckType(self, *args, **kwargs):\n pass", "def validate(t):\n return _dispatcher[type(t)](t)", "def _validate_type(self, key, type_):\n if type_ is None:\n type_ = \"\"\n \n if not isinstance(type_, (str, unicode)):\n raise TypeError(\"FileLink.type sho...
[ "0.6280784", "0.60769475", "0.60204196", "0.5949436", "0.5938662", "0.5920147", "0.5846806", "0.58452845", "0.5788779", "0.57818824", "0.577826", "0.57727426", "0.57689863", "0.57664907", "0.57622844", "0.5745901", "0.5737489", "0.5723846", "0.5698527", "0.5692912", "0.56907"...
0.7827961
0
This function obtains the primary email address for a user by looking up their User ID or username.
def get_primary_email(lookup_value, lookup_type="id"): lookup_type = _validate_lookup_type(lookup_type, 'email') user_data = core.get_data('people', lookup_value, lookup_type, return_json=True) primary_email = user_data['emails'][0]['value'] return primary_email
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_email_address(user_id: UserID) -> str:\n email_address = db.session \\\n .query(DbUser.email_address) \\\n .filter_by(id=user_id) \\\n .scalar()\n\n if email_address is None:\n raise ValueError(\n f\"Unknown user ID '{user_id}' or user has no email address\"\n ...
[ "0.77690506", "0.77565724", "0.76010233", "0.7498759", "0.7349504", "0.7336229", "0.72988003", "0.72099537", "0.7158339", "0.70910954", "0.7052061", "0.7027128", "0.69666564", "0.69346976", "0.69088876", "0.6837055", "0.6816422", "0.6793141", "0.67788017", "0.67773724", "0.67...
0.77739346
0
This function obtains the username for a user by looking up their User ID or email address.
def get_username(lookup_value, lookup_type="id"): lookup_type = _validate_lookup_type(lookup_type, 'username') user_data = core.get_data('people', lookup_value, lookup_type, return_json=True) username = user_data['jive']['username'] return username
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_username(user_id):\n username = select(u.username for u in UserInformationData if u.user_id == user_id).first()\n\n return username", "def get_username(self):\n if not self.is_valid():\n return None\n try:\n # NOTE: all emails stored in lower-case\n e...
[ "0.8161617", "0.7873838", "0.7810039", "0.77785224", "0.77628773", "0.77615076", "0.7744752", "0.76252383", "0.7569991", "0.7569044", "0.7556496", "0.75094366", "0.74189776", "0.7349395", "0.7343433", "0.7337727", "0.72996664", "0.72889817", "0.72484714", "0.7235415", "0.7233...
0.7706719
7
This function constructs the URL to a user's profile.
def get_profile_url(lookup_value, lookup_type="id"): if lookup_type == "username": username = lookup_value else: username = get_username(lookup_value, lookup_type) profile_url = f"{base_url}/people/{username}" return profile_url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile_url(self):\n return reverse(\"auth_profile\", args=[self.user.username])", "def get_absolute_url(self):\n return '/profile/%s' % self.id", "def get_absolute_url(self):\n\n return reverse('profile', args=[str(self.user.username)])", "def get_absolute_url(self):\n return...
[ "0.8227132", "0.7430972", "0.71914357", "0.6894003", "0.6826512", "0.6684108", "0.6663101", "0.6608801", "0.6577758", "0.6514719", "0.6459156", "0.64151084", "0.6401612", "0.63838965", "0.63838965", "0.63838965", "0.6374063", "0.6371142", "0.6349622", "0.6319628", "0.6292984"...
0.7533327
1
This function identifies the content count for an individual REST API call.
def _get_paginated_content_count(_user_uri, _start_index, _count=100): _content_uri = f"{base_url}/contents?filter=author({_user_uri})&count={_count}&startIndex={_start_index}" _response = core.get_request_with_retries(_content_uri) if _response.status_code == 200: _response_json = _response.json() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self):\r\n url = '{0}/{1}'.format(self.get_url(), 'count')\r\n\r\n return http.Request('GET', url), parsers.parse_json", "def get_resource_count(har_json):\n entries = har_json['log']['entries']\n\n resource_type_counts = Counter()\n\n for entry in entries:\n resource = en...
[ "0.68372214", "0.6524679", "0.6381083", "0.634387", "0.6243201", "0.6172337", "0.61580133", "0.6127514", "0.6106211", "0.6097753", "0.6074798", "0.6067487", "0.60662615", "0.60662615", "0.60662615", "0.60662615", "0.6049658", "0.60130095", "0.6008954", "0.6006984", "0.5984527...
0.67813146
1
This function obtains the number of content items created by a particular user.
def get_user_content_count(user_id, start_index=0): # Define the variable to track the total content count and structure the user URI total_count = 0 user_uri = f"{base_url}/people/{user_id}" # Get the content count for the first 100 results and increment the total count accordingly content_count =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_usage_count(request, user_id):\n board_count = Member.objects.filter(user_id=user_id, is_creator=True).count()\n return Response({\"board_count\": board_count})", "def get_total_items(self, user: User, transforms: Optional[List[Callable]] = None) -> int:", "def count_revisions_by_user(self):\n ...
[ "0.6730025", "0.6686577", "0.6600662", "0.6510088", "0.6475355", "0.6426317", "0.6405162", "0.63020605", "0.6255534", "0.61494267", "0.6139892", "0.6139045", "0.60678715", "0.6058692", "0.60302025", "0.6009511", "0.6008887", "0.59358513", "0.59263605", "0.5913929", "0.5907688...
0.74049693
0
This function returns a list of users followed by a particular user.
def get_people_followed(user_id, ignore_exceptions=False, return_type=list, start_index=0): def _get_followed(_user_id, _ignore_exceptions=False, _start_index=0, _count=100): """This function performs the API call to get the users followed from a single GET request. .. versionchanged:: 3.1.0 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def get_new_followers(self, bearer_token:str, user_id:str, after:str) -> list:\n\n headers = {\"Client-Id\": self.TWITCH_PARAMS['client_id'], \"Authorization\": f\"Bearer {bearer_token}\"}\n params = {\"to_id\": user_id, \"first\": 100}\n if after:\n params[\"after\"] = after\...
[ "0.7290584", "0.7224232", "0.71426654", "0.7053847", "0.7016795", "0.6990444", "0.69876266", "0.6973309", "0.6892305", "0.6805332", "0.67873687", "0.6695358", "0.6676869", "0.66697973", "0.66493213", "0.6647961", "0.6645527", "0.6629329", "0.66166395", "0.6608287", "0.6581198...
0.6450729
32
This function performs the API call to get the users followed from a single GET request.
def _get_followed(_user_id, _ignore_exceptions=False, _start_index=0, _count=100): _following_url = f"{base_url}/people/{_user_id}/@following?count={_count}" + \ f"&startIndex={_start_index}" _response = core.get_request_with_retries(_following_url) if _response.status_c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def follows(self):\r\n request = http.Request('GET', '{0}/follows/'.format(self.get_url()))\r\n\r\n return request, parsers.parse_json", "def get_followings(request):\n user_id = request.GET.get(\"user_id\")\n if not user_id:\n return {\"error\": \"User Id should be provided\"}, 400\n ...
[ "0.74524915", "0.7451734", "0.7411945", "0.7273588", "0.7230201", "0.7144421", "0.7144421", "0.7144421", "0.7020813", "0.70104915", "0.70104915", "0.70104915", "0.70104915", "0.6976389", "0.6941813", "0.6930851", "0.6921965", "0.68312484", "0.6744993", "0.6698979", "0.6666516...
0.75183386
0
This function returns the most recent logins that have occurred in the environment.
def get_recent_logins(count=100, start_index=0): # Verify that the core connection has been established verify_core_connection() # Perform and parse the query query_url = f"{base_url}/people?sort=lastLoggedIn&" + \ f"fields=jive,emails,name&count={count}&startIndex={start_index}" re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_rolling_log_history():\n current_tag = get_current_tag()\n return get_log_history(current_tag)", "def last_log(self) -> List:\n logs_list: List = os.listdir(LOGS_BASE_PATH)\n full_list = [os.path.join(LOGS_BASE_PATH, i) for i in logs_list]\n time_sorted_list: List = sorted(full...
[ "0.62533057", "0.6127016", "0.5962094", "0.5580813", "0.55602443", "0.55220354", "0.5503221", "0.5459608", "0.54517496", "0.5433043", "0.5422859", "0.53946495", "0.53740424", "0.5363544", "0.5360245", "0.5341821", "0.5305654", "0.52805936", "0.5263784", "0.52597564", "0.52460...
0.6475265
0
19200 correspond to F and 9600 to S
def baudrate_cmd(self, baudrate): if baudrate is 19200: baudrate = "F" else: baudrate = "S" return "*99!BR=bd\r".replace("bd", baudrate).encode()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def y2k_coding(n):\n if n < 60:\n return 2000 + n\n else:\n return 1900 + n", "def twenty_seventeen():\n return 2017", "def new_years_eve(year):\n return (year, DEC, 31)", "def fv(rate, n_years):\n return pow(1 + rate, n_years)", "def get_years(met_fname, nyear_spinup):\n pr...
[ "0.62622607", "0.5538103", "0.5387271", "0.53655094", "0.5281453", "0.5275056", "0.52705556", "0.52415746", "0.5233109", "0.5232555", "0.5198662", "0.5185992", "0.5181842", "0.5156015", "0.5150428", "0.51500607", "0.514978", "0.5136431", "0.51294935", "0.50904584", "0.5090403...
0.0
-1
Send command to get Device ID
def init_com(self): self.__ser = serial.Serial( self.__dev_no, self.__baudrate, timeout=self.__timeout) # Stop the Continious Stream, avoid error self.__ser.write(self.__api.esc_cmd()) self.__ser.write(self.__api.devid_cmd()) tmp = self.__ser.readline().decode...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def device_id(self):\n data = fcntl.ioctl(self._fd, _EVIOCGID, '\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')\n idbus, idvendor, idproduct, idversion = struct.unpack(\"hhhh\", data)\n return idbus, idvendor, idproduct, idversion", "def get_id(self):\n try:\n return self.inst.q...
[ "0.68931824", "0.67137796", "0.6710456", "0.66909766", "0.66231805", "0.6570856", "0.65618247", "0.6559433", "0.6478275", "0.6471906", "0.6348307", "0.6279984", "0.6250359", "0.6236253", "0.6222079", "0.6214735", "0.62019837", "0.61913437", "0.61772615", "0.6175224", "0.61653...
0.0
-1
Do not return anything, modify board inplace instead.
def solveSudoku(self, board: List[List[str]]) -> None: row = collections.defaultdict(set) col = collections.defaultdict(set) block = collections.defaultdict(set) pos = [] for i in range(9): for j in range(9): if board[i][j] != '.': ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def applyMove(self, (from_row,from_col), (to_row,to_col)):\n newboard = deepcopy(self)\n piece = newboard.board[from_row][from_col]\n newboard.board[from_row][from_col] = None\n newboard.board[to_row][to_col] = piece\n newboard.toplay = 'BLACK' if self.toplay == 'WHITE' else 'WHI...
[ "0.7664789", "0.70971596", "0.70476234", "0.7024398", "0.69861203", "0.6829364", "0.6778242", "0.6727011", "0.66938925", "0.6692377", "0.6625323", "0.6625323", "0.65893996", "0.6565318", "0.6564258", "0.65587217", "0.6539339", "0.65249294", "0.65223134", "0.6520972", "0.65202...
0.0
-1
Parse a type declaration from a str.
def LoadTypeDeclaration(self, content): type_decl_unit = self._parser.Parse(content) functions_by_name = {f_name: list(g) for f_name, g in itertools.groupby( type_decl_unit.funcdefs, lambda f: f.name)} interface_by_name = {i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unparse_type(type_str):\n if not type_str.startswith('array'):\n return type_str\n arg_dim = type_str.lstrip('array')[0]\n data_type = type_str.lstrip('array')[1:]\n arg_type = \"vizgen.ndarray('\" + data_type + \"', \" + arg_dim + \")\"\n return arg_type", "def ...
[ "0.6656149", "0.6619672", "0.66187406", "0.6326907", "0.632081", "0.62572104", "0.62192476", "0.6218978", "0.62022847", "0.62020844", "0.60300356", "0.5892663", "0.58687246", "0.5863348", "0.5820116", "0.578828", "0.5759169", "0.57202244", "0.56879276", "0.56603414", "0.56585...
0.5025832
85
Parse a type declaration and convert it to a list of functions.
def LoadTypeDeclarationFromFile(self, type_decl_path): with open(type_decl_path) as f: return self.LoadTypeDeclaration(f.read())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LoadTypeDeclaration(self, content):\n type_decl_unit = self._parser.Parse(content)\n functions_by_name = {f_name: list(g) for f_name, g\n in itertools.groupby(\n type_decl_unit.funcdefs,\n lambda f: f.name)}\n\n interface_...
[ "0.6756747", "0.6038395", "0.5836166", "0.579168", "0.5640722", "0.558481", "0.5549694", "0.5523721", "0.5480223", "0.54721963", "0.54591095", "0.5423281", "0.5347036", "0.53366476", "0.53262216", "0.5262503", "0.5250559", "0.52312094", "0.51606005", "0.5130728", "0.5127467",...
0.4679416
56
Utility function to run operations in a thread but honors the thread limit
def run_in_a_thread(func, args, limit): def get_active_threads(): active = 0 for t in Utility.__THREADS: if t.isAlive(): active += 1 else: Utility.__THREADS.remove(t) return active while get_acti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_time_limit(arg):\n pass", "async def test_exectution_limit_throttle(coresys: CoreSys, loop: asyncio.BaseEventLoop):\n\n class TestClass:\n \"\"\"Test class.\"\"\"\n\n def __init__(self, coresys: CoreSys):\n \"\"\"Initialize the test class.\"\"\"\n self.coresys = ...
[ "0.6147261", "0.60309714", "0.6018473", "0.59771776", "0.59549063", "0.5948192", "0.5915713", "0.58854884", "0.5860164", "0.5856046", "0.5856046", "0.5810252", "0.57848454", "0.5737032", "0.5730728", "0.56780916", "0.5657357", "0.5654869", "0.56539977", "0.56539977", "0.56349...
0.7635067
0
Creates CIRD range notation (network) based on the currently configures network interfaces/adapters If scanning range was set at run time, it will just use that one
def __get_scanning_range(self): if self.__network is not None: return [self.__network] networks = [] interfaces = netifaces.interfaces() for data in interfaces: ips = netifaces.ifaddresses(data) for key, interface_data in ips.items(): f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dhcp_range(options, index):\n second_octet = 160 + index\n return \"192.%s.1.2-192.%s.255.254\" % (second_octet, second_octet)", "def change_default_range(networks, number_excluded_ips,\n cut_from_start=True):\n for default_network in filter(\n lamb...
[ "0.6023686", "0.581812", "0.58151424", "0.5770609", "0.5480118", "0.5452671", "0.5420384", "0.54121625", "0.53247935", "0.5291674", "0.52649754", "0.52291876", "0.52005047", "0.5171426", "0.51680905", "0.5166946", "0.5145584", "0.514271", "0.51361144", "0.51302284", "0.512298...
0.626305
0
Converts CIRD notation(network) to IP addresses and maps them to the network
def __get_potential_targets(self): network_targets = {} for network in self.__get_scanning_range(): ips = IPNetwork(network) # converts CIRD notation to IP addresses targets = [] for ip in ips: targets.append(ip) print("Potential targets o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self):\n self.networks = [\n ipaddress.ip_network(address)\n for address in self.addresses\n ]", "def to_python(self, value):\n if isinstance(value, (ipaddress.IPv4Network, ipaddress.IPv6Network)):\n return value\n\n if val...
[ "0.6179653", "0.61625284", "0.604074", "0.5831263", "0.5788037", "0.5781347", "0.5674592", "0.5664921", "0.5541622", "0.55340296", "0.5520692", "0.5473289", "0.5460664", "0.5441231", "0.5440491", "0.5407914", "0.53967446", "0.5378069", "0.53610927", "0.5327011", "0.52733773",...
0.0
-1
Scans a given IP for specific open ports
def __scan_for_open_ports(self, ip, ports_to_scan): ip = str(ip) def run_scan(_port): try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(self.__timeout) result = sock.connect_ex((ip, _port)) if result...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scan_ports(ip: Union[str, IPvAnyAddress]) -> ScanResults:\n if ip == 'localhost':\n ip = '127.0.0.1'\n ip = str(ip)\n\n nmap = nmap3.NmapScanTechniques()\n scan_result = nmap.nmap_tcp_scan(ip, args='-p0-')\n ports = scan_result[ip]['ports']\n\n # TODO: TEMP: Remove this line, debug onl...
[ "0.7841557", "0.7183356", "0.7178773", "0.6932479", "0.6745885", "0.665516", "0.6618246", "0.6496563", "0.6426189", "0.64072084", "0.63629407", "0.6334954", "0.6320099", "0.62818193", "0.6240517", "0.62234575", "0.6187895", "0.61846787", "0.61596686", "0.61544794", "0.6149629...
0.78269833
1
Returns suitable targets to perform vulnerability scans on broken down by open ports
def get_targets(self, ports_to_scan): t1 = datetime.now() network_ips = self.__get_potential_targets() for port in ports_to_scan: self.targets.update({port: []}) print("Port scan in progress for the following open ports: {}".format(ports_to_scan)) for network, ips in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_target_ports(self):\n return self.targets", "def target_builder(target, ports, default_ports):\n methods = [\"http\", \"https\"]\n if not ports:\n ports = default_ports\n URL = []\n if target_type(target) != \"HTTP\":\n for port in ports:\n for method in method...
[ "0.69600135", "0.6610526", "0.65068066", "0.6476772", "0.6418622", "0.6283991", "0.62345856", "0.601926", "0.59702617", "0.59546286", "0.5941063", "0.5938712", "0.58558106", "0.58512944", "0.5773648", "0.5758662", "0.57098186", "0.57098186", "0.57013583", "0.5695864", "0.5672...
0.64940965
3
Returns a map of what ports we can potentially hack services on and what exploits can do it
def get_vulnerable_ports(self): self.__get_vulnerable_ports(modules.__path__[0]) return self.__vulnerable_ports
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_ports():\n ports = [config('admin-port'), config('service-port')]\n return list(set(ports))", "def _get_exposed_ports(debug_port):\n if not debug_port:\n return None\n\n return {\n # container port : host port\n debug_port: debug_port\n }"...
[ "0.6631425", "0.658254", "0.6252307", "0.62312484", "0.619172", "0.6132367", "0.6076404", "0.60520476", "0.6033354", "0.602421", "0.60065967", "0.5940211", "0.5909571", "0.588566", "0.58268833", "0.5826848", "0.5793208", "0.57583857", "0.5735731", "0.5727579", "0.56883043", ...
0.6643077
0
Utility function that will recursively go through all of the RSF modules to find all of the exploits and will map all of the exploits that can be done to ports
def __get_vulnerable_ports(self, path): files = os.listdir(path) for file in files: if file != "__init__.py" and ".pyc" not in file: doc_path = "{}{}{}".format(path, os.sep, file) if os.path.isfile(doc_path): with open(doc_path, "r") as doc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_exploits():\n results = {}\n for loader, name, ispkg in pkgutil.walk_packages(acsploit.exploits.__path__):\n m = loader.find_module(name).load_module(name)\n\n if not ispkg and hasattr(m, 'options') and hasattr(m, 'run'):\n exploit = name.replace('.', '/')\n result...
[ "0.5847549", "0.5810903", "0.575594", "0.5318235", "0.52766615", "0.5236848", "0.5217462", "0.5192389", "0.5159464", "0.51455456", "0.51056087", "0.5068863", "0.50141186", "0.50089616", "0.4964121", "0.48492944", "0.4848821", "0.48147175", "0.48122516", "0.4812014", "0.479382...
0.46486104
36
play gradients norm_grad = np.linalg.norm(gradient) tone = self.f + (norm_grad 500.0) samples = self.generate_tone(self.fs, tone, self.duration).astype(np.float32)
def __call__(self, gradient): audio_out = self.modem.convert_data_to_audio(gradient.flatten()) decoded_gradients = self.modem.convert_audio_to_floats(audio_out) # if you want to regret being alive, # self.stream.write(audio_out.tobytes()) return decoded_gradients.reshape(gradie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generateSound(amps_samples, channel_fs, sampleRate):\r\n\r\n samples_to_gen = len(amps_samples[0]) \r\n nb_channels = len(amps_samples)\r\n duration = samples_to_gen / sampleRate # in s\r\n\r\n \r\n t = np.linspace(0.0, duration, samples_to_gen) # Produces length of samples\r\n\r\n sines = ...
[ "0.57237077", "0.5707015", "0.5682976", "0.56029904", "0.55295414", "0.5526577", "0.55244416", "0.5501788", "0.5442099", "0.5416417", "0.5373929", "0.5359383", "0.5344165", "0.5339903", "0.53293294", "0.53061014", "0.5304661", "0.5303725", "0.53028196", "0.5297751", "0.528846...
0.66777045
0
Checks if there are 3 digits the same. returns the repeating digit and its indices.
def check_if_has_3_repeated_digits(prime: str) -> (str, list): num_dict = {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0} for digit in prime: num_dict[int(digit)] += 1 for k, v in num_dict.items(): if v > 2: repeating_digit = k indices = [i for i, x in e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_digits(n):\n \"*** YOUR CODE HERE ***\"\n count = 0\n for k in range(0, 10):\n if has_digit(n, k):\n count = count + 1\n return count", "def unique_digits(n):\n #return len(set(str(n)))\n f = sorted(list(str(n)))\n return len([x for i,x in enumerate(f) if x not i...
[ "0.62621343", "0.62330055", "0.6103015", "0.6061804", "0.5992376", "0.5973955", "0.59315914", "0.59144604", "0.5909071", "0.58491397", "0.57401156", "0.5738626", "0.5728421", "0.5718985", "0.5690673", "0.5680208", "0.56766343", "0.5627409", "0.5604609", "0.56018883", "0.56004...
0.7790202
0
Check if by replacing the repeating digit with the other 9 possible digits, how many are primes. we return a list of those which are.
def check_for_family_of_primes(r: str, ind: list, p: list) -> list: values_to_check = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] values_to_check.remove(r) counter = ["".join(p)] for d in values_to_check: p[ind[0]] = d p[ind[1]] = d p[ind[2]] = d if is_prime(int(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replace_count_primes(n):\n s = list(str(n))\n length = len(s)\n print(n)\n for c in combinations(digits[:length], mu):\n test_list = []\n for i in range(10):\n new_s = deepcopy(s)\n for place in c:\n new_s[int(place)] = str(i)\n new_n = ...
[ "0.809213", "0.7492911", "0.7384596", "0.7349347", "0.7320951", "0.7264534", "0.7223761", "0.7144266", "0.7047477", "0.7023293", "0.7022972", "0.6982218", "0.69794196", "0.6964489", "0.6952429", "0.6946584", "0.69340545", "0.69195366", "0.6897837", "0.6890351", "0.6881369", ...
0.7327216
4
Generate prime numbers and pass to the other two functions. If we find a family of 8 primes, we break and return the answer.
def main() -> int: a = None for n, g in enumerate(gen_primes(100000, 1000000)): repeat, indices = check_if_has_3_repeated_digits(str(g)) if repeat: a = check_for_family_of_primes(repeat, indices, list(str(g))) if len(a) > 7 and min(a) > 100000: EULER_LOGG...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def primes():\n yield 2\n found_primes = [2]\n a = 3\n while True:\n for p in found_primes:\n if p**2 > a:\n found_primes.append(a)\n yield a\n a += 2\n break\n elif a % p == 0:\n a += 2\n ...
[ "0.6861571", "0.68444514", "0.68444514", "0.67335594", "0.6598026", "0.65894234", "0.6584745", "0.65420634", "0.6494829", "0.6491836", "0.6470535", "0.6460577", "0.64547604", "0.64448065", "0.6430741", "0.64283806", "0.63516057", "0.6323416", "0.6313036", "0.6292335", "0.6286...
0.6197531
31
Performs a single optimization step.
def step(self, closure: Optional[Callable[[], float]] = None) -> Optional[float]: loss = None if closure is not None: with torch.enable_grad(): loss = closure() for group in self.param_groups: for p in group["params"]: if p.grad is None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def optimization_step(self):\n \n if \"CSS\" in self.algorithm:\n \n input_dict = {self.x: self.train_inputs[self.minibatch_set,:]}\n \n var_list = [self.x_tilda, self.minibatch_set]\n \n if (self.num_samples > 0) a...
[ "0.70355856", "0.69881725", "0.6772841", "0.6642373", "0.64311093", "0.63344187", "0.62806904", "0.62103254", "0.62090313", "0.61938447", "0.6175672", "0.61515605", "0.6140446", "0.61175907", "0.61063343", "0.6095171", "0.6089585", "0.6081353", "0.60701174", "0.6013111", "0.6...
0.0
-1
Loads a data file into a list of `InputBatch`s
def convert_examples_to_features(self, examples, sequence_a_segment_id=0, mask_padding_with_zero=True): # label2id = {label: i for i, label in enumerate(label_list)} cls_token = self.tokenizer.cls_token sep_token = self.tokenizer.sep_token pad_token_id = self.tokenizer.pad_token_id ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def LoadBatch(filename):", "def load_batch(fpath, label_key='labels'):\n f = open(fpath, 'rb')\n if sys.version_info < (3,):\n d = cPickle.load(f)\n else:\n d = cPickle.load(f, encoding='bytes')\n # decode utf8\n d_decoded = {}\n for k, v in d.items():\n d_d...
[ "0.7339138", "0.7088603", "0.68152064", "0.66804737", "0.6677221", "0.6673983", "0.66573095", "0.66420156", "0.66143215", "0.65928704", "0.65928704", "0.6543405", "0.6530698", "0.6480809", "0.647069", "0.64682585", "0.6405377", "0.63913566", "0.6391015", "0.6371047", "0.63698...
0.0
-1
Adds an extra axis to a data slab.
def addExtraAxis(slab,newaxis=None,axis=0,verbose=False): import cdms2 as cdms import MV2 as MV if newaxis is None: newaxis=cdms.createAxis([1,]) newaxis.units='' # add new axis to axis list of input <slab> axislist=slab.getAxisList() axislist.insert(axis,newaxis) #------...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_extra_dim(self, params: ExtraBytesParams) -> None:\n self.add_extra_dims([params])", "def _appendAxisDefinition(self, axis):\n length = len(axis)\n\n self.na_dict[\"NX\"].append(length)\n self.na_dict[\"XNAME\"].append(xarray_utils.getBestName(axis))\n\n # If only one i...
[ "0.6279864", "0.5876645", "0.57838917", "0.56708485", "0.5641856", "0.55798954", "0.55050075", "0.54636085", "0.5369209", "0.53418547", "0.5340863", "0.5319793", "0.5302775", "0.52753866", "0.5257759", "0.5241214", "0.5231386", "0.52094215", "0.51454324", "0.5124852", "0.5124...
0.79540575
0
Assess if a Mapbox tileset_id is valid
def validate_tileset_id(tileset_id): pattern = r"^[a-z0-9-_]{1,32}\.[a-z0-9-_]{1,32}$" return re.match(pattern, tileset_id, flags=re.IGNORECASE)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tile_is_set(index, level_map):\n return level_map[index] != -1", "def tile_exists_utm(boundsSrc, boundsTile):\n\n\n boundsSrcBox = box(*boundsSrc)\n boundsTileBox = box(*boundsTile)\n\n return boundsSrcBox.intersects(boundsTileBox)", "def test_room_has_tiles(self):\n self.assertEqual(sel...
[ "0.6637304", "0.62335414", "0.6161379", "0.6090846", "0.6027421", "0.5894052", "0.58873093", "0.5880936", "0.5848466", "0.5831871", "0.58296573", "0.58248645", "0.58103555", "0.5810162", "0.57029486", "0.56911117", "0.566734", "0.5657201", "0.5626586", "0.56132966", "0.560689...
0.72017473
0
Extend the functionality of shutil. Correctly copies files and directories in a source directory.
def copydir( source: str, destination: str, includes: List[str], excludes: Optional[List[str]] = None, follow_symlinks: bool = False, ) -> None: files = _find_files(source, includes, excludes, follow_symlinks) def _mkdir(dir_name: str) -> None: """Recursively create directories.""" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __copyFiles(self):\n if os.path.isdir(self.__sourcePath):\n shutil.copytree(self.__sourcePath, self.__targetPath)\n else:\n shutil.copy2(self.__sourcePath, self.__targetPath)", "def copy(source, destination):\r\n\r\n source_ = os.path.abspath(os.path.expanduser(source))...
[ "0.76032", "0.7391529", "0.72444487", "0.72432435", "0.72234124", "0.71827996", "0.71821535", "0.7150849", "0.71507955", "0.7094454", "0.7086299", "0.7064986", "0.7057179", "0.7039594", "0.6978795", "0.6927254", "0.6917816", "0.6904082", "0.6904082", "0.68775254", "0.6874949"...
0.65507185
47
Identify Python requirement files.
def find_requirements(root: str) -> Optional[Dict[str, bool]]: findings = { file_name: os.path.isfile(os.path.join(root, file_name)) for file_name in ["requirements.txt", "Pipfile", "Pipfile.lock"] } if not sum(findings.values()): return None return findings
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def learn_requirements():\n req_file = \"requirements.txt\"\n reqs = []\n\n import os\n\n path = os.path.dirname(__file__)\n req_file = os.path.join(path, \"..\", req_file)\n if not os.path.exists(req_file):\n # not needed with installed package\n return reqs\n\n excludes = \"ver...
[ "0.7247536", "0.7180061", "0.71210736", "0.68924165", "0.68747437", "0.684639", "0.66295767", "0.6607806", "0.66018444", "0.65977806", "0.65653926", "0.6521994", "0.6501912", "0.64777774", "0.6406232", "0.6372848", "0.63446504", "0.63313365", "0.63069576", "0.63003576", "0.62...
0.65735126
10
Assess if Docker should be used based on the value of args.
def should_use_docker(dockerize_pip: DockerizePipArgTypeDef = None) -> bool: if isinstance(dockerize_pip, bool): return dockerize_pip if isinstance(dockerize_pip, str): if dockerize_pip == "non-linux" and not sys.platform.startswith("linux"): return True try: ret...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_docker(self) -> bool:\n from hubble.executor.helper import is_valid_docker_uri\n\n uses = getattr(self.args, 'uses', '')\n return is_valid_docker_uri(uses)", "def docker_allow_fallback():\n return False", "def req_build(container):\n try:\n return 'dock...
[ "0.75592434", "0.6791129", "0.641314", "0.63690114", "0.6301101", "0.61071885", "0.60725427", "0.60477525", "0.58751506", "0.5770867", "0.5769221", "0.5697177", "0.5614681", "0.55873924", "0.55785286", "0.55209535", "0.5489136", "0.545635", "0.53722596", "0.5362115", "0.53584...
0.6928599
1
Return boolean value of string.
def str2bool(v): # type: ignore return v.lower() in ("yes", "true", "t", "1", "on")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toBool( string ):\r\n return string == 'true'", "def __str_to_bool(self, s):\n if s == 'True':\n return True\n elif s == 'False':\n return False\n else:\n raise ValueError", "def getBool(string):\n return (True)", "def boolean(s):\r\n ss = str(...
[ "0.83459866", "0.8246995", "0.82064474", "0.7928407", "0.79133636", "0.79100734", "0.7897386", "0.7884227", "0.78569734", "0.7784944", "0.7784944", "0.7746765", "0.7725692", "0.7694074", "0.7691527", "0.76899177", "0.7624512", "0.7604307", "0.7594454", "0.75818145", "0.757307...
0.7287266
52
Generate a ZIP file inmemory from a list of files. Files will be stored in the archive with relative names, and have their UNIX permissions forced to 755 or 644 (depending on whether they are userexecutable in the source filesystem).
def _zip_files(files: Iterable[str], root: str) -> Tuple[bytes, str]: zip_data = StringIO() files = list(files) # create copy of list also converts generator to list with ZipFile(zip_data, "w", ZIP_DEFLATED) as zip_file: for file_name in files: zip_file.write(os.path.join(root, file_nam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_zip_from_files(files: List[Path]) -> Any:\n temp = tempfile.NamedTemporaryFile()\n with zipfile.ZipFile(temp, 'w') as handle:\n for f in files:\n filename = f.name\n handle.write(f, arcname=filename)\n temp.flush()\n return temp", "d...
[ "0.7924965", "0.7683432", "0.7493491", "0.7410672", "0.7367998", "0.73668987", "0.72115725", "0.7162055", "0.69762313", "0.68842643", "0.68564355", "0.68193173", "0.6806144", "0.67980766", "0.67859745", "0.6773269", "0.67614233", "0.6732942", "0.66457343", "0.65578675", "0.65...
0.7245733
6
Return a hash of all of the given files at the given root.
def _calculate_hash(files: Iterable[str], root: str) -> str: file_hash = hashlib.md5() for file_name in sorted(files): file_path = os.path.join(root, file_name) file_hash.update((file_name + "\0").encode()) with open(file_path, "rb") as file_: # pylint: disable=cell-var-from-...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hash_files(verbose, debug):\n\n found = []\n h = hashlib.new('md5')\n for pattern in FILES_PATTERNS:\n for f in glob.iglob(pattern, flags=FLAGS):\n name = f.replace('\\\\', '/')\n found.append(name)\n if verbose:\n print('FILES:')\n for f in sorted(found):\n ...
[ "0.7420318", "0.73666245", "0.7317427", "0.72091985", "0.71523035", "0.7038823", "0.6978035", "0.69414365", "0.6797267", "0.6717443", "0.6710734", "0.65908384", "0.65727043", "0.65698576", "0.65642035", "0.65586007", "0.6522981", "0.6504305", "0.6416056", "0.63652515", "0.632...
0.8427298
0
List files inside a directory based on include and exclude rules. This is a more advanced version of `glob.glob`, that accepts multiple complex patterns.
def _find_files( root: str, includes: Union[List[str], str], excludes: Optional[List[str]] = None, follow_symlinks: bool = False, ) -> Iterator[str]: root = os.path.abspath(root) file_set = formic.FileSet( directory=root, include=includes, exclude=excludes, symlinks=follow_symlinks )...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_files(path, include=None, exclude=None):\n # If no extension is selected, use the wild card.\n if include is None:\n include = '*'\n # Make sure it is an iterable,\n include = assert_is_iter(include)\n # Find files and flatten.\n files = [glob.glob(f'{path}/**/*.{ext}', recursive=...
[ "0.68052447", "0.6752323", "0.67128164", "0.65114653", "0.6491854", "0.64019465", "0.6395919", "0.638937", "0.6382164", "0.6379858", "0.63603497", "0.63299865", "0.6321224", "0.6305654", "0.62905306", "0.627118", "0.62695813", "0.62695813", "0.625555", "0.62298995", "0.618449...
0.58256245
62
Generate a ZIP file inmemory from file search patterns.
def _zip_from_file_patterns( root: str, includes: List[str], excludes: List[str], follow_symlinks: bool ) -> Tuple[bytes, str]: LOGGER.info("base directory: %s", root) files = list(_find_files(root, includes, excludes, follow_symlinks)) if not files: raise RuntimeError( "Empty list ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zipfile_containing(file_contents: Sequence[Tuple[str, str]]):\n with tempfile.NamedTemporaryFile(suffix='.zip') as temp_file:\n with zipfile.ZipFile(temp_file, 'w') as zip_file:\n for file_name, contents in file_contents:\n zip_file.writestr(file_name, contents)\n temp_file.flush()\n yiel...
[ "0.6358855", "0.6332968", "0.6237753", "0.6205198", "0.6119119", "0.60591304", "0.6006466", "0.59753877", "0.59502417", "0.59296006", "0.58752686", "0.58705527", "0.5846494", "0.57977813", "0.57941663", "0.5774152", "0.57729846", "0.5741223", "0.5736779", "0.57303923", "0.572...
0.6324642
2
Use the correct requirements file.
def handle_requirements( package_root: str, dest_path: str, requirements: Dict[str, bool], pipenv_timeout: int = 300, python_path: Optional[str] = None, use_pipenv: bool = False, ) -> str: if use_pipenv: LOGGER.info("explicitly using pipenv") return _handle_use_pipenv( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main() -> None:\n verify_pip_is_installed()\n print('Regenerating \"requirements.txt\" file...')\n install_python_dev_dependencies.compile_pip_requirements(\n 'requirements.in', 'requirements.txt')\n # Adds a note to the beginning of the 'requirements.txt' file to make sure\n # developers...
[ "0.68906283", "0.67032295", "0.6631099", "0.66131264", "0.6593063", "0.65481037", "0.65020955", "0.6469327", "0.6459697", "0.64563775", "0.64110714", "0.6353754", "0.6347483", "0.63357425", "0.63250405", "0.6262225", "0.62593436", "0.62186176", "0.6217121", "0.62076795", "0.6...
0.5775046
66
Create requirements file from Pipfile.
def _handle_use_pipenv( package_root: str, dest_path: str, python_path: Optional[str] = None, timeout: int = 300, ) -> str: if getattr(sys, "frozen", False): LOGGER.error("pipenv can only be used with python installed from PyPi") sys.exit(1) LOGGER.info("creating requirements.txt...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(requirements_file, skip_requirements_file, pipfile, skip_pipfile):\n # type: (str, bool, str, bool) -> None\n pipfile_path = path.Path(pipfile)\n pf = load_pipfile(pipfile_path)\n\n if not skip_requirements_file:\n requirements_file_path = path.Path(requirements_file)\n update_re...
[ "0.7077445", "0.6942941", "0.6795732", "0.66856635", "0.66856635", "0.6521182", "0.65197855", "0.6484924", "0.6461957", "0.64265215", "0.63328713", "0.6215045", "0.6209", "0.6170975", "0.609325", "0.60709524", "0.6018973", "0.60051984", "0.6004013", "0.59137285", "0.58312577"...
0.56345123
38
Run pip with docker.
def dockerized_pip( work_dir: str, client: Optional[docker.DockerClient] = None, runtime: Optional[str] = None, docker_file: Optional[str] = None, docker_image: Optional[str] = None, python_dontwritebytecode: bool = False, **_: Any, ) -> None: # TODO use kwargs to pass args to docker for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_pip_freeze(docker_image, pip):\n\n match = None\n pip_vers = None\n\n try:\n\n cmd = ['sudo', 'docker', 'run', '--env', \"LD_LIBRARY_PATH=''\", '--rm', '-ti',\n '--entrypoint={}'.format(pip), docker_image, 'freeze']\n\n print(' '.join(cmd))\n r = sp.Popen(cmd, s...
[ "0.6504361", "0.63231766", "0.615957", "0.61558837", "0.60848695", "0.60628784", "0.59793115", "0.5911659", "0.58846164", "0.58580613", "0.58296275", "0.5822538", "0.58122975", "0.57188886", "0.5698203", "0.56575954", "0.5615017", "0.5600989", "0.5595091", "0.55341893", "0.54...
0.6530509
0
Return boolean on whether pip is new enough to have nocolor option. pip v10 introduced this option, and it's used to minimize the effect of
def _pip_has_no_color_option(python_path: str) -> bool: try: pip_version_string = subprocess.check_output( [ python_path, "-c", "from __future__ import print_function;" "import pip;" "print(pip.__version__)", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def no_color():\n return (bool(_environ.get(\"ACCELPY_NO_COLOR\", False)) and\n _system() != 'Windows')", "def _default_color_enabled() -> bool:\n import platform\n\n # If we're not attached to a terminal, go with no-color.\n if not sys.__stdout__.isatty():\n return False\n\n # O...
[ "0.73090255", "0.69218844", "0.6608089", "0.65810806", "0.6552736", "0.65195435", "0.6429177", "0.64068675", "0.6352326", "0.6281814", "0.6131098", "0.5832753", "0.5820403", "0.581131", "0.5655444", "0.555243", "0.55007124", "0.54842734", "0.54663014", "0.54660404", "0.545164...
0.75785536
0
Create zip file in memory with package dependencies.
def _zip_package( # pylint: disable=too-many-locals,too-many-statements package_root: str, *, dockerize_pip: DockerizePipArgTypeDef = False, excludes: Optional[List[str]] = None, follow_symlinks: bool = False, includes: List[str], pipenv_timeout: int = 300, python_dontwritebytecode: boo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_zip_file():\n shutil.make_archive(os.path.join(DIST_DIR, \"build\"), \"zip\", BUILD_DIR)", "def _zip_files(self):\n\n zip_file = Path(self.build_directory.parent).joinpath(\n self.package_name + '.zip'\n )\n logger.info('Creating zip file: %s', zip_file)\n\n ...
[ "0.721739", "0.7214677", "0.6985273", "0.68291426", "0.6790956", "0.67348194", "0.66810083", "0.6600456", "0.63711417", "0.6370397", "0.63341767", "0.6285126", "0.62729836", "0.6266667", "0.6252513", "0.62311554", "0.6206117", "0.61968726", "0.61563855", "0.61393106", "0.6138...
0.6505336
8
Retrieve information about an object in S3 if it exists.
def _head_object( s3_conn: S3Client, bucket: str, key: str ) -> Optional[HeadObjectOutputTypeDef]: try: return s3_conn.head_object(Bucket=bucket, Key=key) except botocore.exceptions.ClientError as err: if err.response["Error"]["Code"] == "404": return None raise
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_s3_object(self, s3_path):\n bucket_name, key = S3Util.get_bucket_and_key(s3_path)\n return self.s3_resource.Object(bucket_name, key)", "def get_s3_object(self, key):\n try:\n bucket_name = app.config['S3_BUCKET_NAME']\n s3_client = app.config['S3']\n ...
[ "0.7691831", "0.73644066", "0.70595527", "0.7028458", "0.695012", "0.6923213", "0.68887043", "0.6855875", "0.6816487", "0.6746061", "0.6737915", "0.67176014", "0.67143047", "0.66835445", "0.66181076", "0.6560689", "0.65342665", "0.6528971", "0.6519632", "0.647861", "0.6476607...
0.65832025
15
Upload a ZIP file to S3 for use by Lambda. The key used for the upload will be unique based on the checksum of the contents. No changes will be made if the contents in S3 already match the expected contents.
def _upload_code( s3_conn: S3Client, bucket: str, prefix: str, name: str, contents: Union[bytes, str], content_hash: str, payload_acl: ObjectCannedACLType, ) -> Code: LOGGER.debug("ZIP hash: %s", content_hash) key = f"{prefix}lambda-{name}-{content_hash}.zip" if _head_object(s3_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def put(self, path: str, filename: str) -> None:\n\n payload_hash, content_md5, length = _hash(path)\n\n now = datetime.datetime.utcnow()\n timestamp = now.strftime('%Y%m%dT%H%M%SZ')\n headers = [\n ('Connection', 'keep-alive'),\n ('Content-Length', str(length)),\n...
[ "0.67361575", "0.666261", "0.6614976", "0.6435008", "0.6353437", "0.63407624", "0.6288499", "0.62856996", "0.6277724", "0.62474364", "0.61759305", "0.6169826", "0.61494434", "0.61441237", "0.61334544", "0.6133251", "0.6112534", "0.6106917", "0.60964257", "0.6085946", "0.60788...
0.6406313
4
Validate file search patterns from user configuration. Acceptable input is a string (which will be converted to a singleton list), a list of strings, or anything falsy (such as None or an empty dictionary). Empty or unset input will be converted to a default.
def _check_pattern_list( patterns: Optional[Union[List[str], str]], key: str, default: Optional[List[str]] = None, ) -> Optional[List[str]]: if not patterns: return default if isinstance(patterns, str): return [patterns] if isinstance(patterns, list) and all(isinstance(p, str) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _resolve_arguments(patterns, packages_path, search_packages_path):\n\n def _read_patterns(path):\n try:\n with open(path, \"r\") as handler:\n return set(handler.read().splitlines())\n except IOError:\n return set()\n\n ignore_patterns = set()\n\n for...
[ "0.5847642", "0.571779", "0.56237805", "0.5558958", "0.5545299", "0.54854465", "0.54795384", "0.53806275", "0.53201216", "0.5245875", "0.52377", "0.5226893", "0.52046716", "0.51762396", "0.5132988", "0.5130737", "0.50783855", "0.50730044", "0.5066616", "0.5059243", "0.5021123...
0.6681264
0
Build a Lambda payload from user configuration and uploads it to S3.
def _upload_function( s3_conn: S3Client, bucket: str, prefix: str, name: str, options: _UploadFunctionOptionsTypeDef, follow_symlinks: bool, payload_acl: ObjectCannedACLType, sys_path: str, work_dir: Path, ) -> Code: try: root = os.path.expanduser(options["path"]) exc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lambda_handler(event, context):\n \n filename = None\n fobj = None\n\n try:\n \n filename = 'dlq' + '-' + datetime.datetime.now().strftime(\"%s\")\n fobj = open('/tmp/'+filename, 'w')\n logger.debug('S3 client set up.')\n\n for record in event['Records']:\n ...
[ "0.6304564", "0.5891823", "0.5874758", "0.58452857", "0.5809447", "0.57816947", "0.5765443", "0.5632585", "0.5528838", "0.5456213", "0.5450615", "0.5446997", "0.5378688", "0.536596", "0.53648275", "0.53620404", "0.53596246", "0.535553", "0.5320906", "0.53192997", "0.5315513",...
0.53822446
12
Return the appropriate region to use when uploading functions. Select the appropriate region for the bucket where lambdas are uploaded in.
def select_bucket_region( custom_bucket: Optional[str], hook_region: Optional[str], cfngin_bucket_region: Optional[str], provider_region: str, ) -> str: region = None region = hook_region if custom_bucket else cfngin_bucket_region return region or provider_region
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def function_region(self) -> str:\n return pulumi.get(self, \"function_region\")", "def load_aws_region_name() -> str:\n session = boto3.session.Session()\n region_name = (\n click.get_current_context().params.get(\"region\") or session.region_name\n )\n return region_name", "def regi...
[ "0.7334205", "0.6579131", "0.6273241", "0.6175507", "0.6165684", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.6162876", "0.61409694", "0.6136126", "0.6130676", ...
0.71261233
1
Build Lambda payloads from user configuration and upload them to S3. Constructs ZIP archives containing files matching specified patterns for each function, uploads the result to Amazon S3, then stores objects (of
def upload_lambda_functions(context: CfnginContext, provider: Provider, **kwargs: Any): LOGGER.warning( "%s is deprecated and will be removed in a future release - " "see documentation for replacement", __name__, ) # TODO add better handling for misconfiguration (e.g. forgetting func...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _upload_function(\n s3_conn: S3Client,\n bucket: str,\n prefix: str,\n name: str,\n options: _UploadFunctionOptionsTypeDef,\n follow_symlinks: bool,\n payload_acl: ObjectCannedACLType,\n sys_path: str,\n work_dir: Path,\n) -> Code:\n try:\n root = os.path.expanduser(options...
[ "0.64204836", "0.63022864", "0.6259235", "0.6092332", "0.59669536", "0.5948963", "0.5852074", "0.5800756", "0.57910043", "0.5769824", "0.5736082", "0.5676278", "0.5634184", "0.5622248", "0.55950046", "0.5543822", "0.55227745", "0.551679", "0.5510865", "0.5473884", "0.54647326...
0.57893515
9
remove distracting whitespaces and newline characters
def bs_preprocess(html): pat = re.compile('(^[\s]+)|([\s]+$)', re.MULTILINE) html = re.sub(pat, '', html) # remove leading and trailing whitespaces html = re.sub('\n', ' ', html) # convert newlines to spaces # this preserves newline delimiters html = re.sub(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_whitespace(text):\n return text\n #return re.sub(r'\\r\\n|\\n', \"\\t\", text)", "def removeSingleChars(self) -> None:\n self.text = re.sub('\\s[^\\n\\s]\\s', ' ', self.text)", "def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})", "...
[ "0.7512734", "0.74011576", "0.73931", "0.7392397", "0.72668093", "0.7214466", "0.71911186", "0.7189776", "0.7180525", "0.7179743", "0.7165845", "0.7156132", "0.71512353", "0.7145525", "0.7124246", "0.71108913", "0.7079354", "0.7075042", "0.7049608", "0.70375574", "0.70324016"...
0.0
-1
calls the 'source()' method of the current (user folder) conanfile.py
def source(self, path, name=None, version=None, user=None, channel=None): app = ConanApp(self._conan_api.cache_folder) conanfile = app.loader.load_consumer(path, name=name, version=version, user=user, channel=channel, graph_lock=None) # This profile i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source(self):\n return some.dap.source(py.path.local(self.co_filename))", "def source(something):\n # How to source? It's impossible. It's like: we fork, run bash, run\n # ourselves in the environment set up by Bash.\n raise NotImplementedError('Impossible.')", "def do_source(self, line):\n...
[ "0.72140634", "0.68528104", "0.67484087", "0.66230774", "0.6607021", "0.6600624", "0.6600589", "0.6545537", "0.65396297", "0.6503178", "0.6457454", "0.6434944", "0.6405547", "0.63944274", "0.63699126", "0.6248467", "0.6179569", "0.6175343", "0.60342467", "0.6005206", "0.59890...
0.6302204
15
calls the 'build()' method of the current (user folder) conanfile.py
def build(self, conanfile): app = ConanApp(self._conan_api.cache_folder) conanfile.folders.set_base_package(conanfile.folders.base_build) conanfile.folders.set_base_pkg_metadata(os.path.join(conanfile.build_folder, "metadata")) run_build_method(conanfile, app.hook_manager)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build():", "def build(config):", "def build(_):", "def build(build_ctx: str, bentofile: str, version: str) -> None: # type: ignore (not accessed)\n if sys.path[0] != build_ctx:\n sys.path.insert(0, build_ctx)\n\n build_bentofile(bentofile, build_ctx=build_ctx, version=version)",...
[ "0.7333871", "0.71412677", "0.6977461", "0.6936356", "0.68916893", "0.68744874", "0.68205845", "0.6769663", "0.6651863", "0.6582709", "0.6576951", "0.6561471", "0.65468836", "0.6516524", "0.65142125", "0.6505344", "0.64734596", "0.6464042", "0.645478", "0.63959265", "0.639177...
0.8105695
0
calls the 'test()' method of the current (user folder) test_package/conanfile.py
def test(conanfile): with conanfile_exception_formatter(conanfile, "test"): with chdir(conanfile.build_folder): conanfile.test()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test():\n current_directory = os.getcwd()\n os.chdir(PACKAGE_DIR)\n pytest.main()\n os.chdir(current_directory)", "def test():\n tests = unittest.TestLoader().discover('project/tests', pattern='test*.py')\n result = unittest.TextTestRunner(verbosity=2).run(tests)\n if result.wasSuccessfu...
[ "0.71587485", "0.6982787", "0.69825524", "0.69750357", "0.6971307", "0.69660246", "0.6936495", "0.6896736", "0.6883618", "0.6883618", "0.6883618", "0.6883618", "0.68168396", "0.6809316", "0.68035895", "0.6797254", "0.67825884", "0.67797387", "0.67692393", "0.6762063", "0.6757...
0.82097435
0
Convenience for adding html to input field
def AddLabel(html_input, label=None): id = html_input.id if label: return html.Div([ html.Label(children=label, htmlFor=id), html_input, ]) else: return html_input
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html(self):\n lbl = escape(self._label)\n dis = ('disabled' if not self._enabled else '')\n typ = ('password' if self._password else 'text')\n nam = escape(self._name)\n val = escape(self._value)\n return '%s <input name=\"%s\" %s type=\"%s\" value=\"%s\" size=\"%i\">' % (lbl, nam, dis, typ, ...
[ "0.7169448", "0.6838431", "0.68178415", "0.665138", "0.65652514", "0.63051593", "0.6252572", "0.6071613", "0.6038615", "0.6019356", "0.59918284", "0.59597725", "0.5938401", "0.5905728", "0.59022725", "0.5801673", "0.57618266", "0.5735567", "0.5700711", "0.56907254", "0.567770...
0.6041001
8
Use matplotlib figure as component (by converting into plotly format first.)
def MatplotlibFigure(id, fig, size_in_pixels): width_height_tuple_in_inches = (size_in_pixels[0]/fig.dpi, size_in_pixels[1]/fig.dpi) fig.set_size_inches(width_height_tuple_in_inches) plotly_fig = mpl_to_plotly(fig, strip_style=True) return dcc.Graph(id, figure=plotly_fig)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_figure(self, traces):\n pass", "def get_div_from_data(mpl_fig):\n res = plotly.offline.plot_mpl(\n mpl_fig,\n include_plotlyjs=False,\n output_type='div',\n resize=True,\n image_height=\"100%\", image_width=\"100%\"\n )\n return res", "def embed_matpl...
[ "0.6617626", "0.6531744", "0.6453837", "0.6431585", "0.6351513", "0.6198196", "0.6140918", "0.6118211", "0.60988694", "0.6052095", "0.60091686", "0.5962658", "0.59478086", "0.59292096", "0.5902695", "0.5902364", "0.5892394", "0.58689743", "0.58653957", "0.58606535", "0.586036...
0.67803866
0