_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q253100 | InlineGrammar.hard_wrap | validation | def hard_wrap(self):
"""Grammar for hard wrap linebreak. You don't need to add two
spaces at the end of a line. | python | {
"resource": ""
} |
q253101 | Renderer.block_code | validation | def block_code(self, code, lang=None):
"""Rendering block level code. ``pre > code``.
:param code: text content of the code block.
:param lang: language of the given code.
"""
code = code.rstrip('\n')
if not lang:
| python | {
"resource": ""
} |
q253102 | Renderer.block_html | validation | def block_html(self, html):
"""Rendering block level pure html content.
:param html: text content of the html snippet.
| python | {
"resource": ""
} |
q253103 | Renderer.autolink | validation | def autolink(self, link, is_email=False):
"""Rendering a given link or email address.
:param link: link content or email address.
:param is_email: whether this is an email or not.
"""
text = | python | {
"resource": ""
} |
q253104 | Renderer.footnote_ref | validation | def footnote_ref(self, key, index):
"""Rendering the ref anchor of a footnote.
:param key: identity key for the footnote.
:param index: the index count of current footnote.
"""
html = (
| python | {
"resource": ""
} |
q253105 | Renderer.footnote_item | validation | def footnote_item(self, key, text):
"""Rendering a footnote item.
:param key: identity key for the footnote.
:param text: text content of the footnote.
"""
back = (
'<a href="#fnref-%s" class="footnote">↩</a>'
) % escape(key)
text = text.rstrip(... | python | {
"resource": ""
} |
q253106 | MetaParameterRecorder.build_metagraph_list | validation | def build_metagraph_list(self):
"""
Convert MetaParams into TF Summary Format and create summary_op.
Returns:
Merged TF Op for TEXT summary elements, should only be executed once to reduce data duplication.
"""
ops = []
self.ignore_unknown_dtypes = True
... | python | {
"resource": ""
} |
q253107 | process_docstring | validation | def process_docstring(app, what, name, obj, options, lines):
"""Enable markdown syntax in docstrings"""
markdown = "\n".join(lines)
# ast = cm_parser.parse(markdown)
# html = cm_renderer.render(ast)
| python | {
"resource": ""
} |
q253108 | PGModel.tf_baseline_loss | validation | def tf_baseline_loss(self, states, internals, reward, update, reference=None):
"""
Creates the TensorFlow operations for calculating the baseline loss of a batch.
Args:
states: Dict of state tensors.
internals: List of prior internal state tensors.
reward: Re... | python | {
"resource": ""
} |
q253109 | PGModel.baseline_optimizer_arguments | validation | def baseline_optimizer_arguments(self, states, internals, reward):
"""
Returns the baseline optimizer arguments including the time, the list of variables to
optimize, and various functions which the optimizer might require to perform an update
step.
Args:
states:... | python | {
"resource": ""
} |
q253110 | KFAC.tf_step | validation | def tf_step(self, time, variables, **kwargs):
"""
Creates the TensorFlow operations for performing an optimization step on the given variables, including
actually changing the values of the variables.
Args:
time: Time tensor. Not used for this optimizer.
variable... | python | {
"resource": ""
} |
q253111 | QDemoModel.setup_components_and_tf_funcs | validation | def setup_components_and_tf_funcs(self, custom_getter=None):
"""
Constructs the extra Replay memory.
"""
custom_getter = super(QDemoModel, self).setup_components_and_tf_funcs(custom_getter)
self.demo_memory = Replay(
states=self.states_spec,
internals=sel... | python | {
"resource": ""
} |
q253112 | QDemoModel.tf_import_demo_experience | validation | def tf_import_demo_experience(self, states, internals, actions, terminal, reward):
"""
Imports a single experience to memory.
"""
return self.demo_memory.store(
states=states,
| python | {
"resource": ""
} |
q253113 | QDemoModel.tf_demo_loss | validation | def tf_demo_loss(self, states, actions, terminal, reward, internals, update, reference=None):
"""
Extends the q-model loss via the dqfd large-margin loss.
"""
embedding = self.network.apply(x=states, internals=internals, update=update)
deltas = list()
for name in sorted(... | python | {
"resource": ""
} |
q253114 | QDemoModel.tf_combined_loss | validation | def tf_combined_loss(self, states, internals, actions, terminal, reward, next_states, next_internals, update, reference=None):
"""
Combines Q-loss and demo loss.
"""
q_model_loss = self.fn_loss(
states=states,
internals=internals,
actions=actions,
... | python | {
"resource": ""
} |
q253115 | QDemoModel.import_demo_experience | validation | def import_demo_experience(self, states, internals, actions, terminal, reward):
"""
Stores demonstrations in the demo memory.
"""
fetches = self.import_demo_experience_output
feed_dict = self.get_feed_dict(
states=states,
| python | {
"resource": ""
} |
q253116 | QDemoModel.demo_update | validation | def demo_update(self):
"""
Performs a demonstration update by calling the demo optimization operation.
Note that the batch data does not have to be fetched from the demo memory as this is now part of
| python | {
"resource": ""
} |
q253117 | Solver.from_config | validation | def from_config(config, kwargs=None):
"""
Creates a solver from a specification dict.
"""
return util.get_object(
obj=config,
| python | {
"resource": ""
} |
q253118 | SetClipboardText | validation | def SetClipboardText(text: str) -> bool:
"""
Return bool, True if succeed otherwise False.
"""
if ctypes.windll.user32.OpenClipboard(0):
ctypes.windll.user32.EmptyClipboard()
textByteLen = (len(text) + 1) * 2
hClipboardData = ctypes.windll.kernel32.GlobalAlloc(0, textByteLen) # ... | python | {
"resource": ""
} |
q253119 | ResetConsoleColor | validation | def ResetConsoleColor() -> bool:
"""
Reset to the default text color on console window.
Return bool, True if succeed otherwise False.
"""
if sys.stdout:
| python | {
"resource": ""
} |
q253120 | WindowFromPoint | validation | def WindowFromPoint(x: int, y: int) -> int:
"""
WindowFromPoint from Win32.
Return int, a native window handle.
"""
| python | {
"resource": ""
} |
q253121 | mouse_event | validation | def mouse_event(dwFlags: int, dx: int, dy: int, dwData: int, dwExtraInfo: int) -> None:
"""mouse_event from Win32.""" | python | {
"resource": ""
} |
q253122 | keybd_event | validation | def keybd_event(bVk: int, bScan: int, dwFlags: int, dwExtraInfo: int) -> None:
"""keybd_event from Win32."""
| python | {
"resource": ""
} |
q253123 | PostMessage | validation | def PostMessage(handle: int, msg: int, wParam: int, lParam: int) -> bool:
"""
PostMessage from Win32.
Return bool, True if succeed otherwise False.
"""
| python | {
"resource": ""
} |
q253124 | SendMessage | validation | def SendMessage(handle: int, msg: int, wParam: int, lParam: int) -> int:
"""
SendMessage from Win32.
Return int, the return value specifies the result of the message processing;
| python | {
"resource": ""
} |
q253125 | GetConsoleOriginalTitle | validation | def GetConsoleOriginalTitle() -> str:
"""
GetConsoleOriginalTitle from Win32.
Return str.
Only available on Windows Vista or higher.
"""
if IsNT6orHigher:
arrayType = ctypes.c_wchar * MAX_PATH
values = arrayType() | python | {
"resource": ""
} |
q253126 | GetConsoleTitle | validation | def GetConsoleTitle() -> str:
"""
GetConsoleTitle from Win32.
Return str.
"""
arrayType = | python | {
"resource": ""
} |
q253127 | IsDesktopLocked | validation | def IsDesktopLocked() -> bool:
"""
Check if desktop is locked.
Return bool.
Desktop is locked if press Win+L, Ctrl+Alt+Del or in remote desktop mode.
"""
isLocked = False
desk = ctypes.windll.user32.OpenDesktopW(ctypes.c_wchar_p('Default'), 0, 0, 0x0100) # DESKTOP_SWITCHDESKTOP = 0x0100
| python | {
"resource": ""
} |
q253128 | IsProcess64Bit | validation | def IsProcess64Bit(processId: int) -> bool:
"""
Return True if process is 64 bit.
Return False if process is 32 bit.
Return None if unknown, maybe caused by having no acess right to the process.
"""
try:
func = ctypes.windll.ntdll.ZwWow64ReadVirtualMemory64 #only 64 bit OS has this func... | python | {
"resource": ""
} |
q253129 | _CreateInput | validation | def _CreateInput(structure) -> INPUT:
"""
Create Win32 struct `INPUT` for `SendInput`.
Return `INPUT`.
"""
if isinstance(structure, MOUSEINPUT):
return INPUT(InputType.Mouse, _INPUTUnion(mi=structure))
if isinstance(structure, KEYBDINPUT):
return INPUT(InputType.Keyboard, | python | {
"resource": ""
} |
q253130 | MouseInput | validation | def MouseInput(dx: int, dy: int, mouseData: int = 0, dwFlags: int = MouseEventFlag.LeftDown, time_: int = 0) -> INPUT:
"""
Create Win32 struct `MOUSEINPUT` for `SendInput`.
| python | {
"resource": ""
} |
q253131 | KeyboardInput | validation | def KeyboardInput(wVk: int, wScan: int, dwFlags: int = KeyboardEventFlag.KeyDown, time_: int = 0) -> INPUT:
"""Create Win32 | python | {
"resource": ""
} |
q253132 | HardwareInput | validation | def HardwareInput(uMsg: int, param: int = 0) -> INPUT:
"""Create Win32 struct | python | {
"resource": ""
} |
q253133 | ControlFromPoint | validation | def ControlFromPoint(x: int, y: int) -> Control:
"""
Call IUIAutomation ElementFromPoint x,y. May return None if mouse is over cmd's title bar icon.
Return `Control` subclass or None.
"""
| python | {
"resource": ""
} |
q253134 | ControlFromPoint2 | validation | def ControlFromPoint2(x: int, y: int) -> Control:
"""
Get a native handle from point x,y and call IUIAutomation.ElementFromHandle.
| python | {
"resource": ""
} |
q253135 | Logger.DeleteLog | validation | def DeleteLog() -> None:
"""Delete log file."""
if | python | {
"resource": ""
} |
q253136 | Bitmap.GetAllPixelColors | validation | def GetAllPixelColors(self) -> ctypes.Array:
"""
Return `ctypes.Array`, an iterable array of int values in argb.
"""
| python | {
"resource": ""
} |
q253137 | Control.GetChildren | validation | def GetChildren(self) -> list:
"""
Return list, a list of `Control` subclasses.
"""
children = [] | python | {
"resource": ""
} |
q253138 | Control.SetWindowText | validation | def SetWindowText(self, text: str) -> bool:
"""
Call native SetWindowText if control has a valid native handle.
"""
| python | {
"resource": ""
} |
q253139 | Control.IsTopLevel | validation | def IsTopLevel(self) -> bool:
"""Determine whether current control is top level."""
| python | {
"resource": ""
} |
q253140 | Control.GetTopLevelControl | validation | def GetTopLevelControl(self) -> 'Control':
"""
Get the top level control which current control lays.
If current control is top level, return self.
If current control is root control, return None.
Return `PaneControl` or `WindowControl` or None.
"""
handle = self.N... | python | {
"resource": ""
} |
q253141 | TopLevel.Maximize | validation | def Maximize(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""
Set top level window maximize. | python | {
"resource": ""
} |
q253142 | TopLevel.MoveToCenter | validation | def MoveToCenter(self) -> bool:
"""
Move window to screen center.
"""
if self.IsTopLevel():
rect = self.BoundingRectangle
screenWidth, screenHeight = GetScreenSize()
x, y = (screenWidth - rect.width()) // 2, (screenHeight - rect.height()) // 2
| python | {
"resource": ""
} |
q253143 | TopLevel.SetActive | validation | def SetActive(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
"""Set top level window active."""
if self.IsTopLevel():
handle = self.NativeWindowHandle
if IsIconic(handle):
| python | {
"resource": ""
} |
q253144 | threadFunc | validation | def threadFunc(root):
"""
If you want to use functionalities related to Controls and Patterns in a new thread.
You must call InitializeUIAutomationInCurrentThread first in the thread
and call UninitializeUIAutomationInCurrentThread when the thread exits.
But you can't use use a Control or a Patt... | python | {
"resource": ""
} |
q253145 | SaliencyMapAttack._saliency_map | validation | def _saliency_map(self, a, image, target, labels, mask, fast=False):
"""Implements Algorithm 3 in manuscript
"""
# pixel influence on target class
alphas = a.gradient(image, target) * mask
# pixel influence on sum of residual classes
# (don't evaluate if fast == True)
... | python | {
"resource": ""
} |
q253146 | TensorFlowModel.from_keras | validation | def from_keras(cls, model, bounds, input_shape=None,
channel_axis=3, preprocessing=(0, 1)):
"""Alternative constructor for a TensorFlowModel that
accepts a `tf.keras.Model` instance.
Parameters
----------
model : `tensorflow.keras.Model`
A `tensorf... | python | {
"resource": ""
} |
q253147 | Adversarial.normalized_distance | validation | def normalized_distance(self, image):
"""Calculates the distance of a given image to the
original image.
Parameters
----------
image : `numpy.ndarray`
The image that should be compared to the original image.
Returns
-------
:class:`Distance`
| python | {
"resource": ""
} |
q253148 | Adversarial.channel_axis | validation | def channel_axis(self, batch):
"""Interface to model.channel_axis for attacks.
Parameters
----------
batch : bool
Controls whether the index | python | {
"resource": ""
} |
q253149 | Adversarial.has_gradient | validation | def has_gradient(self):
"""Returns true if _backward and _forward_backward can be called
by an attack, False otherwise.
"""
try:
self.__model.gradient
| python | {
"resource": ""
} |
q253150 | Adversarial.predictions | validation | def predictions(self, image, strict=True, return_details=False):
"""Interface to model.predictions for attacks.
Parameters
----------
image : `numpy.ndarray`
Single input with shape as expected by the model
(without the batch dimension).
strict : bool
... | python | {
"resource": ""
} |
q253151 | Adversarial.batch_predictions | validation | def batch_predictions(
self, images, greedy=False, strict=True, return_details=False):
"""Interface to model.batch_predictions for attacks.
Parameters
----------
images : `numpy.ndarray`
Batch of inputs with shape as expected by the model.
greedy : bool
... | python | {
"resource": ""
} |
q253152 | Adversarial.gradient | validation | def gradient(self, image=None, label=None, strict=True):
"""Interface to model.gradient for attacks.
Parameters
----------
image : `numpy.ndarray`
Single input with shape as expected by the model
(without the batch dimension).
Defaults to the original... | python | {
"resource": ""
} |
q253153 | Adversarial.predictions_and_gradient | validation | def predictions_and_gradient(
self, image=None, label=None, strict=True, return_details=False):
"""Interface to model.predictions_and_gradient for attacks.
Parameters
----------
image : `numpy.ndarray`
Single input with shape as expected by the model
... | python | {
"resource": ""
} |
q253154 | Adversarial.backward | validation | def backward(self, gradient, image=None, strict=True):
"""Interface to model.backward for attacks.
Parameters
----------
gradient : `numpy.ndarray`
Gradient of some loss w.r.t. the logits.
image : `numpy.ndarray`
Single input with shape as expected by the... | python | {
"resource": ""
} |
q253155 | CarliniWagnerL2Attack.best_other_class | validation | def best_other_class(logits, exclude):
"""Returns the index of the largest logit, ignoring the class that
is passed as `exclude`."""
| python | {
"resource": ""
} |
q253156 | CombinedCriteria.name | validation | def name(self):
"""Concatenates the names of the given criteria in alphabetical order.
If a sub-criterion is itself a combined criterion, its name is
first split into the individual names and the names of the
sub-sub criteria is used instead of the name of the sub-criterion.
Thi... | python | {
"resource": ""
} |
q253157 | softmax | validation | def softmax(logits):
"""Transforms predictions into probability values.
Parameters
----------
logits : array_like
The logits predicted by the model.
Returns
-------
`numpy.ndarray`
Probability values corresponding to the logits.
"""
assert logits.ndim == 1
# f... | python | {
"resource": ""
} |
q253158 | crossentropy | validation | def crossentropy(label, logits):
"""Calculates the cross-entropy.
Parameters
----------
logits : array_like
The logits predicted by the model.
label : int
The label describing the target distribution.
Returns
-------
float
The cross-entropy between softmax(logit... | python | {
"resource": ""
} |
q253159 | batch_crossentropy | validation | def batch_crossentropy(label, logits):
"""Calculates the cross-entropy for a batch of logits.
Parameters
----------
logits : array_like
The logits predicted by the model for a batch of inputs.
label : int
The label describing the target distribution.
Returns
-------
| python | {
"resource": ""
} |
q253160 | binarize | validation | def binarize(x, values, threshold=None, included_in='upper'):
"""Binarizes the values of x.
Parameters
----------
values : tuple of two floats
The lower and upper value to which the inputs are mapped.
threshold : float
The threshold; defaults to (values[0] + values[1]) / 2 if None.
... | python | {
"resource": ""
} |
q253161 | imagenet_example | validation | def imagenet_example(shape=(224, 224), data_format='channels_last'):
""" Returns an example image and its imagenet class label.
Parameters
----------
shape : list of integers
The shape of the returned image.
data_format : str
"channels_first" or "channels_last"
Returns
----... | python | {
"resource": ""
} |
q253162 | samples | validation | def samples(dataset='imagenet', index=0, batchsize=1, shape=(224, 224),
data_format='channels_last'):
''' Returns a batch of example images and the corresponding labels
Parameters
----------
dataset : string
The data set to load (options: imagenet, mnist, cifar10,
cifar100, ... | python | {
"resource": ""
} |
q253163 | onehot_like | validation | def onehot_like(a, index, value=1):
"""Creates an array like a, with all values
set to 0 except one.
Parameters
----------
a : array_like
The returned one-hot array will have the same shape
and dtype as this array
| python | {
"resource": ""
} |
q253164 | PrecomputedImagesAttack._get_output | validation | def _get_output(self, a, image):
""" Looks up the precomputed adversarial image for a given image.
"""
sd = np.square(self._input_images - image)
mses = np.mean(sd, axis=tuple(range(1, sd.ndim)))
index = np.argmin(mses)
# if we run into numerical problems with this appr... | python | {
"resource": ""
} |
q253165 | Model.predictions | validation | def predictions(self, image):
"""Convenience method that calculates predictions for a single image.
Parameters
----------
image : `numpy.ndarray`
Single input with shape as expected by the model
| python | {
"resource": ""
} |
q253166 | DifferentiableModel.gradient | validation | def gradient(self, image, label):
"""Calculates the gradient of the cross-entropy loss w.r.t. the image.
The default implementation calls predictions_and_gradient.
Subclasses can provide more efficient implementations that
only calculate the gradient.
Parameters
-------... | python | {
"resource": ""
} |
q253167 | clone | validation | def clone(git_uri):
"""
Clone a remote git repository to a local path.
:param git_uri: the URI to the git repository to be cloned
:return: the generated local path where the repository has been cloned to
"""
hash_digest = sha256_hash(git_uri) | python | {
"resource": ""
} |
q253168 | BaseHandler.write_success_response | validation | def write_success_response(self, result):
"""
Result may be a python dictionary, array or a primitive type
that can be converted to JSON for writing back the result.
"""
response = self.make_success_response(result)
| python | {
"resource": ""
} |
q253169 | BaseHandler.write_error_response | validation | def write_error_response(self, message):
"""
Writes the message as part of the response and sets 404 status.
"""
self.set_status(404)
response = self.make_error_response(str(message))
now = time.time()
| python | {
"resource": ""
} |
q253170 | BaseHandler.write_json_response | validation | def write_json_response(self, response):
""" write back json response """
| python | {
"resource": ""
} |
q253171 | BaseHandler.make_response | validation | def make_response(self, status):
"""
Makes the base dict for the response.
The status is the string value for
the key "status" of the response. This
should be "success" or "failure". | python | {
"resource": ""
} |
q253172 | BaseHandler.make_success_response | validation | def make_success_response(self, result):
"""
Makes the python dict corresponding to the
JSON that needs to be sent for a successful
response. Result is the actual payload
that gets sent.
| python | {
"resource": ""
} |
q253173 | BaseHandler.make_error_response | validation | def make_error_response(self, message):
"""
Makes the python dict corresponding to the
JSON that needs to be sent for a failed
response. Message is the message that is
sent as the reason for failure.
| python | {
"resource": ""
} |
q253174 | BaseHandler.get_argument_cluster | validation | def get_argument_cluster(self):
"""
Helper function to get request argument.
Raises exception if argument is missing.
Returns the cluster argument.
"""
try: | python | {
"resource": ""
} |
q253175 | BaseHandler.get_argument_role | validation | def get_argument_role(self):
"""
Helper function to get request argument.
Raises exception if argument is missing.
Returns the role argument.
"""
try:
| python | {
"resource": ""
} |
q253176 | BaseHandler.get_argument_environ | validation | def get_argument_environ(self):
"""
Helper function to get request argument.
Raises exception if argument is missing.
Returns the environ argument.
"""
try: | python | {
"resource": ""
} |
q253177 | BaseHandler.get_argument_topology | validation | def get_argument_topology(self):
"""
Helper function to get topology argument.
Raises exception if argument is missing.
Returns the topology argument.
"""
try:
| python | {
"resource": ""
} |
q253178 | BaseHandler.get_argument_component | validation | def get_argument_component(self):
"""
Helper function to get component argument.
Raises exception if argument is missing.
Returns the component argument.
"""
try:
| python | {
"resource": ""
} |
q253179 | BaseHandler.get_argument_instance | validation | def get_argument_instance(self):
"""
Helper function to get instance argument.
Raises exception if argument is missing.
Returns the instance argument.
"""
try:
| python | {
"resource": ""
} |
q253180 | BaseHandler.get_argument_starttime | validation | def get_argument_starttime(self):
"""
Helper function to get starttime argument.
Raises exception if argument is missing.
Returns the starttime argument.
"""
try:
| python | {
"resource": ""
} |
q253181 | BaseHandler.get_argument_endtime | validation | def get_argument_endtime(self):
"""
Helper function to get endtime argument.
Raises exception if argument is missing.
Returns the endtime argument.
"""
try:
| python | {
"resource": ""
} |
q253182 | BaseHandler.get_argument_query | validation | def get_argument_query(self):
"""
Helper function to get query argument.
Raises exception if argument is missing.
Returns the query argument.
"""
try:
| python | {
"resource": ""
} |
q253183 | BaseHandler.get_argument_offset | validation | def get_argument_offset(self):
"""
Helper function to get offset argument.
Raises exception if argument is missing.
Returns the offset argument.
"""
try:
| python | {
"resource": ""
} |
q253184 | BaseHandler.get_argument_length | validation | def get_argument_length(self):
"""
Helper function to get length argument.
Raises exception if argument is missing.
Returns the length argument.
"""
try:
| python | {
"resource": ""
} |
q253185 | BaseHandler.get_required_arguments_metricnames | validation | def get_required_arguments_metricnames(self):
"""
Helper function to get metricname arguments.
Notice that it is get_argument"s" variation, which means that this can be repeated.
Raises exception if argument is missing.
Returns a list of metricname arguments
"""
try:
metricnames = self... | python | {
"resource": ""
} |
q253186 | BaseHandler.validateInterval | validation | def validateInterval(self, startTime, endTime):
"""
Helper function to validate interval.
An interval is valid if starttime and endtime are integrals,
| python | {
"resource": ""
} |
q253187 | HeronClient.start_connect | validation | def start_connect(self):
"""Tries to connect to the Heron Server
``loop()`` method needs to be called after this.
"""
Log.debug("In start_connect() of %s" % self._get_classname())
# TODO: specify buffer size, exception handling
| python | {
"resource": ""
} |
q253188 | HeronClient.register_on_message | validation | def register_on_message(self, msg_builder):
"""Registers protobuf message builders that this client wants to receive
:param msg_builder: callable to create a protobuf message that this client wants to receive
"""
| python | {
"resource": ""
} |
q253189 | create_tar | validation | def create_tar(tar_filename, files, config_dir, config_files):
'''
Create a tar file with a given set of files
'''
with contextlib.closing(tarfile.open(tar_filename, 'w:gz', dereference=True)) as tar:
for filename in files:
if os.path.isfile(filename):
tar.add(filename, arcname=os.path.basenam... | python | {
"resource": ""
} |
q253190 | get_subparser | validation | def get_subparser(parser, command):
'''
Retrieve the given subparser from parser
'''
# pylint: disable=protected-access
subparsers_actions = [action for action in parser._actions
if isinstance(action, argparse._SubParsersAction)]
# there will probably only be one subparser_action,
... | python | {
"resource": ""
} |
q253191 | get_heron_dir | validation | def get_heron_dir():
"""
This will extract heron directory from .pex file.
For example,
when __file__ is '/Users/heron-user/bin/heron/heron/tools/common/src/python/utils/config.pyc', and
its real path is '/Users/heron-user/.heron/bin/heron/tools/common/src/python/utils/config.pyc',
the internal variable ``... | python | {
"resource": ""
} |
q253192 | get_heron_libs | validation | def get_heron_libs(local_jars):
"""Get all the heron lib jars with the absolute paths"""
heron_lib_dir = get_heron_lib_dir()
heron_libs = | python | {
"resource": ""
} |
q253193 | defaults_cluster_role_env | validation | def defaults_cluster_role_env(cluster_role_env):
"""
if role is not provided, supply userid
if environ is not provided, supply 'default'
"""
if len(cluster_role_env[1]) == 0 and len(cluster_role_env[2]) == 0:
return | python | {
"resource": ""
} |
q253194 | parse_override_config_and_write_file | validation | def parse_override_config_and_write_file(namespace):
"""
Parse the command line for overriding the defaults and
create an override file.
"""
overrides = parse_override_config(namespace)
try:
tmp_dir = tempfile.mkdtemp()
override_config_file = os.path.join(tmp_dir, OVERRIDE_YAML)
| python | {
"resource": ""
} |
q253195 | parse_override_config | validation | def parse_override_config(namespace):
"""Parse the command line for overriding the defaults"""
overrides = dict()
for config in namespace:
kv = config.split("=")
if len(kv) != 2:
raise Exception("Invalid config property format (%s) expected key=value" % config)
if kv[1] | python | {
"resource": ""
} |
q253196 | get_java_path | validation | def get_java_path():
"""Get the path of java executable""" | python | {
"resource": ""
} |
q253197 | check_java_home_set | validation | def check_java_home_set():
"""Check if the java home set"""
# check if environ variable is set
if "JAVA_HOME" not in os.environ:
Log.error("JAVA_HOME not set")
return False
# check if the value set is correct
java_path = | python | {
"resource": ""
} |
q253198 | check_release_file_exists | validation | def check_release_file_exists():
"""Check if the release.yaml file exists"""
release_file = get_heron_release_file()
# if the file does not exist and is not a file
if | python | {
"resource": ""
} |
q253199 | print_build_info | validation | def print_build_info(zipped_pex=False):
"""Print build_info from release.yaml
:param zipped_pex: True if the PEX file is built with flag `zip_safe=False'.
"""
if zipped_pex:
release_file = get_zipped_heron_release_file()
else:
release_file = get_heron_release_file()
with open(release_file) as rele... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.