function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def _getPythonVersionFromPath(self, pathName, destdir):
if destdir and pathName.startswith(destdir):
pathName = pathName[len(destdir):]
pathList = pathName.split('/')
for dirName in pathList:
if dirName.startswith('python') and self._stringIsPythonVersion(
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _isJava(self, m, contents=None):
return m and isinstance(m, (magic.jar, magic.java)) and self._hasContents(m, contents) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _isPerl(self, path, m, f):
return self._isPerlModule(path) or (
f.inode.perms() & 0111 and m and m.name == 'script'
and 'interpreter' in m.contents
and '/bin/perl' in m.contents['interpreter']) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addDepToMap(self, path, depMap, depType, dep):
"Add a single dependency to a map, regardless of whether path was listed before"
if path not in depMap:
depMap[path] = deps.DependencySet()
depMap[path].addDep(depType, dep) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _recurseSymlink(path, destdir, fullpath=None):
"""
Recurse through symlinks in destdir and get the final path and fullpath.
If initial fullpath (or destdir+path if fullpath not specified)
does not exist, return path.
"""
if fullpath is None:
fullpath = des... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _enforceProvidedPath(self, path, fileType='interpreter',
unmanagedError=False):
key = path, fileType
if key in self.cachedProviders:
return self.cachedProviders[key]
db = self._getDb()
troveNames = [ x.getName() for x in db.iterTrovesByPath(pa... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getRubyLoadPath(self, macros, rubyInvocation, bootstrap):
# Returns tuple of (invocationString, loadPathList)
destdir = macros.destdir
if bootstrap:
rubyLibPath = [destdir + x for x in self.bootstrapRubyLibs]
rubyInvocation = (('LD_LIBRARY_PATH=%(destdir)s%(libdir)s ... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getRubyFlagsFromPath(self, pathName, rubyVersion):
pathList = pathName.split('/')
pathList = [ x for x in pathList if x ]
foundLib = False
foundVer = False
flags = set()
for dirName in pathList:
if not foundLib and dirName.startswith('lib'):
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getperlincpath(self, perl, destdir):
"""
Fetch the perl @INC path, falling back to bootstrapPerlIncPath
only if perl cannot be run. All elements of the search path
will be resolved against symlinks in destdir if they exist. (CNY-2949)
"""
if not perl:
re... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _perlDestInc(destdir, perlDestInc):
return ' '.join(['-I' + destdir + x for x in perlDestInc]) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getPython(self, macros, path):
"""
Takes a path
Returns, for that path, a tuple of
- the preferred instance of python to use
- whether that instance is in the destdir
"""
m = self.recipe.magic[path]
if m and m.name == 'script' and 'python' in ... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
_dependency.__init__(self, *args, **keywords)
self.provisions = []
self.sonameSubtrees = set()
self.sysPath = None
self.monodisPath = None
self.rubyInterpreter = None
self.rubyVersion = None
self.rubyInvocation = None... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def preProcess(self):
macros = self.macros
if self.bootstrapPythonFlags is not None:
self.bootstrapPythonFlags = set(x % macros
for x in self.bootstrapPythonFlags)
if self.bootstrapSysPath:
self.bootstrapSysPath = [x % macros fo... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def whiteOut(self, path, pkgFiles):
# remove intentionally discarded provides
for pkg, f in pkgFiles:
if self.exceptDeps and path in pkg.providesMap:
depSet = deps.DependencySet()
for depClass, dep in pkg.providesMap[path].iterDeps():
for f... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def addPathDeps(self, path, dirpath, pkgFiles):
# Because paths can change, individual files do not provide their
# paths. However, within a trove, a file does provide its name.
# Furthermore, non-regular files can be path dependency targets
# Therefore, we have to handle this case a bi... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getELFinfo(self, m, soname):
if 'provides' in m.contents and m.contents['provides']:
return m.contents['provides']
else:
# we need to synthesize some provides information
return [('soname', soname, ())] | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getPythonProvidesSysPath(self, path):
"""Generate an ordered list of python paths for the target package.
This includes the current system path, plus any paths added by the new
package in the destdir through .pth files or a newly built python.
@return: (sysPath, pythonVersion)
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addPythonProvides(self, path, m, pkgFiles, macros):
if not self._isPythonModuleCandidate(path):
return
sysPath, pythonVersion = self._getPythonProvidesSysPath(path)
if not sysPath:
return
# Add provides for every match in sys.path. For example, PIL.Imaging... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addOneCILProvide(self, pkgFiles, path, name, ver):
for pkg, _ in pkgFiles:
self._addDepToMap(path, pkg.providesMap, deps.CILDependencies,
deps.Dependency(name, [(ver, deps.FLAG_SENSE_REQUIRED)])) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addCILProvides(self, path, m, pkgFiles, macros):
if not m or m.name != 'CIL':
return
fullpath = macros.destdir + path
if not self.monodisPath:
self.monodisPath = self._getmonodis(macros, path)
if not self.monodisPath:
return
p = ut... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addRubyProvides(self, path, m, pkgFiles, macros, prov):
flags = self._getRubyFlagsFromPath(path, self.rubyVersion)
flags = [(x, deps.FLAG_SENSE_REQUIRED) for x in sorted(list(flags))]
dep = deps.Dependency(prov, flags)
for pkg, _ in pkgFiles:
self._addDepToMap(path, pkg.... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addPerlProvides(self, path, m, pkgFiles):
# do not call perl to get @INC unless we have something to do for perl
self._fetchPerlIncPath()
# It is possible that we'll want to allow user-specified
# additions to the perl search path, but if so, we need
# to path-encode those ... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
_dependency.__init__(self, *args, **keywords)
self.bootstrapPythonFlags = set()
self.bootstrapSysPath = []
self.bootstrapPerlIncPath = []
self.bootstrapRubyLibs = []
self.pythonFlagNamespace = None
self.sonameSubtrees = set()... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def preProcess(self):
macros = self.macros
self.systemLibPaths = set(os.path.normpath(x % macros)
for x in self.sonameSubtrees)
self.bootstrapPythonFlags = set(x % macros
for x in self.bootstrapPythonFlags)
self.bo... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def doFile(self, path):
pkgs = self.recipe.autopkg.findComponents(path)
if not pkgs:
return
pkgFiles = [(x, x.getFile(path)) for x in pkgs]
# this file object used only for tests, not for doing packaging
f = pkgFiles[0][1]
macros = self.recipe.macros
f... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def whiteOut(self, path, pkgFiles):
# remove intentionally discarded dependencies
for pkg, _ in pkgFiles:
if self.exceptDeps and path in pkg.requiresMap:
depSet = deps.DependencySet()
for depClass, dep in pkg.requiresMap[path].iterDeps():
f... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addELFRequirements(self, path, m, pkgFiles):
"""
Add ELF and abi dependencies, including paths when not shlibs
"""
def appendUnique(ul, items):
for item in items:
if item not in ul:
ul.append(item)
def _canonicalRPATH(rpath, ... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getPythonRequiresModuleFinder(self, pythonPath, destdir, libdir, sysPath, bootstrapPython):
if self.recipe.isCrossCompiling():
return None
if pythonPath not in self.pythonModuleFinderMap:
try:
self.pythonModuleFinderMap[pythonPath] = pydeps.moduleFinderProxy... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addPythonRequirements(self, path, fullpath, pkgFiles):
destdir = self.recipe.macros.destdir
destDirLen = len(destdir)
(sysPath, pythonModuleFinder, pythonVersion
)= self._getPythonRequiresSysPath(path)
if not sysPath:
# Probably a bad interpreter path
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _checkSystemPythonDeps(self, depNames, flags):
if flags:
flags = [ (x, deps.FLAG_SENSE_REQUIRED) for x in flags ]
for dp in depNames:
depSet = deps.DependencySet()
depSet.addDep(deps.PythonDependencies, deps.Dependency(dp, flags))
troves = self.depCac... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _addRubyRequirements(self, path, fullpath, pkgFiles, script=False):
macros = self.recipe.macros
destdir = macros.destdir
destDirLen = len(destdir)
if self.rubyInterpreter is None:
self.rubyInterpreter, bootstrap = self._getRuby(macros, path)
if not self.rubyI... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _getPerlReqs(self, path, fullpath):
if self.perlReqs is None:
self._fetchPerl()
if not self.perlPath:
# no perl == bootstrap, but print warning
self.info('Unable to find perl interpreter,'
' disabling perl: requirements')
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _checkInclusion(self, info, path):
if info in self.excluded:
for filt in self.excluded[info]:
# exception handling is per-requirement,
# so handled specially
if filt.match(path):
self.info('ignoring requirement match for %s: %s'... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def preProcess(self):
# We want to inherit the exceptions from the Requires class, so we
# need to peek into the Required policy object. We can still pass
# explicit exceptions into the pluggable sub-policies, and they will
# only apply to the sub-policy.
exceptions = self.recipe... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def error(self, *args, **kwargs):
return self.recipe._policyMap['Requires'].error(*args, **kwargs) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def info(self, *args, **kwargs):
return self.recipe._policyMap['Requires'].info(*args, **kwargs) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def doFile(self, path):
pkgs = self.recipe.autopkg.findComponents(path)
if not pkgs:
return
pkgFiles = [(x, x.getFile(path)) for x in pkgs]
macros = self.recipe.macros
fullpath = macros.destdir + path
self.addPluggableRequirements(path, fullpath, pkgFiles, ma... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def do(self):
if use.Use.bootstrap._get():
return
for comp in self.recipe.autopkg.getComponents():
comp.requires -= comp.provides | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def preProcess(self):
self.libRe = re.compile(
'^(%(libdir)s'
'|/%(lib)s'
'|%(x11prefix)s/%(lib)s'
'|%(krbprefix)s/%(lib)s)(/|$)' %self.recipe.macros)
self.libReException = re.compile('^/usr/(lib|%(lib)s)/(python|ruby).*$')
self.baseIsnset = use.Ar... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def hasLibInPath(self, path):
return self.libRe.match(path) and not self.libReException.match(path) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def doFile(self, path):
autopkg = self.recipe.autopkg
pkg = autopkg.findComponent(path)
if pkg is None:
return
f = pkg.getFile(path)
m = self.recipe.magic[path]
if m and m.name == 'ELF' and 'isnset' in m.contents:
isnset = m.contents['isnset']
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def preProcess(self):
if self.exceptions:
self.error('%s does not honor exceptions' % self.__class__.__name__)
self.exceptions = None
if self.inclusions:
self.inclusions = None | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def parseInfoFile(self, path):
infoname = "info-%s:%s" % (os.path.basename(path), self.component)
data = {}
try:
data = dict([x.strip().split('=', 1) \
for x in open(path).readlines()])
extraKeys = set(data.keys()).difference(self.legalKeys)
... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def addRequires(self, path):
realpath, fileObj = self.recipe.autopkg.findComponent(path)[path]
data = self.parseInfoFile(realpath)
pkg = self.recipe.autopkg.componentMap[path]
infoname = os.path.basename(path)
if path in pkg.requiresMap:
# only deps related to userinf... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def parseInfoFile(self, path):
if self.recipe._getCapsulePathsForFile(path):
return {}
data = _ProcessInfoPackage.parseInfoFile(self, path)
if data:
supplemental = data.get('SUPPLEMENTAL')
if supplemental is not None:
data['SUPPLEMENTAL'] = sup... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def getRequires(self, infoname, data):
groupname = data.get('GROUP', infoname)
supp = data.get('SUPPLEMENTAL', [])
depSet = deps.DependencySet()
for grpDep in supp:
depSet.addDep(deps.GroupInfoDependencies,
deps.Dependency(grpDep, []))
if not... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def getProvides(self, groupname, data):
depSet = deps.DependencySet()
depSet.addDep(deps.GroupInfoDependencies,
deps.Dependency(groupname, []))
return depSet | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
self.found = set()
policy.Policy.__init__(self, *args, **keywords) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def do(self):
# If absolutely no buildRequires were found automatically,
# assume that the buildRequires list has been carefully crafted
# for some reason that the buildRequires enforcement policy
# doesn't yet support, and don't warn that all of the listed
# buildRequires might ... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def _reportExcessSuperclassBuildRequires(self, reqList):
self.recipe._logFile.reportExcessSuperclassBuildRequires(
sorted(list(reqList))) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
self.errors = set()
policy.Policy.__init__(self, *args, **keywords) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def do(self):
if self.errors and self.recipe._logFile:
self.recipe._logFile.reportMissingBuildRequires(
sorted(list(self.errors))) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
self.errors = []
policy.Policy.__init__(self, *args, **keywords) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def do(self):
if self.errors:
msg = self.groupError and 'Group' or 'Package'
raise policy.PolicyError, ('%s Policy errors found:\n%%s' % msg) \
% "\n".join(self.errors) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def __init__(self, *args, **keywords):
policy.PackagePolicy.__init__(self, *args, **keywords) | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def do(self):
if not self.contents:
return
# Build component map
availTroveNames = dict((x.name, None) for x in
self.recipe.autopkg.getComponents())
availTroveNames.update(self.recipe.packages)
troveNames = set(self.troveNames) & set(a... | sassoftware/conary | [
47,
9,
47,
4,
1396904066
] |
def setUp(self):
self.user1 = db_utils.create_user()
self.user2 = db_utils.create_user()
self.friend1 = db_utils.create_user()
db_utils.create_friendship(self.user1, self.friend1)
self.count = 20
self.pivot = 5
s = db_utils.create_characters(self.count, self.user1... | Weasyl/weasyl | [
106,
28,
106,
115,
1462586006
] |
def test_count_nextid(self):
self.assertEqual(
self.pivot,
character.select_count(self.user1, ratings.GENERAL.code, nextid=self.pivotid)) | Weasyl/weasyl | [
106,
28,
106,
115,
1462586006
] |
def test_cannot_see_non_friends_character(self):
"""
Should not be able to see a non-friend's friends-ony character in a listing.
"""
db_utils.create_character(self.user2, friends_only=True)
self.assertEqual(
self.count,
character.select_count(self.user1, ... | Weasyl/weasyl | [
106,
28,
106,
115,
1462586006
] |
def __init__(self):
super(MenuBarItemStylesExample, self).__init__()
self._menubar = MenuBar()
menuCommand = MenuCommand(self)
# Save reference to individual items so we can add sub-menu items to
# them
f = self._menubar.addItem('File', None)
newItem = f.addIte... | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def __init__(self, c):
self._c = c | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def __init__(self, c):
self._c = c | rwl/muntjac | [
43,
14,
43,
5,
1316308871
] |
def log(level: int, x: Any) -> None:
if logging.getLogger(None).isEnabledFor(level):
for line in pprint.pformat(x).split('\n'):
logging.log(level, line) | project-chip/connectedhomeip | [
5774,
1369,
5774,
982,
1583255110
] |
def test_box_nms_op():
def test_box_nms_forward(data, expected, thresh=0.5, valid=0, topk=-1, coord=2, score=1, cid=0, bid=-1,
force=False, in_format='corner', out_format='corner'):
for dtype in ['float16', 'float32', 'float64']:
data = mx.nd.array(data, dtype=dtype)... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def numpy_box_iou(a, b, fmt='corner'):
def area(left, top, right, bottom):
return np.maximum(0, right - left) * np.maximum(0, bottom - top)
assert a.shape[-1] == 4
assert b.shape[-1] == 4
oshape = a.shape[:-1] + b.shape[:-1]
a = a.reshape((-1, 4))
ashape = a.... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def test_bipartite_matching_op():
def assert_match(inputs, x, y, threshold, is_ascend=False):
for dtype in ['float16', 'float32', 'float64']:
inputs = mx.nd.array(inputs, dtype=dtype)
x = np.array(x, dtype=dtype)
y = np.array(y, dtype=dtype)
a, b = mx.nd.contr... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def test_gradient_multiplier_op():
# We use the quadratic function in combination with gradient multiplier
def f(x, a, b, c):
return a * x**2 + b * x + c
a = np.random.random_sample()
b = np.random.random_sample()
c = np.random.random_sample()
m = np.random.random_sample() - 0.5
da... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def test_box_encode_op():
anchors = mx.nd.array([[0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.7, 0.8]]).reshape((1, -1, 4))
refs = mx.nd.array([[0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.7, 0.8]]).reshape((1, -1, 4))
samples = mx.nd.array([[0, 1]])
matches = mx.nd.array([[0, 1]])
means = mx.nd.array([0.0, 0.0, 0.0, 0... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def test_op_mrcnn_mask_target():
if default_context().device_type != 'gpu':
return
num_rois = 2
num_classes = 4
mask_size = (3, 3)
ctx = mx.gpu(0)
# (B, N, 4)
rois = mx.nd.array([[[2.3, 4.3, 2.2, 3.3],
[3.5, 5.5, 0.9, 2.4]]], ctx=ctx)
gt_masks = mx.nd.ara... | mlperf/training_results_v0.7 | [
11,
25,
11,
1,
1606268455
] |
def plugin(self):
return plugins.get(self.plugin_name) | Netflix/lemur | [
1615,
314,
1615,
125,
1434472567
] |
def get_attn(attn_type):
if isinstance(attn_type, torch.nn.Module):
return attn_type
module_cls = None
if attn_type is not None:
if isinstance(attn_type, str):
attn_type = attn_type.lower()
# Lightweight attention modules (channel and/or coarse spatial).
#... | rwightman/pytorch-image-models | [
23978,
3956,
23978,
96,
1549086672
] |
def setUp(self):
super(NotificationsTestCase, self).setUp()
self.net_info = fake_network.fake_get_instance_nw_info(self.stubs, 1,
1)
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_send_api_fault_disabled(self):
self.flags(notify_api_faults=False)
notifications.send_api_fault("http://example.com/foo", 500, None)
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS)) | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_notif_disabled(self):
# test config disable of the notifications
self.flags(notify_on_state_change=None)
old = copy.copy(self.instance)
self.instance["vm_state"] = vm_states.ACTIVE
old_vm_state = old['vm_state']
new_vm_state = self.instance["vm_state"]
... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_send_no_notif(self):
# test notification on send no initial vm state:
old_vm_state = self.instance['vm_state']
new_vm_state = self.instance['vm_state']
old_task_state = self.instance['task_state']
new_task_state = self.instance['task_state']
notifications.send_... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_send_on_task_change(self):
# pretend we just transitioned to task SPAWNING:
params = {"task_state": task_states.SPAWNING}
(old_ref, new_ref) = db.instance_update_and_get_original(self.context,
self.instance['uuid'], params)
notifications.send_update(self.context... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_vm_update_with_states(self):
notifications.send_update_with_states(self.context, self.instance,
vm_states.BUILDING, vm_states.ACTIVE, task_states.SPAWNING,
task_states.SPAWNING, verify_states=True)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
no... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_update_no_service_name(self):
notifications.send_update_with_states(self.context, self.instance,
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
None)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
# service name should default to 'c... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_update_with_host_name(self):
notifications.send_update_with_states(self.context, self.instance,
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
None, host="someotherhost")
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
# service name... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_send_access_ip_update(self):
notifications.send_update(self.context, self.instance, self.instance)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
notif = fake_notifier.NOTIFICATIONS[0]
payload = notif.payload
access_ip_v4 = self.instance["access_ip_v4"]
ac... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def test_send_no_state_change(self):
called = [False]
def sending_no_state_change(context, instance, **kwargs):
called[0] = True
self.stubs.Set(notifications, '_send_instance_update_notification',
sending_no_state_change)
notifications.send_update(self... | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def fail_sending(context, instance, **kwargs):
raise Exception('failed to notify') | CiscoSystems/nova | [
4,
9,
4,
1,
1323390460
] |
def start(self, action_name: str) -> None:
"""Defines how to start recording an action.""" | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def stop(self, action_name: str) -> None:
"""Defines how to record the duration once an action is complete.""" | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def summary(self) -> str:
"""Create profiler summary in text format.""" | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def setup(self, **kwargs: Any) -> None:
"""Execute arbitrary pre-profiling set-up steps as defined by subclass.""" | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def teardown(self, **kwargs: Any) -> None:
"""Execute arbitrary post-profiling tear-down steps as defined by subclass.""" | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def __init__(
self,
dirpath: Optional[Union[str, Path]] = None,
filename: Optional[str] = None, | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def profile(self, action_name: str) -> Generator:
"""
Yields a context manager to encapsulate the scope of a profiled action.
Example::
with self.profile('load training data'):
# load training data code
The profiler will start once you've entered the contex... | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def _rank_zero_info(self, *args, **kwargs) -> None:
if self._local_rank in (None, 0):
log.info(*args, **kwargs) | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def _prepare_streams(self) -> None:
if self._write_stream is not None:
return
if self.filename:
filepath = os.path.join(self.dirpath, self._prepare_filename())
fs = get_filesystem(filepath)
file = fs.open(filepath, "a")
self._output_file = file... | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def _stats_to_str(self, stats: Dict[str, str]) -> str:
stage = f"{self._stage.upper()} " if self._stage is not None else ""
output = [stage + "Profiler Report"]
for action, value in stats.items():
header = f"Profile stats for: {action}"
if self._local_rank is not None:
... | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def teardown(self, stage: Optional[str] = None) -> None:
"""
Execute arbitrary post-profiling tear-down steps.
Closes the currently open file and stream.
"""
self._write_stream = None
if self._output_file is not None:
self._output_file.close()
sel... | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def start(self, action_name: str) -> None:
raise NotImplementedError | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def summary(self) -> str:
raise NotImplementedError | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def local_rank(self) -> int:
return 0 if self._local_rank is None else self._local_rank | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def start(self, action_name: str) -> None:
pass | williamFalcon/pytorch-lightning | [
21876,
2764,
21876,
665,
1553993157
] |
def check_parameters(pjson):
if not pjson or not 'app_account' in pjson or not 'card' in pjson or not 'appid' in pjson:
no_db_logger.info('No Parameter')
abort(400)
cli = {'account':pjson['app_account'], 'card':pjson['card'], 'appid':pjson['appid']}
return client(cli['account'], cli['card'], cli['appid']) | zznn/futu-openAPI | [
38,
18,
38,
1,
1462535088
] |
def hello_world():
no_db_logger.info('server start#####')
return 'hello 22222222 world!' | zznn/futu-openAPI | [
38,
18,
38,
1,
1462535088
] |
def trade_token():
trade_pswd = request.json['trade_pswd']
account = request.json['app_account']
card = request.json['card']
appid = request.json['appid']
cc = check_parameters(request.json)
message = cc.get_trade_token(trade_pswd)
if message['result_code'] != 0 and message['error_msg'] == 'didn\'t get accesstok... | zznn/futu-openAPI | [
38,
18,
38,
1,
1462535088
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.