INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Reserve a set of values for this execution.
No other process can reserve the same set of values while the set is
reserved. Acquired value set needs to be released after use to allow
other processes to access it.
Add tags to limit the possible value sets that this returns. | def acquire_value_set(self, *tags):
"""
Reserve a set of values for this execution.
No other process can reserve the same set of values while the set is
reserved. Acquired value set needs to be released after use to allow
other processes to access it.
Add tags to limit th... |
Get a value from previously reserved value set. | def get_value_from_set(self, key):
"""
Get a value from previously reserved value set.
"""
#TODO: This should be done locally.
# We do not really need to call centralised server if the set is already
# reserved as the data there is immutable during execution
key ... |
Release a reserved value set so that other executions can use it also. | def release_value_set(self):
"""
Release a reserved value set so that other executions can use it also.
"""
if self._remotelib:
self._remotelib.run_keyword('release_value_set', [self._my_id], {})
else:
_PabotLib.release_value_set(self, self._my_id) |
A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored. | def install_all_patches():
"""
A convenience method that installs all available hooks.
If a specific module is not available on the path, it is ignored.
"""
from . import mysqldb
from . import psycopg2
from . import strict_redis
from . import sqlalchemy
from . import tornado_http
... |
Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all client patches
* empty list - does not install ... | def install_patches(patchers='all'):
"""
Usually called from middleware to install client hooks
specified in the client_hooks section of the configuration.
:param patchers: a list of patchers to run. Acceptable values include:
* None - installs all client patches
* 'all' - installs all clie... |
Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes | def install_client_interceptors(client_interceptors=()):
"""
Install client interceptors for the patchers.
:param client_interceptors: a list of client interceptors to install.
Should be a list of classes
"""
if not _valid_args(client_interceptors):
raise ValueError('client_intercep... |
Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned. | def _load_symbol(name):
"""Load a symbol by name.
:param str name: The name to load, specified by `module.attr`.
:returns: The attribute value. If the specified module does not contain
the requested attribute then `None` is returned.
"""
module_name, key = name.rsplit('.', 1)
try:... |
Access current request context and extract current Span from it.
:return:
Return current span associated with the current request context.
If no request context is present in thread local, or the context
has no span, return None. | def get_current_span():
"""
Access current request context and extract current Span from it.
:return:
Return current span associated with the current request context.
If no request context is present in thread local, or the context
has no span, return None.
"""
# Check agains... |
Create a context manager that stores the given span in the thread-local
request context. This function should only be used in single-threaded
applications like Flask / uWSGI.
## Usage example in WSGI middleware:
.. code-block:: python
from opentracing_instrumentation.http_server import WSGIReq... | def span_in_context(span):
"""
Create a context manager that stores the given span in the thread-local
request context. This function should only be used in single-threaded
applications like Flask / uWSGI.
## Usage example in WSGI middleware:
.. code-block:: python
from opentracing_ins... |
Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
## Usage example in Tornado application
Su... | def span_in_stack_context(span):
"""
Create Tornado's StackContext that stores the given span in the
thread-local request context. This function is intended for use
in Tornado applications based on IOLoop, although will work fine
in single-threaded apps like Flask, albeit with more overhead.
##... |
Creates a new local span for execution of the given `func`.
The returned span is best used as a context manager, e.g.
.. code-block:: python
with func_span('my_function'):
return my_function(...)
At this time the func should be a string name. In the future this code
can be enhance... | def func_span(func, tags=None, require_active_trace=False):
"""
Creates a new local span for execution of the given `func`.
The returned span is best used as a context manager, e.g.
.. code-block:: python
with func_span('my_function'):
return my_function(...)
At this time the ... |
A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def my_function1(arg1, arg2=None)
...
:param func: decorated function or Tornado co-routine
:param na... | def traced_function(func=None, name=None, on_start=None,
require_active_trace=False):
"""
A decorator that enables tracing of the wrapped function or
Tornado co-routine provided there is a parent span already established.
.. code-block:: python
@traced_function
def ... |
Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Span or None
:param tags: optional tags
:return: new span | def start_child_span(operation_name, tracer=None, parent=None, tags=None):
"""
Start a new span as a child of parent_span. If parent_span is None,
start a new root span.
:param operation_name: operation name
:param tracer: Tracer or None (defaults to opentracing.tracer)
:param parent: parent Sp... |
Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a regular dictionary interface
:param tracer: optional... | def before_request(request, tracer=None):
"""
Attempts to extract a tracing span from incoming request.
If no tracing context is passed in the headers, or the data
cannot be parsed, a new root span is started.
:param request: HTTP request with `.headers` property exposed
that satisfies a re... |
HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a dictionary of headers | def _parse_wsgi_headers(wsgi_environ):
"""
HTTP headers are presented in WSGI environment with 'HTTP_' prefix.
This method finds those headers, removes the prefix, converts
underscores to dashes, and converts to lower case.
:param wsgi_environ:
:return: returns a diction... |
Taken from
http://legacy.python.org/dev/peps/pep-3333/#url-reconstruction
:return: Reconstructed URL from WSGI environment. | def full_url(self):
"""
Taken from
http://legacy.python.org/dev/peps/pep-3333/#url-reconstruction
:return: Reconstructed URL from WSGI environment.
"""
environ = self.wsgi_environ
url = environ['wsgi.url_scheme'] + '://'
if environ.get('HTTP_HOST'):
... |
Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor`` | def append(cls, interceptor):
"""
Add interceptor to the end of the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.append(interceptor) |
Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor`` | def insert(cls, index, interceptor):
"""
Add interceptor to the given index in the internal list.
Note: Raises ``ValueError`` if interceptor
does not extend ``OpenTracingInterceptor``
"""
cls._check(interceptor)
cls._interceptors.insert(index, interceptor) |
This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!! | def singleton(func):
"""
This decorator allows you to make sure that a function is called once and
only once. Note that recursive functions will still work.
WARNING: Not thread-safe!!!
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
if wrapper.__call_state__ == CALLED:
... |
A hook to be executed before HTTP request is executed.
It returns a Span object that can be used as a context manager around
the actual HTTP call implementation, or in case of async callback,
it needs its `finish()` method to be called explicitly.
:param request: request must match API defined by Abstr... | def before_http_request(request, current_span_extractor):
"""
A hook to be executed before HTTP request is executed.
It returns a Span object that can be used as a context manager around
the actual HTTP call implementation, or in case of async callback,
it needs its `finish()` method to be called ex... |
Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is applied to each dimension, or a vector of length dim(inimage) to specify a unique smoothness for each dimension.... | def smooth_image(image, sigma, sigma_in_physical_coordinates=True, FWHM=False, max_kernel_width=32):
"""
Smooth an image
ANTsR function: `smoothImage`
Arguments
---------
image
Image to smooth
sigma
Smoothing factor. Can be scalar, in which case the same sigma is... |
Estimate an optimal template from an input image_list
ANTsR function: N/A
Arguments
---------
initial_template : ANTsImage
initialization for the template building
image_list : ANTsImages
images from which to estimate template
iterations : integer
number of template b... | def build_template(
initial_template=None,
image_list=None,
iterations = 3,
gradient_step = 0.2,
**kwargs ):
"""
Estimate an optimal template from an input image_list
ANTsR function: N/A
Arguments
---------
initial_template : ANTsImage
initialization for the templat... |
X : ANTsImage | string | list of ANTsImage types | list of strings
images to register to fixed image
y : string | list of strings
labels for images | def fit(self, X, y=None):
"""
X : ANTsImage | string | list of ANTsImage types | list of strings
images to register to fixed image
y : string | list of strings
labels for images
"""
moving_images = X if isinstance(X, (list,tuple)) else [X]
moving_... |
A multiple atlas voting scheme to customize labels for a new subject.
This function will also perform intensity fusion. It almost directly
calls the C++ in the ANTs executable so is much faster than other
variants in ANTsR.
One may want to normalize image intensities for each input image before
pas... | def joint_label_fusion(target_image, target_image_mask, atlas_list, beta=4, rad=2,
label_list=None, rho=0.01, usecor=False, r_search=3,
nonnegative=False, verbose=False):
"""
A multiple atlas voting scheme to customize labels for a new subject.
This function w... |
Create a tiled mosaic of 2D slice images from a 3D ANTsImage.
ANTsR function : N/A
ANTs function : `createTiledMosaic`
Arguments
---------
image : ANTsImage
base image to visualize
rgb : ANTsImage
optional overlay image to display on top of base image
mask : ANTsImag... | def create_tiled_mosaic(image, rgb=None, mask=None, overlay=None,
output=None, alpha=1., direction=0,
pad_or_crop=None, slices=None,
flip_slice=None, permute_axes=False):
"""
Create a tiled mosaic of 2D slice images from a 3D ANTsImage.
... |
Impute missing values on a numpy ndarray in a column-wise manner.
ANTsR function: `antsrimpute`
Arguments
---------
data : numpy.ndarray
data to impute
method : string or float
type of imputation method to use
Options:
mean
median
co... | def impute(data, method='mean', value=None, nan_value=np.nan):
"""
Impute missing values on a numpy ndarray in a column-wise manner.
ANTsR function: `antsrimpute`
Arguments
---------
data : numpy.ndarray
data to impute
method : string or float
type of imputation method... |
Resample image by spacing or number of voxels with
various interpolators. Works with multi-channel images.
ANTsR function: `resampleImage`
Arguments
---------
image : ANTsImage
input image
resample_params : tuple/list
vector of size dimension with numeric values
... | def resample_image(image, resample_params, use_voxels=False, interp_type=1):
"""
Resample image by spacing or number of voxels with
various interpolators. Works with multi-channel images.
ANTsR function: `resampleImage`
Arguments
---------
image : ANTsImage
input image
re... |
Resample image by using another image as target reference.
This function uses ants.apply_transform with an identity matrix
to achieve proper resampling.
ANTsR function: `resampleImageToTarget`
Arguments
---------
image : ANTsImage
image to resample
target : ANTsImage
... | def resample_image_to_target(image, target, interp_type='linear', imagetype=0, verbose=False, **kwargs):
"""
Resample image by using another image as target reference.
This function uses ants.apply_transform with an identity matrix
to achieve proper resampling.
ANTsR function: `resampleImageT... |
Apply ANTsTransform to data
ANTsR function: `applyAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to apply to image
data : ndarray/list/tuple
data to which transform will be applied
data_type : string
type of data
Options :
... | def apply_ants_transform(transform, data, data_type="point", reference=None, **kwargs):
"""
Apply ANTsTransform to data
ANTsR function: `applyAntsrTransform`
Arguments
---------
transform : ANTsTransform
transform to apply to image
data : ndarray/list/tuple
data to which t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.