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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9021370b3f34e6823279777a | train | function | def MobileNetV2(input_shape=None,
alpha=1.0,
depth_multiplier=1,
include_top=True,
weights='imagenet',
input_tensor=None,
pooling=None,
classes=1000,
channels="gray"):
"""Instantiates the ... | def MobileNetV2(input_shape=None,
alpha=1.0,
depth_multiplier=1,
include_top=True,
weights='imagenet',
input_tensor=None,
pooling=None,
classes=1000,
channels="gray"):
| """Instantiates the MobileNetV2 architecture.
To load a MobileNetV2 model via `load_model`, import the custom
objects `relu6` and pass them to the `custom_objects` parameter.
E.g.
model = load_model('mobilenet.h5', custom_objects={
'relu6': mobilenet.relu6})
# Arguments
... | .
# Arguments
x: a 4D numpy array consists of RGB values within [0, 255].
# Returns
Preprocessed array.
"""
x /= 128.
x -= 1.
return x.astype(np.float32)
# This function is taken from the original tf repo.
# It ensures that all layers have a channel number that is divisible b... | 256 | 256 | 2,943 | 53 | 202 | RamsteinWR/PneumoniaRSNA1 | src/GrayscaleModels/mobilenet_v2_gray.py | Python | MobileNetV2 | MobileNetV2 | 134 | 433 | 134 | 142 | 0a5169293d9c959683ed22f2b3e4df7b37b67b1e | bigcode/the-stack | train |
d5fe0194239af2470a9067db | train | function | def zerorank2(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[sp.sympify(0) for i in range(DIM)] for j in range(DIM)]
| def zerorank2(DIM=-1):
| if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[sp.sympify(0) for i in range(DIM)] for j in range(DIM)]
| , "symmetry_axes", ""))
def zerorank1(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [sp.sympify(0) for i in range(DIM)]
def zerorank2(DIM=-1):
| 64 | 64 | 52 | 10 | 54 | kazewong/nrpytutorial | indexedexp.py | Python | zerorank2 | zerorank2 | 18 | 21 | 18 | 18 | f5cc75a308efe15e00f8134d53753eadb4e27171 | bigcode/the-stack | train |
04199855c1b23d978405a08f | train | function | def zerorank1(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [sp.sympify(0) for i in range(DIM)]
| def zerorank1(DIM=-1):
| if DIM == -1:
DIM = par.parval_from_str("DIM")
return [sp.sympify(0) for i in range(DIM)]
| Load needed modules
import NRPy_param_funcs as par
import grid as gri
import sympy as sp
import sys
thismodule = __name__
par.initialize_param(par.glb_param("char", thismodule, "symmetry_axes", ""))
def zerorank1(DIM=-1):
| 64 | 64 | 45 | 10 | 54 | kazewong/nrpytutorial | indexedexp.py | Python | zerorank1 | zerorank1 | 13 | 16 | 13 | 13 | 4122502d72f5ab05c0c0be997c411a69669e5547 | bigcode/the-stack | train |
ef0b4b92500426707871b4f4 | train | function | def symm_matrix_inverter3x3(a):
# It is far more efficient to write out the matrix determinant and inverse by hand
# instead of using symmetry_optionPy's built-in functions, since the matrix is symmetric.
outDET = -a[0][2]**2*a[1][1] + 2*a[0][1]*a[0][2]*a[1][2] - \
a[0][0]*a[1][2]**2 - a[0... | def symm_matrix_inverter3x3(a):
# It is far more efficient to write out the matrix determinant and inverse by hand
# instead of using symmetry_optionPy's built-in functions, since the matrix is symmetric.
| outDET = -a[0][2]**2*a[1][1] + 2*a[0][1]*a[0][2]*a[1][2] - \
a[0][0]*a[1][2]**2 - a[0][1]**2*a[2][2] + \
a[0][0]*a[1][1]*a[2][2]
outINV = [[sp.sympify(0) for i in range(3)] for j in range(3)]
# First fill in the upper-triangle of the gPhysINV matrix...
outINV[0][0] = (-... | j][l][k]
if not (symmetry_option=="sym01" or symmetry_option=="sym23" or symmetry_option=="sym01_sym23" or symmetry_option=="none"):
print("Error: symmetry option "+symmetry_option+" unsupported.")
sys.exit(1)
return apply_symmetry_condition_to_der... | 137 | 137 | 459 | 49 | 87 | kazewong/nrpytutorial | indexedexp.py | Python | symm_matrix_inverter3x3 | symm_matrix_inverter3x3 | 214 | 233 | 214 | 216 | 46dce59686689084baad62becc19f64554e327bc | bigcode/the-stack | train |
e93a193e314553b1c6afc3cc | train | function | def declarerank4(objname, symmetry_option, DIM=-1):
if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[[[sp.sympify(objname + str(i) + str(j) + str(k) + str(l)) for l in range(DIM)] for k in range(DIM)] for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(D... | def declarerank4(objname, symmetry_option, DIM=-1):
| if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[[[sp.sympify(objname + str(i) + str(j) + str(k) + str(l)) for l in range(DIM)] for k in range(DIM)] for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(DIM):
for k in range(DIM):
... | "sym12":
if k < j:
IDX_OBJ_TMP[i][j][k] = IDX_OBJ_TMP[i][k][j]
if not (symmetry_option == "sym01" or symmetry_option == "sym12" or symmetry_option == "nosym"):
print("Error: symmetry option " + symmetry_option + " unsupported.")
... | 108 | 108 | 360 | 15 | 93 | kazewong/nrpytutorial | indexedexp.py | Python | declarerank4 | declarerank4 | 189 | 210 | 189 | 189 | 6ceca8fc63e222c0c36f8479855fd470effde451 | bigcode/the-stack | train |
29d1e23d73a9a69aaeb5e3ab | train | function | def generic_matrix_inverter3x3(a):
outDET = -a[0][2]*a[1][1]*a[2][0] + a[0][1]*a[1][2]*a[2][0] + \
a[0][2]*a[1][0]*a[2][1] - a[0][0]*a[1][2]*a[2][1] - \
a[0][1]*a[1][0]*a[2][2] + a[0][0]*a[1][1]*a[2][2]
outINV = [[sp.sympify(0) for i in range(3)] for j in range(3)]
outINV[0][0]... | def generic_matrix_inverter3x3(a):
| outDET = -a[0][2]*a[1][1]*a[2][0] + a[0][1]*a[1][2]*a[2][0] + \
a[0][2]*a[1][0]*a[2][1] - a[0][0]*a[1][2]*a[2][1] - \
a[0][1]*a[1][0]*a[2][2] + a[0][0]*a[1][1]*a[2][2]
outINV = [[sp.sympify(0) for i in range(3)] for j in range(3)]
outINV[0][0] = -a[1][2]*a[2][1] + a[1][1]*a[2][... | Then we fill the lower triangle of the symmetric matrix
outINV[1][0] = outINV[0][1]
outINV[2][0] = outINV[0][2]
outINV[2][1] = outINV[1][2]
outINV[3][0] = outINV[0][3]
outINV[3][1] = outINV[1][3]
outINV[3][2] = outINV[2][3]
return outINV, outDET
# symmetry_optionPy's generic matrix i... | 152 | 152 | 508 | 10 | 142 | kazewong/nrpytutorial | indexedexp.py | Python | generic_matrix_inverter3x3 | generic_matrix_inverter3x3 | 273 | 294 | 273 | 273 | a36c676b575bc9084f1070d6ae4b7abd6b1d7174 | bigcode/the-stack | train |
8ad465f3dd69859235757d22 | train | function | def apply_symmetry_condition_to_derivatives(IDX_OBJ):
symmetry_axes = par.parval_from_str("indexedexp::symmetry_axes")
if symmetry_axes == "":
return IDX_OBJ
rank = 1
if isinstance(IDX_OBJ[0], list):
if not isinstance(IDX_OBJ[0][0], list):
rank = 2
elif not isinstanc... | def apply_symmetry_condition_to_derivatives(IDX_OBJ):
| symmetry_axes = par.parval_from_str("indexedexp::symmetry_axes")
if symmetry_axes == "":
return IDX_OBJ
rank = 1
if isinstance(IDX_OBJ[0], list):
if not isinstance(IDX_OBJ[0][0], list):
rank = 2
elif not isinstance(IDX_OBJ[0][0][0], list):
rank = 3
... | if DIM == -1:
DIM = par.parval_from_str("DIM")
return [sp.sympify(0) for i in range(DIM)]
def zerorank2(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[sp.sympify(0) for i in range(DIM)] for j in range(DIM)]
def zerorank3(DIM=-1):
if DIM == -1:
DIM = par.parva... | 224 | 224 | 747 | 12 | 212 | kazewong/nrpytutorial | indexedexp.py | Python | apply_symmetry_condition_to_derivatives | apply_symmetry_condition_to_derivatives | 33 | 97 | 33 | 33 | d7d906190c4d907d2ec095cf2b8433fcac9b6f97 | bigcode/the-stack | train |
f9d62d8eef78afe5b4ee6e5d | train | function | def declarerank1(objname, DIM=-1):
if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [sp.sympify(objname + str(i)) for i in range(DIM)]
return apply_symmetry_condition_to_derivatives(IDX_OBJ_TMP)
| def declarerank1(objname, DIM=-1):
| if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [sp.sympify(objname + str(i)) for i in range(DIM)]
return apply_symmetry_condition_to_derivatives(IDX_OBJ_TMP)
| _across_symmetry_axis(str(IDX_OBJ[i0][i1][i2][i3])) == True:
IDX_OBJ[i0][i1][i2][i3] = sp.sympify(0)
return IDX_OBJ
def declarerank1(objname, DIM=-1):
| 64 | 64 | 66 | 12 | 51 | kazewong/nrpytutorial | indexedexp.py | Python | declarerank1 | declarerank1 | 99 | 103 | 99 | 99 | e314db1b388f441d8b51a9c5d5aedde34694b648 | bigcode/the-stack | train |
77d63525a7398d01d7d39428 | train | function | def zerorank3(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[[sp.sympify(0) for i in range(DIM)] for j in range(DIM)] for k in range(DIM)]
| def zerorank3(DIM=-1):
| if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[[sp.sympify(0) for i in range(DIM)] for j in range(DIM)] for k in range(DIM)]
| IM)]
def zerorank2(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[sp.sympify(0) for i in range(DIM)] for j in range(DIM)]
def zerorank3(DIM=-1):
| 64 | 64 | 59 | 10 | 54 | kazewong/nrpytutorial | indexedexp.py | Python | zerorank3 | zerorank3 | 23 | 26 | 23 | 23 | 43321fb204f816ba72d84203fae0f2509616aa4c | bigcode/the-stack | train |
da6b631ada1e99f0773b9cdf | train | function | def register_gridfunctions_for_single_rank2(gf_type,gf_basename, symmetry_option, DIM=-1):
# Step 0: Verify the gridfunction basename is valid:
gri.verify_gridfunction_basename_is_valid(gf_basename)
# Step 1: Declare a list of lists of SymPy variables,
# where IDX_OBJ_TMP[i][j] = gf_basename+s... | def register_gridfunctions_for_single_rank2(gf_type,gf_basename, symmetry_option, DIM=-1):
# Step 0: Verify the gridfunction basename is valid:
| gri.verify_gridfunction_basename_is_valid(gf_basename)
# Step 1: Declare a list of lists of SymPy variables,
# where IDX_OBJ_TMP[i][j] = gf_basename+str(i)+str(j)
IDX_OBJ_TMP = declarerank2(gf_basename,symmetry_option, DIM)
# Step 2: register each gridfunction, being careful not
# ... | elif symmetry_option == "nosym":
pass
else:
print("Error: symmetry option " + symmetry_option + " unsupported.")
sys.exit(1)
return apply_symmetry_condition_to_derivatives(IDX_OBJ_TMP)
def register_gridfunctions_for_single_rank2(gf_type,gf_base... | 87 | 87 | 293 | 37 | 50 | kazewong/nrpytutorial | indexedexp.py | Python | register_gridfunctions_for_single_rank2 | register_gridfunctions_for_single_rank2 | 143 | 169 | 143 | 144 | 51379293f664768f7e96ab9315a1285d1b1ab140 | bigcode/the-stack | train |
37c2ee03c4d1a3fb4eff31f1 | train | function | def zerorank4(DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[[[sp.sympify(0) for i in range(DIM)] for j in range(DIM)] for k in range(DIM)] for l in range(DIM)]
| def zerorank4(DIM=-1):
| if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[[[sp.sympify(0) for i in range(DIM)] for j in range(DIM)] for k in range(DIM)] for l in range(DIM)]
| (DIM=-1):
if DIM == -1:
DIM = par.parval_from_str("DIM")
return [[[sp.sympify(0) for i in range(DIM)] for j in range(DIM)] for k in range(DIM)]
def zerorank4(DIM=-1):
| 64 | 64 | 67 | 10 | 54 | kazewong/nrpytutorial | indexedexp.py | Python | zerorank4 | zerorank4 | 28 | 31 | 28 | 28 | f57442c471d5acf2ecc5c179d54fdd23722567bc | bigcode/the-stack | train |
71c7cb933c15a7ca49747956 | train | function | def symm_matrix_inverter4x4(a):
# It is far more efficient to write out the matrix determinant and inverse by hand
# instead of using symmetry_optionPy's built-in functions, since the matrix is symmetric.
outDET = + a[0][2]*a[0][2]*a[1][3]*a[1][3] + a[0][3]*a[0][3]*a[1][2]*a[1][2] + a[0][1]*a[0][1]*a[2][3... | def symm_matrix_inverter4x4(a):
# It is far more efficient to write out the matrix determinant and inverse by hand
# instead of using symmetry_optionPy's built-in functions, since the matrix is symmetric.
| outDET = + a[0][2]*a[0][2]*a[1][3]*a[1][3] + a[0][3]*a[0][3]*a[1][2]*a[1][2] + a[0][1]*a[0][1]*a[2][3]*a[2][3] \
- a[0][0]*a[1][3]*a[1][3]*a[2][2] - a[0][3]*a[0][3]*a[1][1]*a[2][2] - a[0][0]*a[1][1]*a[2][3]*a[2][3] \
- 2*(+ a[0][1]*a[0][2]*a[1][3]*a[2][3] - a[0][0]*a[1][2]*a[1][3]*a[2][3] ... | 2])/outDET
outINV[0][2] = (-a[0][2]*a[1][1] + a[0][1]*a[1][2])/outDET
outINV[1][1] = (-a[0][2]**2 + a[0][0]*a[2][2])/outDET
outINV[1][2] = (+a[0][1]*a[0][2] - a[0][0]*a[1][2])/outDET
outINV[2][2] = (-a[0][1]**2 + a[0][0]*a[1][1])/outDET
outINV[1][0] = outINV[0][1]
outIN... | 256 | 256 | 1,837 | 49 | 206 | kazewong/nrpytutorial | indexedexp.py | Python | symm_matrix_inverter4x4 | symm_matrix_inverter4x4 | 235 | 269 | 235 | 237 | 336e634c9d9da1374d823b5cbcd9a4a4e99abd46 | bigcode/the-stack | train |
2d5a3a91e00ac8c170b8f31f | train | function | def declarerank2(objname, symmetry_option, DIM=-1):
if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[sp.sympify(objname + str(i) + str(j)) for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(DIM):
if symmetry_option == "sym01":
... | def declarerank2(objname, symmetry_option, DIM=-1):
| if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[sp.sympify(objname + str(i) + str(j)) for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(DIM):
if symmetry_option == "sym01":
if (j < i):
# j<i in g_{ij} wo... | IM):
gf_list.append(str(IDX_OBJ_TMP[i]))
gri.register_gridfunctions(gf_type, gf_list, is_indexed=True)
# Step 3: Return array of SymPy variables
return IDX_OBJ_TMP
def declarerank2(objname, symmetry_option, DIM=-1):
| 64 | 64 | 207 | 15 | 48 | kazewong/nrpytutorial | indexedexp.py | Python | declarerank2 | declarerank2 | 124 | 141 | 124 | 124 | 2ca540ee925aa0da2a421b1e5ba542ef0d11e346 | bigcode/the-stack | train |
d8391e27c0afdcfebe816b2a | train | function | def register_gridfunctions_for_single_rank1(gf_type,gf_basename, DIM=-1):
# Step 0: Verify the gridfunction basename is valid:
gri.verify_gridfunction_basename_is_valid(gf_basename)
# Step 1: Declare a list of SymPy variables,
# where IDX_OBJ_TMP[i] = gf_basename+str(i)
IDX_OBJ_TMP = d... | def register_gridfunctions_for_single_rank1(gf_type,gf_basename, DIM=-1):
# Step 0: Verify the gridfunction basename is valid:
| gri.verify_gridfunction_basename_is_valid(gf_basename)
# Step 1: Declare a list of SymPy variables,
# where IDX_OBJ_TMP[i] = gf_basename+str(i)
IDX_OBJ_TMP = declarerank1(gf_basename, DIM)
# Step 2: Register each gridfunction
if DIM==-1:
DIM = par.parval_from_str("DIM")
... | .sympify(objname + str(i)) for i in range(DIM)]
return apply_symmetry_condition_to_derivatives(IDX_OBJ_TMP)
def register_gridfunctions_for_single_rank1(gf_type,gf_basename, DIM=-1):
# Step 0: Verify the gridfunction basename is valid:
| 64 | 64 | 185 | 34 | 30 | kazewong/nrpytutorial | indexedexp.py | Python | register_gridfunctions_for_single_rank1 | register_gridfunctions_for_single_rank1 | 105 | 122 | 105 | 106 | f6f5bff124eeb5d50400174ad4a4ce492ebff924 | bigcode/the-stack | train |
d9855f2d0b27a42461f16624 | train | function | def declarerank3(objname, symmetry_option, DIM=-1):
if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[[sp.sympify(objname + str(i) + str(j) + str(k)) for k in range(DIM)] for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(DIM):
for k in range... | def declarerank3(objname, symmetry_option, DIM=-1):
| if DIM==-1:
DIM = par.parval_from_str("DIM")
IDX_OBJ_TMP = [[[sp.sympify(objname + str(i) + str(j) + str(k)) for k in range(DIM)] for j in range(DIM)] for i in range(DIM)]
for i in range(DIM):
for j in range(DIM):
for k in range(DIM):
if symmetry_option == "sym01"... | if save == True:
gf_list.append(str(IDX_OBJ_TMP[i][j]))
gri.register_gridfunctions(gf_type,gf_list, is_indexed=True)
# Step 3: Return array of SymPy variables
return IDX_OBJ_TMP
def declarerank3(objname, symmetry_option, DIM=-1):
| 70 | 70 | 234 | 15 | 54 | kazewong/nrpytutorial | indexedexp.py | Python | declarerank3 | declarerank3 | 171 | 187 | 171 | 171 | bcd653e0a5bcc6116111bb7354deef167df31e85 | bigcode/the-stack | train |
e16c0c2e004fc3599563c13d | train | function | def increment_version_release():
v = increment_release(version)
with open(version_file, "w") as f:
f.write("version = '%s'\n" % v)
| def increment_version_release():
| v = increment_release(version)
with open(version_file, "w") as f:
f.write("version = '%s'\n" % v)
| 3:]) + 1)]
return ".".join(v)
def increment_version_dev():
v = increment_dev(version)
os.path.dirname(__file__)
with open(version_file, "w") as f:
f.write("version = '%s'\n" % v)
def increment_version_release():
| 64 | 64 | 38 | 5 | 59 | jselvam11/problog | setup.py | Python | increment_version_release | increment_version_release | 113 | 116 | 113 | 113 | 84022ec36eb88e378f63a4067b981b6cf20985e3 | bigcode/the-stack | train |
3930f552015e6330ef568118 | train | function | def increment_release(v):
v = v.split(".")
if len(v) == 4:
v = v[:3] + [str(int(v[3]) + 1)]
else:
v = v[:4]
return ".".join(v)
| def increment_release(v):
| v = v.split(".")
if len(v) == 4:
v = v[:3] + [str(int(v[3]) + 1)]
else:
v = v[:4]
return ".".join(v)
| =find_packages(),
extras_require={"sdd": ["pysdd>=0.2.6"]},
entry_points={"console_scripts": ["problog=problog.tasks:main"]},
package_data=package_data,
cmdclass={"install": ProbLogInstall},
)
def increment_release(v):
| 64 | 64 | 57 | 5 | 59 | jselvam11/problog | setup.py | Python | increment_release | increment_release | 88 | 94 | 88 | 88 | 71bae1c5b8b2adfffb82748e9045765d5c034a42 | bigcode/the-stack | train |
1cc48842e275356271041558 | train | function | def increment_version_dev():
v = increment_dev(version)
os.path.dirname(__file__)
with open(version_file, "w") as f:
f.write("version = '%s'\n" % v)
| def increment_version_dev():
| v = increment_dev(version)
os.path.dirname(__file__)
with open(version_file, "w") as f:
f.write("version = '%s'\n" % v)
| :
v = v[:3] + [str(int(v[3]) + 1), "dev1"]
else:
v = v[:4] + ["dev" + str(int(v[4][3:]) + 1)]
return ".".join(v)
def increment_version_dev():
| 64 | 64 | 45 | 5 | 59 | jselvam11/problog | setup.py | Python | increment_version_dev | increment_version_dev | 106 | 110 | 106 | 106 | 0d48a979cc9a2b16e00afac387cd595a5186b771 | bigcode/the-stack | train |
b32a54e3ddf0765bf990ac67 | train | function | def increment_dev(v):
v = v.split(".")
if len(v) == 4:
v = v[:3] + [str(int(v[3]) + 1), "dev1"]
else:
v = v[:4] + ["dev" + str(int(v[4][3:]) + 1)]
return ".".join(v)
| def increment_dev(v):
| v = v.split(".")
if len(v) == 4:
v = v[:3] + [str(int(v[3]) + 1), "dev1"]
else:
v = v[:4] + ["dev" + str(int(v[4][3:]) + 1)]
return ".".join(v)
| )
def increment_release(v):
v = v.split(".")
if len(v) == 4:
v = v[:3] + [str(int(v[3]) + 1)]
else:
v = v[:4]
return ".".join(v)
def increment_dev(v):
| 64 | 64 | 79 | 5 | 59 | jselvam11/problog | setup.py | Python | increment_dev | increment_dev | 97 | 103 | 97 | 97 | b1b77a7709bb5fd454c1a92ebaf6efebc49429e1 | bigcode/the-stack | train |
306e02815c7bbd28250c35dd | train | function | def get_dataset(dataset, task):
# 多继承,返回的Dataset继承了KITTI类和DddDataset类
class Dataset(dataset_factory[dataset], _sample_factory[task]):
pass
return Dataset
| def get_dataset(dataset, task):
# 多继承,返回的Dataset继承了KITTI类和DddDataset类
| class Dataset(dataset_factory[dataset], _sample_factory[task]):
pass
return Dataset
| 'exdet': EXDetDataset,
'ctdet': CTDetDataset,
'ddd': DddDataset,
'multi_pose': MultiPoseDataset
}
def get_dataset(dataset, task):
# 多继承,返回的Dataset继承了KITTI类和DddDataset类
| 64 | 64 | 49 | 28 | 36 | kaixinbear/rtm | src/lib/datasets/dataset_factory.py | Python | get_dataset | get_dataset | 31 | 35 | 31 | 32 | 517a2950ddfe035096c0e13422343c593d37cf2b | bigcode/the-stack | train |
e40ed43e207910a1d47c78c4 | train | function | def test_is_valid_parcel_string_has_valid_format():
assert is_valid_parcel_string('123-12-123') is True
| def test_is_valid_parcel_string_has_valid_format():
| assert is_valid_parcel_string('123-12-123') is True
| import pytest
from cle_parcel_lookup.utils.validator import is_valid_parcel_string
def test_is_valid_parcel_string_has_valid_format():
| 28 | 64 | 28 | 11 | 16 | gsvolt/cle_parcel_lookup | tests/test_validator.py | Python | test_is_valid_parcel_string_has_valid_format | test_is_valid_parcel_string_has_valid_format | 5 | 6 | 5 | 5 | b43f31f5a15dbaeb3f1e742f7ca22b54f7b23861 | bigcode/the-stack | train |
ce9bb6cb0a198beaff7e0581 | train | function | def test_is_valid_parcel_string_has_invalid_format():
assert is_valid_parcel_string('lorem ipsum') is False
with pytest.raises(TypeError):
assert is_valid_parcel_string(object()) is False
| def test_is_valid_parcel_string_has_invalid_format():
| assert is_valid_parcel_string('lorem ipsum') is False
with pytest.raises(TypeError):
assert is_valid_parcel_string(object()) is False
| import pytest
from cle_parcel_lookup.utils.validator import is_valid_parcel_string
def test_is_valid_parcel_string_has_valid_format():
assert is_valid_parcel_string('123-12-123') is True
def test_is_valid_parcel_string_has_invalid_format():
| 56 | 64 | 45 | 11 | 44 | gsvolt/cle_parcel_lookup | tests/test_validator.py | Python | test_is_valid_parcel_string_has_invalid_format | test_is_valid_parcel_string_has_invalid_format | 9 | 12 | 9 | 9 | 29111a5be76baa99f0faaa02447e54b189094b3a | bigcode/the-stack | train |
91950ae39941851e94e41e8d | train | function | @tvm.te.tag_scope(tag=tag.INJECTIVE+",fifo_buffer")
def fifo_buffer(data, buffer, axis):
"""
FIFO buffer to enable computation reuse in CNNs with sliding indow input
Compute equivalent of
.. code-block:: python
concat(buffer, data, axis=axis)
.slice_axis(axis=axis,
... | @tvm.te.tag_scope(tag=tag.INJECTIVE+",fifo_buffer")
def fifo_buffer(data, buffer, axis):
| """
FIFO buffer to enable computation reuse in CNNs with sliding indow input
Compute equivalent of
.. code-block:: python
concat(buffer, data, axis=axis)
.slice_axis(axis=axis,
begin=data.shape[axis],
end=data.shape[axis]+buffer.shape[axis])
... | # Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | 240 | 256 | 1,249 | 25 | 214 | jiangzoi/incubator-tvm | topi/python/topi/nn/fifo_buffer.py | Python | fifo_buffer | fifo_buffer | 25 | 156 | 25 | 26 | e41bbe817a5c98de3822eec40a4e083bc94c81a9 | bigcode/the-stack | train |
2dc7e50242956f278ac36b8a | train | class | class FilterBase(object):
def __init__(self, csv_path, filters: dict = None):
self._path = csv_path
self.filters = filters.copy() if filters is not None else None
@property
def path(self) -> str:
return self._path
def isValid(self, row: dict) -> bool:
if not isinstance(... | class FilterBase(object):
| def __init__(self, csv_path, filters: dict = None):
self._path = csv_path
self.filters = filters.copy() if filters is not None else None
@property
def path(self) -> str:
return self._path
def isValid(self, row: dict) -> bool:
if not isinstance(row, dict):
re... | """Restaurant Site - Gathernomics Filter Base.
Copyright (c) 2018 Alex Dale
See LICENSE for information.
"""
import re
import csv
from datetime import datetime as DateTime
from datetime import date as Date
import logging
from typing import List
from gathernomics.models.factor import TemporalFrequency
logger = loggi... | 86 | 170 | 568 | 5 | 81 | SuperOxigen/CanDev-Finance-Canada | gathernomics/filters/base.py | Python | FilterBase | FilterBase | 19 | 94 | 19 | 19 | 0adf4bf2386dad05c0b76b921eec787d447e274f | bigcode/the-stack | train |
bbb921531b4d109919a24e97 | train | class | class TestSSHLs(MockBoto3TestCase):
def setUp(self):
super(TestSSHLs, self).setUp()
self.make_runner()
def tearDown(self):
super(TestSSHLs, self).tearDown()
def make_runner(self):
self.runner = EMRJobRunner(conf_paths=[])
self.prepare_runner_for_ssh(self.runner)
... | class TestSSHLs(MockBoto3TestCase):
| def setUp(self):
super(TestSSHLs, self).setUp()
self.make_runner()
def tearDown(self):
super(TestSSHLs, self).tearDown()
def make_runner(self):
self.runner = EMRJobRunner(conf_paths=[])
self.prepare_runner_for_ssh(self.runner)
def test_ssh_ls(self):
sel... | mapreduce.amazonaws.com')
def test_explicit_endpoint(self):
runner = EMRJobRunner(conf_paths=[], region='eu-west-2',
emr_endpoint='emr-proxy')
self.assertEqual(runner._opts['region'], 'eu-west-2')
self.assertEqual(runner.make_emr_client().meta.endpoint_url,
... | 93 | 93 | 312 | 12 | 81 | Affirm/mrjob | tests/test_emr.py | Python | TestSSHLs | TestSSHLs | 1,462 | 1,495 | 1,462 | 1,463 | 7fbefc9773b07430725a466602dbc1046a57f54e | bigcode/the-stack | train |
c4a4c39f31c53ff544b8d402 | train | class | class MasterBootstrapScriptTestCase(MockBoto3TestCase):
def test_usr_bin_env(self):
runner = EMRJobRunner(conf_paths=[],
bootstrap_mrjob=True,
sh_bin='bash -e')
runner._add_bootstrap_files_for_upload()
self.assertIsNotNone(runner... | class MasterBootstrapScriptTestCase(MockBoto3TestCase):
| def test_usr_bin_env(self):
runner = EMRJobRunner(conf_paths=[],
bootstrap_mrjob=True,
sh_bin='bash -e')
runner._add_bootstrap_files_for_upload()
self.assertIsNotNone(runner._master_bootstrap_script_path)
self.assertTrue(o... | '), b'')
self.assertEqual(
sorted(self.runner.fs.ls('ssh://testmaster/test')),
['ssh://testmaster/test/one', 'ssh://testmaster/test/two'])
self.assertEqual(
list(self.runner.fs.ls('ssh://testmaster!testworker0/test')),
['ssh://testmaster!testworker0/test... | 256 | 256 | 2,677 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | MasterBootstrapScriptTestCase | MasterBootstrapScriptTestCase | 1,512 | 1,820 | 1,512 | 1,513 | 133416e13ca3049ed4795333f6e85e06baab5f70 | bigcode/the-stack | train |
36931ddb7a6039cf165da7e8 | train | class | class LsStepStderrLogsTestCase(MockBoto3TestCase):
def setUp(self):
super(LsStepStderrLogsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_step_stderr_logs = self.start(patch(
'mrjob.emr._ls_emr_step_stderr_logs'))
self._stream_step_lo... | class LsStepStderrLogsTestCase(MockBoto3TestCase):
| def setUp(self):
super(LsStepStderrLogsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_step_stderr_logs = self.start(patch(
'mrjob.emr._ls_emr_step_stderr_logs'))
self._stream_step_log_dirs = self.start(patch(
'mrjob.emr.EM... | self._ls_emr_step_syslogs.assert_called_once_with(
runner.fs,
self._stream_step_log_dirs.return_value,
step_id='s-STEPID')
self.assertEqual(self.log.info.call_count, 1)
self.assertIn('s3://bucket/logs/steps/syslog',
self.log.info.call_args[0][0... | 104 | 104 | 348 | 16 | 88 | Affirm/mrjob | tests/test_emr.py | Python | LsStepStderrLogsTestCase | LsStepStderrLogsTestCase | 3,882 | 3,924 | 3,882 | 3,883 | dca11bfb4aa0c6ca209f16a0c318a57e7af6db1f | bigcode/the-stack | train |
1039a22accb10aae5a0a83a7 | train | class | class SetupLineEncodingTestCase(MockBoto3TestCase):
def test_setup_wrapper_script_uses_unix_line_endings(self):
job = MRTwoStepJob(['-r', 'emr', '--setup', 'true'])
job.sandbox(stdin=BytesIO(b'foo\nbar\n'))
# tests #1071. Unfortunately, we mostly run these tests on machines
# that ... | class SetupLineEncodingTestCase(MockBoto3TestCase):
| def test_setup_wrapper_script_uses_unix_line_endings(self):
job = MRTwoStepJob(['-r', 'emr', '--setup', 'true'])
job.sandbox(stdin=BytesIO(b'foo\nbar\n'))
# tests #1071. Unfortunately, we mostly run these tests on machines
# that use unix line endings anyway. So monitor open() inste... | ', 'iam.us-gov.amazonaws.com'])
with mr_job.make_runner() as runner:
iam_client = runner.make_iam_client()
self.assertEqual(iam_client.meta.endpoint_url,
'https://iam.us-gov.amazonaws.com')
class SetupLineEncodingTestCase(MockBoto3TestCase):
| 64 | 64 | 155 | 13 | 51 | Affirm/mrjob | tests/test_emr.py | Python | SetupLineEncodingTestCase | SetupLineEncodingTestCase | 3,391 | 3,406 | 3,391 | 3,392 | e3adf9ce4de208231ade149fc5bd6a211acfd11f | bigcode/the-stack | train |
c4a53af1f20ef499d4b24e36 | train | class | class AWSSessionTokenTestCase(MockBoto3TestCase):
def setUp(self):
super(AWSSessionTokenTestCase, self).setUp()
self.mock_client = self.start(patch('boto3.client'))
self.mock_resource = self.start(patch('boto3.resource'))
def assert_conns_use_session_token(self, runner, session_token)... | class AWSSessionTokenTestCase(MockBoto3TestCase):
| def setUp(self):
super(AWSSessionTokenTestCase, self).setUp()
self.mock_client = self.start(patch('boto3.client'))
self.mock_resource = self.start(patch('boto3.resource'))
def assert_conns_use_session_token(self, runner, session_token):
runner.make_emr_client()
self.as... | to simulate multipart upload, but now we leave
# that to boto3
runner = EMRJobRunner(cloud_part_size_mb=50.0 / 1024 / 1024)
data = b'Mew' * 20
self.assert_upload_succeeds(runner, data, 50)
def test_disable_multipart(self):
runner = EMRJobRunner(cloud_part_size_mb=0)
... | 134 | 134 | 449 | 14 | 120 | Affirm/mrjob | tests/test_emr.py | Python | AWSSessionTokenTestCase | AWSSessionTokenTestCase | 2,974 | 3,024 | 2,974 | 2,975 | 676f62698163fac947516b3d40b12fa3ae7a4c36 | bigcode/the-stack | train |
c75a65fe5bf9957fd43bda55 | train | class | class BadBashWorkaroundTestCase(MockBoto3TestCase):
# regression test for 1548
def _test_sh_bin(self, image_version, expected_bin, expected_pre_commands):
cookie_jar = self.makefile('cookie.jar')
job = MRTwoStepJob(['-r', 'emr', '--image-version', image_version,
'--... | class BadBashWorkaroundTestCase(MockBoto3TestCase):
# regression test for 1548
| def _test_sh_bin(self, image_version, expected_bin, expected_pre_commands):
cookie_jar = self.makefile('cookie.jar')
job = MRTwoStepJob(['-r', 'emr', '--image-version', image_version,
'--libjars', cookie_jar])
job.sandbox()
def check_script(path):
... | _core_nodes(self):
self.assertEqual(
len(self._ssh_worker_hosts('--num-core-instances', '2')),
2)
def test_include_task_nodes(self):
self.assertEqual(
len(self._ssh_worker_hosts('--num-core-instances', '2',
'--num-task-insta... | 96 | 96 | 323 | 24 | 72 | Affirm/mrjob | tests/test_emr.py | Python | BadBashWorkaroundTestCase | BadBashWorkaroundTestCase | 5,405 | 5,444 | 5,405 | 5,407 | 1850ab059e370d3f87db854bb9cf553e8c016880 | bigcode/the-stack | train |
872ce146649114ff5c4799d7 | train | class | class EMRNoMapperTestCase(MockBoto3TestCase):
def test_no_mapper(self):
# read from STDIN, a local file, and a remote file
stdin = BytesIO(b'foo\nbar\n')
local_input_path = os.path.join(self.tmp_dir, 'input')
with open(local_input_path, 'wb') as local_input_file:
local_... | class EMRNoMapperTestCase(MockBoto3TestCase):
| def test_no_mapper(self):
# read from STDIN, a local file, and a remote file
stdin = BytesIO(b'foo\nbar\n')
local_input_path = os.path.join(self.tmp_dir, 'input')
with open(local_input_path, 'wb') as local_input_file:
local_input_file.write(b'one fish two fish\nred fish ... | _setup=['cat moo.txt > meow.txt'])
runner._add_master_node_setup_files_for_upload()
self.assertIsNotNone(runner._master_node_setup_script_path)
self.assertIn('moo.txt', runner._upload_mgr._path_to_name)
self.assertNotIn('meow.txt', runner._upload_mgr._path_to_name)
class EMRNoMapperTes... | 86 | 86 | 289 | 14 | 72 | Affirm/mrjob | tests/test_emr.py | Python | EMRNoMapperTestCase | EMRNoMapperTestCase | 1,916 | 1,947 | 1,916 | 1,917 | a7901ad9cec836a23a5efa0cf4a3a05ef78b48db | bigcode/the-stack | train |
3819c7a03fb6db15d1d87443 | train | class | class EMRApplicationsTestCase(MockBoto3TestCase):
def test_default_on_3_x_ami(self):
job = MRTwoStepJob(['-r', 'emr', '--image-version', '3.11.0'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(runner._applications(), set())
self.launch(runner)
... | class EMRApplicationsTestCase(MockBoto3TestCase):
| def test_default_on_3_x_ami(self):
job = MRTwoStepJob(['-r', 'emr', '--image-version', '3.11.0'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(runner._applications(), set())
self.launch(runner)
cluster = runner._describe_cluster()
... | erTestCase, self).setUp()
# _hadoop_args_for_step() needs this
self.start(patch(
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='1.2.0'))
def test_sort_values(self):
job = MRSortValues(['-r', 'emr'])
with job.make_runner() as runner:
s... | 165 | 166 | 555 | 13 | 152 | Affirm/mrjob | tests/test_emr.py | Python | EMRApplicationsTestCase | EMRApplicationsTestCase | 4,089 | 4,159 | 4,089 | 4,090 | 6c60615820f989b38b903665133123603ed1eb48 | bigcode/the-stack | train |
253a7e8bbbb2e30a061dbfb3 | train | class | class BuildMasterNodeSetupStepTestCase(MockBoto3TestCase):
def test_build_master_node_setup_step(self):
runner = EMRJobRunner(libjars=['cookie.jar'])
runner._add_master_node_setup_files_for_upload()
self.assertIsNotNone(runner._master_node_setup_script_path)
master_node_setup_uri =... | class BuildMasterNodeSetupStepTestCase(MockBoto3TestCase):
| def test_build_master_node_setup_step(self):
runner = EMRJobRunner(libjars=['cookie.jar'])
runner._add_master_node_setup_files_for_upload()
self.assertIsNotNone(runner._master_node_setup_script_path)
master_node_setup_uri = runner._upload_mgr.uri(
runner._master_node_set... | self.assertEqual(
step_args[1:],
[
'<spark submit args>',
script_uri,
input1_uri + ',' + input2_uri,
'-o',
runner._output_dir,
]
)
class BuildMaster... | 64 | 64 | 171 | 15 | 49 | Affirm/mrjob | tests/test_emr.py | Python | BuildMasterNodeSetupStepTestCase | BuildMasterNodeSetupStepTestCase | 2,857 | 2,875 | 2,857 | 2,858 | 5e8dec354da1bdc607b24173580de21aa1f15f59 | bigcode/the-stack | train |
b0241a9d34d364c76c0722ca | train | class | class ExistingClusterTestCase(MockBoto3TestCase):
def test_attach_to_existing_cluster(self):
emr_client = EMRJobRunner(conf_paths=[]).make_emr_client()
# create cluster without LogUri, to test Issue #112
cluster_id = emr_client.run_job_flow(
Instances=dict(
Insta... | class ExistingClusterTestCase(MockBoto3TestCase):
| def test_attach_to_existing_cluster(self):
emr_client = EMRJobRunner(conf_paths=[]).make_emr_client()
# create cluster without LogUri, to test Issue #112
cluster_id = emr_client.run_job_flow(
Instances=dict(
InstanceCount=1,
KeepJobFlowAliveWhenNoS... | (self):
self._test_cloud_tmp_cleanup('CLOUD_TMP', 0, 1)
def test_cleanup_local(self):
self._test_cloud_tmp_cleanup('LOCAL_TMP', 5, 1)
def test_cleanup_logs(self):
self._test_cloud_tmp_cleanup('LOGS', 5, 0)
def test_cleanup_none(self):
self._test_cloud_tmp_cleanup('NONE', 5... | 194 | 194 | 649 | 12 | 182 | Affirm/mrjob | tests/test_emr.py | Python | ExistingClusterTestCase | ExistingClusterTestCase | 351 | 427 | 351 | 352 | 4f8d40182e6463a05969b2215124a2d397208e11 | bigcode/the-stack | train |
12911f399437ee97f80e656e | train | class | class TmpBucketTestCase(MockBoto3TestCase):
def assert_new_tmp_bucket(self, location, **runner_kwargs):
"""Assert that if we create an EMRJobRunner with the given keyword
args, it'll create a new tmp bucket with the given location
constraint.
"""
existing_bucket_names = set(... | class TmpBucketTestCase(MockBoto3TestCase):
| def assert_new_tmp_bucket(self, location, **runner_kwargs):
"""Assert that if we create an EMRJobRunner with the given keyword
args, it'll create a new tmp bucket with the given location
constraint.
"""
existing_bucket_names = set(self.mock_s3_fs)
runner = EMRJobRunn... | get('Ec2AvailabilityZone'),
'PUPPYLAND')
class EnableDebuggingTestCase(MockBoto3TestCase):
def test_debugging_works(self):
with self.make_runner('--enable-emr-debugging') as runner:
runner.run()
steps = _list_all_steps(runner)
self.assertEqual(steps[0]... | 210 | 210 | 703 | 12 | 198 | Affirm/mrjob | tests/test_emr.py | Python | TmpBucketTestCase | TmpBucketTestCase | 851 | 929 | 851 | 852 | 93f39f57c0c6679e031ea659179fe6b591950699 | bigcode/the-stack | train |
e75bb6334055d98bd3579bac | train | class | class AMIAndHadoopVersionTestCase(MockBoto3TestCase):
def test_default(self):
with self.make_runner() as runner:
runner.run()
self.assertEqual(runner.get_image_version(),
_DEFAULT_IMAGE_VERSION)
self.assertEqual(runner.get_hadoop_version(), '... | class AMIAndHadoopVersionTestCase(MockBoto3TestCase):
| def test_default(self):
with self.make_runner() as runner:
runner.run()
self.assertEqual(runner.get_image_version(),
_DEFAULT_IMAGE_VERSION)
self.assertEqual(runner.get_hadoop_version(), '2.8.4')
def test_ami_version_1_0_no_longer_support... | acement=null')
self.assertIsNone(
cluster['Ec2InstanceAttributes'].get('Ec2AvailabilityZone'))
# shoudn't blow away subnet, also set in Instances
self.assertEqual(
cluster['Ec2InstanceAttributes']['Ec2SubnetId'],
'subnet-ffffffff')
def test_set_nested_p... | 208 | 208 | 694 | 16 | 192 | Affirm/mrjob | tests/test_emr.py | Python | AMIAndHadoopVersionTestCase | AMIAndHadoopVersionTestCase | 707 | 767 | 707 | 708 | 72346d9ff3df1b4e02639c30576486a24862037f | bigcode/the-stack | train |
9ba6cf2ac503143f390fbabb | train | class | class IAMTestCase(MockBoto3TestCase):
def setUp(self):
super(IAMTestCase, self).setUp()
# wrap boto3.client() so we can see if it was called
self.start(patch('boto3.client', wraps=boto3.client))
def test_role_auto_creation(self):
cluster = self.run_and_get_cluster()
se... | class IAMTestCase(MockBoto3TestCase):
| def setUp(self):
super(IAMTestCase, self).setUp()
# wrap boto3.client() so we can see if it was called
self.start(patch('boto3.client', wraps=boto3.client))
def test_role_auto_creation(self):
cluster = self.run_and_get_cluster()
self.assertTrue(boto3.client.called)
... | net', '')
self.assertEqual(cluster['Ec2InstanceAttributes'].get('Ec2SubnetId'),
None)
def test_blank_out_subnet_in_mrjob_conf(self):
# regression test for #1931
self.start(mrjob_conf_patcher(dict(runners=dict(emr=dict(
subnet='subnet-ffffffff')))))
... | 236 | 237 | 793 | 11 | 225 | Affirm/mrjob | tests/test_emr.py | Python | IAMTestCase | IAMTestCase | 519 | 614 | 519 | 520 | 293a3cb5df4f6140323a5569f08c04470eaf783b | bigcode/the-stack | train |
89168a895a6ad9cc05d335ac | train | class | class LogProgressTestCase(MockBoto3TestCase):
def setUp(self):
super(LogProgressTestCase, self).setUp()
self._progress_html_from_tunnel = self.start(patch(
'mrjob.emr.EMRJobRunner._progress_html_from_tunnel'))
self._progress_html_over_ssh = self.start(patch(
'mrjob.... | class LogProgressTestCase(MockBoto3TestCase):
| def setUp(self):
super(LogProgressTestCase, self).setUp()
self._progress_html_from_tunnel = self.start(patch(
'mrjob.emr.EMRJobRunner._progress_html_from_tunnel'))
self._progress_html_over_ssh = self.start(patch(
'mrjob.emr.EMRJobRunner._progress_html_over_ssh'))
... | (script)
self.assertEqual(lines[0].strip(),
'#!%s' % cmd_line(expected_bin))
# everything up to first newline is a pre-command
pre_commands = []
for line in lines[1:]:
cmd = line.strip()
... | 220 | 221 | 739 | 12 | 208 | Affirm/mrjob | tests/test_emr.py | Python | LogProgressTestCase | LogProgressTestCase | 5,447 | 5,534 | 5,447 | 5,448 | 108adbfc655dc5957ed07e964bb97ccbdb428f24 | bigcode/the-stack | train |
86ed57832ede73457dd49495 | train | class | class MaxMinsIdleTestCase(MockBoto3TestCase):
def assertRanIdleTimeoutScriptWith(self, runner, args):
actions = _list_all_bootstrap_actions(runner)
action = actions[-1]
self.assertEqual(action['Name'], 'idle timeout')
self.assertEqual(
action['ScriptPath'],
... | class MaxMinsIdleTestCase(MockBoto3TestCase):
| def assertRanIdleTimeoutScriptWith(self, runner, args):
actions = _list_all_bootstrap_actions(runner)
action = actions[-1]
self.assertEqual(action['Name'], 'idle timeout')
self.assertEqual(
action['ScriptPath'],
runner._upload_mgr.uri(_MAX_MINS_IDLE_BOOTSTRAP... | '}})
# setup fake output
self.mock_emr_output = {('j-MOCKCLUSTER0', 1): [
b'1\t["blue", "one", "red", "two"]\n',
b'4\t["fish"]\n']}
mr_job = MRNoMapper(['-r', 'emr', '-v',
'-', local_input_path, remote_input_path])
mr_job.sandbox(std... | 173 | 173 | 578 | 14 | 159 | Affirm/mrjob | tests/test_emr.py | Python | MaxMinsIdleTestCase | MaxMinsIdleTestCase | 1,950 | 2,016 | 1,950 | 1,951 | e2140f797a4ef1b079b416ec166e269f15925774 | bigcode/the-stack | train |
6f7a640588101aa1946e9f13 | train | class | class GetStepLogInterpretationTestCase(MockBoto3TestCase):
def setUp(self):
super(GetStepLogInterpretationTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._interpret_emr_step_syslog = self.start(patch(
'mrjob.emr._interpret_emr_step_syslog'))
... | class GetStepLogInterpretationTestCase(MockBoto3TestCase):
| def setUp(self):
super(GetStepLogInterpretationTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._interpret_emr_step_syslog = self.start(patch(
'mrjob.emr._interpret_emr_step_syslog'))
self._ls_step_syslogs = self.start(patch(
'mrjob... | ._stream_step_log_dirs'))
def test_basic(self):
# just verify that the keyword args get passed through and
# that logging happens in the right order
self._ls_emr_step_stderr_logs.return_value = [
dict(path='s3://bucket/logs/steps/stderr'),
]
runner = EMRJobRunn... | 256 | 256 | 1,038 | 15 | 241 | Affirm/mrjob | tests/test_emr.py | Python | GetStepLogInterpretationTestCase | GetStepLogInterpretationTestCase | 3,927 | 4,049 | 3,927 | 3,928 | 428c0f32e54dc08dbecb52d6090706a764bfa78c | bigcode/the-stack | train |
4296043e554d626e578c210c | train | class | class EMRCredentialsObfuscationTestCase(MockBoto3TestCase):
def get_debug_printout(self, **opts):
with patch('mrjob.runner.log') as log:
# debug printout happens in constructor
EMRJobRunner(**opts)
return ''.join(a[0] + '\n' for a, kw in log.debug.call_args_list)
d... | class EMRCredentialsObfuscationTestCase(MockBoto3TestCase):
| def get_debug_printout(self, **opts):
with patch('mrjob.runner.log') as log:
# debug printout happens in constructor
EMRJobRunner(**opts)
return ''.join(a[0] + '\n' for a, kw in log.debug.call_args_list)
def test_non_obfuscated_option_on_emr(self):
printout ... | OCK_MASTER,
['curl', self.MOCK_JOB_TRACKER_URL])
self.assertEqual(html, self._ssh_run.return_value[0])
def test_no_key_pair_file(self):
self.assertIsNone(self._launch_and_get_progress_html(
'--ec2-key-pair-file', ''))
self.assertFalse(self._ssh_run.called)
def... | 134 | 134 | 448 | 16 | 118 | Affirm/mrjob | tests/test_emr.py | Python | EMRCredentialsObfuscationTestCase | EMRCredentialsObfuscationTestCase | 5,672 | 5,723 | 5,672 | 5,673 | 180214bb9f71cb1a2af2d6ce7a58ed867be96684 | bigcode/the-stack | train |
d2abe3319a3537ae7983820b | train | class | class JobWaitTestCase(MockBoto3TestCase):
# A list of job ids that hold booleans of whether or not the job can
# acquire a lock. Helps simulate mrjob.emr._attempt_to_acquire_lock.
JOB_ID_LOCKS = {
'j-fail-lock': False,
'j-successful-lock': True,
'j-brown': True,
'j-epic-fail... | class JobWaitTestCase(MockBoto3TestCase):
# A list of job ids that hold booleans of whether or not the job can
# acquire a lock. Helps simulate mrjob.emr._attempt_to_acquire_lock.
| JOB_ID_LOCKS = {
'j-fail-lock': False,
'j-successful-lock': True,
'j-brown': True,
'j-epic-fail-lock': False
}
def setUp(self):
super(JobWaitTestCase, self).setUp()
self.future_mock_cluster_ids = []
self.mock_cluster_ids = []
self.sleep_counte... | ') as m:
r._cleanup_cluster()
self.assertTrue(m().terminate_job_flows.called)
def test_kill_cluster_if_successful(self):
# If they are setting up the cleanup to kill the cluster, mrjob should
# kill the cluster independent of job success.
r = self._quick_runner()
... | 237 | 237 | 792 | 51 | 186 | Affirm/mrjob | tests/test_emr.py | Python | JobWaitTestCase | JobWaitTestCase | 2,135 | 2,225 | 2,135 | 2,138 | b0d5e13fc33a12bbca9d6df30ed56ec70e6b8923 | bigcode/the-stack | train |
eeedfe6fcac1685fbeb71bee | train | class | class ExtraClusterParamsTestCase(MockBoto3TestCase):
def test_set_unsupported_json_param(self):
cluster = self.run_and_get_cluster(
'--image-version', '3.7.0',
'--extra-cluster-param', 'SupportedProducts=["mapr-m3"]')
self.assertIn('mapr-m3', [a['Name'] for a in cluster['Ap... | class ExtraClusterParamsTestCase(MockBoto3TestCase):
| def test_set_unsupported_json_param(self):
cluster = self.run_and_get_cluster(
'--image-version', '3.7.0',
'--extra-cluster-param', 'SupportedProducts=["mapr-m3"]')
self.assertIn('mapr-m3', [a['Name'] for a in cluster['Applications']])
def test_set_unsupported_string_pa... | .assertEqual(cluster['ServiceRole'], 'EMR_DefaultRole')
def test_no_iam_access(self):
boto3_client = boto3.client
def forbidding_boto3_client(service_name, **kwargs):
if service_name == 'iam':
raise ClientError(
dict(
Error=di... | 214 | 214 | 714 | 13 | 201 | Affirm/mrjob | tests/test_emr.py | Python | ExtraClusterParamsTestCase | ExtraClusterParamsTestCase | 617 | 704 | 617 | 618 | 5ac3622d2a5ef2acaf3297ad20b64a57e3d62a8f | bigcode/the-stack | train |
952deebaa351b69bc83dd28a | train | class | class ImageVersionGteTestCase(MockBoto3TestCase):
def test_image_version(self):
runner = EMRJobRunner(image_version='3.7.0')
self.assertTrue(runner._image_version_gte('3'))
self.assertTrue(runner._image_version_gte('3.7.0'))
self.assertFalse(runner._image_version_gte('3.8.0'))
... | class ImageVersionGteTestCase(MockBoto3TestCase):
| def test_image_version(self):
runner = EMRJobRunner(image_version='3.7.0')
self.assertTrue(runner._image_version_gte('3'))
self.assertTrue(runner._image_version_gte('3.7.0'))
self.assertFalse(runner._image_version_gte('3.8.0'))
def test_release_label(self):
runner = EMR... | DemandCapacity=1,
),
]
job = MRNullSpark(
['-r', 'emr', '--instance-fleets', json.dumps(instance_fleets)])
job.sandbox()
with job.make_runner() as runner:
self.launch(runner)
message = runner._cluster_spark_support_warning()
... | 90 | 90 | 300 | 14 | 76 | Affirm/mrjob | tests/test_emr.py | Python | ImageVersionGteTestCase | ImageVersionGteTestCase | 5,327 | 5,352 | 5,327 | 5,328 | fb7968ac7bba3f0c086c8b700d803e4083828362 | bigcode/the-stack | train |
9a6977ce47a6e21b95a079f9 | train | class | class BootstrapPythonTestCase(MockBoto3TestCase):
if PY2:
EXPECTED_BOOTSTRAP = []
else:
EXPECTED_BOOTSTRAP = [
['sudo yum install -y python34 python34-devel python34-pip']]
def _assert_installs_python3_on_py3(self, *args):
mr_job = MRTwoStepJob(['-r', 'emr'] + list(args... | class BootstrapPythonTestCase(MockBoto3TestCase):
| if PY2:
EXPECTED_BOOTSTRAP = []
else:
EXPECTED_BOOTSTRAP = [
['sudo yum install -y python34 python34-devel python34-pip']]
def _assert_installs_python3_on_py3(self, *args):
mr_job = MRTwoStepJob(['-r', 'emr'] + list(args))
with mr_job.make_runner() as runner:
... | aws_session_token'], session_token)
self.mock_client.reset_mock()
runner.fs.s3.make_s3_client()
self.assertTrue(self.mock_client.called)
s3_client_args, s3_client_kwargs = self.mock_client.call_args
self.assertEqual(s3_client_args, ('s3',))
self.assertIn('aws_session_to... | 256 | 256 | 918 | 12 | 244 | Affirm/mrjob | tests/test_emr.py | Python | BootstrapPythonTestCase | BootstrapPythonTestCase | 3,027 | 3,123 | 3,027 | 3,028 | e02235697b1b9bc32d73f286aee038e89247e31c | bigcode/the-stack | train |
b02c714667d75e99ffc10aa6 | train | class | class EMRConfigurationsTestCase(MockBoto3TestCase):
# don't patch load_opts_from_mrjob_confs()
MRJOB_CONF_CONTENTS = None
# example from:
# http://docs.aws.amazon.com/ElasticMapReduce/latest/ReleaseGuide/emr-configure-apps.html # noqa
def test_default(self):
job = MRTwoStepJob(['-r', 'em... | class EMRConfigurationsTestCase(MockBoto3TestCase):
# don't patch load_opts_from_mrjob_confs()
| MRJOB_CONF_CONTENTS = None
# example from:
# http://docs.aws.amazon.com/ElasticMapReduce/latest/ReleaseGuide/emr-configure-apps.html # noqa
def test_default(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.launch(runner... | r', '--applications', 'Hadoop,Mahout'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(runner._applications(),
set(['Hadoop', 'Mahout']))
self.launch(runner)
cluster = runner._describe_cluster()
application... | 255 | 256 | 1,322 | 26 | 229 | Affirm/mrjob | tests/test_emr.py | Python | EMRConfigurationsTestCase | EMRConfigurationsTestCase | 4,162 | 4,331 | 4,162 | 4,164 | 09fe0d3f19f9d97ea131366f0f77e41bd32e6037 | bigcode/the-stack | train |
7fbb8f3f740f50033332aa4d | train | class | class NoBoto3TestCase(SandboxedTestCase):
def setUp(self):
super(NoBoto3TestCase, self).setUp()
self.start(patch('mrjob.emr.boto3', None))
self.start(patch('mrjob.fs.s3.boto3', None))
def test_init(self):
# merely creating an EMRJobRunner should raise an exception
# be... | class NoBoto3TestCase(SandboxedTestCase):
| def setUp(self):
super(NoBoto3TestCase, self).setUp()
self.start(patch('mrjob.emr.boto3', None))
self.start(patch('mrjob.fs.s3.boto3', None))
def test_init(self):
# merely creating an EMRJobRunner should raise an exception
# because it'll need to connect to S3 to set cl... | worker0/test/three'])
# ls() is a generator, so the exception won't fire until we list() it
self.assertRaises(IOError, list,
self.runner.fs.ls('ssh://testmaster/does_not_exist'))
class NoBoto3TestCase(SandboxedTestCase):
| 63 | 64 | 119 | 13 | 50 | Affirm/mrjob | tests/test_emr.py | Python | NoBoto3TestCase | NoBoto3TestCase | 1,498 | 1,509 | 1,498 | 1,499 | a7b2575351d97bc6a814391b6ef78ae938dc771c | bigcode/the-stack | train |
e3eef6b15c1baf59b46c0687 | train | class | class MasterPrivateIPTestCase(MockBoto3TestCase):
# logic for runner._master_private_ip()
def test_master_private_ip(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertIsNone(runner._master_private_ip())
self.la... | class MasterPrivateIPTestCase(MockBoto3TestCase):
# logic for runner._master_private_ip()
| def test_master_private_ip(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertIsNone(runner._master_private_ip())
self.launch(runner)
self.assertIsNone(runner._master_private_ip())
self.simul... | with job.make_runner() as runner:
self.assertFalse(hasattr(runner.fs, 'ssh'))
self.launch(runner)
self.assertFalse(hasattr(runner.fs, 'ssh'))
class MasterPrivateIPTestCase(MockBoto3TestCase):
# logic for runner._master_private_ip()
| 63 | 64 | 116 | 23 | 40 | Affirm/mrjob | tests/test_emr.py | Python | MasterPrivateIPTestCase | MasterPrivateIPTestCase | 4,760 | 4,776 | 4,760 | 4,763 | f0ffd0f489fa2c488220c1e6b364c0cc46eb10b9 | bigcode/the-stack | train |
94acc9890dbfa93dc8527e8a | train | class | class TestCatFallback(MockBoto3TestCase):
def test_s3_cat(self):
self.add_mock_s3_data(
{'walrus': {'one': b'one_text',
'two': b'two_text',
'three': b'three_text'}})
runner = EMRJobRunner(cloud_tmp_dir='s3://walrus/tmp',
... | class TestCatFallback(MockBoto3TestCase):
| def test_s3_cat(self):
self.add_mock_s3_data(
{'walrus': {'one': b'one_text',
'two': b'two_text',
'three': b'three_text'}})
runner = EMRJobRunner(cloud_tmp_dir='s3://walrus/tmp',
conf_paths=[])
self.a... | r', 'emr', '--max-mins-idle', '60.00006'])
mr_job.sandbox()
with mr_job.make_runner() as runner:
runner.make_persistent_cluster()
self.assertRanIdleTimeoutScriptWith(runner, ['3600'])
def test_bootstrap_script_is_actually_installed(self):
self.assertTrue(os.path.exi... | 99 | 99 | 330 | 11 | 88 | Affirm/mrjob | tests/test_emr.py | Python | TestCatFallback | TestCatFallback | 2,019 | 2,053 | 2,019 | 2,020 | eae217267c1418647908c63f9abf14bcd78070e9 | bigcode/the-stack | train |
87677329dc818a5a15ca0b9b | train | class | class SSHWorkerHostsTestCase(MockBoto3TestCase):
def _ssh_worker_hosts(self, *args):
mr_job = MRTwoStepJob(['-r', 'emr'] + list(args))
mr_job.sandbox()
with mr_job.make_runner() as runner:
runner.run()
return runner._ssh_worker_hosts()
def test_ignore_master(s... | class SSHWorkerHostsTestCase(MockBoto3TestCase):
| def _ssh_worker_hosts(self, *args):
mr_job = MRTwoStepJob(['-r', 'emr'] + list(args))
mr_job.sandbox()
with mr_job.make_runner() as runner:
runner.run()
return runner._ssh_worker_hosts()
def test_ignore_master(self):
self.assertEqual(len(self._ssh_worke... | _mode_are_hard_coded(self):
runner = EMRJobRunner()
# these can't be configured
self.assertNotIn('spark_master', runner._opts)
self.assertNotIn('spark_deploy_mode', runner._opts)
class SSHWorkerHostsTestCase(MockBoto3TestCase):
| 64 | 64 | 169 | 13 | 51 | Affirm/mrjob | tests/test_emr.py | Python | SSHWorkerHostsTestCase | SSHWorkerHostsTestCase | 5,379 | 5,402 | 5,379 | 5,380 | 7a06f33c45cbdd0cf09a1bc8660cb364044a27c2 | bigcode/the-stack | train |
58d03cd4eb23d1a67bcb5eb7 | train | class | class WaitForStepsToCompleteTestCase(MockBoto3TestCase):
# TODO: test more functionality. This currently
# mostly ensures that we open the SSH tunnel at an appropriate time
class StopTest(Exception):
pass
def setUp(self):
super(WaitForStepsToCompleteTestCase, self).setUp()
# ... | class WaitForStepsToCompleteTestCase(MockBoto3TestCase):
# TODO: test more functionality. This currently
# mostly ensures that we open the SSH tunnel at an appropriate time
| class StopTest(Exception):
pass
def setUp(self):
super(WaitForStepsToCompleteTestCase, self).setUp()
# mock out setting up SSH tunnel
self.start(patch.object(EMRJobRunner, '_set_up_ssh_tunnel_and_hdfs'))
# mock out logging
self.start(patch('mrjob.emr.log'))
... | JobFlowId=runner.get_cluster_id(),
Steps=[dict(Name='dummy step',
HadoopJarStep=(dict(Jar='dummy.jar')))] * n,
)
job = MRTwoStepJob(['-r', 'emr', '--cluster-id', cluster_id]).sandbox()
with job.make_runner() as runner:
... | 256 | 256 | 1,655 | 41 | 215 | Affirm/mrjob | tests/test_emr.py | Python | WaitForStepsToCompleteTestCase | WaitForStepsToCompleteTestCase | 4,386 | 4,581 | 4,386 | 4,390 | e5a47ef16447cfe7aedf90bd1dab943620bded05 | bigcode/the-stack | train |
32c649a3232e7e4371bcc097 | train | class | class JarStepTestCase(MockBoto3TestCase):
MRJOB_CONF_CONTENTS = {'runners': {'emr': {
'emr_backoff': 0.01, # must be non-zero
'check_cluster_every': 0.00,
'cloud_fs_sync_secs': 0.00,
}}}
def test_local_jar_gets_uploaded(self):
fake_jar = os.path.join(self.tmp_dir, 'fake.ja... | class JarStepTestCase(MockBoto3TestCase):
| MRJOB_CONF_CONTENTS = {'runners': {'emr': {
'emr_backoff': 0.01, # must be non-zero
'check_cluster_every': 0.00,
'cloud_fs_sync_secs': 0.00,
}}}
def test_local_jar_gets_uploaded(self):
fake_jar = os.path.join(self.tmp_dir, 'fake.jar')
with open(fake_jar, 'w'):
... | 4_X_COMMAND_RUNNER_JAR, ['hadoop-streaming']))
def test_local_hadoop_streaming_jar(self):
jar_path = os.path.join(self.tmp_dir, 'righteousness.jar')
open(jar_path, 'w').close()
runner = self.launch_runner(
'--hadoop-streaming-jar', jar_path)
jar_uri = runner._upload_mg... | 256 | 256 | 1,308 | 12 | 244 | Affirm/mrjob | tests/test_emr.py | Python | JarStepTestCase | JarStepTestCase | 2,488 | 2,644 | 2,488 | 2,489 | d5bbbdc944bc273b12fd76ad432b75f6fc7c4297 | bigcode/the-stack | train |
c952d41bf76d57d9552a30c5 | train | class | class CustomAmiTestCase(MockBoto3TestCase):
def test_default(self):
with self.make_runner() as runner:
runner.run()
cluster = runner._describe_cluster()
self.assertNotIn('CustomAmiId', cluster)
def test_custom_ami(self):
with self.make_runner('--image-id', ... | class CustomAmiTestCase(MockBoto3TestCase):
| def test_default(self):
with self.make_runner() as runner:
runner.run()
cluster = runner._describe_cluster()
self.assertNotIn('CustomAmiId', cluster)
def test_custom_ami(self):
with self.make_runner('--image-id', 'ami-blanchin') as runner:
runner... | test_hadoop_version_option_does_nothing(self):
with self.make_runner('--hadoop-version', '1.2.3.4') as runner:
runner.run()
self.assertEqual(runner.get_image_version(),
_DEFAULT_IMAGE_VERSION)
self.assertEqual(runner.get_hadoop_version(), '2.8.4'... | 84 | 84 | 281 | 13 | 71 | Affirm/mrjob | tests/test_emr.py | Python | CustomAmiTestCase | CustomAmiTestCase | 770 | 804 | 770 | 771 | 9229536b8672e186f4ea63720b2500c9f5d758de | bigcode/the-stack | train |
7e58446e3c8c1e1d43557d74 | train | class | class CleanupClusterTestCase(MockBoto3TestCase):
def _quick_runner(self):
r = EMRJobRunner(conf_paths=[], ec2_key_pair_file='fake.pem',
pool_clusters=True)
r._cluster_id = 'j-ESSEOWENS'
r._address = 'Albuquerque, NM'
r._ran_job = False
return r
... | class CleanupClusterTestCase(MockBoto3TestCase):
| def _quick_runner(self):
r = EMRJobRunner(conf_paths=[], ec2_key_pair_file='fake.pem',
pool_clusters=True)
r._cluster_id = 'j-ESSEOWENS'
r._address = 'Albuquerque, NM'
r._ran_job = False
return r
def test_kill_cluster(self):
r = self._qui... | .assertFalse(EMRJobRunner._cleanup_cluster.called)
self.assertFalse(EMRJobRunner._cleanup_hadoop_tmp.called)
self.assertFalse(EMRJobRunner._cleanup_job.called) # only on failure
self.assertFalse(EMRJobRunner._cleanup_local_tmp.called)
self.assertFalse(EMRJobRunner._cleanup_logs.called)
... | 89 | 89 | 297 | 12 | 77 | Affirm/mrjob | tests/test_emr.py | Python | CleanupClusterTestCase | CleanupClusterTestCase | 2,102 | 2,132 | 2,102 | 2,103 | 8bab9b5077143dcc7423664151ec24a3bf7915d0 | bigcode/the-stack | train |
65c1dcdd53449f70ac5477c9 | train | class | class PartitionerTestCase(MockBoto3TestCase):
def setUp(self):
super(PartitionerTestCase, self).setUp()
# _hadoop_args_for_step() needs this
self.start(patch(
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='1.2.0'))
def test_sort_values(self):
... | class PartitionerTestCase(MockBoto3TestCase):
| def setUp(self):
super(PartitionerTestCase, self).setUp()
# _hadoop_args_for_step() needs this
self.start(patch(
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='1.2.0'))
def test_sort_values(self):
job = MRSortValues(['-r', 'emr'])
wit... | (
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='2.4.0'))
RUNNER = 'emr'
# make sure we don't override the partitioner on EMR (tests #1294)
class PartitionerTestCase(MockBoto3TestCase):
| 64 | 64 | 174 | 12 | 52 | Affirm/mrjob | tests/test_emr.py | Python | PartitionerTestCase | PartitionerTestCase | 4,067 | 4,086 | 4,067 | 4,068 | b7db18508da62ba2e83f8a1dad55f6bacae92875 | bigcode/the-stack | train |
98a4420cdfc0f5f3ab9e196f | train | class | class EMRInputManifestTestCase(InlineInputManifestTestCase, MockBoto3TestCase):
RUNNER = 'emr'
def test_input_manifest(self):
p = JSONProtocol()
output_lines = [p.write(k, v) + b'\n'
for k, v in self.EXPECTED_OUTPUT.items()]
self.mock_emr_output = {('j-MOCKCLUS... | class EMRInputManifestTestCase(InlineInputManifestTestCase, MockBoto3TestCase):
| RUNNER = 'emr'
def test_input_manifest(self):
p = JSONProtocol()
output_lines = [p.write(k, v) + b'\n'
for k, v in self.EXPECTED_OUTPUT.items()]
self.mock_emr_output = {('j-MOCKCLUSTER0', 1): output_lines}
super(EMRInputManifestTestCase, self).test_inpu... | = MRTwoStepJob(['-r', 'emr', '--check-cluster-every', '5.0'])
job.sandbox()
with job.make_runner() as runner:
runner.run()
class EMRInputManifestTestCase(InlineInputManifestTestCase, MockBoto3TestCase):
| 64 | 64 | 204 | 21 | 43 | Affirm/mrjob | tests/test_emr.py | Python | EMRInputManifestTestCase | EMRInputManifestTestCase | 5,831 | 5,853 | 5,831 | 5,832 | a591f49ae55cd33447ffc53b8a317083f3445872 | bigcode/the-stack | train |
b02cb0fe05edaaa847ead863 | train | class | class EMRTagsTestCase(MockBoto3TestCase):
def test_default_tags(self):
cluster = self.run_and_get_cluster()
tags = _extract_tags(cluster)
self.assertNotIn('__mrjob_pool_hash', tags)
self.assertNotIn('__mrjob_pool_name', tags)
self.assertEqual(tags['__mrjob_version'], mrjob... | class EMRTagsTestCase(MockBoto3TestCase):
| def test_default_tags(self):
cluster = self.run_and_get_cluster()
tags = _extract_tags(cluster)
self.assertNotIn('__mrjob_pool_hash', tags)
self.assertNotIn('__mrjob_pool_name', tags)
self.assertEqual(tags['__mrjob_version'], mrjob.__version__)
# MRTwoStepJob is use... | _runner() as runner:
self.assertEqual(
runner._should_bootstrap_spark(), False)
def test_explicit_true(self):
job = MRTwoStepJob(['-r', 'emr', '--bootstrap-spark'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(
run... | 256 | 256 | 875 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | EMRTagsTestCase | EMRTagsTestCase | 3,250 | 3,359 | 3,250 | 3,251 | 8c17869c8c9e56e5977c0ade906a7d817f9d84bd | bigcode/the-stack | train |
202bc70394bba4d565f28b52 | train | class | class EbsRootVolumeGBTestCase(MockBoto3TestCase):
def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertNotIn('EbsRootVolumeSize', cluster)
def test_set_to_integer(self):
cluster = self.run_and_get_cluster('--ebs-root-volume-gb', '999')
self.assertEqual(clust... | class EbsRootVolumeGBTestCase(MockBoto3TestCase):
| def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertNotIn('EbsRootVolumeSize', cluster)
def test_set_to_integer(self):
cluster = self.run_and_get_cluster('--ebs-root-volume-gb', '999')
self.assertEqual(cluster['EbsRootVolumeSize'], 999)
def test_zero_me... | 'WAITING')
# job shouldn't get terminated by cleanup
for _ in range(10):
self.simulate_emr_progress(runner.get_cluster_id())
cluster = runner._describe_cluster()
self.assertEqual(cluster['Status']['State'], 'WAITING')
class EbsRootVolumeGBTestCase(MockBoto3TestCase):
| 71 | 71 | 238 | 15 | 56 | Affirm/mrjob | tests/test_emr.py | Python | EbsRootVolumeGBTestCase | EbsRootVolumeGBTestCase | 430 | 453 | 430 | 431 | df78339daa3d60573299ab68de942d1e5bc8dd23 | bigcode/the-stack | train |
eb41fc317bdffbf8fc14441d | train | class | class EMRJobRunnerEndToEndTestCase(MockBoto3TestCase):
MRJOB_CONF_CONTENTS = dict(
runners=dict(
emr=dict(
additional_emr_info=dict(key='value'),
check_cluster_every=0.00,
cloud_fs_sync_secs=0.00,
pool_clusters=False, # so we can ... | class EMRJobRunnerEndToEndTestCase(MockBoto3TestCase):
| MRJOB_CONF_CONTENTS = dict(
runners=dict(
emr=dict(
additional_emr_info=dict(key='value'),
check_cluster_every=0.00,
cloud_fs_sync_secs=0.00,
pool_clusters=False, # so we can test cleanup
),
),
)
def te... | Configurations=[],
Properties={
'HADOOP_DATANODE_HEAPSIZE': 2048,
'HADOOP_NAMENODE_OPTS': '-XX:GCTimeRatio=19',
},
),
],
)
def _list_all_bootstrap_actions(runner):
"""Get bootstrap action for the runner's cluster as a list."""
ret... | 255 | 256 | 1,741 | 17 | 238 | Affirm/mrjob | tests/test_emr.py | Python | EMRJobRunnerEndToEndTestCase | EMRJobRunnerEndToEndTestCase | 152 | 348 | 152 | 153 | 598b2af8b6650b39572b52c4744c48c9e8a11bdf | bigcode/the-stack | train |
abaedfa57821d7a74e97c390 | train | function | def _extract_non_mrjob_tags(cluster):
"""get tags from a cluster as a dict, excluding tags starting with
``__mrjob_``"""
return {k: v for k, v in _extract_tags(cluster).items()
if not k.startswith('__mrjob_')}
| def _extract_non_mrjob_tags(cluster):
| """get tags from a cluster as a dict, excluding tags starting with
``__mrjob_``"""
return {k: v for k, v in _extract_tags(cluster).items()
if not k.startswith('__mrjob_')}
| """Get steps for the runner's cluster as a list (in forward order)"""
return list(reversed(list(_boto3_paginate(
'Steps', runner.make_emr_client(), 'list_steps',
ClusterId=runner.get_cluster_id()))))
def _extract_non_mrjob_tags(cluster):
| 64 | 64 | 62 | 10 | 54 | Affirm/mrjob | tests/test_emr.py | Python | _extract_non_mrjob_tags | _extract_non_mrjob_tags | 145 | 149 | 145 | 145 | d5efd690bad9424a854c82123cd7a9ddfda21183 | bigcode/the-stack | train |
d463e61fc5471beacb683130 | train | class | class LogAddressOfMasterTestCase(MockBoto3TestCase):
"""Test that we log the address of the master node."""
def setUp(self):
super(LogAddressOfMasterTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
def _num_times_address_of_master_logged(self):
return sum(1 fo... | class LogAddressOfMasterTestCase(MockBoto3TestCase):
| """Test that we log the address of the master node."""
def setUp(self):
super(LogAddressOfMasterTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
def _num_times_address_of_master_logged(self):
return sum(1 for args, kwargs in self.log.info.call_args_list
... | (emr_client.list_clusters()['Clusters'], [])
self.sleep.assert_called_with(expected_backoff)
def test_default_backoff(self):
self._test_backoff(20) # default value of emr_backoff
def test_large_emr_backoff(self):
self._test_backoff(1000, emr_backoff=1000)
def test_small_check_clu... | 122 | 122 | 409 | 14 | 108 | Affirm/mrjob | tests/test_emr.py | Python | LogAddressOfMasterTestCase | LogAddressOfMasterTestCase | 5,895 | 5,947 | 5,895 | 5,895 | 5770828526f2178de0fc76726f31f50929cb5001 | bigcode/the-stack | train |
99255e6060668dfa70763bee | train | class | class IAMEndpointTestCase(MockBoto3TestCase):
def test_default(self):
runner = EMRJobRunner()
iam_client = runner.make_iam_client()
self.assertEqual(iam_client.meta.endpoint_url,
'https://iam.amazonaws.com')
def test_explicit_iam_endpoint(self):
runner... | class IAMEndpointTestCase(MockBoto3TestCase):
| def test_default(self):
runner = EMRJobRunner()
iam_client = runner.make_iam_client()
self.assertEqual(iam_client.meta.endpoint_url,
'https://iam.amazonaws.com')
def test_explicit_iam_endpoint(self):
runner = EMRJobRunner(iam_endpoint='https://iam.us-go... | ),
dict(tag_one='foo', tag_two='bar'))
# this isn't actually enough to support GovCloud; see:
# http://docs.aws.amazon.com/govcloud-us/latest/UserGuide/using-govcloud-arns.html # noqa
class IAMEndpointTestCase(MockBoto3TestCase):
| 64 | 64 | 205 | 12 | 51 | Affirm/mrjob | tests/test_emr.py | Python | IAMEndpointTestCase | IAMEndpointTestCase | 3,364 | 3,388 | 3,364 | 3,365 | 58be273f20f0edbcfc740d3ae29e31ea09c41c0e | bigcode/the-stack | train |
83212b76c5eb4906c075e93b | train | class | class EMRClientBackoffTest(MockBoto3TestCase):
"""Test backoff behavior of EMR client on transient errors."""
# this tests #1799
# don't set check_cluster_every to 0; we mock out time.sleep() instead
MRJOB_CONF_CONTENTS = {}
def setUp(self):
super(EMRClientBackoffTest, self).setUp()
... | class EMRClientBackoffTest(MockBoto3TestCase):
| """Test backoff behavior of EMR client on transient errors."""
# this tests #1799
# don't set check_cluster_every to 0; we mock out time.sleep() instead
MRJOB_CONF_CONTENTS = {}
def setUp(self):
super(EMRClientBackoffTest, self).setUp()
# don't actually wait between retries
... | 0']
first_step_cmd = cmd_line(cluster['_Steps'][0]['Config']['Args'])
# verify that the correct input format was set
self.assertIn(
'-inputformat org.apache.hadoop.mapred.lib.NLineInputFormat',
first_step_cmd)
# verify that the input manfiest was used
se... | 95 | 95 | 317 | 14 | 81 | Affirm/mrjob | tests/test_emr.py | Python | EMRClientBackoffTest | EMRClientBackoffTest | 5,856 | 5,892 | 5,856 | 5,856 | a95ef0c5b02ee7ddc4d19bbfcd93771ff20171d5 | bigcode/the-stack | train |
7abc7f4c6da4a29ad72ab6ee | train | function | def _list_all_steps(runner):
"""Get steps for the runner's cluster as a list (in forward order)"""
return list(reversed(list(_boto3_paginate(
'Steps', runner.make_emr_client(), 'list_steps',
ClusterId=runner.get_cluster_id()))))
| def _list_all_steps(runner):
| """Get steps for the runner's cluster as a list (in forward order)"""
return list(reversed(list(_boto3_paginate(
'Steps', runner.make_emr_client(), 'list_steps',
ClusterId=runner.get_cluster_id()))))
| strap_actions(runner):
"""Get bootstrap action for the runner's cluster as a list."""
return list(_boto3_paginate(
'BootstrapActions', runner.make_emr_client(), 'list_bootstrap_actions',
ClusterId=runner.get_cluster_id()))
def _list_all_steps(runner):
| 63 | 64 | 63 | 8 | 55 | Affirm/mrjob | tests/test_emr.py | Python | _list_all_steps | _list_all_steps | 138 | 142 | 138 | 138 | f62235e9916a230b19caa25a3d8502e256cbbf34 | bigcode/the-stack | train |
e12c894f75dfaf0e148bd09d | train | class | class BootstrapSparkTestCase(MockBoto3TestCase):
def setUp(self):
super(BootstrapSparkTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
def get_cluster(self, *args):
job = MRNullSpark(['-r', 'emr'] + list(args))
job.sandbox()
with job.make_runner()... | class BootstrapSparkTestCase(MockBoto3TestCase):
| def setUp(self):
super(BootstrapSparkTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
def get_cluster(self, *args):
job = MRNullSpark(['-r', 'emr'] + list(args))
job.sandbox()
with job.make_runner() as runner:
self.assertTrue(runner._sh... | ):
self._assert_never_installs_python3(
'--release-label', 'emr-4.6.0',
'--image-version', '3.11.0',
)
def test_force_booststrap_python(self):
self._assert_installs_python3_on_py3(
'--bootstrap-python', '--image-version', '4.6.0')
def test_force_no_b... | 203 | 203 | 678 | 12 | 191 | Affirm/mrjob | tests/test_emr.py | Python | BootstrapSparkTestCase | BootstrapSparkTestCase | 3,126 | 3,204 | 3,126 | 3,127 | d89bb06ba59ec5b5f9aa751cb2cdceb192c94291 | bigcode/the-stack | train |
af1c397933f0ff5e0e4d555b | train | class | class MultiPartUploadTestCase(MockBoto3TestCase):
DEFAULT_PART_SIZE = 100 * 1024 * 1024
PART_SIZE_IN_MB = 50.0 / 1024 / 1024
TEST_BUCKET = 'walrus'
TEST_FILENAME = 'data.dat'
TEST_S3_URI = 's3://%s/%s' % (TEST_BUCKET, TEST_FILENAME)
def setUp(self):
super(MultiPartUploadTestCase, self... | class MultiPartUploadTestCase(MockBoto3TestCase):
| DEFAULT_PART_SIZE = 100 * 1024 * 1024
PART_SIZE_IN_MB = 50.0 / 1024 / 1024
TEST_BUCKET = 'walrus'
TEST_FILENAME = 'data.dat'
TEST_S3_URI = 's3://%s/%s' % (TEST_BUCKET, TEST_FILENAME)
def setUp(self):
super(MultiPartUploadTestCase, self).setUp()
# create the walrus bucket
... | (runner._action_on_failure(),
'CANCEL_AND_WAIT')
def test_default_with_cluster_id(self):
runner = EMRJobRunner(cluster_id='j-CLUSTER')
self.assertEqual(runner._action_on_failure(),
'CANCEL_AND_WAIT')
def test_option(self):
runner = EMRJ... | 173 | 173 | 579 | 13 | 160 | Affirm/mrjob | tests/test_emr.py | Python | MultiPartUploadTestCase | MultiPartUploadTestCase | 2,909 | 2,971 | 2,909 | 2,910 | f4c1fb9d59a92c7adcdd0bc4b303b162f245f238 | bigcode/the-stack | train |
1ff42114152fe16fef5d5d1b | train | class | class InstanceGroupAndFleetTestCase(MockBoto3TestCase):
maxDiff = None
def _test_instance_groups(self, opts, **expected):
"""Run a job with the given option dictionary, and check for
for instance, number, and optional bid price for each instance role.
Specify expected instance group i... | class InstanceGroupAndFleetTestCase(MockBoto3TestCase):
| maxDiff = None
def _test_instance_groups(self, opts, **expected):
"""Run a job with the given option dictionary, and check for
for instance, number, and optional bid price for each instance role.
Specify expected instance group info like:
<role>=(num_instances, instance_type, ... | ')
runner = EMRJobRunner(region='us-east-1')
self.assertEqual(runner._opts['cloud_tmp_dir'],
's3://mrjob-1/tmp/')
def test_explicit_tmp_uri(self):
self.add_mock_s3_data({'walrus': {}}, location='us-west-2')
runner = EMRJobRunner(cloud_tmp_dir='s3://walrus... | 256 | 256 | 3,329 | 14 | 241 | Affirm/mrjob | tests/test_emr.py | Python | InstanceGroupAndFleetTestCase | InstanceGroupAndFleetTestCase | 933 | 1,331 | 933 | 934 | 4fc1bc38837a0eb6fa6188ba3837bc7b71a0d940 | bigcode/the-stack | train |
b4e6b7394fd434b074532d44 | train | class | class ProgressHtmlOverSshTestCase(MockBoto3TestCase):
MOCK_MASTER = 'mockmaster'
MOCK_JOB_TRACKER_URL = 'http://1.2.3.4:8088/cluster'
MOCK_EC2_KEY_PAIR_FILE = 'mock.pem'
def setUp(self):
super(ProgressHtmlOverSshTestCase, self).setUp()
self._ssh_run = self.start(patch('mrjob.fs.ssh.S... | class ProgressHtmlOverSshTestCase(MockBoto3TestCase):
| MOCK_MASTER = 'mockmaster'
MOCK_JOB_TRACKER_URL = 'http://1.2.3.4:8088/cluster'
MOCK_EC2_KEY_PAIR_FILE = 'mock.pem'
def setUp(self):
super(ProgressHtmlOverSshTestCase, self).setUp()
self._ssh_run = self.start(patch('mrjob.fs.ssh.SSHFilesystem._ssh_run',
... | .urlopen.return_value.close.called)
def test_urlopen_exception(self):
self.urlopen.side_effect = Exception('BOOM')
self.assertIsNone(self._launch_and_get_progress_html())
self.urlopen.assert_called_once_with(self.MOCK_TUNNEL_URL)
self.assertFalse(self.urlopen.return_value.read.cal... | 163 | 163 | 546 | 15 | 148 | Affirm/mrjob | tests/test_emr.py | Python | ProgressHtmlOverSshTestCase | ProgressHtmlOverSshTestCase | 5,600 | 5,669 | 5,600 | 5,601 | 7c8c6bd86bf97cf7bff2c077f1af2541fab31b09 | bigcode/the-stack | train |
22230a113e793ebd52df3985 | train | class | class BuildStreamingStepTestCase(MockBoto3TestCase):
def setUp(self):
super(BuildStreamingStepTestCase, self).setUp()
self.start(patch(
'mrjob.emr.EMRJobRunner._step_input_uris',
return_value=['input']))
self.start(patch(
'mrjob.emr.EMRJobRunner._step_o... | class BuildStreamingStepTestCase(MockBoto3TestCase):
| def setUp(self):
super(BuildStreamingStepTestCase, self).setUp()
self.start(patch(
'mrjob.emr.EMRJobRunner._step_input_uris',
return_value=['input']))
self.start(patch(
'mrjob.emr.EMRJobRunner._step_output_uri',
return_value='output'))
... | _id, None)
def test_acquire_lock_on_first_attempt(self):
self.mock_cluster_ids.append('j-successful-lock')
runner = EMRJobRunner(conf_paths=[], pool_wait_minutes=1)
cluster_id = runner._find_cluster()
self.assertEqual(cluster_id, 'j-successful-lock')
self.assertEqual(self.s... | 256 | 256 | 1,515 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | BuildStreamingStepTestCase | BuildStreamingStepTestCase | 2,228 | 2,409 | 2,228 | 2,229 | ef350aba1400c0e2c478455daf03cd0fe878c274 | bigcode/the-stack | train |
7b8969c8b1dd97f5e4e2bdb2 | train | class | class WaitForLogsOnS3TestCase(MockBoto3TestCase):
def setUp(self):
super(WaitForLogsOnS3TestCase, self).setUp()
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox(stdin=BytesIO(b'foo\nbar\n'))
self.runner = job.make_runner()
self.launch(self.runner)
self.cluster = self... | class WaitForLogsOnS3TestCase(MockBoto3TestCase):
| def setUp(self):
super(WaitForLogsOnS3TestCase, self).setUp()
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox(stdin=BytesIO(b'foo\nbar\n'))
self.runner = job.make_runner()
self.launch(self.runner)
self.cluster = self.mock_emr_clusters[self.runner._cluster_id]
... | point', 'iam.us-gov.amazonaws.com'])
with mr_job.make_runner() as runner:
iam_client = runner.make_iam_client()
self.assertEqual(iam_client.meta.endpoint_url,
'https://iam.us-gov.amazonaws.com')
class SetupLineEncodingTestCase(MockBoto3TestCase):
def ... | 223 | 223 | 745 | 16 | 207 | Affirm/mrjob | tests/test_emr.py | Python | WaitForLogsOnS3TestCase | WaitForLogsOnS3TestCase | 3,409 | 3,505 | 3,409 | 3,410 | 93076cfeb2748772cea58fa3b851c302f55d1d7e | bigcode/the-stack | train |
7c959ebdc6220097fd6ec4c1 | train | function | def make_input_uri_line(input_uri):
return ("2010-07-27 17:55:29,400 INFO"
" org.apache.hadoop.fs.s3native.NativeS3FileSystem (main):"
" Opening '%s' for reading\n" % input_uri).encode('utf_8')
| def make_input_uri_line(input_uri):
| return ("2010-07-27 17:55:29,400 INFO"
" org.apache.hadoop.fs.s3native.NativeS3FileSystem (main):"
" Opening '%s' for reading\n" % input_uri).encode('utf_8')
| _DIR = TASK_ATTEMPTS_DIR + 'attempt_201007271720_0001_m_000126_0/'
ATTEMPT_1_DIR = TASK_ATTEMPTS_DIR + 'attempt_201007271720_0001_m_000126_0/'
def make_input_uri_line(input_uri):
| 63 | 64 | 65 | 8 | 55 | Affirm/mrjob | tests/test_emr.py | Python | make_input_uri_line | make_input_uri_line | 1,373 | 1,376 | 1,373 | 1,373 | 1bd3c294f795320bcc0071a5adcce1bd7468f26b | bigcode/the-stack | train |
c88ebce136eac438d69f6846 | train | class | class LibjarPathsTestCase(MockBoto3TestCase):
def test_no_libjars(self):
runner = EMRJobRunner()
runner._add_master_node_setup_files_for_upload()
self.assertEqual(runner._libjar_paths(), [])
def test_libjars(self):
runner = EMRJobRunner(libjars=[
'cookie.jar',
... | class LibjarPathsTestCase(MockBoto3TestCase):
| def test_no_libjars(self):
runner = EMRJobRunner()
runner._add_master_node_setup_files_for_upload()
self.assertEqual(runner._libjar_paths(), [])
def test_libjars(self):
runner = EMRJobRunner(libjars=[
'cookie.jar',
's3://pooh/honey.jar',
'fil... | ora.jar',
'-D', 'foo=bar',
'-input', 'input', '-output', 'output',
'-mapper',
'%s my_job.py --step-num=0 --mapper' % PYTHON_BIN,
])
class LibjarPathsTestCase(MockBoto3TestCase):
| 63 | 64 | 165 | 13 | 50 | Affirm/mrjob | tests/test_emr.py | Python | LibjarPathsTestCase | LibjarPathsTestCase | 2,412 | 2,437 | 2,412 | 2,413 | f0bf5695b87d86648d1fd2b0bc253ed08b07f2f0 | bigcode/the-stack | train |
c6aea74d7d51f1326e59c3ff | train | class | class RegionTestCase(MockBoto3TestCase):
def test_default(self):
runner = EMRJobRunner()
self.assertEqual(runner._opts['region'], 'us-west-2')
def test_explicit_region(self):
runner = EMRJobRunner(region='us-east-1')
self.assertEqual(runner._opts['region'], 'us-east-1')
de... | class RegionTestCase(MockBoto3TestCase):
| def test_default(self):
runner = EMRJobRunner()
self.assertEqual(runner._opts['region'], 'us-west-2')
def test_explicit_region(self):
runner = EMRJobRunner(region='us-east-1')
self.assertEqual(runner._opts['region'], 'us-east-1')
def test_cannot_be_empty(self):
runn... | test_debugging_works(self):
with self.make_runner('--enable-emr-debugging') as runner:
runner.run()
steps = _list_all_steps(runner)
self.assertEqual(steps[0]['Name'], 'Setup Hadoop Debugging')
class RegionTestCase(MockBoto3TestCase):
| 64 | 64 | 116 | 11 | 53 | Affirm/mrjob | tests/test_emr.py | Python | RegionTestCase | RegionTestCase | 836 | 848 | 836 | 837 | f1cb4ce417224344ef67f2469fc0ca34b3c5b17d | bigcode/the-stack | train |
203f7a60c6d1a82246f6be54 | train | class | class SparkJarStepTestCase(MockBoto3TestCase):
def setUp(self):
super(SparkJarStepTestCase, self).setUp()
self.fake_jar = self.makefile('fake.jar')
# _spark_submit_args() is tested elsewhere
self.start(patch(
'mrjob.bin.MRJobBinRunner._spark_submit_args',
r... | class SparkJarStepTestCase(MockBoto3TestCase):
| def setUp(self):
super(SparkJarStepTestCase, self).setUp()
self.fake_jar = self.makefile('fake.jar')
# _spark_submit_args() is tested elsewhere
self.start(patch(
'mrjob.bin.MRJobBinRunner._spark_submit_args',
return_value=['<spark submit args>']))
def t... | arg is spark-submit and varies by AMI
self.assertEqual(
step_args[1:],
[
'<spark submit args>',
script_uri,
'--step-num=0',
'--spark',
input1_uri + ',' + input2_uri,
... | 77 | 78 | 263 | 13 | 64 | Affirm/mrjob | tests/test_emr.py | Python | SparkJarStepTestCase | SparkJarStepTestCase | 2,721 | 2,752 | 2,721 | 2,722 | 23ae8c48a58cf23f181a6b30c129097a7e003295 | bigcode/the-stack | train |
93195d95248fa0c2b67678fb | train | class | class MasterNodeSetupScriptTestCase(MockBoto3TestCase):
def setUp(self):
super(MasterNodeSetupScriptTestCase, self).setUp()
self.start(patch('mrjob.emr.log'))
def test_no_script_needed(self):
runner = EMRJobRunner()
runner._add_master_node_setup_files_for_upload()
self... | class MasterNodeSetupScriptTestCase(MockBoto3TestCase):
| def setUp(self):
super(MasterNodeSetupScriptTestCase, self).setUp()
self.start(patch('mrjob.emr.log'))
def test_no_script_needed(self):
runner = EMRJobRunner()
runner._add_master_node_setup_files_for_upload()
self.assertIsNone(runner._master_node_setup_script_path)
... | bootstrap=['cd ' + foo_dir + '/#'])
runner._add_bootstrap_files_for_upload()
self.assertIsNotNone(runner._master_bootstrap_script_path)
self.assertTrue(os.path.exists(runner._master_bootstrap_script_path))
self.assertIn(foo_dir, runner._dir_to_archive_pat... | 250 | 250 | 834 | 14 | 236 | Affirm/mrjob | tests/test_emr.py | Python | MasterNodeSetupScriptTestCase | MasterNodeSetupScriptTestCase | 1,823 | 1,913 | 1,823 | 1,824 | 4874b79caed0b8bdf23e16651d344d86547cb30e | bigcode/the-stack | train |
2fbfe24b4b962dd9a32e3a4c | train | class | class LsBootstrapStderrLogsTestCase(MockBoto3TestCase):
def setUp(self):
super(LsBootstrapStderrLogsTestCase, self).setUp()
self.runner = EMRJobRunner()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_bootstrap_stderr_logs = self.start(
patch('mrjob.emr._ls_... | class LsBootstrapStderrLogsTestCase(MockBoto3TestCase):
| def setUp(self):
super(LsBootstrapStderrLogsTestCase, self).setUp()
self.runner = EMRJobRunner()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_bootstrap_stderr_logs = self.start(
patch('mrjob.emr._ls_emr_bootstrap_stderr_logs'))
self.runner._stream_... | StateChangeReason={},
),
),
),
))
self.start(patch.object(
runner, '_check_for_missing_default_iam_roles'))
self.start(patch.object(
runner, '_check_for_failed_bootstrap_action',
side_effect=self.StopTest))
... | 120 | 120 | 403 | 16 | 104 | Affirm/mrjob | tests/test_emr.py | Python | LsBootstrapStderrLogsTestCase | LsBootstrapStderrLogsTestCase | 4,584 | 4,634 | 4,584 | 4,585 | 3eb463fc01607f0d0d53bc0b4142504da01dcb94 | bigcode/the-stack | train |
10050f8b85e8372765ec52e1 | train | function | def _list_all_bootstrap_actions(runner):
"""Get bootstrap action for the runner's cluster as a list."""
return list(_boto3_paginate(
'BootstrapActions', runner.make_emr_client(), 'list_bootstrap_actions',
ClusterId=runner.get_cluster_id()))
| def _list_all_bootstrap_actions(runner):
| """Get bootstrap action for the runner's cluster as a list."""
return list(_boto3_paginate(
'BootstrapActions', runner.make_emr_client(), 'list_bootstrap_actions',
ClusterId=runner.get_cluster_id()))
| export',
Configurations=[],
Properties={
'HADOOP_DATANODE_HEAPSIZE': 2048,
'HADOOP_NAMENODE_OPTS': '-XX:GCTimeRatio=19',
},
),
],
)
def _list_all_bootstrap_actions(runner):
| 64 | 64 | 60 | 10 | 54 | Affirm/mrjob | tests/test_emr.py | Python | _list_all_bootstrap_actions | _list_all_bootstrap_actions | 131 | 135 | 131 | 131 | e805d2dfbf65392683b5f0e2ac069b99ff1cc2f8 | bigcode/the-stack | train |
eb9b58446fa5f97b91154009 | train | class | class SetUpSSHTunnelTestCase(MockBoto3TestCase):
def setUp(self, *args):
super(SetUpSSHTunnelTestCase, self).setUp()
self.mock_Popen = self.start(patch('mrjob.cloud.Popen'))
# simulate successfully binding port
self.mock_Popen.return_value.returncode = None
self.mock_Popen.... | class SetUpSSHTunnelTestCase(MockBoto3TestCase):
| def setUp(self, *args):
super(SetUpSSHTunnelTestCase, self).setUp()
self.mock_Popen = self.start(patch('mrjob.cloud.Popen'))
# simulate successfully binding port
self.mock_Popen.return_value.returncode = None
self.mock_Popen.return_value.pid = 99999
self.mock_kill =... | )
self.assertFalse(runner.fs.ssh._sudo)
def test_ami_4_3_0_without_ssh_fs(self):
# just make sure we don't cause an error trying to set up sudo
# on a nonexistent filesystem
job = MRTwoStepJob(
['-r', 'emr', '--image-version', '4.3.0']).sandbox()
with job.m... | 256 | 256 | 1,188 | 15 | 241 | Affirm/mrjob | tests/test_emr.py | Python | SetUpSSHTunnelTestCase | SetUpSSHTunnelTestCase | 4,779 | 4,928 | 4,779 | 4,780 | 155fea8cb33487a1514db5c4579f19a43feeb0eb | bigcode/the-stack | train |
3ff7078e96ae9298e7dae228 | train | class | class EnableDebuggingTestCase(MockBoto3TestCase):
def test_debugging_works(self):
with self.make_runner('--enable-emr-debugging') as runner:
runner.run()
steps = _list_all_steps(runner)
self.assertEqual(steps[0]['Name'], 'Setup Hadoop Debugging')
| class EnableDebuggingTestCase(MockBoto3TestCase):
| def test_debugging_works(self):
with self.make_runner('--enable-emr-debugging') as runner:
runner.run()
steps = _list_all_steps(runner)
self.assertEqual(steps[0]['Name'], 'Setup Hadoop Debugging')
| _config(self):
with self.make_runner() as runner:
runner.run()
cluster = runner._describe_cluster()
self.assertEqual(
cluster['Ec2InstanceAttributes'].get('Ec2AvailabilityZone'),
'PUPPYLAND')
class EnableDebuggingTestCase(MockBoto3TestCase):
| 64 | 64 | 68 | 13 | 51 | Affirm/mrjob | tests/test_emr.py | Python | EnableDebuggingTestCase | EnableDebuggingTestCase | 826 | 833 | 826 | 827 | 5df58899627afd3eb6296506fc92d1b5cfa7fa7c | bigcode/the-stack | train |
5130b3abf3d3faac5ed696c0 | train | class | class UsesSparkTestCase(MockBoto3TestCase):
def test_default(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertFalse(runner._uses_spark())
self.assertFalse(runner._has_spark_steps())
self.assertFalse(runn... | class UsesSparkTestCase(MockBoto3TestCase):
| def test_default(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertFalse(runner._uses_spark())
self.assertFalse(runner._has_spark_steps())
self.assertFalse(runner._has_spark_install_bootstrap_action())
... | codes = [None, 255, 255] # in reverse order
def popen_side_effect(*args, **kwargs):
return_value = Mock()
return_value.pid = 99999
return_value.returncode = returncodes.pop()
return return_value
self.mock_Popen.side_effect = popen_side_effect
s... | 256 | 256 | 1,075 | 12 | 244 | Affirm/mrjob | tests/test_emr.py | Python | UsesSparkTestCase | UsesSparkTestCase | 4,931 | 5,065 | 4,931 | 4,932 | 621fb081006e4bb1234f9265bc059aa931b58cd1 | bigcode/the-stack | train |
48cb52d765177275eaf028bd | train | class | class StreamingJarAndStepArgPrefixTestCase(MockBoto3TestCase):
def launch_runner(self, *args):
"""make and launch runner, so cluster is created and files
are uploaded."""
runner = self.make_runner(*args)
self.launch(runner)
return runner
def test_default(self):
... | class StreamingJarAndStepArgPrefixTestCase(MockBoto3TestCase):
| def launch_runner(self, *args):
"""make and launch runner, so cluster is created and files
are uploaded."""
runner = self.make_runner(*args)
self.launch(runner)
return runner
def test_default(self):
runner = self.launch_runner()
self.assertEqual(runner._g... | Equal(runner._libjar_paths(), [])
def test_libjars(self):
runner = EMRJobRunner(libjars=[
'cookie.jar',
's3://pooh/honey.jar',
'file:///left/dora.jar',
])
runner._add_master_node_setup_files_for_upload()
working_dir = runner._master_node_setup_wo... | 137 | 137 | 457 | 16 | 121 | Affirm/mrjob | tests/test_emr.py | Python | StreamingJarAndStepArgPrefixTestCase | StreamingJarAndStepArgPrefixTestCase | 2,440 | 2,485 | 2,440 | 2,441 | 5dc48f3db8b6628a2776a1366c4aa52aee94a48e | bigcode/the-stack | train |
4356e2f4b3c52de71128820e | train | class | class CleanupOptionsTestCase(MockBoto3TestCase):
def setUp(self):
super(CleanupOptionsTestCase, self).setUp()
self.start(patch.object(EMRJobRunner, '_cleanup_cloud_tmp'))
self.start(patch.object(EMRJobRunner, '_cleanup_cluster'))
self.start(patch.object(EMRJobRunner, '_cleanup_hado... | class CleanupOptionsTestCase(MockBoto3TestCase):
| def setUp(self):
super(CleanupOptionsTestCase, self).setUp()
self.start(patch.object(EMRJobRunner, '_cleanup_cloud_tmp'))
self.start(patch.object(EMRJobRunner, '_cleanup_cluster'))
self.start(patch.object(EMRJobRunner, '_cleanup_hadoop_tmp'))
self.start(patch.object(EMRJobRu... | (
IOError, list,
runner.fs.cat('ssh://testmaster/does_not_exist'))
def test_ssh_cat_errlog(self):
# A file *containing* an error message shouldn't cause an error.
runner = EMRJobRunner(conf_paths=[])
self.prepare_runner_for_ssh(runner)
error_message = b'cat:... | 144 | 144 | 482 | 12 | 132 | Affirm/mrjob | tests/test_emr.py | Python | CleanupOptionsTestCase | CleanupOptionsTestCase | 2,056 | 2,099 | 2,056 | 2,057 | 7bb0980bdf30ecd08923295a53b757f1ca8aae34 | bigcode/the-stack | train |
c9c7584c3be023fce52ee6ff | train | class | class SparkStepTestCase(MockBoto3TestCase):
def setUp(self):
super(SparkStepTestCase, self).setUp()
# _spark_submit_args() is tested elsewhere
self.start(patch(
'mrjob.bin.MRJobBinRunner._spark_submit_args',
return_value=['<spark submit args>']))
# TODO: test w... | class SparkStepTestCase(MockBoto3TestCase):
| def setUp(self):
super(SparkStepTestCase, self).setUp()
# _spark_submit_args() is tested elsewhere
self.start(patch(
'mrjob.bin.MRJobBinRunner._spark_submit_args',
return_value=['<spark submit args>']))
# TODO: test warning for for AMIs prior to 3.8.0, which don... | ):
# don't forget to make sure main_class is respected. tests #1572
self.add_mock_s3_data({'dubliners': {'whiskeyinthe.jar': b''}})
JAR_URI = 's3://dubliners/whiskeyinthe.jar'
job = MRJustAJar(['-r', 'emr', '--jar', JAR_URI,
'--main-class', 'ThingAnalyzer'])
... | 174 | 174 | 582 | 12 | 162 | Affirm/mrjob | tests/test_emr.py | Python | SparkStepTestCase | SparkStepTestCase | 2,647 | 2,718 | 2,647 | 2,648 | 090496c28c886959ffc16d636365c3abc2cedc1c | bigcode/the-stack | train |
2ae676c24d855c9302afd1c8 | train | class | class SparkPyFilesTestCase(MockBoto3TestCase):
def setUp(self):
super(SparkPyFilesTestCase, self).setUp()
# so we don't need to start a (mock) cluster
self.start(patch('mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='2'))
def test_eggs(self):
... | class SparkPyFilesTestCase(MockBoto3TestCase):
| def setUp(self):
super(SparkPyFilesTestCase, self).setUp()
# so we don't need to start a (mock) cluster
self.start(patch('mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='2'))
def test_eggs(self):
egg1_path = self.makefile('dragon.egg')
... | _application())
def test_bootstrap_spark(self):
# tests #1465
job = MRTwoStepJob(['-r', 'emr', '--bootstrap-spark'])
job.sandbox()
with job.make_runner() as runner:
self.assertTrue(runner._uses_spark())
self.assertTrue(runner._opts['bootstrap_spark'])
class ... | 89 | 90 | 300 | 13 | 76 | Affirm/mrjob | tests/test_emr.py | Python | SparkPyFilesTestCase | SparkPyFilesTestCase | 5,068 | 5,102 | 5,068 | 5,069 | 9f9cfed4239128bc2df112754b7e9fec65fb2571 | bigcode/the-stack | train |
40d0b36e91087aed45ebc14b | train | class | class StreamLogDirsTestCase(MockBoto3TestCase):
def setUp(self):
super(StreamLogDirsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._address_of_master = self.start(patch(
'mrjob.emr.EMRJobRunner._address_of_master',
return_value='master')... | class StreamLogDirsTestCase(MockBoto3TestCase):
| def setUp(self):
super(StreamLogDirsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._address_of_master = self.start(patch(
'mrjob.emr.EMRJobRunner._address_of_master',
return_value='master'))
self.get_image_version = self.start(pa... | .info.called)
def test_terminated(self):
self.cluster['Status']['State'] = 'TERMINATED'
self.assert_silently_exits()
def test_terminated_with_errors(self):
self.cluster['Status']['State'] = 'TERMINATED_WITH_ERRORS'
self.assert_silently_exits()
def test_ctrl_c(self):
... | 256 | 256 | 2,789 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | StreamLogDirsTestCase | StreamLogDirsTestCase | 3,508 | 3,834 | 3,508 | 3,509 | b355f51d93bcdd41f9bd3496f46d51a1d27ca5a4 | bigcode/the-stack | train |
6b267e6d79823f2e14ba8102 | train | class | class CheckClusterEveryTestCase(MockBoto3TestCase):
def test_command_line_option(self):
# regression test for #1664
job = MRTwoStepJob(['-r', 'emr', '--check-cluster-every', '5.0'])
job.sandbox()
with job.make_runner() as runner:
runner.run()
| class CheckClusterEveryTestCase(MockBoto3TestCase):
| def test_command_line_option(self):
# regression test for #1664
job = MRTwoStepJob(['-r', 'emr', '--check-cluster-every', '5.0'])
job.sandbox()
with job.make_runner() as runner:
runner.run()
| StepJob(['-r', 'emr', 'hdfs:///path/to/input/'])
# no way to check hdfs://, ignore
with job.make_runner() as runner:
self.assertRaises(StopIteration, runner.run)
class CheckClusterEveryTestCase(MockBoto3TestCase):
| 64 | 64 | 75 | 13 | 51 | Affirm/mrjob | tests/test_emr.py | Python | CheckClusterEveryTestCase | CheckClusterEveryTestCase | 5,820 | 5,828 | 5,820 | 5,821 | 8ccf171ebe054bf2128a4924659155d990baf8cc | bigcode/the-stack | train |
f5e9eac825b1a54a29bee998 | train | class | class ShouldBootstrapSparkTestCase(MockBoto3TestCase):
def test_default(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(
runner._should_bootstrap_spark(), False)
def test_explicit_true(self):
... | class ShouldBootstrapSparkTestCase(MockBoto3TestCase):
| def test_default(self):
job = MRTwoStepJob(['-r', 'emr'])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(
runner._should_bootstrap_spark(), False)
def test_explicit_true(self):
job = MRTwoStepJob(['-r', 'emr', '--bootstrap-spark'])
... | '4.7.2',
'--application', 'spark')
# shouldn't add "Spark" application on top of "spark"
self.assertTrue(self.installed_spark_application(cluster, 'spark'))
self.assertFalse(self.installed_spark_application(cluster, 'Spark'))
self.assertFalse(self.ran_spark_bootstrap_action... | 85 | 85 | 286 | 13 | 72 | Affirm/mrjob | tests/test_emr.py | Python | ShouldBootstrapSparkTestCase | ShouldBootstrapSparkTestCase | 3,207 | 3,247 | 3,207 | 3,208 | 500bc287fd4f21bd70cd4ddb55634cc3a29a05ba | bigcode/the-stack | train |
8f8a17728c4e5f1c6c0c907a | train | class | class CheckForFailedBootstrapActionTestCase(MockBoto3TestCase):
def setUp(self):
super(CheckForFailedBootstrapActionTestCase, self).setUp()
self.start(patch('mrjob.emr._get_reason'))
self._check_for_nonzero_return_code = self.start(
patch('mrjob.emr._check_for_nonzero_return_co... | class CheckForFailedBootstrapActionTestCase(MockBoto3TestCase):
| def setUp(self):
super(CheckForFailedBootstrapActionTestCase, self).setUp()
self.start(patch('mrjob.emr._get_reason'))
self._check_for_nonzero_return_code = self.start(
patch('mrjob.emr._check_for_nonzero_return_code',
return_value=None))
self.log = sel... | ,
node_id='i-e647eb49',
path=stderr_path,
),
]
results = self.runner._ls_bootstrap_stderr_logs(
action_num=0,
node_id='i-e647eb49',
)
self.assertFalse(self.log.info.called)
self.assertEqual(next(results), dict... | 202 | 202 | 676 | 15 | 187 | Affirm/mrjob | tests/test_emr.py | Python | CheckForFailedBootstrapActionTestCase | CheckForFailedBootstrapActionTestCase | 4,637 | 4,714 | 4,637 | 4,638 | 0b6d4f569568958f14e2031c7f8b1a3b10a960cc | bigcode/the-stack | train |
1ac19446d301668eecc510c3 | train | class | class EC2EndpointTestCase(MockBoto3TestCase):
def make_client(self, **kwargs):
runner = EMRJobRunner(conf_paths=[], **kwargs)
return runner.make_ec2_client()
def test_default_region(self):
client = self.make_client()
self.assertEqual(client.meta.endpoint_url,
... | class EC2EndpointTestCase(MockBoto3TestCase):
| def make_client(self, **kwargs):
runner = EMRJobRunner(conf_paths=[], **kwargs)
return runner.make_ec2_client()
def test_default_region(self):
client = self.make_client()
self.assertEqual(client.meta.endpoint_url,
'https://ec2.us-west-2.amazonaws.com')
... | 07-27 17:55:29,400 INFO"
" org.apache.hadoop.fs.s3native.NativeS3FileSystem (main):"
" Opening '%s' for reading\n" % input_uri).encode('utf_8')
class EC2EndpointTestCase(MockBoto3TestCase):
| 64 | 64 | 214 | 13 | 51 | Affirm/mrjob | tests/test_emr.py | Python | EC2EndpointTestCase | EC2EndpointTestCase | 1,379 | 1,405 | 1,379 | 1,380 | 862ba29abb30573963dcc286ddca30f22952dd99 | bigcode/the-stack | train |
df1ad9872069f2e57403d91b | train | class | class EMREndpointTestCase(MockBoto3TestCase):
# back when we used boto 2, mrjob used to figure out endpoints itself
# Now we leave that to boto3, so this is more a benchmark that makes sure
# mock_boto3 matches boto3 1.4.4
def test_default_region(self):
runner = EMRJobRunner(conf_paths=[])
... | class EMREndpointTestCase(MockBoto3TestCase):
# back when we used boto 2, mrjob used to figure out endpoints itself
# Now we leave that to boto3, so this is more a benchmark that makes sure
# mock_boto3 matches boto3 1.4.4
| def test_default_region(self):
runner = EMRJobRunner(conf_paths=[])
self.assertEqual(runner._opts['region'], 'us-west-2')
self.assertEqual(runner.make_emr_client().meta.endpoint_url,
'https://us-west-2.elasticmapreduce.amazonaws.com')
def test_none_region(self):... | ):
client = self.make_client(region='us-west-1')
self.assertEqual(client.meta.endpoint_url,
'https://ec2.us-west-1.amazonaws.com')
self.assertEqual(client.meta.region_name, 'us-west-1')
def test_set_endpoint(self):
client = self.make_client(region='eu-west-... | 183 | 183 | 610 | 69 | 114 | Affirm/mrjob | tests/test_emr.py | Python | EMREndpointTestCase | EMREndpointTestCase | 1,408 | 1,459 | 1,408 | 1,413 | 5ca06456695b5bcb062a72da9c780d1d7c43c3ac | bigcode/the-stack | train |
4335acc048dea2f2a0586d43 | train | class | class LsStepSyslogsTestCase(MockBoto3TestCase):
def setUp(self):
super(LsStepSyslogsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_step_syslogs = self.start(patch(
'mrjob.emr._ls_emr_step_syslogs'))
self._stream_step_log_dirs = self.... | class LsStepSyslogsTestCase(MockBoto3TestCase):
| def setUp(self):
super(LsStepSyslogsTestCase, self).setUp()
self.log = self.start(patch('mrjob.emr.log'))
self._ls_emr_step_syslogs = self.start(patch(
'mrjob.emr._ls_emr_step_syslogs'))
self._stream_step_log_dirs = self.start(patch(
'mrjob.emr.EMRJobRunner.... | ',
expected_dir_name='hadoop/userlogs',
expected_s3_dir_name='task-attempts')
def test_stream_task_log_dirs_no_read_logs(self):
self._test_stream_task_log_dirs(
ssh=True, application_id='application_1',
expected_dir_name='hadoop-yarn/containers/application_1'... | 102 | 102 | 341 | 15 | 87 | Affirm/mrjob | tests/test_emr.py | Python | LsStepSyslogsTestCase | LsStepSyslogsTestCase | 3,837 | 3,879 | 3,837 | 3,838 | 1407285490804f10d4117371bd23762c618511ec | bigcode/the-stack | train |
d23a05a2115c974316cd2c6c | train | class | class ActionOnFailureTestCase(MockBoto3TestCase):
def test_default(self):
runner = EMRJobRunner()
self.assertEqual(runner._action_on_failure(),
'TERMINATE_CLUSTER')
def test_default_with_pooling(self):
runner = EMRJobRunner(pool_clusters=True)
self.asse... | class ActionOnFailureTestCase(MockBoto3TestCase):
| def test_default(self):
runner = EMRJobRunner()
self.assertEqual(runner._action_on_failure(),
'TERMINATE_CLUSTER')
def test_default_with_pooling(self):
runner = EMRJobRunner(pool_clusters=True)
self.assertEqual(runner._action_on_failure(),
... | (step['HadoopJarStep']['Jar'],
runner._script_runner_jar_uri())
self.assertEqual(step['HadoopJarStep']['Args'],
[master_node_setup_uri])
self.assertEqual(step['ActionOnFailure'],
runner._action_on_failure())
class ActionOnFailure... | 68 | 68 | 229 | 13 | 55 | Affirm/mrjob | tests/test_emr.py | Python | ActionOnFailureTestCase | ActionOnFailureTestCase | 2,878 | 2,906 | 2,878 | 2,879 | 088554e83104a0f1119fa9c51dab4076d567f086 | bigcode/the-stack | train |
a146a96fa444e43481ce40c1 | train | class | class GetJobStepsTestCase(MockBoto3TestCase):
def test_empty(self):
runner = EMRJobRunner()
runner.make_persistent_cluster()
self.assertEqual(runner.get_job_steps(), [])
def test_own_cluster(self):
job = MRTwoStepJob(['-r', 'emr']).sandbox()
with job.make_runner() as ... | class GetJobStepsTestCase(MockBoto3TestCase):
| def test_empty(self):
runner = EMRJobRunner()
runner.make_persistent_cluster()
self.assertEqual(runner.get_job_steps(), [])
def test_own_cluster(self):
job = MRTwoStepJob(['-r', 'emr']).sandbox()
with job.make_runner() as runner:
self.launch(runner)
... | Classification: hive-site""")
job = MRTwoStepJob(
['-r', 'emr', '-c', mrjob_1_conf, '-c', mrjob_2_conf])
job.sandbox()
with job.make_runner() as runner:
self.assertEqual(
runner._opts['emr_configurations'],
[dict(Classification='spark-de... | 127 | 127 | 424 | 13 | 114 | Affirm/mrjob | tests/test_emr.py | Python | GetJobStepsTestCase | GetJobStepsTestCase | 4,334 | 4,383 | 4,334 | 4,335 | 64e17d9a01f74625ed66ce33920d580f266fbf3a | bigcode/the-stack | train |
ef0cf6f6bfa5412e9ef5d549 | train | class | class VisibleToAllUsersTestCase(MockBoto3TestCase):
def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertEqual(cluster['VisibleToAllUsers'], True)
def test_overridden_false(self):
cluster = self.run_and_get_cluster(
'--extra-cluster-param', 'VisibleToAll... | class VisibleToAllUsersTestCase(MockBoto3TestCase):
| def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertEqual(cluster['VisibleToAllUsers'], True)
def test_overridden_false(self):
cluster = self.run_and_get_cluster(
'--extra-cluster-param', 'VisibleToAllUsers=false')
self.assertEqual(cluster['Visib... | runners': {'emr': {'ebs_root_volume_gb': 99.99}}}
with mrjob_conf_patcher(BAD_MRJOB_CONF):
self.assertRaises(ParamValidationError, self.run_and_get_cluster)
class VisibleToAllUsersTestCase(MockBoto3TestCase):
| 64 | 64 | 194 | 14 | 50 | Affirm/mrjob | tests/test_emr.py | Python | VisibleToAllUsersTestCase | VisibleToAllUsersTestCase | 456 | 476 | 456 | 457 | 6af90151ead45f5136603cf93c11778f6a94e1b5 | bigcode/the-stack | train |
f255859779b6a7bb3fa2e037 | train | class | class CheckInputPathsTestCase(MockBoto3TestCase):
def setUp(self):
super(CheckInputPathsTestCase, self).setUp()
# stop at _run()
self.start(patch('mrjob.emr.EMRJobRunner._run',
side_effect=StopIteration))
# this assumes we really ran the job
self.c... | class CheckInputPathsTestCase(MockBoto3TestCase):
| def setUp(self):
super(CheckInputPathsTestCase, self).setUp()
# stop at _run()
self.start(patch('mrjob.emr.EMRJobRunner._run',
side_effect=StopIteration))
# this assumes we really ran the job
self.cleanup = self.start(patch('mrjob.emr.EMRJobRunner.c... | _printout(
aws_access_key_id=['AKIATOPQUALITYSALESEVENT'])
self.assertIn("'aws_access_key_id'", printout)
self.assertNotIn('VENT', printout)
self.assertIn("'...'", printout)
def test_aws_secret_access_key(self):
printout = self.get_debug_printout(
aws_secret... | 256 | 256 | 859 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | CheckInputPathsTestCase | CheckInputPathsTestCase | 5,726 | 5,817 | 5,726 | 5,727 | 883dce1c365547ae230687534fdc8c1bb33638c3 | bigcode/the-stack | train |
5dae56b1e159fd7a7add31d1 | train | class | class HadoopExtraArgsOnEMRTestCase(HadoopExtraArgsTestCase, MockBoto3TestCase):
def setUp(self):
super(HadoopExtraArgsTestCase, self).setUp()
self.start(patch(
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='2.4.0'))
RUNNER = 'emr'
| class HadoopExtraArgsOnEMRTestCase(HadoopExtraArgsTestCase, MockBoto3TestCase):
| def setUp(self):
super(HadoopExtraArgsTestCase, self).setUp()
self.start(patch(
'mrjob.emr.EMRJobRunner.get_hadoop_version',
return_value='2.4.0'))
RUNNER = 'emr'
| r_step_syslog.called)
self.assertFalse(self._interpret_emr_step_stderr.called)
# this basically just checks that hadoop_extra_args is an option
# for the EMR runner
class HadoopExtraArgsOnEMRTestCase(HadoopExtraArgsTestCase, MockBoto3TestCase):
| 64 | 64 | 82 | 23 | 40 | Affirm/mrjob | tests/test_emr.py | Python | HadoopExtraArgsOnEMRTestCase | HadoopExtraArgsOnEMRTestCase | 4,054 | 4,063 | 4,054 | 4,055 | d0387fe39598aecbbb6307dab49f583568184744 | bigcode/the-stack | train |
bf1cdb081b2825a4104d1763 | train | class | class SubnetTestCase(MockBoto3TestCase):
def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertEqual(cluster['Ec2InstanceAttributes'].get('Ec2SubnetId'),
None)
def test_subnet_option(self):
cluster = self.run_and_get_cluster('--subnet', 'subn... | class SubnetTestCase(MockBoto3TestCase):
| def test_defaults(self):
cluster = self.run_and_get_cluster()
self.assertEqual(cluster['Ec2InstanceAttributes'].get('Ec2SubnetId'),
None)
def test_subnet_option(self):
cluster = self.run_and_get_cluster('--subnet', 'subnet-ffffffff')
self.assertEqual(clu... | '--extra-cluster-param', 'VisibleToAllUsers=true')
self.assertEqual(cluster['VisibleToAllUsers'], True)
def test_mock_boto3_does_not_force_to_bool(self):
# make sure that mrjob is converting to bool, not mock_boto3
self.assertRaises(ParamValidationError,
... | 103 | 103 | 346 | 12 | 91 | Affirm/mrjob | tests/test_emr.py | Python | SubnetTestCase | SubnetTestCase | 479 | 516 | 479 | 480 | 762a90f7a016e031b068e56f01443cf8df5a2064 | bigcode/the-stack | train |
d61e7af7aad30e7ec9eeff05 | train | class | class TestClusterSparkSupportWarning(MockBoto3TestCase):
def test_okay(self):
job = MRNullSpark(['-r', 'emr', '--image-version', '4.0.0'])
job.sandbox()
with job.make_runner() as runner:
self.launch(runner)
message = runner._cluster_spark_support_warning()
... | class TestClusterSparkSupportWarning(MockBoto3TestCase):
| def test_okay(self):
job = MRNullSpark(['-r', 'emr', '--image-version', '4.0.0'])
job.sandbox()
with job.make_runner() as runner:
self.launch(runner)
message = runner._cluster_spark_support_warning()
self.assertIsNone(message)
def test_no_python_3(s... | .EMRJobRunner.get_hadoop_version',
return_value='2'))
def test_eggs(self):
egg1_path = self.makefile('dragon.egg')
egg2_path = self.makefile('horton.egg')
job = MRNullSpark([
'-r', 'emr',
'--py-files', '%s,%s' % (egg1_path, egg2_path)])
... | 256 | 256 | 1,682 | 13 | 243 | Affirm/mrjob | tests/test_emr.py | Python | TestClusterSparkSupportWarning | TestClusterSparkSupportWarning | 5,105 | 5,324 | 5,105 | 5,106 | 227d952af2f6dfdcd684a11e5b7374cccd450f29 | bigcode/the-stack | train |
ee80ccb295ba8599431cc748 | train | class | class UseSudoOverSshTestCase(MockBoto3TestCase):
def test_ami_4_3_0_with_ssh_fs(self):
job = MRTwoStepJob(
['-r', 'emr', '--ec2-key-pair-file', '/path/to/EMR.pem',
'--image-version', '4.3.0']).sandbox()
with job.make_runner() as runner:
self.assertTrue(hasattr(... | class UseSudoOverSshTestCase(MockBoto3TestCase):
| def test_ami_4_3_0_with_ssh_fs(self):
job = MRTwoStepJob(
['-r', 'emr', '--ec2-key-pair-file', '/path/to/EMR.pem',
'--image-version', '4.3.0']).sandbox()
with job.make_runner() as runner:
self.assertTrue(hasattr(runner.fs, 'ssh'))
self.assertFalse(ru... | ['read_logs'] = False
# add a real error to investigate
self._check_for_nonzero_return_code.return_value = dict(
action_num=0, node_id='i-e647eb49')
self.runner._check_for_failed_bootstrap_action(cluster=Mock())
# should bail out before we call _interpret_emr_bootstrap_std... | 107 | 107 | 359 | 16 | 91 | Affirm/mrjob | tests/test_emr.py | Python | UseSudoOverSshTestCase | UseSudoOverSshTestCase | 4,717 | 4,757 | 4,717 | 4,718 | 90a077da97d44ef2db750382d624199c279fb96f | bigcode/the-stack | train |
c21841308b56a6029f3f8e7c | train | class | class SparkMasterAndDeployModeTestCase(MockBoto3TestCase):
def test_default(self):
mr_job = MRNullSpark(['-r', 'emr'])
mr_job.sandbox()
with mr_job.make_runner() as runner:
# patch this so we don't have to start a (mock) cluster
self.start(patch('mrjob.emr.EMRJobRun... | class SparkMasterAndDeployModeTestCase(MockBoto3TestCase):
| def test_default(self):
mr_job = MRNullSpark(['-r', 'emr'])
mr_job.sandbox()
with mr_job.make_runner() as runner:
# patch this so we don't have to start a (mock) cluster
self.start(patch('mrjob.emr.EMRJobRunner.get_hadoop_version',
return... | .assertTrue(runner._image_version_gte('4.6.0'))
self.assertTrue(runner._image_version_gte('4.8.2'))
self.assertFalse(runner._image_version_gte('5'))
class SparkMasterAndDeployModeTestCase(MockBoto3TestCase):
| 63 | 64 | 190 | 15 | 48 | Affirm/mrjob | tests/test_emr.py | Python | SparkMasterAndDeployModeTestCase | SparkMasterAndDeployModeTestCase | 5,355 | 5,376 | 5,355 | 5,356 | 6500f66c06d9ad89efc9252864e6260ecc3282f1 | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.