The AccessLayer

You can import from ./ or with bfly installed.

from bfly import AccessLayer

Or, in scripts in some directories:

# if './bfly/' in sys.path
from CoreLayer import AccessLayer
# if './bfly/CoreLayer/' in sys.path
import AccessLayer

You can from AccessLayer import All QueryLayer.

# if './bfly/CoreLayer' in sys.path
from AccessLayer import QueryLayer, ImageLayer, UtilityLayer

AccessLayer

You can import AccessLayer from bfly and CoreLayer.

AccessLayer classes

class AccessLayer.Websocket(application, request, **kwargs)[source]
class AccessLayer.NDStore(application, request, **kwargs)[source]

Responds to bfly.Webserver._webapp /nd endpoint

inherits

RequestHandler

Methods

get_info(_keywords)[source]

Loads InfoQuery for INPUT.METHODS.META

Returns:made with info from get_config
Return type:InfoQuery
get_slice(_keywords)[source]

Make DataQuery for an image at request path

Parameters:_keywords (dict) – All URL parameters
Returns:Created with the sub_data() for the full request
Return type:DataQuery
get_vol(_keywords)[source]

Make DataQuery for an image at request path

Parameters:_keywords (dict) – All URL parameters
Returns:Created with the sub_data() for the full request
Return type:DataQuery
parse(request)[source]

Extract details from any of the methods Overrides Database.parse()

Parameters:request (str) – The full request
Returns:contains standard details for each request
Return type:QueryLayer.Query
sub_data(_keywords, bounds, resolution, img_fmt='tif')[source]

Make DataQuery for any subregion or request

Parameters:
  • _keywords (dict) – All URL parameters
  • bounds (numpy.ndarray) – The 6x1 array of z,y,x,depth,width,height values for the bounds requested for a data query
  • resolution (int) – the number of halvings along the X and Y axes
Returns:

Return type:

DataQuery

class AccessLayer.API(application, request, **kwargs)[source]

Responds to bfly.Webserver._webapp /api endpoint

inherits

RequestHandler

Methods

get_data(_method)[source]

Make DataQuery for an image at request path

Parameters:_method (str) – The name of the method requesting image information
Returns:Created with the sub_data() for the full request
Return type:DataQuery
get_value(g)[source]

get the name of a group

Parameters:g (dict) – The group from BFLY_CONFIG
Returns:the name of g
Return type:str
parse(request)[source]

Extract details from any of the methods Overrides Database.parse()

Calls _meta_info(), _feature_info(), _get_group(), or _get_data() to return an InfoQuery or DataQuery as a response to the given method

Parameters:request (str) – The single method requested in the URL
Returns:contains standard details for each request
Return type:QueryLayer.Query
sub_data(_method, bounds)[source]

Make DataQuery for any subregion or request

Parameters:
  • _method (str) – The name of the method requesting image information
  • bounds (numpy.ndarray) – The 6x1 array of z,y,x,depth,width,height values for the bounds requested for a data query
Returns:

The OUTPUT.INFO .Path.NAME keyword has the path to data in the requested group from _get_group_dict()

Return type:

DataQuery

class AccessLayer.Precomputed(application, request, **kwargs)[source]

Responds to bfly.Webserver._webapp /nd endpoint

inherits

RequestHandler

Methods

get_info(_keywords)[source]

Loads InfoQuery for INPUT.METHODS.META

Returns:made with info from get_config
Return type:InfoQuery
get_vol(_keywords)[source]

Make DataQuery for an image at request path

Parameters:_keywords (dict) – All URL parameters
Returns:Created with the sub_data() for the full request
Return type:DataQuery
parse(request)[source]

Extract details from any of the methods Overrides Database.parse()

Parameters:request (str) – The full request
Returns:contains standard details for each request
Return type:QueryLayer.Query
sub_data(_keywords, bounds, resolution, img_fmt='tif')[source]

Make DataQuery for any subregion or request

Parameters:
  • _keywords (dict) – All URL parameters
  • bounds (numpy.ndarray) – The 6x1 array of z,y,x,depth,width,height values for the bounds requested for a data query
  • resolution (int) – the number of halvings along the X and Y axes
Returns:

Return type:

DataQuery

class AccessLayer.StaticHandler(application, request, **kwargs)[source]

Returns static files to bfly.Webserver._webapp

Parameters:_root (__name__) – A module in the directory containing the static path
_basic_mime

str – The default mime type for static requests

_root

__name__ – taken from the _root argument

:h:`Methods`
get(*args, **kwargs)[source]

Asynchronously call handle() with _ex

Parameters:path (str) – the static path requested in the URL
handle(filepath)[source]

Serves a path in the ./bfly/static directory

Parameters:path (str) – the actual path to a file on the server
initialize(_root)[source]

Create new handler for static data

parse(path)[source]

Convert the requested path into a real system path

Parameters:path (str) – the static path requested in the URL
Returns:filepath – the actual path to a file on the server
Return type:str

Request Handler base class

class AccessLayer.RequestHandler(application, request, **kwargs)[source]

Responds to requests from bfly.Webserver._webapp

INPUT

INPUT – Static input keywords for all in AccessLayer

RUNTIME

RUNTIME – Static runtime keywords for all in AccessLayer

OUTPUT

OUTPUT – Static output keywords for all in AccessLayer

BFLY_CONFIG

dict – All data from rh-config

_ex

concurrent.futures.ThreadPoolExecutor – Allows handling of parallel requests

_core

CoreLayer.Core – Converts a request into a response

_db

DatabaseLayer.Database – Loads data for INPUT .METHODS.FEATURE

:h:`Methods`
get_query_argument(name, default=<object object>, strip=True)[source]

Returns the value of the argument with the given name from the request query string.

If default is not provided, the argument is considered to be required, and we raise a MissingArgumentError if it is missing.

If the argument appears in the url more than once, we return the last value.

The returned value is always unicode.

New in version 3.2.

get(*args, **kwargs)[source]

Asynchronously uses _ex to call handle()

The query is returned from parse() and passed asynchronously to handle().

Parameters:args (list) – args[0] (str) method requested in the URL
handle(_query)[source]

Sends response of _core to _query

Calls Core.get_data() or Core.get_info() based on the type of the query from Query.is_data()

Parameters:_query (Query) – The details formatted by parse()
handle_static(filepath)[source]

Serves a path in the ./bfly/static directory

Parameters:path (str) – the actual path to a file on the server
initialize(_core, _db, _config, _root='')[source]

Bind Core, database, and configuration

Parameters:
parse(request)[source]

Extract details from any of the methods

Must be overridden by derived classes

Parameters:request (str) – The single method requested in the URL
Returns:contains standard details for each request
Return type:QueryLayer.Query