uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
85b3ccace449ae34da7998ed
train
function
def define_resnet_flags(resnet_size_choices=None): """Add flags and validators for ResNet.""" flags_core.define_base() flags_core.define_performance(num_parallel_calls=False) flags_core.define_image() flags_core.define_benchmark() flags.adopt_module_key_flags(flags_core) flags.DEFINE_enum( name='re...
def define_resnet_flags(resnet_size_choices=None):
"""Add flags and validators for ResNet.""" flags_core.define_base() flags_core.define_performance(num_parallel_calls=False) flags_core.define_image() flags_core.define_benchmark() flags.adopt_module_key_flags(flags_core) flags.DEFINE_enum( name='resnet_version', short_name='rv', default='2', ...
_result(eval_results) if model_helpers.past_stop_threshold( flags_obj.stop_threshold, eval_results['accuracy']): break if flags_obj.export_dir is not None: # Exports a saved model for the given classifier. input_receiver_fn = export.build_tensor_serving_input_receiver_fn( shape, ba...
99
99
332
11
88
jovialio/models
official/resnet/resnet_run_loop.py
Python
define_resnet_flags
define_resnet_flags
441
471
441
441
4dbbcac7e1c645f7e14eb4537674f7af5ed1c0d4
bigcode/the-stack
train
17b4f7341521aa4d04e67cf2
train
function
def get_synth_input_fn(height, width, num_channels, num_classes): """Returns an input function that returns a dataset with zeroes. This is useful in debugging input pipeline performance, as it removes all elements of file reading and image preprocessing. Args: height: Integer height that will be used to c...
def get_synth_input_fn(height, width, num_channels, num_classes):
"""Returns an input function that returns a dataset with zeroes. This is useful in debugging input pipeline performance, as it removes all elements of file reading and image preprocessing. Args: height: Integer height that will be used to create a fake image tensor. width: Integer width that will be u...
. Setting buffer_size to tf.contrib.data.AUTOTUNE # allows DistributionStrategies to adjust how many batches to fetch based # on how many devices are present. dataset = dataset.prefetch(buffer_size=tf.contrib.data.AUTOTUNE) return dataset def get_synth_input_fn(height, width, num_channels, num_classes):
72
72
241
16
55
jovialio/models
official/resnet/resnet_run_loop.py
Python
get_synth_input_fn
get_synth_input_fn
110
134
110
110
47df5a17e35e81bd1a2ea57b1a6a4a2578c0c82e
bigcode/the-stack
train
7e2aaa9457a896d6389425da
train
function
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, resnet_version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE): """Shared functionality for different resnet mode...
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, resnet_version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE):
"""Shared functionality for different resnet model_fns. Initializes the ResnetModel representing the model layers and uses that model to build the necessary EstimatorSpecs for the `mode` in question. For training, this means building losses, the optimizer, and the train op that get passed into the EstimatorS...
Returns: Returns a function that takes a single argument - the number of batches trained so far (global_step)- and returns the learning rate to be used for training the next batch. """ initial_learning_rate = 0.1 * batch_size / batch_denom batches_per_epoch = num_images / batch_size # Reduce the l...
256
256
1,377
53
202
jovialio/models
official/resnet/resnet_run_loop.py
Python
resnet_model_fn
resnet_model_fn
177
321
177
180
c2d451b6829c1e38aa542309539f67d1b80fc674
bigcode/the-stack
train
cddc682d65de3c68a42af412
train
function
def get_version_string(): """ get the mssdk version number :return: str version number """ with open("mssdk/__init__.py", "rb") as file: version_line = re.search( r"__version__\s+=\s+(.*)", file.read().decode("utf-8") ).group(1) return str(ast.literal_eval(version...
def get_version_string():
""" get the mssdk version number :return: str version number """ with open("mssdk/__init__.py", "rb") as file: version_line = re.search( r"__version__\s+=\s+(.*)", file.read().decode("utf-8") ).group(1) return str(ast.literal_eval(version_line))
0/4/23 13:58 Desc: mssdk 的 pypi 基本信息文件 """ import re import ast import setuptools with open("README.md", "r", encoding="utf-8") as f: long_description = f.read() def get_version_string():
64
64
89
5
59
wuyaoyao99/mssdk
setup.py
Python
get_version_string
get_version_string
16
25
16
16
5007798ebc9574a10430f799059e6624455bf4a1
bigcode/the-stack
train
f09cd12eb30bab33a9541347
train
class
class MarkovText(Markov): """Markov text generator class. """ DEFAULT_SCANNER = RegExpScanner DEFAULT_PARSER = Parser DEFAULT_FORMATTER = Formatter DEFAULT_RANK = Const def __init__(self, scanner=None, parser=None, storage=None, ...
class MarkovText(Markov):
"""Markov text generator class. """ DEFAULT_SCANNER = RegExpScanner DEFAULT_PARSER = Parser DEFAULT_FORMATTER = Formatter DEFAULT_RANK = Const def __init__(self, scanner=None, parser=None, storage=None, formatter=None, ...
import random from itertools import chain, islice, cycle from .formatter import FormatterBase, Formatter from .rank import Rank, Const from .scanner import RegExpScanner from .util import get_words, ReplyMode from ..parser import Parser from ..base import Markov from ..util import load, state_size_dataset class Markov...
79
256
1,382
8
70
akx/markovchain
markovchain/text/markov.py
Python
MarkovText
MarkovText
13
245
13
13
f25ef6abcdf98f1e00565dc8644ba80e33e1a99d
bigcode/the-stack
train
7677920e60b8833c318cbc57
train
class
class Person(): def __init__(self, name, family, phone): self.name = name self.family = family self.phone = phone def __str__(self): return self.name def __repr__(self): return "{name} ({family}), tel: {phone}".format(name=self.name, family=self.family, phone=self.p...
class Person():
def __init__(self, name, family, phone): self.name = name self.family = family self.phone = phone def __str__(self): return self.name def __repr__(self): return "{name} ({family}), tel: {phone}".format(name=self.name, family=self.family, phone=self.phone)
family name, phone number.".format(row)) if len(row) == 3: name, family, phone = row else: phone = None name, family = row person = Person(name, family, phone) people.append(person) return people class Person():
64
64
79
3
60
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
Person
Person
126
136
126
126
cac2890ae4978aef3349c3688fa4817116bc2b74
bigcode/the-stack
train
90226d513acd1bc0aca4b3ad
train
function
def load_people(filename): people = [] with open(filename) as people_file: reader = csv.reader(people_file, skipinitialspace=True) for row in reader: if len(row) < 2 or len(row) > 3: raise ValueError("{} has incorrect format: expecting name, family name, phone number....
def load_people(filename):
people = [] with open(filename) as people_file: reader = csv.reader(people_file, skipinitialspace=True) for row in reader: if len(row) < 2 or len(row) > 3: raise ValueError("{} has incorrect format: expecting name, family name, phone number.".format(row)) ...
[giftee] = gifter match = calculate_gift_pairs(gifters, giftees, no_family_match, no_reversal_match, matches, gifter_index + 1) if match: return matches del matches[giftee] return None def load_people(filename):
64
64
127
5
58
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
load_people
load_people
108
124
108
108
0fba5dbfa079e4cba94f21429a8bbac0629d18b2
bigcode/the-stack
train
d3aabf518542b4d0c0a2750b
train
function
def calculate_gift_pairs(gifters, giftees, no_family_match, no_reversal_match, matches = {}, gifter_index = 0): if gifter_index >= len(gifters): return matches gifter = gifters[gifter_index] for giftee in giftees: if gifter is giftee: continue if giftee in matches: ...
def calculate_gift_pairs(gifters, giftees, no_family_match, no_reversal_match, matches = {}, gifter_index = 0):
if gifter_index >= len(gifters): return matches gifter = gifters[gifter_index] for giftee in giftees: if gifter is giftee: continue if giftee in matches: continue if no_family_match and gifter.family == giftee.family: continue if no...
(gifter.phone, message)) else: sns_client.publish(PhoneNumber=gifter.phone, Message=message, MessageAttributes=message_attribtues) def calculate_gift_pairs(gifters, giftees, no_family_match, no_reversal_match, matches = {}, gifter_index = 0):
64
64
186
31
33
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
calculate_gift_pairs
calculate_gift_pairs
88
106
88
88
fb0e380a4fdd51729fec23bfda0725a5123ac1ef
bigcode/the-stack
train
c299bb041835e6d5bc0494da
train
function
def main(): arg_parser = argparse.ArgumentParser(description='Generates a list of people pairings for a secret santa exchange.') arg_parser.add_argument('file', help='path to the csv containing a list of people for the exchange') arg_parser.add_argument( '-f', '--no-family-match', help='do ...
def main():
arg_parser = argparse.ArgumentParser(description='Generates a list of people pairings for a secret santa exchange.') arg_parser.add_argument('file', help='path to the csv containing a list of people for the exchange') arg_parser.add_argument( '-f', '--no-family-match', help='do not match fa...
import argparse import sys import random import csv import time import boto3 def main():
22
107
358
3
18
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
main
main
8
49
8
8
d3537a5f184cdcf5baaadf5c735c484b77e47fa1
bigcode/the-stack
train
e99c42920a6a28e2f4d8cc99
train
function
def print_audit_log(audit_log_file, matches): with open(audit_log_file, 'w') as audit_file: for giftee, gifter in matches.items(): print('gifter:{} giftee:{}'.format(gifter, giftee), file=audit_file)
def print_audit_log(audit_log_file, matches):
with open(audit_log_file, 'w') as audit_file: for giftee, gifter in matches.items(): print('gifter:{} giftee:{}'.format(gifter, giftee), file=audit_file)
people) sns_client = boto3.client('sns', region_name='us-east-1') send_sms(sns_client, matches, people_by_household, args.dry_run) print_audit_log(args.file + '.audit', matches) def print_audit_log(audit_log_file, matches):
64
64
59
12
52
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
print_audit_log
print_audit_log
51
54
51
51
6b06e96089ddaf5d81bfd8d9a308e94f80144f04
bigcode/the-stack
train
11b41474dbd44d64cf1c4709
train
function
def send_sms(sns_client, matches, people_by_household, dry_run): for giftee, gifter in matches.items(): household_names = None if people_by_household: people_in_household = people_by_household[gifter.family] household_excluding_gifter = list(map(lambda x: str(x), filter(lambd...
def send_sms(sns_client, matches, people_by_household, dry_run):
for giftee, gifter in matches.items(): household_names = None if people_by_household: people_in_household = people_by_household[gifter.family] household_excluding_gifter = list(map(lambda x: str(x), filter(lambda x: x is not gifter, people_in_household))) if house...
ifter, giftee), file=audit_file) def construct_households(people): people_by_household = {} for person in people: if person.family in people_by_household: people_by_household[person.family].append(person) else: people_by_household[person.family] = [person] return peo...
92
92
309
17
74
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
send_sms
send_sms
65
86
65
65
5d0f2f6a75791f9984fe8931e5c3dab2fd135578
bigcode/the-stack
train
bda668b791803c291da494f9
train
function
def construct_households(people): people_by_household = {} for person in people: if person.family in people_by_household: people_by_household[person.family].append(person) else: people_by_household[person.family] = [person] return people_by_household
def construct_households(people):
people_by_household = {} for person in people: if person.family in people_by_household: people_by_household[person.family].append(person) else: people_by_household[person.family] = [person] return people_by_household
_audit_log(audit_log_file, matches): with open(audit_log_file, 'w') as audit_file: for giftee, gifter in matches.items(): print('gifter:{} giftee:{}'.format(gifter, giftee), file=audit_file) def construct_households(people):
64
64
65
7
57
shiift/dickson-secret-santa
dickson_secret_santa/__main__.py
Python
construct_households
construct_households
56
63
56
56
4cc059030a6ff217c1b8a35e2437e4e88d9ef790
bigcode/the-stack
train
ddc6fa445be23cd254c49068
train
function
def generate_keypair(p, q): if not (sympy.isprime(p) and sympy.isprime(q)): raise ValueError('Both numbers must be prime.') elif p == q: raise ValueError('p and q cannot be equal') n = p * q phi = (p-1) * (q-1) e = sympy.randprime(3, phi) g = gcd(e, phi) while g != 1: ...
def generate_keypair(p, q):
if not (sympy.isprime(p) and sympy.isprime(q)): raise ValueError('Both numbers must be prime.') elif p == q: raise ValueError('p and q cannot be equal') n = p * q phi = (p-1) * (q-1) e = sympy.randprime(3, phi) g = gcd(e, phi) while g != 1: e = sympy.randprime(3, p...
a, b = b, a % b return a def multiplicative_inverse(a, b): mult_inv = 3 while (a * mult_inv) % b != 1: mult_inv += 1 return mult_inv def generate_keypair(p, q):
64
64
144
8
55
Savital/IS
lab4/rsa.py
Python
generate_keypair
generate_keypair
19
37
19
19
912f2832a412bddb2d2366ed59cf86c9415f65de
bigcode/the-stack
train
a74f62e2a0205cc57d054e63
train
function
def multiplicative_inverse(a, b): mult_inv = 3 while (a * mult_inv) % b != 1: mult_inv += 1 return mult_inv
def multiplicative_inverse(a, b):
mult_inv = 3 while (a * mult_inv) % b != 1: mult_inv += 1 return mult_inv
import sys, getopt import random from array import array import sympy def gcd(a, b): while b != 0: a, b = b, a % b return a def multiplicative_inverse(a, b):
53
64
41
8
44
Savital/IS
lab4/rsa.py
Python
multiplicative_inverse
multiplicative_inverse
11
17
11
11
5d930d44c37fb99a2dac078a3a3df0b9c44613db
bigcode/the-stack
train
dc4567d190701927e73f966b
train
function
def decrypt(pk, ciphertext): key, n = pk plain = [chr(pow(char, key, n)) for char in ciphertext] return ''.join(plain)
def decrypt(pk, ciphertext):
key, n = pk plain = [chr(pow(char, key, n)) for char in ciphertext] return ''.join(plain)
phi) d = multiplicative_inverse(e, phi) return ((e, n), (d, n)) def encrypt(pk, plaintext): key, n = pk cipher = [pow(ord(char), key, n) for char in plaintext] return cipher def decrypt(pk, ciphertext):
64
64
37
6
57
Savital/IS
lab4/rsa.py
Python
decrypt
decrypt
44
47
44
44
662368d24a6fe90d05137554f99815f1cf333aa8
bigcode/the-stack
train
200c537e28526f2cd88e8ec7
train
function
def bytes_from_file(filename, chunksize=8192): with open(filename, "rb") as f: return f.read()
def bytes_from_file(filename, chunksize=8192):
with open(filename, "rb") as f: return f.read()
(char), key, n) for char in plaintext] return cipher def decrypt(pk, ciphertext): key, n = pk plain = [chr(pow(char, key, n)) for char in ciphertext] return ''.join(plain) def bytes_from_file(filename, chunksize=8192):
64
64
28
12
52
Savital/IS
lab4/rsa.py
Python
bytes_from_file
bytes_from_file
49
51
49
49
200ebd00c33570d40a1d9c47dde17cb4d5aedb8b
bigcode/the-stack
train
fd365b835cea7b51dc593e88
train
function
def encrypt(pk, plaintext): key, n = pk cipher = [pow(ord(char), key, n) for char in plaintext] return cipher
def encrypt(pk, plaintext):
key, n = pk cipher = [pow(ord(char), key, n) for char in plaintext] return cipher
) g = gcd(e, phi) while g != 1: e = sympy.randprime(3, phi) g = gcd(e, phi) d = multiplicative_inverse(e, phi) return ((e, n), (d, n)) def encrypt(pk, plaintext):
64
64
34
6
58
Savital/IS
lab4/rsa.py
Python
encrypt
encrypt
39
42
39
39
eb8987dac081b78f8f94e82678221c28274e846d
bigcode/the-stack
train
6e81a736f34604dd18e7de7b
train
function
def encrypt_and_write(inputfile, outputfile, key): some_str = bytes_from_file(inputfile) decode_str = some_str.decode("latin-1") encrypted_msg = encrypt(key, decode_str) encrypted_msg_str = ','.join([str(x) for x in encrypted_msg]) encode_result = encrypted_msg_str.encode('latin-1') writeToBinar...
def encrypt_and_write(inputfile, outputfile, key):
some_str = bytes_from_file(inputfile) decode_str = some_str.decode("latin-1") encrypted_msg = encrypt(key, decode_str) encrypted_msg_str = ','.join([str(x) for x in encrypted_msg]) encode_result = encrypted_msg_str.encode('latin-1') writeToBinaryFile(outputfile, encode_result)
return f.read() def writeToBinaryFile(path, text): try: with open(path, "wb") as file_handler: file_handler.write(text) return True except IOError: print("Some error") return False def encrypt_and_write(inputfile, outputfile, key):
64
64
86
12
51
Savital/IS
lab4/rsa.py
Python
encrypt_and_write
encrypt_and_write
62
68
62
62
6e8f63f1100f085d4ba2ada91d0a231899c8b10a
bigcode/the-stack
train
faafe3a95db5d73660ceb855
train
function
def generate_primes(a, b): prime1 = prime2 = 0 while prime1 == prime2: prime1 = sympy.randprime(a, b) prime2 = sympy.randprime(a, b) if prime2 < prime1: return prime2, prime1 return prime1, prime2
def generate_primes(a, b):
prime1 = prime2 = 0 while prime1 == prime2: prime1 = sympy.randprime(a, b) prime2 = sympy.randprime(a, b) if prime2 < prime1: return prime2, prime1 return prime1, prime2
_str.decode("latin-1").split(',') decode_str = [int(x) for x in decode_str] encrypted_msg = decrypt(key, decode_str) encode_result = encrypted_msg.encode('latin-1') writeToBinaryFile(outputfile, encode_result) def generate_primes(a, b):
64
64
73
8
56
Savital/IS
lab4/rsa.py
Python
generate_primes
generate_primes
78
87
78
78
d7266e799f6c951bcc5ca60a827be61487903352
bigcode/the-stack
train
c89f0874be486fc5f07203c7
train
function
def gcd(a, b): while b != 0: a, b = b, a % b return a
def gcd(a, b):
while b != 0: a, b = b, a % b return a
import sys, getopt import random from array import array import sympy def gcd(a, b):
23
64
28
6
16
Savital/IS
lab4/rsa.py
Python
gcd
gcd
6
9
6
6
49eb9686e84e497fb5412381346eb0e95c40176f
bigcode/the-stack
train
733a8e5525db7c049c7f7367
train
function
def writeToBinaryFile(path, text): try: with open(path, "wb") as file_handler: file_handler.write(text) return True except IOError: print("Some error") return False
def writeToBinaryFile(path, text):
try: with open(path, "wb") as file_handler: file_handler.write(text) return True except IOError: print("Some error") return False
= pk plain = [chr(pow(char, key, n)) for char in ciphertext] return ''.join(plain) def bytes_from_file(filename, chunksize=8192): with open(filename, "rb") as f: return f.read() def writeToBinaryFile(path, text):
64
64
48
9
55
Savital/IS
lab4/rsa.py
Python
writeToBinaryFile
writeToBinaryFile
53
60
53
53
db55c75b12832202bbebe7e16f23603d1b40c321
bigcode/the-stack
train
9a6a7c7054b75f891b91d0b5
train
function
def decrypt_and_write(inputfile, outputfile, key): some_str = bytes_from_file(inputfile) decode_str = some_str.decode("latin-1").split(',') decode_str = [int(x) for x in decode_str] encrypted_msg = decrypt(key, decode_str) encode_result = encrypted_msg.encode('latin-1') writeToBinaryFile(outputf...
def decrypt_and_write(inputfile, outputfile, key):
some_str = bytes_from_file(inputfile) decode_str = some_str.decode("latin-1").split(',') decode_str = [int(x) for x in decode_str] encrypted_msg = decrypt(key, decode_str) encode_result = encrypted_msg.encode('latin-1') writeToBinaryFile(outputfile, encode_result)
encrypted_msg = encrypt(key, decode_str) encrypted_msg_str = ','.join([str(x) for x in encrypted_msg]) encode_result = encrypted_msg_str.encode('latin-1') writeToBinaryFile(outputfile, encode_result) def decrypt_and_write(inputfile, outputfile, key):
64
64
83
12
52
Savital/IS
lab4/rsa.py
Python
decrypt_and_write
decrypt_and_write
70
76
70
70
9f9ce91b98356b28382b1247d3e26a01c002d88c
bigcode/the-stack
train
a5fa3e1fef677a28c43c5625
train
function
def get_text(driver: object, xpath: str, timeout: int = timeout.DEFAULT) -> str: def get_inner_text_of_element(driver: object, xpath: str) -> str: return driver.find_element(By.XPATH, xpath).text # type: ignore xpath = XPath(xpath) wait_for_element(driver, xpath, timeout) return helper.retry.g...
def get_text(driver: object, xpath: str, timeout: int = timeout.DEFAULT) -> str:
def get_inner_text_of_element(driver: object, xpath: str) -> str: return driver.find_element(By.XPATH, xpath).text # type: ignore xpath = XPath(xpath) wait_for_element(driver, xpath, timeout) return helper.retry.get_text(driver, xpath, get_inner_text_of_element)
from selenium.webdriver.common.by import By from ... import helper from ...constant import timeout from ...model.type.xpath import XPath from ..wait.for_element import wait_for_element def get_text(driver: object, xpath: str, timeout: int = timeout.DEFAULT) -> str:
58
64
88
21
36
jakob-bagterp/browserist
src/browserist/browser/get/text.py
Python
get_text
get_text
9
15
9
9
62e07bfa172b5817efb087c4b2fa30a4ff09ae59
bigcode/the-stack
train
12e2c14c14fb0195adcaa9d8
train
function
def randomStory(update, context): update.message.reply_text(random.choice(msg))
def randomStory(update, context):
update.message.reply_text(random.choice(msg))
from telegram.ext import Dispatcher,CommandHandler import random story = [ "" ] def randomStory(update, context):
25
64
16
7
18
Claireyao123/MyFirstBot
madlip.py
Python
randomStory
randomStory
8
9
8
8
73c921d5ce8dd1a9e1a3cf37bc2c92c86b937680
bigcode/the-stack
train
bbde2e7fd0017c1d818cb2fd
train
function
def add_handler(dp:Dispatcher): story_handler = CommandHandler('madlib', randomStory) dp.add_handler(story_handler)
def add_handler(dp:Dispatcher):
story_handler = CommandHandler('madlib', randomStory) dp.add_handler(story_handler)
from telegram.ext import Dispatcher,CommandHandler import random story = [ "" ] def randomStory(update, context): update.message.reply_text(random.choice(msg)) def add_handler(dp:Dispatcher):
41
64
28
7
34
Claireyao123/MyFirstBot
madlip.py
Python
add_handler
add_handler
11
13
11
11
74284ad00b7a58a5d24e3fe0c9263391aba20eec
bigcode/the-stack
train
c2f9ece04364f542837d9041
train
class
class BaseResponseHandler: """Parses the response according to the strategy set.""" @staticmethod def get_request_data(response: Response): raise NotImplementedError
class BaseResponseHandler:
"""Parses the response according to the strategy set.""" @staticmethod def get_request_data(response: Response): raise NotImplementedError
from json import JSONDecodeError from typing import Optional from xml.etree import ElementTree import requests from apiclient.exceptions import ResponseParseError from apiclient.response import Response from apiclient.utils.typing import JsonType, XmlType class BaseResponseHandler:
60
64
36
5
54
mom1/api-client
apiclient/response_handlers.py
Python
BaseResponseHandler
BaseResponseHandler
12
17
12
12
ad5e7d5fc61bb440fb661171547b119e6213e0f4
bigcode/the-stack
train
b8ff3407c27890f54a5968da
train
class
class JsonResponseHandler(BaseResponseHandler): """Attempt to return the decoded response data as json.""" @staticmethod def get_request_data(response: Response) -> Optional[JsonType]: if response.get_raw_data() == "": return None try: response_json = response.get_j...
class JsonResponseHandler(BaseResponseHandler):
"""Attempt to return the decoded response data as json.""" @staticmethod def get_request_data(response: Response) -> Optional[JsonType]: if response.get_raw_data() == "": return None try: response_json = response.get_json() except JSONDecodeError as error: ...
staticmethod def get_request_data(response: Response): raise NotImplementedError class RequestsResponseHandler(BaseResponseHandler): """Return the original requests response.""" @staticmethod def get_request_data(response: Response) -> requests.Response: return response.get_original()...
64
64
107
8
56
mom1/api-client
apiclient/response_handlers.py
Python
JsonResponseHandler
JsonResponseHandler
28
42
28
28
fe63292690df990916907463d5b994c6fbd576ca
bigcode/the-stack
train
a248c4ea079ffd88e8690b4d
train
class
class XmlResponseHandler(BaseResponseHandler): """Attempt to return the decoded response to an xml Element.""" @staticmethod def get_request_data(response: Response) -> Optional[XmlType]: if response.get_raw_data() == "": return None try: xml_element = ElementTree.f...
class XmlResponseHandler(BaseResponseHandler):
"""Attempt to return the decoded response to an xml Element.""" @staticmethod def get_request_data(response: Response) -> Optional[XmlType]: if response.get_raw_data() == "": return None try: xml_element = ElementTree.fromstring(response.get_raw_data()) exce...
try: response_json = response.get_json() except JSONDecodeError as error: raise ResponseParseError( f"Unable to decode response data to json. data='{response.get_raw_data()}'" ) from error return response_json class XmlResponseHandler(BaseRes...
64
64
114
8
55
mom1/api-client
apiclient/response_handlers.py
Python
XmlResponseHandler
XmlResponseHandler
45
59
45
45
1bf3b7150a99194eaa47e156301586fde1143757
bigcode/the-stack
train
d08632e6ef5783ee19c0781d
train
class
class RequestsResponseHandler(BaseResponseHandler): """Return the original requests response.""" @staticmethod def get_request_data(response: Response) -> requests.Response: return response.get_original()
class RequestsResponseHandler(BaseResponseHandler):
"""Return the original requests response.""" @staticmethod def get_request_data(response: Response) -> requests.Response: return response.get_original()
iclient.response import Response from apiclient.utils.typing import JsonType, XmlType class BaseResponseHandler: """Parses the response according to the strategy set.""" @staticmethod def get_request_data(response: Response): raise NotImplementedError class RequestsResponseHandler(BaseResponseHan...
64
64
39
8
55
mom1/api-client
apiclient/response_handlers.py
Python
RequestsResponseHandler
RequestsResponseHandler
20
25
20
20
5996f02c52ceab48fb841ccf36eb4e460416abd9
bigcode/the-stack
train
e1837aee3d8936c81cb4a363
train
class
class BlackJackState(GameState): ''' Contains deck info for playing blackjack ''' def __init__(self): GameState.__init__(self) self.deck: Deck = Deck() self.dealerCards: List[CardData] = [] self.playerCards: List[CardData] = [] self.playerCardTota...
class BlackJackState(GameState):
''' Contains deck info for playing blackjack ''' def __init__(self): GameState.__init__(self) self.deck: Deck = Deck() self.dealerCards: List[CardData] = [] self.playerCards: List[CardData] = [] self.playerCardTotal: int = 0 self.dealerCar...
# Copyright Clayton Brown 2019. See LICENSE file. from gent import GameState from typing import List from .deck import CardData, Deck class BlackJackState(GameState):
39
160
534
7
31
flywinged/TGL
examples/Blackjack/state/gameState.py
Python
BlackJackState
BlackJackState
9
97
9
9
e768be5412d5dc26315dc92ae0a256ee54e9b499
bigcode/the-stack
train
040bf35a35d9daf872a34991
train
class
class ChatThreadClientTestAsync(AsyncCommunicationTestCase): def setUp(self): super(ChatThreadClientTestAsync, self).setUp() self.recording_processors.extend([ BodyReplacerProcessor(keys=["id", "token", "senderId", "chatMessageId", "nextLink", "participants", "multipleStatus", "value"])...
class ChatThreadClientTestAsync(AsyncCommunicationTestCase):
def setUp(self): super(ChatThreadClientTestAsync, self).setUp() self.recording_processors.extend([ BodyReplacerProcessor(keys=["id", "token", "senderId", "chatMessageId", "nextLink", "participants", "multipleStatus", "value"]), URIIdentityReplacer(), ResponseRepl...
# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- import pyt...
216
256
2,769
12
203
mohamedshabanofficial/azure-sdk-for-python
sdk/communication/azure-communication-chat/tests/test_chat_thread_client_e2e_async.py
Python
ChatThreadClientTestAsync
ChatThreadClientTestAsync
30
408
30
30
03474ccad5e17a2f1aeb3973d605da28d7d305fe
bigcode/the-stack
train
5d164b4241fa3ff4c95d1772
train
function
def test(): anp = np.random.randn(4, 5) b = random.randint(1, 13) a = num.array(anp) # test with scalar on the rhs assert np.array_equal(num.less_equal(a, b), np.less_equal(anp, b)) # test with scalar on the lhs assert np.array_equal(num.less_equal(b, a), np.less_equal(b, anp)) return...
def test():
anp = np.random.randn(4, 5) b = random.randint(1, 13) a = num.array(anp) # test with scalar on the rhs assert np.array_equal(num.less_equal(a, b), np.less_equal(anp, b)) # test with scalar on the lhs assert np.array_equal(num.less_equal(b, a), np.less_equal(b, anp)) return
distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # import random import numpy as np import cunumeric as num def test():
64
64
96
3
60
bryevdv/cunumeric
tests/universal_functions_tests/less_equal_tests/broadcast.py
Python
test
test
23
34
23
23
06429e67c77a70c8275fd52d14361c518710491c
bigcode/the-stack
train
a53b0e626de9b878c53692ee
train
class
class SparsePauliOp(LinearOp): """Sparse N-qubit operator in a Pauli basis representation. This is a sparse representation of an N-qubit matrix :class:`~qiskit.quantum_info.Operator` in terms of N-qubit :class:`~qiskit.quantum_info.PauliTable` and complex coefficients. It can be used for performin...
class SparsePauliOp(LinearOp):
"""Sparse N-qubit operator in a Pauli basis representation. This is a sparse representation of an N-qubit matrix :class:`~qiskit.quantum_info.Operator` in terms of N-qubit :class:`~qiskit.quantum_info.PauliTable` and complex coefficients. It can be used for performing operator arithmetic for hundr...
part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative works of t...
256
256
3,994
9
246
gadial/qiskit-terra
qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py
Python
SparsePauliOp
SparsePauliOp
28
489
28
28
d373044da11db0632c26689fe4e7d4d10fd9f9f9
bigcode/the-stack
train
4249f39583fa7436e274f5ae
train
function
def includeme(config): config.register_service_factory( OIDCProviderServiceFactory( provider="github", issuer_url="https://token.actions.githubusercontent.com" ), IOIDCProviderService, name="github", )
def includeme(config):
config.register_service_factory( OIDCProviderServiceFactory( provider="github", issuer_url="https://token.actions.githubusercontent.com" ), IOIDCProviderService, name="github", )
BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from warehouse.oidc.interfaces import IOIDCProviderService from warehouse.oidc.services import OIDCProviderServiceFactory def include...
64
64
48
5
58
pradyunsg/warehouse
warehouse/oidc/__init__.py
Python
includeme
includeme
17
24
17
17
5eca2590e82bd288a861cc3547da4e48c99a0e4f
bigcode/the-stack
train
30214af2b7fab21a6adcd3d1
train
class
class Transposition: """A pitch transposition represented as an interval""" def __init__(self, interval): """ Args: interval (Interval or str representation): """ self.interval = (interval if isinstance(interval, Interval) else Interval(inte...
class Transposition:
"""A pitch transposition represented as an interval""" def __init__(self, interval): """ Args: interval (Interval or str representation): """ self.interval = (interval if isinstance(interval, Interval) else Interval(interval))
from brown.models.interval import Interval class Transposition:
11
64
56
4
6
craigvear/school_improv_bot
brown/models/transposition.py
Python
Transposition
Transposition
4
14
4
5
bf2eab93de28d3b2f31477f8ecab17cc79fc4b47
bigcode/the-stack
train
32bfa47db8d313e0975e12d9
train
class
class Yandex(Geocoder): # pylint: disable=W0223 """ Yandex geocoder, documentation at: http://api.yandex.com/maps/doc/geocoder/desc/concepts/input_params.xml """ def __init__( self, api_key=None, lang=None, timeout=DEFAULT_TIMEOUT, pro...
class Yandex(Geocoder): # pylint: disable=W0223
""" Yandex geocoder, documentation at: http://api.yandex.com/maps/doc/geocoder/desc/concepts/input_params.xml """ def __init__( self, api_key=None, lang=None, timeout=DEFAULT_TIMEOUT, proxies=None ): """ Create ...
""" :class:`Yandex` geocoder. """ from geopy.compat import urlencode from geopy.geocoders.base import Geocoder, DEFAULT_TIMEOUT from geopy.location import Location from geopy.exc import ( GeocoderServiceError, GeocoderParseError ) from geopy.util import logger __all__ = ("Yandex", ) class Yandex(Geocoder): ...
89
256
1,099
15
74
mwtoews/geopy
geopy/geocoders/yandex.py
Python
Yandex
Yandex
19
164
19
19
c6f067d64d005a77cc6a25caa211d65823c35707
bigcode/the-stack
train
6f9506d157093a2b3d3225dd
train
function
def get_version_from_spec(): this_dir = os.path.dirname(__file__) with open(os.path.join(this_dir, 'sesdev.spec'), 'r') as file: while True: line = file.readline() if not line: return 'unknown' m = re.match(r'^Version:\s+(\d.*)', line) if m...
def get_version_from_spec():
this_dir = os.path.dirname(__file__) with open(os.path.join(this_dir, 'sesdev.spec'), 'r') as file: while True: line = file.readline() if not line: return 'unknown' m = re.match(r'^Version:\s+(\d.*)', line) if m: return m[1]...
# -*- coding: utf-8 -*- from setuptools import setup import os import re def get_version_from_spec():
25
64
83
6
18
p-se/sesdev
setup.py
Python
get_version_from_spec
get_version_from_spec
8
17
8
8
e7be05af7368f3e03845f2cd23c684554d9089fd
bigcode/the-stack
train
4b98df34e9dc2a8562c9b4bd
train
class
class TestExceptions(unittest.TestCase): def test_ApexCompilationException_str(self): err = exceptions.ApexCompilationException(42, "Too many braces") self.assertEqual( "Apex compilation failed on line 42: Too many braces", str(err) ) def test_ApexException(self): er...
class TestExceptions(unittest.TestCase):
def test_ApexCompilationException_str(self): err = exceptions.ApexCompilationException(42, "Too many braces") self.assertEqual( "Apex compilation failed on line 42: Too many braces", str(err) ) def test_ApexException(self): err = exceptions.ApexException("Things got ...
import unittest from cumulusci.core import exceptions class TestExceptions(unittest.TestCase):
18
64
116
7
10
jdominiczak/CumulusCI
cumulusci/core/tests/test_exceptions.py
Python
TestExceptions
TestExceptions
6
17
6
6
163c3a64c9c97bfdbfca9f46016324f099cef014
bigcode/the-stack
train
3408df4379780c1744cea440
train
class
class Network(nn.Module): def __init__(self, in_feats, out_feats, n_layers): super().__init__() self.linear = nn.Linear(in_feats, out_feats) self.n_layers = n_layers def forward(self, a, x): z = self.linear(x) for i in range(self.n_layers): z = th.spmm(a, z) ...
class Network(nn.Module):
def __init__(self, in_feats, out_feats, n_layers): super().__init__() self.linear = nn.Linear(in_feats, out_feats) self.n_layers = n_layers def forward(self, a, x): z = self.linear(x) for i in range(self.n_layers): z = th.spmm(a, z) return z
import argparse import torch as th import torch.nn as nn import utils parser = argparse.ArgumentParser() parser.add_argument('--n-layers', type=int) Parse = utils.Parse(parser) class Network(nn.Module):
45
64
85
5
40
GaiYu0/clustering
sgc.py
Python
Network
Network
12
22
12
12
f5db2d079e3f8dfd90b37a14d014ea85042e3d69
bigcode/the-stack
train
959604ef6da5a337590a42af
train
function
def train(x, **params): epochs = params['epochs'] lr = params['lr'] lamb = params['lamb'] loss_np = [] eae = EAE() optimizer = torch.optim.Adam(eae.parameters(), lr=lr) for i in range(epochs): z, x_hat = eae.forward(x) log_det_j = log_det_jacobian(x, z) rec = mse...
def train(x, **params):
epochs = params['epochs'] lr = params['lr'] lamb = params['lamb'] loss_np = [] eae = EAE() optimizer = torch.optim.Adam(eae.parameters(), lr=lr) for i in range(epochs): z, x_hat = eae.forward(x) log_det_j = log_det_jacobian(x, z) rec = mse_loss(x, x_hat) ...
(torch.cat([x1_hat, z2], dim=1)) x_hat = torch.cat([x1_hat, x2_hat], dim=1) z = torch.cat([z1, z2], dim=1) return z, x_hat def train(x, **params):
64
64
172
7
56
tyuioahxvm/EAE
EAE.py
Python
train
train
64
87
64
64
857023273f784148349e0155e7737e8ef0ad3f74
bigcode/the-stack
train
2e858fa429b344d74527ce57
train
class
class EAE(nn.Module): def __init__(self): super(EAE, self).__init__() nh = 5 self.encoder = nn.Sequential( nn.Linear(2, nh), nn.ELU(), nn.Linear(nh, 2), nn.ELU() ) self.phi1 = nn.Sequential( nn.Linear(1, nh), ...
class EAE(nn.Module):
def __init__(self): super(EAE, self).__init__() nh = 5 self.encoder = nn.Sequential( nn.Linear(2, nh), nn.ELU(), nn.Linear(nh, 2), nn.ELU() ) self.phi1 = nn.Sequential( nn.Linear(1, nh), nn.ELU(), ...
import torch import torch.nn.functional as F import torch.nn as nn import numpy as np from torch.nn.functional import mse_loss from utils import log_det_jacobian, compute_jacobian, jacobian import matplotlib.pyplot as plt EPS = 1e-8 class EAE(nn.Module):
66
122
407
6
59
tyuioahxvm/EAE
EAE.py
Python
EAE
EAE
12
62
12
12
3c20de9626e789aab5c1e0187008e7d8101867f5
bigcode/the-stack
train
ef52c06dbd53e3d72353afe5
train
function
def make_valid_filename(s): valid_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-' return ''.join(c for c in s if c in valid_chars)
def make_valid_filename(s):
valid_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-' return ''.join(c for c in s if c in valid_chars)
build_dir]) return subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=build_dir).decode('utf-8') def get_project_name(build_dir): info = json.loads(mesonintrospect(['--projectinfo'], build_dir)) return info['name'] def make_valid_filename(s):
64
64
34
6
58
simevo/meson2ide
meson2ide.py
Python
make_valid_filename
make_valid_filename
123
125
123
123
ff58e9cae692ef209a75d0132abc9828a5d0d82b
bigcode/the-stack
train
c6917ee133e30cec1116563f
train
function
def generator_qtcreator(build_dir, src_dir): # Read the compile database. file_db = load_compile_db(os.path.join(build_dir, 'compile_commands.json')) project_name = make_valid_filename(get_project_name(build_dir)) # Generate the .creator file. creator_file = os.path.join(build_dir, project_name + ...
def generator_qtcreator(build_dir, src_dir): # Read the compile database.
file_db = load_compile_db(os.path.join(build_dir, 'compile_commands.json')) project_name = make_valid_filename(get_project_name(build_dir)) # Generate the .creator file. creator_file = os.path.join(build_dir, project_name + '.creator') with open(creator_file, 'w') as file: file.write('[Gen...
) args.extend([build_dir]) return subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=build_dir).decode('utf-8') def get_project_name(build_dir): info = json.loads(mesonintrospect(['--projectinfo'], build_dir)) return info['name'] def make_valid_filename(s): valid_chars = 'abcdefghijklmn...
115
115
386
18
97
simevo/meson2ide
meson2ide.py
Python
generator_qtcreator
generator_qtcreator
128
170
128
129
19b95467b8efab029d8a5ced42ed3f7e0c77c8d7
bigcode/the-stack
train
5fed4ca1a081281f48f54817
train
function
def is_build_dir(dir): return os.path.isfile(os.path.join(dir, 'build.ninja')) and os.path.isfile(os.path.join(dir, 'compile_commands.json'))
def is_build_dir(dir):
return os.path.isfile(os.path.join(dir, 'build.ninja')) and os.path.isfile(os.path.join(dir, 'compile_commands.json'))
))) with open(includes_file, 'w') as file: for item in includes: file.write(os.path.relpath(item, build_dir) + '\n') def is_src_dir(dir): return os.path.isfile(os.path.join(dir, 'meson.build')) def is_build_dir(dir):
63
64
35
6
57
simevo/meson2ide
meson2ide.py
Python
is_build_dir
is_build_dir
177
178
177
177
5c818d4dd79f9b9603136665b795d9f413143fa8
bigcode/the-stack
train
be1ba637865ea3e5e724e692
train
function
def load_compile_db(file_name): with open(file_name, 'r') as file: db_json = json.loads(file.read()) file_db = [] found_headers = set() for item in db_json: # Get the directory for this compile unit (all paths are releative to this dir). dir = item['directory'] # Get the...
def load_compile_db(file_name):
with open(file_name, 'r') as file: db_json = json.loads(file.read()) file_db = [] found_headers = set() for item in db_json: # Get the directory for this compile unit (all paths are releative to this dir). dir = item['directory'] # Get the include dirs and defines for th...
e: print("FAIL :%s\n" % e.output.decode('utf-8')) return [] def collect_header_files(cmd, dir): # Collect all included header files for this complie unit. # TODO(m): Here we assume that we're running a compiler that understands GCC options. header_files = gcc_get_included_files(cmd, dir) ...
88
88
295
7
80
simevo/meson2ide
meson2ide.py
Python
load_compile_db
load_compile_db
73
99
73
73
8acaa0c59b045c1558ae904e7f55cbb758b1a992
bigcode/the-stack
train
732d73359e8f5776f37d77de
train
function
def collect_meson_files(src_dir): meson_files = [] for root, dir_names, file_names in os.walk(src_dir): for file_name in file_names: if file_name == 'meson.build': meson_files.append(os.path.abspath(os.path.join(root, file_name))) return meson_files
def collect_meson_files(src_dir):
meson_files = [] for root, dir_names, file_names in os.walk(src_dir): for file_name in file_names: if file_name == 'meson.build': meson_files.append(os.path.abspath(os.path.join(root, file_name))) return meson_files
and so we will not know other include dirs/defines combinations for this # header file. Maybe we should do a union of sorts? file_db.append({'src': header_file, 'include_dirs': include_dirs, 'defines': defines}) return file_db def collect_meson_files(src_dir):
64
64
69
8
55
simevo/meson2ide
meson2ide.py
Python
collect_meson_files
collect_meson_files
102
108
102
102
8dff53e7ce84dd0a6124d137aa500cb17105ee05
bigcode/the-stack
train
21d0d36840122526f9db8d95
train
function
def gcc_get_included_files(cmd, dir): opts = shlex.split(cmd) for i in range(len(opts) - 1, 0, -1): opt = opts[i].strip() if opt == '': # Drop empty items. opts.pop(i) if opt == '-c': # We only do the preprocessing step. opts[i] = '-E' ...
def gcc_get_included_files(cmd, dir):
opts = shlex.split(cmd) for i in range(len(opts) - 1, 0, -1): opt = opts[i].strip() if opt == '': # Drop empty items. opts.pop(i) if opt == '-c': # We only do the preprocessing step. opts[i] = '-E' elif opt == '-o' and (i + 1) < len...
import os import re import shlex import subprocess def parse_compile_command(cmd, dir): opts = shlex.split(cmd) includes = [] defines = [] for opt in opts: # TODO(m): Add support for more compilers (this is GCC/clang syntax). if opt.startswith('-I'): includes.append(os.path...
119
119
398
10
109
simevo/meson2ide
meson2ide.py
Python
gcc_get_included_files
gcc_get_included_files
24
63
24
24
35291710d6cab20eb56e88a1eeae3b297875a729
bigcode/the-stack
train
144961f601687435febb45e4
train
function
def main(): parser = argparse.ArgumentParser(description='Generate IDE projects from Meson.') parser.add_argument('path', metavar='PATH', help='source or build path') args = parser.parse_args() # Determine source and build folders. if is_src_dir(args.path): src_dir = args.path build...
def main():
parser = argparse.ArgumentParser(description='Generate IDE projects from Meson.') parser.add_argument('path', metavar='PATH', help='source or build path') args = parser.parse_args() # Determine source and build folders. if is_src_dir(args.path): src_dir = args.path build_dir = os.ge...
'\n') def is_src_dir(dir): return os.path.isfile(os.path.join(dir, 'meson.build')) def is_build_dir(dir): return os.path.isfile(os.path.join(dir, 'build.ninja')) and os.path.isfile(os.path.join(dir, 'compile_commands.json')) def main():
63
64
168
3
60
simevo/meson2ide
meson2ide.py
Python
main
main
181
199
181
181
ba4a8d59225b30270d23b6e80585fec9ff9b9325
bigcode/the-stack
train
00e7695974b5c70069b51a3e
train
function
def parse_compile_command(cmd, dir): opts = shlex.split(cmd) includes = [] defines = [] for opt in opts: # TODO(m): Add support for more compilers (this is GCC/clang syntax). if opt.startswith('-I'): includes.append(os.path.abspath(os.path.join(dir, opt[2:].strip()))) ...
def parse_compile_command(cmd, dir):
opts = shlex.split(cmd) includes = [] defines = [] for opt in opts: # TODO(m): Add support for more compilers (this is GCC/clang syntax). if opt.startswith('-I'): includes.append(os.path.abspath(os.path.join(dir, opt[2:].strip()))) elif opt.startswith('-D'): ...
#!/usr/bin/env python3 import argparse import json import os import re import shlex import subprocess def parse_compile_command(cmd, dir):
34
64
96
8
25
simevo/meson2ide
meson2ide.py
Python
parse_compile_command
parse_compile_command
10
21
10
10
706e572b9e0cfa8ed388f03c161504bbfbe32fe5
bigcode/the-stack
train
f62f0077f7c9ed00ad98795b
train
function
def mesonintrospect(commands, build_dir): args = ['/usr/bin/mesonintrospect'] args.extend(commands) args.extend([build_dir]) return subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=build_dir).decode('utf-8')
def mesonintrospect(commands, build_dir):
args = ['/usr/bin/mesonintrospect'] args.extend(commands) args.extend([build_dir]) return subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=build_dir).decode('utf-8')
root, dir_names, file_names in os.walk(src_dir): for file_name in file_names: if file_name == 'meson.build': meson_files.append(os.path.abspath(os.path.join(root, file_name))) return meson_files def mesonintrospect(commands, build_dir):
64
64
60
11
52
simevo/meson2ide
meson2ide.py
Python
mesonintrospect
mesonintrospect
111
115
111
111
43f4fd657cae805a10f68a9b77ebd61292288741
bigcode/the-stack
train
99e7f3e3396fada0a3dd0670
train
function
def get_project_name(build_dir): info = json.loads(mesonintrospect(['--projectinfo'], build_dir)) return info['name']
def get_project_name(build_dir):
info = json.loads(mesonintrospect(['--projectinfo'], build_dir)) return info['name']
introspect(commands, build_dir): args = ['/usr/bin/mesonintrospect'] args.extend(commands) args.extend([build_dir]) return subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=build_dir).decode('utf-8') def get_project_name(build_dir):
64
64
31
7
57
simevo/meson2ide
meson2ide.py
Python
get_project_name
get_project_name
118
120
118
118
06fefb846735a70a07241ed5bd7e03b0ad5ddefb
bigcode/the-stack
train
cac500808324ee3934b21ceb
train
function
def collect_header_files(cmd, dir): # Collect all included header files for this complie unit. # TODO(m): Here we assume that we're running a compiler that understands GCC options. header_files = gcc_get_included_files(cmd, dir) return header_files
def collect_header_files(cmd, dir): # Collect all included header files for this complie unit. # TODO(m): Here we assume that we're running a compiler that understands GCC options.
header_files = gcc_get_included_files(cmd, dir) return header_files
as e: print("FAIL :%s\n" % e.output.decode('utf-8')) return [] def collect_header_files(cmd, dir): # Collect all included header files for this complie unit. # TODO(m): Here we assume that we're running a compiler that understands GCC options.
63
64
57
39
24
simevo/meson2ide
meson2ide.py
Python
collect_header_files
collect_header_files
66
70
66
68
a990bc2d69c49058f81cb40d165efb3c1f595c69
bigcode/the-stack
train
699774248028699685b2eb42
train
function
def is_src_dir(dir): return os.path.isfile(os.path.join(dir, 'meson.build'))
def is_src_dir(dir):
return os.path.isfile(os.path.join(dir, 'meson.build'))
for item in file_db: includes.extend(item['include_dirs']) includes = sorted(list(set(includes))) with open(includes_file, 'w') as file: for item in includes: file.write(os.path.relpath(item, build_dir) + '\n') def is_src_dir(dir):
64
64
21
6
58
simevo/meson2ide
meson2ide.py
Python
is_src_dir
is_src_dir
173
174
173
173
9a8db8c2e96d29e3047c21735535ebaea4904eba
bigcode/the-stack
train
8a50f8de8f6258f6dc824f72
train
function
def test_update_to_null_valid(client, pg_driver, cgci_blgsp, submitter): """ Test that updating a non required field to null works correctly """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects":...
def test_update_to_null_valid(client, pg_driver, cgci_blgsp, submitter):
""" Test that updating a non required field to null works correctly """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, "experimenta...
, sorted(data.keys()), delimiter="\t") dw.writeheader() dw.writerow(data) # read the TSV data data = None with open(file_path, "r") as f: data = f.read() os.remove(file_path) # clean up (delete file) assert data headers = submitter headers["Content-Type"] = "text/t...
151
151
505
20
130
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_update_to_null_valid
test_update_to_null_valid
1,178
1,232
1,178
1,178
9bd2f3920b50f008607abb7c8c7f7d312e19ba39
bigcode/the-stack
train
8065bd0a06a7c0b9f0afd34f
train
function
def test_timestamps(client, pg_driver, cgci_blgsp, submitter): test_post_example_entities(client, pg_driver, cgci_blgsp, submitter) with pg_driver.session_scope(): case = pg_driver.nodes(md.Case).first() ct = case.created_datetime print(case.props) assert ct is not None, case.pro...
def test_timestamps(client, pg_driver, cgci_blgsp, submitter):
test_post_example_entities(client, pg_driver, cgci_blgsp, submitter) with pg_driver.session_scope(): case = pg_driver.nodes(md.Case).first() ct = case.created_datetime print(case.props) assert ct is not None, case.props
assert "BLGSP-71-experiment-01" in str_data assert "BLGSP-71-experiment-02" in str_data assert "experiments.submitter_id" in str_data def test_timestamps(client, pg_driver, cgci_blgsp, submitter):
64
64
78
18
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_timestamps
test_timestamps
476
482
476
476
2bc50ce82e3299b9ccecdb8e11933761d749b821
bigcode/the-stack
train
72a22e7d3f789af0e0ab9de2
train
function
def get_export_data(client, submitter, node_type, format_type, without_id): path = "/v0/submission/CGCI/BLGSP/export/?node_label={}&format={}".format( node_type, format_type ) if without_id: path += "&without_id=True" r = client.get(path, headers=submitter) return r
def get_export_data(client, submitter, node_type, format_type, without_id):
path = "/v0/submission/CGCI/BLGSP/export/?node_label={}&format={}".format( node_type, format_type ) if without_id: path += "&without_id=True" r = client.get(path, headers=submitter) return r
("\n")) == experimental_metadata_count + 1 return str_data else: js_data = json.loads(r.data) assert len(js_data["data"]) == experimental_metadata_count return js_data def get_export_data(client, submitter, node_type, format_type, without_id):
64
64
82
18
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
get_export_data
get_export_data
858
865
858
858
0d9025c4ef9532a43eb7653ff64dc6dff371072c
bigcode/the-stack
train
f03e1dc36bd1edae80334e1a
train
function
def put_tcga_brca(client, submitter): headers = submitter data = json.dumps( { "name": "TCGA", "type": "program", "dbgap_accession_number": "phs000178", } ) r = client.put("/v0/submission/", headers=headers, data=data) assert r.status_code == 200, ...
def put_tcga_brca(client, submitter):
headers = submitter data = json.dumps( { "name": "TCGA", "type": "program", "dbgap_accession_number": "phs000178", } ) r = client.put("/v0/submission/", headers=headers, data=data) assert r.status_code == 200, r.data headers = submitter dat...
ymphoma Genome Sequencing Project", "state": "open", } ) r = client.put(path, headers=headers, data=data) assert r.status_code == 200, r.data del g.user return r def put_tcga_brca(client, submitter):
64
64
190
12
51
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
put_tcga_brca
put_tcga_brca
97
121
97
97
9255725bf3bae83207cb4c47e056ff54113f45aa
bigcode/the-stack
train
d609bf2da031eab2d54e14c0
train
function
def test_insert_multiple_parents_and_export_by_ids( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): post_example_entities_together(client, submitter) path = BLGSP_PATH with open(os.path.join(DATA_DIR, "experimental_metadata.tsv"), "r") as f: headers = submitter head...
def test_insert_multiple_parents_and_export_by_ids( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
post_example_entities_together(client, submitter) path = BLGSP_PATH with open(os.path.join(DATA_DIR, "experimental_metadata.tsv"), "r") as f: headers = submitter headers["Content-Type"] = "text/tsv" resp = client.post(path, headers=headers, data=f.read()) assert resp.status_c...
assert resp_json["created_entity_count"] == 0 assert resp_json["entities"][0]["errors"][0]["type"] == "INVALID_PERMISSIONS" def test_insert_multiple_parents_and_export_by_ids( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
67
67
226
32
35
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_insert_multiple_parents_and_export_by_ids
test_insert_multiple_parents_and_export_by_ids
454
473
454
456
c5d25c062eb389ac5d789b3e8e345a2e05267929
bigcode/the-stack
train
29cb4de46000aff5a04fb6a6
train
function
def test_disallow_cross_project_references(client, pg_driver, cgci_blgsp, submitter): put_tcga_brca(client, submitter) data = { "progression_or_recurrence": "unknown", "classification_of_tumor": "other", "last_known_disease_status": "Unknown tumor status", "tumor_grade": "", ...
def test_disallow_cross_project_references(client, pg_driver, cgci_blgsp, submitter):
put_tcga_brca(client, submitter) data = { "progression_or_recurrence": "unknown", "classification_of_tumor": "other", "last_known_disease_status": "Unknown tumor status", "tumor_grade": "", "tissue_or_organ_of_origin": "c34.3", "days_to_last_follow_up": -1.0, ...
_timestamps(client, pg_driver, cgci_blgsp, submitter): test_post_example_entities(client, pg_driver, cgci_blgsp, submitter) with pg_driver.session_scope(): case = pg_driver.nodes(md.Case).first() ct = case.created_datetime print(case.props) assert ct is not None, case.props def t...
98
98
328
22
75
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_disallow_cross_project_references
test_disallow_cross_project_references
485
509
485
485
0f538b33dca720620283b1d38ad85c234e58e0f6
bigcode/the-stack
train
376cdfbe95582acf6551a7eb
train
function
def test_program_creation_endpoint(client, pg_driver, submitter): # Does not test authz. resp = put_cgci(client, auth=submitter) assert resp.status_code == 200, resp.data print(resp.data) resp = client.get("/v0/submission/") condition_to_check = "/v0/submission/CGCI" in resp.json["links"] and re...
def test_program_creation_endpoint(client, pg_driver, submitter): # Does not test authz.
resp = put_cgci(client, auth=submitter) assert resp.status_code == 200, resp.data print(resp.data) resp = client.get("/v0/submission/") condition_to_check = "/v0/submission/CGCI" in resp.json["links"] and resp.json assert condition_to_check, resp.json
new_experimental_metadata.submitter_id = "case-2" s.add(new_experimental_metadata) experimental_metadata_count = pg_driver.nodes(md.ExperimentalMetadata).count() return experimental_metadata_count def test_program_creation_endpoint(client, pg_driver, submitter): # Does not test authz.
64
64
96
21
42
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_program_creation_endpoint
test_program_creation_endpoint
135
142
135
136
c41ae90d80587febefad0e36fbf0a831b187edd6
bigcode/the-stack
train
ec19071f81beefb9dffee31e
train
function
def test_update_to_null_enum(client, pg_driver, cgci_blgsp, submitter): """ Test that updating a non required enum field to null works correctly """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projec...
def test_update_to_null_enum(client, pg_driver, cgci_blgsp, submitter):
""" Test that updating a non required enum field to null works correctly """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, "type_o...
400, resp.data resp = client.get( f"/v0/submission/CGCI/BLGSP/entities/{entity_id}", headers=headers ) print(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)) assert ( json.loads(resp.data)["entities"][0]["properties"]["submitter_id"] == "BLGSP-71-06-00019" ) ...
126
126
421
20
105
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_update_to_null_enum
test_update_to_null_enum
1,403
1,442
1,403
1,403
9cdd36ea1539e75e131f49170c8c96238ae6b92e
bigcode/the-stack
train
06ad142d47afafaac77addf6
train
function
def test_project_creation_unauthorized( client, pg_driver, submitter, mock_arborist_requests ): # Just checks that this is guarded with an Arborist auth request. # (Does not check that the auth request is for the Sheepdog admin policy.) put_cgci(client, submitter) path = "/v0/submission/CGCI/" ...
def test_project_creation_unauthorized( client, pg_driver, submitter, mock_arborist_requests ): # Just checks that this is guarded with an Arborist auth request. # (Does not check that the auth request is for the Sheepdog admin policy.)
put_cgci(client, submitter) path = "/v0/submission/CGCI/" mock_arborist_requests(authorized=False) resp = client.put( path, headers=submitter, data=json.dumps( { "type": "project", "code": "BLGSP", "dbgap_accession_numb...
BLGSP"], resp.json def test_project_creation_unauthorized( client, pg_driver, submitter, mock_arborist_requests ): # Just checks that this is guarded with an Arborist auth request. # (Does not check that the auth request is for the Sheepdog admin policy.)
64
64
180
57
6
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_project_creation_unauthorized
test_project_creation_unauthorized
178
200
178
182
64e25bdd916fa50b3268b0f9061dbb2d75ec9750
bigcode/the-stack
train
9db85a2c14df7ec6f3acc9cb
train
function
def test_unauthorized_post( client, pg_driver, cgci_blgsp, submitter, mock_arborist_requests ): headers = submitter mock_arborist_requests(authorized=False) resp = client.post( BLGSP_PATH, headers=headers, data=json.dumps( { "type": "experiment", ...
def test_unauthorized_post( client, pg_driver, cgci_blgsp, submitter, mock_arborist_requests ):
headers = submitter mock_arborist_requests(authorized=False) resp = client.post( BLGSP_PATH, headers=headers, data=json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-56...
c77542c98"}, } ) resp = client.post(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 401 def test_unauthorized_post( client, pg_driver, cgci_blgsp, submitter, mock_arborist_requests ):
64
64
139
29
34
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_unauthorized_post
test_unauthorized_post
230
246
230
232
5116a23a783136584fc85285232ea2d12423a520
bigcode/the-stack
train
e37707b8582dcfda09108f02
train
function
def test_can_submit_with_asterisk_json(client, pg_driver, cgci_blgsp, submitter): """ Test that we can submit when some fields have asterisks prepended """ headers = submitter data = json.dumps( { "*type": "experiment", "*submitter_id": "BLGSP-71-06-00019", ...
def test_can_submit_with_asterisk_json(client, pg_driver, cgci_blgsp, submitter):
""" Test that we can submit when some fields have asterisks prepended """ headers = submitter data = json.dumps( { "*type": "experiment", "*submitter_id": "BLGSP-71-06-00019", "*projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, } ) ...
headers["Content-Type"] = "text/csv" resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 200, resp.data def test_can_submit_with_asterisk_json(client, pg_driver, cgci_blgsp, submitter):
64
64
146
23
40
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_can_submit_with_asterisk_json
test_can_submit_with_asterisk_json
777
791
777
777
8f3b37eef4f665aadb4a425e78b748ff2df007d0
bigcode/the-stack
train
41d9782a0c9c76d2f9fb4da4
train
function
def test_dictionary_get_entries(client, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary/aliquot") assert json.loads(resp.data)["id"] == "aliquot"
def test_dictionary_get_entries(client, pg_driver, cgci_blgsp, submitter):
resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary/aliquot") assert json.loads(resp.data)["id"] == "aliquot"
)["links"] assert "/v0/submission/_dictionary/case" in json.loads(resp.data)["links"] assert "/v0/submission/_dictionary/aliquot" in json.loads(resp.data)["links"] def test_dictionary_get_entries(client, pg_driver, cgci_blgsp, submitter):
63
64
56
19
44
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_dictionary_get_entries
test_dictionary_get_entries
386
388
386
386
22a89f73df8622472581c18da97b47b7bb577f13
bigcode/the-stack
train
87d63e18b92e7d60bef1c496
train
function
def test_export_all_node_types_and_resubmit_tsv( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): str_id_data = do_test_export( client, pg_driver, submitter, "experimental_metadata", "tsv" ) str_data = str( get_export_data(client, submitter, "experimental_metadata", ...
def test_export_all_node_types_and_resubmit_tsv( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
str_id_data = do_test_export( client, pg_driver, submitter, "experimental_metadata", "tsv" ) str_data = str( get_export_data(client, submitter, "experimental_metadata", "tsv", True).data, "utf-8", ) reader = csv.DictReader(StringIO(str_id_data), dialect="excel-tab") for ...
ter resp = client.post(BLGSP_PATH, headers=headers, data=json.dumps(js_data["data"])) assert resp.status_code == 201, resp.data def test_export_all_node_types_and_resubmit_tsv( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
68
68
229
33
34
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_all_node_types_and_resubmit_tsv
test_export_all_node_types_and_resubmit_tsv
899
921
899
901
6a8194cb5cc77d02940273d9f66a6b814b07cc01
bigcode/the-stack
train
45c04d197b4af56dc3a7b9c1
train
function
def test_export_all_node_types_json( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): post_example_entities_together(client, submitter, extended_data_fnames) with pg_driver.session_scope() as s: case = pg_driver.nodes(md.Case).first() new_case = md.Case(str(uuid.uuid4())...
def test_export_all_node_types_json( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
post_example_entities_together(client, submitter, extended_data_fnames) with pg_driver.session_scope() as s: case = pg_driver.nodes(md.Case).first() new_case = md.Case(str(uuid.uuid4())) new_case.props = case.props new_case.submitter_id = "case-2" s.add(new_case) ...
=headers, data=str_data) print(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)) assert resp.status_code == 200, resp.data def test_export_all_node_types_json( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
64
64
201
29
34
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_all_node_types_json
test_export_all_node_types_json
974
990
974
976
c6ca3bd2d485bcfa586ba2926b83c04485627db8
bigcode/the-stack
train
f05bfbf3380fd5dbaca31fff
train
function
def test_update_to_null_invalid(client, pg_driver, cgci_blgsp, submitter): """ Test that updating a required field to null results in an error """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects...
def test_update_to_null_invalid(client, pg_driver, cgci_blgsp, submitter):
""" Test that updating a required field to null results in an error """ headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, } ) resp...
(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)) assert ( json.loads(resp.data)["entities"][0]["properties"]["experimental_description"] is None ) assert ( json.loads(resp.data)["entities"][0]["properties"][ "number_samples_per_experimental_group" ] ...
117
117
391
20
97
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_update_to_null_invalid
test_update_to_null_invalid
1,235
1,272
1,235
1,235
de9e4dd12770165e74cfa47a3518bbb9c910fbe7
bigcode/the-stack
train
6c5c39cb6daefba14f3175f5
train
function
def test_update_to_null_link(client, cgci_blgsp, submitter, require_index_exists_off): """ Test that updating a non required link to null works correctly """ # create an entity with a link headers = submitter experiement_submitter_id = "BLGSP-71-06-00019" experimental_metadata = { "t...
def test_update_to_null_link(client, cgci_blgsp, submitter, require_index_exists_off):
""" Test that updating a non required link to null works correctly """ # create an entity with a link headers = submitter experiement_submitter_id = "BLGSP-71-06-00019" experimental_metadata = { "type": "experimental_metadata", "experiments": {"submitter_id": experiement_subm...
None, } ) resp = client.put(BLGSP_PATH, headers=headers, data=data) print(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)) assert resp.status_code == 200, resp.data resp = client.get( f"/v0/submission/CGCI/BLGSP/entities/{json.loads(resp.data)['entities'][0]['id']}", ...
150
150
502
22
127
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_update_to_null_link
test_update_to_null_link
1,445
1,501
1,445
1,445
c8f4ea05762c1f1eb178ac6594f8b0214b4b5293
bigcode/the-stack
train
4cc6ab47b9effcc0bb7fb67f
train
function
def test_catch_internal_errors(monkeypatch, client, pg_driver, cgci_blgsp, submitter): """ Monkey patch an essential function to just raise an error and assert that this error is caught and recorded as a transactional_error. """ def just_raise_exception(self): raise Exception("test") m...
def test_catch_internal_errors(monkeypatch, client, pg_driver, cgci_blgsp, submitter):
""" Monkey patch an essential function to just raise an error and assert that this error is caught and recorded as a transactional_error. """ def just_raise_exception(self): raise Exception("test") monkeypatch.setattr(UploadTransaction, "pre_validate", just_raise_exception) try: ...
assert resp.status_code == 200, resp.data def test_delete_entity(client, pg_driver, cgci_blgsp, submitter): do_test_delete_entity(client, submitter) def test_catch_internal_errors(monkeypatch, client, pg_driver, cgci_blgsp, submitter):
64
64
124
24
40
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_catch_internal_errors
test_catch_internal_errors
535
549
535
535
b2ade8910b098ac0b75527c6990980b79b9d24a4
bigcode/the-stack
train
e340b9011b518c80087f2864
train
function
def test_export_all_node_types( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv")
def test_export_all_node_types( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv")
_type, format_type ) if without_id: path += "&without_id=True" r = client.get(path, headers=submitter) return r def test_export_all_node_types( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
64
64
48
28
35
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_all_node_types
test_export_all_node_types
868
871
868
870
a8c556697cd30e4ac1d63f3a55cc87bce9daea02
bigcode/the-stack
train
b5d99f57e084dfa2b22df2b9
train
function
def test_put_entity_creation_valid(client, pg_driver, cgci_blgsp, submitter): headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, } ) resp = cli...
def test_put_entity_creation_valid(client, pg_driver, cgci_blgsp, submitter):
headers = submitter data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, } ) resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code ==...
"phs000527", "name": "Burkitt Lymphoma Genome Sequencing Project", "state": "open", } ), ) assert resp.status_code == 403 def test_put_entity_creation_valid(client, pg_driver, cgci_blgsp, submitter):
64
64
122
20
43
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_put_entity_creation_valid
test_put_entity_creation_valid
203
213
203
203
e24bf8190bd0e6abcba57e6822581be17f57488c
bigcode/the-stack
train
bef1c8bda97d0bbcb6eaaf5f
train
function
def test_can_submit_with_asterisk_tsv(client, pg_driver, cgci_blgsp, submitter): """ Test that we can submit when some fields have asterisks prepended """ data = { "*type": "experiment", "*submitter_id": "BLGSP-71-06-00019", "*projects.id": "daa208a7-f57a-562c-a04a-7a7c77542c98"...
def test_can_submit_with_asterisk_tsv(client, pg_driver, cgci_blgsp, submitter):
""" Test that we can submit when some fields have asterisks prepended """ data = { "*type": "experiment", "*submitter_id": "BLGSP-71-06-00019", "*projects.id": "daa208a7-f57a-562c-a04a-7a7c77542c98", } # convert to TSV (save to file) file_path = os.path.join(DATA_DIR...
208a7-f57a-562c-a04a-7a7c77542c98"}, } ) resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 200, resp.data def test_can_submit_with_asterisk_tsv(client, pg_driver, cgci_blgsp, submitter):
78
78
263
24
53
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_can_submit_with_asterisk_tsv
test_can_submit_with_asterisk_tsv
794
821
794
794
ff9cfa6f3cfed39547732a308d0ef394b467311f
bigcode/the-stack
train
c261b36c63ed2d9f1394367a
train
function
def test_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary") print(resp.data) assert ( "/v0/submission/CGCI/BLGSP/_dictionary/slide" in json.loads(resp.data)["links"] ) assert ( "/v0/submission/CGCI/BLGSP/_dict...
def test_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter):
resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary") print(resp.data) assert ( "/v0/submission/CGCI/BLGSP/_dictionary/slide" in json.loads(resp.data)["links"] ) assert ( "/v0/submission/CGCI/BLGSP/_dictionary/case" in json.loads(resp.data)["links"] ) assert ( "/...
) assert condition_to_check, resp.data def test_post_example_entities_together(client, pg_driver, cgci_blgsp, submitter): do_test_post_example_entities_together(client, submitter) def test_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter):
64
64
139
19
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_dictionary_list_entries
test_dictionary_list_entries
363
375
363
363
87a9484f7302602985627409b414d75a80b83a14
bigcode/the-stack
train
b0c20e00f692be8bcaf98b16
train
function
def test_dictionary_get_definitions(client, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary/_definitions") assert "UUID" in resp.json
def test_dictionary_get_definitions(client, pg_driver, cgci_blgsp, submitter):
resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary/_definitions") assert "UUID" in resp.json
(client, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/_dictionary/aliquot") assert json.loads(resp.data)["id"] == "aliquot" def test_dictionary_get_definitions(client, pg_driver, cgci_blgsp, submitter):
64
64
51
20
44
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_dictionary_get_definitions
test_dictionary_get_definitions
396
398
396
396
72a4e8ac08e4296b65baf096293d78590bfe84f6
bigcode/the-stack
train
abccb32eb220fdafc8e7f069
train
function
def do_test_submit_valid_tsv(client, submitter): """ Test that we can submit a valid TSV file """ data = { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects.id": "daa208a7-f57a-562c-a04a-7a7c77542c98", } # convert to TSV (save to file) file_path =...
def do_test_submit_valid_tsv(client, submitter):
""" Test that we can submit a valid TSV file """ data = { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects.id": "daa208a7-f57a-562c-a04a-7a7c77542c98", } # convert to TSV (save to file) file_path = os.path.join(DATA_DIR, "experiment_tmp.tsv") ...
for entity in resp.json["entities"]: if entity["type"] == "submitted_unaligned_reads": sur_entity = entity assert sur_entity, "No submitted_unaligned_reads entity created" assert index_client.get(sur_entity["id"]), "No indexd document created" def do_test_submit_valid_tsv(client, submi...
73
73
245
12
61
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
do_test_submit_valid_tsv
do_test_submit_valid_tsv
709
737
709
709
36839da1bf11933210c8fb2ea2cfd9dc59ff5293
bigcode/the-stack
train
76ca58aaf3f4effec368e1f7
train
function
def add_and_get_new_experimental_metadata_count(pg_driver): with pg_driver.session_scope() as s: experimental_metadata = pg_driver.nodes(md.ExperimentalMetadata).first() new_experimental_metadata = md.ExperimentalMetadata(str(uuid.uuid4())) new_experimental_metadata.props = experimental_meta...
def add_and_get_new_experimental_metadata_count(pg_driver):
with pg_driver.session_scope() as s: experimental_metadata = pg_driver.nodes(md.ExperimentalMetadata).first() new_experimental_metadata = md.ExperimentalMetadata(str(uuid.uuid4())) new_experimental_metadata.props = experimental_metadata.props new_experimental_metadata.submitter_id = ...
"state": "open", } ) r = client.put("/v0/submission/TCGA/", headers=headers, data=data) assert r.status_code == 200, r.data del g.user return r def add_and_get_new_experimental_metadata_count(pg_driver):
64
64
102
12
51
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
add_and_get_new_experimental_metadata_count
add_and_get_new_experimental_metadata_count
124
132
124
124
9c2907335a2ee156ccf6dfb0063d3ab135b52c11
bigcode/the-stack
train
004476ac896aeb590e222d0c
train
function
def put_cgci_blgsp(client, auth=None): r = put_cgci(client, auth=auth) assert r.status_code == 200, r.data path = "/v0/submission/CGCI/" headers = auth data = json.dumps( { "type": "project", "code": "BLGSP", "dbgap_accession_number": "phs000527", ...
def put_cgci_blgsp(client, auth=None):
r = put_cgci(client, auth=auth) assert r.status_code == 200, r.data path = "/v0/submission/CGCI/" headers = auth data = json.dumps( { "type": "project", "code": "BLGSP", "dbgap_accession_number": "phs000527", "name": "Burkitt Lymphoma Genome S...
{ "name": "CGCI", "type": "program", "dbgap_accession_number": "phs000235", } ) r = client.put(path, headers=headers, data=data) return r def put_cgci_blgsp(client, auth=None):
64
64
154
13
50
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
put_cgci_blgsp
put_cgci_blgsp
76
94
76
76
bf1ac7e355b9ade599e0513601e45549a1203236
bigcode/the-stack
train
5b03c78ed82bdd1d6ca7623e
train
function
def test_submit_blank_link( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): """ Test that a TSV can be submitted with an empty link column, when the link is not required. """ data = { "type": "experimental_metadata", "experiments.submitter_id": "", # TSV li...
def test_submit_blank_link( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
""" Test that a TSV can be submitted with an empty link column, when the link is not required. """ data = { "type": "experimental_metadata", "experiments.submitter_id": "", # TSV link format "data_type": "Experimental Metadata", "file_name": "CGCI-file-b.bam", ...
.dumps(json.loads(resp.data), indent=2) resp = client.get( f"/v0/submission/CGCI/BLGSP/entities/{json.loads(resp.data)['entities'][0]['id']}", headers=headers, ) entity = json.loads(resp.data) assert "experiments" not in entity, json.dumps(entity, indent=2) def test_submit_blank_link( ...
103
103
346
27
76
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_submit_blank_link
test_submit_blank_link
1,504
1,543
1,504
1,506
0360c1f4c40e9b3d4ac510d03d9ab06f6714b3d5
bigcode/the-stack
train
7f275d5cbdcd72898d1b0da7
train
function
def test_program_creation_endpoint_for_program_not_supported( client, pg_driver, submitter ): path = "/v0/submission/abc/" resp = client.post(path, headers=submitter) assert resp.status_code == 404
def test_program_creation_endpoint_for_program_not_supported( client, pg_driver, submitter ):
path = "/v0/submission/abc/" resp = client.post(path, headers=submitter) assert resp.status_code == 404
= submitter data = json.dumps({"name": "CGCI", "type": "program"}) resp = client.put(path, headers=headers, data=data) assert resp.status_code == 403 def test_program_creation_endpoint_for_program_not_supported( client, pg_driver, submitter ):
64
64
52
20
43
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_program_creation_endpoint_for_program_not_supported
test_program_creation_endpoint_for_program_not_supported
158
163
158
160
6700a939dcddaf32eef7586bb507eceeebb73ac0
bigcode/the-stack
train
44b4e12642252df9db731b3e
train
function
def test_validator_format(client, pg_driver, cgci_blgsp, submitter): """ Test that validator errors are returned for invalid formats. The `time_between_clamping_and_freezing` schema is defined as: { "type": "string", "format": "date-time" } """ assert put_example_entities_together(client, submit...
def test_validator_format(client, pg_driver, cgci_blgsp, submitter):
""" Test that validator errors are returned for invalid formats. The `time_between_clamping_and_freezing` schema is defined as: { "type": "string", "format": "date-time" } """ assert put_example_entities_together(client, submitter).status_code == 200 # Test that a string that is not a valid...
Normal", "submitter_id": "BLGSP-71-06-00019", "longest_dimension": -1.0, } ), ) errors = {e["keys"][0]: e["type"] for e in r.json["entities"][0]["errors"]} assert r.status_code == 400, r.data assert errors["is_ffpe"] == "INVALID_VALUE" assert erro...
119
119
397
18
101
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_validator_format
test_validator_format
575
615
575
575
c3535c5f2ffd1e660ef330de75d866cefb82c267
bigcode/the-stack
train
fd98d5bdaa77ebecf6970ef2
train
function
def test_get_entity_by_id(client, pg_driver, cgci_blgsp, submitter): post_example_entities_together(client, submitter) with pg_driver.session_scope(): case_id = pg_driver.nodes(md.Case).first().node_id path = "/v0/submission/CGCI/BLGSP/entities/{case_id}".format(case_id=case_id) r = client.get(p...
def test_get_entity_by_id(client, pg_driver, cgci_blgsp, submitter):
post_example_entities_together(client, submitter) with pg_driver.session_scope(): case_id = pg_driver.nodes(md.Case).first().node_id path = "/v0/submission/CGCI/BLGSP/entities/{case_id}".format(case_id=case_id) r = client.get(path, headers=submitter) assert r.status_code == 200, r.data a...
value", "key2": not a string, }""", ) print(resp.data) assert resp.status_code == 400 assert "Expecting value" in resp.json["message"] def test_get_entity_by_id(client, pg_driver, cgci_blgsp, submitter):
63
64
125
20
43
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_get_entity_by_id
test_get_entity_by_id
632
639
632
632
fc2f8763ad0eab389e7fb1328eb5965f03d22648
bigcode/the-stack
train
9b421845eb35aa3d7bd6a2af
train
function
def test_delete_entity(client, pg_driver, cgci_blgsp, submitter): do_test_delete_entity(client, submitter)
def test_delete_entity(client, pg_driver, cgci_blgsp, submitter):
do_test_delete_entity(client, submitter)
.json["entities"][0]["id"] path = BLGSP_PATH + "entities/" + did resp = client.delete(path, headers=submitter) assert resp.status_code == 200, resp.data def test_delete_entity(client, pg_driver, cgci_blgsp, submitter):
64
64
28
18
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_delete_entity
test_delete_entity
531
532
531
531
64d9ec421272b26973c0fdd91588f88dab6a54c1
bigcode/the-stack
train
cd4682fa2ce0ca58c9e60800
train
function
def test_update_to_null_valid_tsv(client, pg_driver, cgci_blgsp, submitter): """ Test that we can update a TSV file with null """ data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c7...
def test_update_to_null_valid_tsv(client, pg_driver, cgci_blgsp, submitter):
""" Test that we can update a TSV file with null """ data = json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, "experimental_description": "my desc", "nu...
data = json.dumps({"id": None}) resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 400, resp.data resp = client.get( f"/v0/submission/CGCI/BLGSP/entities/{entity_id}", headers=headers ) print(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)...
181
181
606
22
158
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_update_to_null_valid_tsv
test_update_to_null_valid_tsv
1,275
1,343
1,275
1,275
2ea52a8d0533482242e8bd30ffcf71ebf8f7a1a8
bigcode/the-stack
train
8a5c36038fccc3ca41a0dff0
train
function
def put_example_entities_together(client, headers): path = BLGSP_PATH data = [] for fname in data_fnames: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) return client.put(path, headers=headers, data=json.dumps(data))
def put_example_entities_together(client, headers):
path = BLGSP_PATH data = [] for fname in data_fnames: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) return client.put(path, headers=headers, data=json.dumps(data))
for fname in data_fnames2: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) resp = client.post(path, headers=submitter, data=json.dumps(data)) return resp def put_example_entities_together(client, headers):
64
64
69
10
53
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
put_example_entities_together
put_example_entities_together
334
340
334
334
6f2f6625b4909ce8f2269de127581bf3df2b8026
bigcode/the-stack
train
163353f64c928cba0ab9b03b
train
function
def post_example_entities_together(client, submitter, data_fnames2=None): if not data_fnames2: data_fnames2 = data_fnames path = BLGSP_PATH data = [] for fname in data_fnames2: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) resp = cl...
def post_example_entities_together(client, submitter, data_fnames2=None):
if not data_fnames2: data_fnames2 = data_fnames path = BLGSP_PATH data = [] for fname in data_fnames2: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) resp = client.post(path, headers=submitter, data=json.dumps(data)) return resp
.data) or ( resp.status_code == 400 and "already exists in the DB" in resp_data["entities"][0]["errors"][0]["message"] ) assert condition_to_check, resp.data def post_example_entities_together(client, submitter, data_fnames2=None):
64
64
102
17
46
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
post_example_entities_together
post_example_entities_together
322
331
322
322
a08d02cb0f41511ddc4baaae5aff432f180ba4db
bigcode/the-stack
train
aa9bb33a8f17785813f12a2b
train
function
def test_invalid_file_index(monkeypatch, client, pg_driver, cgci_blgsp, submitter): """ Test that submitting an invalid data file doesn't create an index and an alias. """ def fail_index_test(_): raise AssertionError("IndexClient tried to create index or alias") # Since the IndexClient...
def test_invalid_file_index(monkeypatch, client, pg_driver, cgci_blgsp, submitter):
""" Test that submitting an invalid data file doesn't create an index and an alias. """ def fail_index_test(_): raise AssertionError("IndexClient tried to create index or alias") # Since the IndexClient should never be called to register anything if the # file is invalid, change th...
r = client.get(path, headers=submitter) assert r.status_code == 200, r.data assert r.json["entities"][0]["properties"]["id"] == case_id, r.data def test_invalid_file_index(monkeypatch, client, pg_driver, cgci_blgsp, submitter):
66
66
223
23
42
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_invalid_file_index
test_invalid_file_index
642
672
642
642
2f0bb0437050aec6cb2ac888b61424332bc42cfa
bigcode/the-stack
train
e53199afb02571bf90d57fa3
train
function
def test_valid_file_index( monkeypatch, client, pg_driver, cgci_blgsp, submitter, index_client, require_index_exists_off, ): """ Test that submitting a valid data file creates an index and an alias. """ # Update this dictionary in the patched functions to check that they are...
def test_valid_file_index( monkeypatch, client, pg_driver, cgci_blgsp, submitter, index_client, require_index_exists_off, ):
""" Test that submitting a valid data file creates an index and an alias. """ # Update this dictionary in the patched functions to check that they are # called. # Attempt to post the valid entities. test_fnames = data_fnames + [ "read_group.json", "submitted_unaligned_reads...
", ] resp = post_example_entities_together(client, submitter, data_fnames2=test_fnames) print(resp) def test_valid_file_index( monkeypatch, client, pg_driver, cgci_blgsp, submitter, index_client, require_index_exists_off, ):
67
67
225
39
28
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_valid_file_index
test_valid_file_index
675
706
675
683
02964110eb2826fd04df36ab9a9aedd30359eb1a
bigcode/the-stack
train
d796f2c8676954125e9fcfc1
train
function
def do_test_post_example_entities_together(client, submitter): with open(os.path.join(DATA_DIR, "case.json"), "r") as f: case_sid = json.loads(f.read())["submitter_id"] print(case_sid) resp = post_example_entities_together(client, submitter) print(resp.data) resp_data = json.loads(resp.d...
def do_test_post_example_entities_together(client, submitter):
with open(os.path.join(DATA_DIR, "case.json"), "r") as f: case_sid = json.loads(f.read())["submitter_id"] print(case_sid) resp = post_example_entities_together(client, submitter) print(resp.data) resp_data = json.loads(resp.data) # could already exist in the DB. condition_to_chec...
data = [] for fname in data_fnames: with open(os.path.join(DATA_DIR, fname), "r") as f: data.append(json.loads(f.read())) return client.put(path, headers=headers, data=json.dumps(data)) def do_test_post_example_entities_together(client, submitter):
64
64
148
13
51
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
do_test_post_example_entities_together
do_test_post_example_entities_together
343
356
343
343
73a5f3eb0e8ed571441fbb88073fb4c15693ea75
bigcode/the-stack
train
80e81d7f8e5188d2c8e3a0ab
train
function
def test_incorrect_project_error(client, pg_driver, cgci_blgsp, submitter): put_tcga_brca(client, submitter) resp = client.put( BLGSP_PATH, headers=submitter, data=json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", ...
def test_incorrect_project_error(client, pg_driver, cgci_blgsp, submitter):
put_tcga_brca(client, submitter) resp = client.put( BLGSP_PATH, headers=submitter, data=json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, ...
resp.status_code == 200, resp.data resp_json = json.loads(resp.data) assert resp_json["entity_error_count"] == 0 assert resp_json["created_entity_count"] == 1 with pg_driver.session_scope(): assert not pg_driver.nodes(md.Experiment).first() def test_incorrect_project_error(client, pg_driver, cg...
84
84
281
20
64
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_incorrect_project_error
test_incorrect_project_error
422
451
422
422
ffb5f09b4dc8f98e8a9d27236268f4103f9a3273
bigcode/the-stack
train
317e0074671b05b11231301a
train
function
def test_zero_decimal_float(client, pg_driver, cgci_blgsp, submitter): """ Test that float values with a zero decimal are accepted by Sheepdog for properites of type "number" even if they look like integers. We are testing with TSV because the str values from TSV are cast to the proper type by Sheep...
def test_zero_decimal_float(client, pg_driver, cgci_blgsp, submitter):
""" Test that float values with a zero decimal are accepted by Sheepdog for properites of type "number" even if they look like integers. We are testing with TSV because the str values from TSV are cast to the proper type by Sheepdog. """ resp = client.put( BLGSP_PATH, headers...
utx1.integrity_check() response = utx1.json assert response["entity_error_count"] == 1 assert response["code"] == 400 assert ( response["entities"][0]["errors"][0]["message"] == "experiment with {'project_id': 'CGCI-BLGSP', 'submitter_id': 'BLGSP-71-06-00019'} already exist...
135
135
453
19
115
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_zero_decimal_float
test_zero_decimal_float
1,121
1,175
1,121
1,121
2e82e14a00bc1ff38ff0986ea8224c7839258bd5
bigcode/the-stack
train
5ce1fd306dc79ba4ccee4727
train
function
def test_export_non_string_array_values(): assert list_to_comma_string(["string", 1, 0.5, True], "tsv") == "string,1,0.5,True"
def test_export_non_string_array_values():
assert list_to_comma_string(["string", 1, 0.5, True], "tsv") == "string,1,0.5,True"
=submitter) return r def test_export_all_node_types( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): do_test_export(client, pg_driver, submitter, "experimental_metadata", "tsv") def test_export_non_string_array_values():
64
64
44
8
56
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_non_string_array_values
test_export_non_string_array_values
874
875
874
874
cbc38e941e46a260b34255b01e7031e523604c10
bigcode/the-stack
train
d488b3a834bafebcbe041667
train
function
def put_cgci(client, auth=None): path = "/v0/submission" headers = auth data = json.dumps( { "name": "CGCI", "type": "program", "dbgap_accession_number": "phs000235", } ) r = client.put(path, headers=headers, data=data) return r
def put_cgci(client, auth=None):
path = "/v0/submission" headers = auth data = json.dumps( { "name": "CGCI", "type": "program", "dbgap_accession_number": "phs000235", } ) r = client.put(path, headers=headers, data=data) return r
**kwargs): mock = mock_s3() mock.start(reset=False) conn = boto.connect_s3() conn.create_bucket("test_submission") result = f(*args, **kwargs) mock.stop() return result return wrapper def put_cgci(client, auth=None):
64
64
82
10
53
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
put_cgci
put_cgci
62
73
62
62
1b19c193a63b200ec7a21423535bc3320678f31c
bigcode/the-stack
train
10ea6dfba0210db94096f290
train
function
def test_export_all_node_types_and_resubmit_tsv_with_empty_field( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): """ Test we can export an entity with empty fields (as tsv) then resubmit it. The empty values of the exported entity should be empty strings. """ str_id_data =...
def test_export_all_node_types_and_resubmit_tsv_with_empty_field( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
""" Test we can export an entity with empty fields (as tsv) then resubmit it. The empty values of the exported entity should be empty strings. """ str_id_data = do_test_export(client, pg_driver, submitter, "experiment", "tsv") assert str_id_data str_data = get_export_data(client, submitter, ...
.put(BLGSP_PATH, headers=headers, data=json.dumps(js_data["data"])) print(json.dumps(json.loads(resp.data), indent=4, sort_keys=True)) assert resp.status_code == 200, resp.data def test_export_all_node_types_and_resubmit_tsv_with_empty_field( client, pg_driver, cgci_blgsp, submitter, require_index_exists_of...
82
82
275
36
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_all_node_types_and_resubmit_tsv_with_empty_field
test_export_all_node_types_and_resubmit_tsv_with_empty_field
948
971
948
950
3f39c720f46fbf50168d0eb86601add14d2a6214
bigcode/the-stack
train
917b1a0bd3d4e072fe168312
train
function
def test_export_entity_by_id( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ): post_example_entities_together(client, submitter, extended_data_fnames) with pg_driver.session_scope(): case_id = pg_driver.nodes(md.Case).first().node_id path = "/v0/submission/CGCI/BLGSP/export/...
def test_export_entity_by_id( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
post_example_entities_together(client, submitter, extended_data_fnames) with pg_driver.session_scope(): case_id = pg_driver.nodes(md.Case).first().node_id path = "/v0/submission/CGCI/BLGSP/export/?ids={case_id}".format(case_id=case_id) r = client.get(path, headers=submitter) assert r.status_...
"] = "text/tsv" resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 200, resp.data def test_export_entity_by_id( client, pg_driver, cgci_blgsp, submitter, require_index_exists_off ):
64
64
182
28
35
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_export_entity_by_id
test_export_entity_by_id
824
839
824
826
ebeb756f5b5b879254ac8d6fa1156fecc4134d93
bigcode/the-stack
train
4c51437b622b0af3e67b24ab
train
function
def test_unauthenticated_post(client, pg_driver, cgci_blgsp, submitter): # send garbage token headers = {"Authorization": "test"} data = json.dumps( { "type": "case", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, ...
def test_unauthenticated_post(client, pg_driver, cgci_blgsp, submitter): # send garbage token
headers = {"Authorization": "test"} data = json.dumps( { "type": "case", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, } ) resp = client.post(BLGSP_PATH, headers=headers, data=data) assert resp.sta...
77542c98"}, } ) resp = client.put(BLGSP_PATH, headers=headers, data=data) assert resp.status_code == 200, resp.data def test_unauthenticated_post(client, pg_driver, cgci_blgsp, submitter): # send garbage token
64
64
129
27
36
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_unauthenticated_post
test_unauthenticated_post
216
227
216
217
50351b0ae2d1fd0c16d44479d30c171766e5f474
bigcode/the-stack
train
d82e64bc9185f5ff924bef55
train
function
@contextlib.contextmanager def s3_conn(): mock = mock_s3() mock.start(reset=False) conn = boto.connect_s3() yield conn bucket = conn.get_bucket("test_submission") for part in bucket.list_multipart_uploads(): part.cancel_upload() mock.stop()
@contextlib.contextmanager def s3_conn():
mock = mock_s3() mock.start(reset=False) conn = boto.connect_s3() yield conn bucket = conn.get_bucket("test_submission") for part in bucket.list_multipart_uploads(): part.cancel_upload() mock.stop()
SP_PATH = "/v0/submission/CGCI/BLGSP/" BRCA_PATH = "/v0/submission/TCGA/BRCA/" DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") @contextlib.contextmanager def s3_conn():
64
64
66
11
53
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
s3_conn
s3_conn
36
45
36
37
a20f74f5f1f61c483a714066fd0c802ac9b79e55
bigcode/the-stack
train
31be8f96ebb9b3b95488bc96
train
function
def test_top_level_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/_dictionary") print(resp.data) assert "/v0/submission/_dictionary/slide" in json.loads(resp.data)["links"] assert "/v0/submission/_dictionary/case" in json.loads(resp.data)["links"] ...
def test_top_level_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter):
resp = client.get("/v0/submission/_dictionary") print(resp.data) assert "/v0/submission/_dictionary/slide" in json.loads(resp.data)["links"] assert "/v0/submission/_dictionary/case" in json.loads(resp.data)["links"] assert "/v0/submission/_dictionary/aliquot" in json.loads(resp.data)["links"]
in json.loads(resp.data)["links"] ) assert ( "/v0/submission/CGCI/BLGSP/_dictionary/aliquot" in json.loads(resp.data)["links"] ) def test_top_level_dictionary_list_entries(client, pg_driver, cgci_blgsp, submitter):
64
64
100
21
43
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_top_level_dictionary_list_entries
test_top_level_dictionary_list_entries
378
383
378
378
8739e52fb91ae05143d6a9c5b30dc8dbaefa9275
bigcode/the-stack
train
5c2ae71191cfe96340ed1f14
train
function
def do_test_export(client, pg_driver, submitter, node_type, format_type): post_example_entities_together(client, submitter, extended_data_fnames) experimental_metadata_count = add_and_get_new_experimental_metadata_count(pg_driver) r = get_export_data(client, submitter, node_type, format_type, False) ass...
def do_test_export(client, pg_driver, submitter, node_type, format_type):
post_example_entities_together(client, submitter, extended_data_fnames) experimental_metadata_count = add_and_get_new_experimental_metadata_count(pg_driver) r = get_export_data(client, submitter, node_type, format_type, False) assert r.status_code == 200, r.data assert r.headers["Content-Disposition...
+= "&format=json" r = client.get(path, headers=submitter) data = r.json assert data and len(data) == 1 assert data[0]["id"] == case_id def do_test_export(client, pg_driver, submitter, node_type, format_type):
64
64
170
18
45
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
do_test_export
do_test_export
842
855
842
842
1d5c33f4ee6cbbc670fea7ac870a47bca163601b
bigcode/the-stack
train
52a8c55e2f415461baccc130
train
function
def test_put_dry_run(client, pg_driver, cgci_blgsp, submitter): path = "/v0/submission/CGCI/BLGSP/_dry_run/" resp = client.put( path, headers=submitter, data=json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", ...
def test_put_dry_run(client, pg_driver, cgci_blgsp, submitter):
path = "/v0/submission/CGCI/BLGSP/_dry_run/" resp = client.put( path, headers=submitter, data=json.dumps( { "type": "experiment", "submitter_id": "BLGSP-71-06-00019", "projects": {"id": "daa208a7-f57a-562c-a04a-7a7c77542c98"}, ...
, pg_driver, cgci_blgsp, submitter): resp = client.get("/v0/submission/CGCI/BLGSP/_dictionary/_definitions") assert "UUID" in resp.json def test_put_dry_run(client, pg_driver, cgci_blgsp, submitter):
64
64
189
20
43
rpatil524/sheepdog
tests/integration/datadict/submission/test_endpoints.py
Python
test_put_dry_run
test_put_dry_run
401
419
401
401
018ca0ad40dbff80b2191973d1e283b1993e05c0
bigcode/the-stack
train