intern.remote.boss.remote module
Copyright 2016 The Johns Hopkins University Applied Physics Laboratory
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
# Copyright 2016 The Johns Hopkins University Applied Physics Laboratory
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
from intern.remote import Remote
from intern.resource.boss.resource import *
from intern.service.boss.project import ProjectService
from intern.service.boss.metadata import MetadataService
from intern.service.boss.volume import VolumeService
CONFIG_PROJECT_SECTION = 'Project Service'
CONFIG_METADATA_SECTION = 'Metadata Service'
CONFIG_VOLUME_SECTION = 'Volume Service'
CONFIG_PROTOCOL = 'protocol'
# CONFIG_HOST example: api.theboss.io
CONFIG_HOST = 'host'
CONFIG_TOKEN = 'token'
LATEST_VERSION = 'v1'
class BossRemote(Remote):
"""
Remote provides an SDK to the Boss API.
Attributes:
_token_project (string): Django Framework token for auth to the
project service.
_token_metadata (string): Django Framework token for auth to the
metadata service.
_token_volume (string): Django Framework token for auth to the
volume service.
"""
def __init__(self, cfg_file_or_dict=None, version=None):
"""
Constructor.
If not config arguments are passed in, ~/.intern/intern.cfg is read by
default. Config data is in INI format. If both cfg_file and cfg_str
are passed in, the value in cfg_str is used.
Args:
version (optional[string]): Version of Boss API to use.
cfg_file_or_dict (optional[string|dict]): Path to config file in
INI format or a dict of config parameters.
Raises:
(FileNotFoundError): if can't load given config file.
(KeyError): if given invalid version.
"""
Remote.__init__(self, cfg_file_or_dict)
if version is None:
version = LATEST_VERSION
# Init the services
self._init_project_service(version)
self._init_metadata_service(version)
self._init_volume_service(version)
def _init_project_service(self, version):
"""
Method to initialize the Project Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
project_cfg = self._load_config_section(CONFIG_PROJECT_SECTION)
self._token_project = project_cfg[CONFIG_TOKEN]
proto = project_cfg[CONFIG_PROTOCOL]
host = project_cfg[CONFIG_HOST]
self._project = ProjectService(host, version)
self._project.base_protocol = proto
self._project.set_auth(self._token_project)
def _init_metadata_service(self, version):
"""
Method to initialize the Metadata Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
metadata_cfg = self._load_config_section(CONFIG_METADATA_SECTION)
self._token_metadata = metadata_cfg[CONFIG_TOKEN]
proto = metadata_cfg[CONFIG_PROTOCOL]
host = metadata_cfg[CONFIG_HOST]
self._metadata = MetadataService(host, version)
self._metadata.base_protocol = proto
self._metadata.set_auth(self._token_metadata)
def _init_volume_service(self, version):
"""
Method to initialize the Volume Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
volume_cfg = self._load_config_section(CONFIG_VOLUME_SECTION)
self._token_volume = volume_cfg[CONFIG_TOKEN]
proto = volume_cfg[CONFIG_PROTOCOL]
host = volume_cfg[CONFIG_HOST]
self._volume = VolumeService(host, version)
self._volume.base_protocol = proto
self._volume.set_auth(self._token_volume)
def _load_config_section(self, section_name):
"""
Method to load the specific Service section from the config file if it
exists, or fall back to the default
Args:
section_name (str): The desired service section name
Returns:
(dict): the section parameters
"""
if self._config.has_section(section_name):
# Load specific section
section = dict(self._config.items(section_name))
elif self._config.has_section("Default"):
# Load Default section
section = dict(self._config.items("Default"))
else:
raise KeyError((
"'{}' was not found in the configuration file and no default " +
"configuration was provided."
).format(section_name))
# Make sure section is valid
if "protocol" in section and "host" in section and "token" in section:
return section
else:
raise KeyError(
"Missing values in configuration data. " +
"Must contain: protocol, host, token"
)
@property
def token_project(self):
"""
Returns the current token
"""
return self._token_project
@token_project.setter
def token_project(self, value):
self._token_project = value
self.project_service.set_auth(self._token_project)
@property
def token_metadata(self):
"""
Returns metadata for the current token
"""
return self._token_metadata
@token_metadata.setter
def token_metadata(self, value):
self._token_metadata = value
self.metadata_service.set_auth(self._token_metadata)
@property
def token_volume(self):
"""
Get the current token volume
"""
return self._token_volume
@token_volume.setter
def token_volume(self, value):
self._token_volume = value
self.volume_service.set_auth(self._token_volume)
def list_groups(self, filtr=None):
"""
Get the groups the logged in user is a member of.
Optionally filter by 'member' or 'maintainer'.
Args:
filtr (optional[string|None]): ['member'|'maintainer']
Returns:
(list[string]): List of group names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_groups(filtr)
def get_group(self, name, user_name=None):
"""
Get information on the given group or whether or not a user is a member
of the group.
Args:
name (string): Name of group to query.
user_name (optional[string]): Supply None if not interested in
determining if user is a member of the given group.
Returns:
(mixed): Dictionary if getting group information or bool if a user
name is supplied.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_group(name, user_name)
def create_group(self, name):
"""
Create a new group.
Args:
name (string): Name of the group to create.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create_group(name)
def delete_group(self, name):
"""
Delete given group.
Args:
name (string): Name of group.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.delete_group(name)
def list_group_members(self, name):
"""
Get the members of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of member names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_members(name)
def add_group_member(self, grp_name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_member(grp_name, user)
def delete_group_member(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to delete from the group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_member(grp_name, user)
def get_is_group_member(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Note that a group maintainer is not considered a member unless the
user is also explicitly added as a member.
Args:
name (string): Name of group.
user_name (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_member(grp_name, user)
def list_group_maintainers(self, name):
"""
Get the maintainers of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of maintainer names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_maintainers(name)
def add_group_maintainer(self, name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_maintainer(name, user)
def delete_group_maintainer(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_maintainer(grp_name, user)
def get_is_group_maintainer(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Args:
name (string): Name of group.
user (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_maintainer(grp_name, user)
def list_permissions(self, group_name=None, resource=None):
"""
List permission sets associated filtering by group and/or resource.
Args:
group_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_permissions(group_name, resource)
def get_permissions(self, grp_name, resource):
"""
Get permissions associated the group has with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_permissions(grp_name, resource)
def add_permissions(self, grp_name, resource, permissions):
"""
Add additional permissions for the group associated with the resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_permissions(grp_name, resource, permissions)
def update_permissions(self, grp_name, resource, permissions):
"""
Update permissions for the group associated with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.update_permissions(grp_name, resource, permissions)
def delete_permissions(self, grp_name, resource):
"""
Removes permissions from the group for the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_permissions(grp_name, resource)
def get_user_roles(self, user):
"""
Get roles associated with the given user.
Args:
user (string): User name.
Returns:
(list): List of roles that user has.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_roles(user)
def add_user_role(self, user, role):
"""
Add role to given user.
Args:
user (string): User name.
role (string): Role to assign.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user_role(user, role)
def delete_user_role(self, user, role):
"""
Remove role from given user.
Args:
user (string): User name.
role (string): Role to remove.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user_role(user, role)
def get_user(self, user):
"""
Get user's data (first and last name, email, etc).
Args:
user (string): User name.
Returns:
(dictionary): User's data encoded in a dictionary.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user(user)
def get_user_groups(self, user):
"""
Get user's group memberships.
Args:
user (string): User name.
Returns:
(list): User's groups.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_groups(user)
def add_user(
self, user,
first_name=None, last_name=None,
email=None, password=None
):
"""
Add a new user.
Args:
user (string): User name.
first_name (optional[string]): User's first name. Defaults to None.
last_name (optional[string]): User's last name. Defaults to None.
email: (optional[string]): User's email address. Defaults to None.
password: (optional[string]): User's password. Defaults to None.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user(
user, first_name, last_name, email, password)
def delete_user(self, user):
"""
Delete the given user.
Args:
user (string): User name.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user(user)
def _list_resource(self, resource):
"""
List all instances of the given resource type.
Use the specific list_() methods instead:
list_collections()
list_experiments()
list_channels()
list_coordinate_frames()
Args:
resource (intern.resource.boss.BossResource): resource.name may be
an empty string.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return super(BossRemote, self).list_project(resource=resource)
def list_collections(self):
"""
List all collections.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
coll = CollectionResource(name='')
return self._list_resource(coll)
def list_experiments(self, collection_name):
"""
List all experiments that belong to a collection.
Args:
collection_name (string): Name of the parent collection.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
exp = ExperimentResource(
name='', collection_name=collection_name, coord_frame='foo')
return self._list_resource(exp)
def list_channels(self, collection_name, experiment_name):
"""
List all channels belonging to the named experiment that is part
of the named collection.
Args:
collection_name (string): Name of the parent collection.
experiment_name (string): Name of the parent experiment.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
dont_care = 'image'
chan = ChannelResource(
name='', collection_name=collection_name,
experiment_name=experiment_name, type=dont_care)
return self._list_resource(chan)
def list_coordinate_frames(self):
"""
List all coordinate_frames.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
cf = CoordinateFrameResource(name='')
return self._list_resource(cf)
def create_project(self, resource):
"""
Create the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create(resource)
def get_project(self, resource):
"""
Get attributes of the data model object named by the given resource.
Args:
resource (intern.resource.boss.BossResource): resource.name as well
as any parents must be identified to succeed.
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get(resource)
def update_project(self, resource_name, resource):
"""
Updates an entity in the data model using the given resource.
Args:
resource_name (string): Current name of the resource (in case the
resource is getting its name changed).
resource (intern.resource.boss.BossResource): New attributes for
the resource.
Returns:
(intern.resource.boss.BossResource): Returns updated resource of
given type on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.update(resource_name, resource)
def delete_project(self, resource):
"""
Deletes the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Raises:
requests.HTTPError on a failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete(resource)
def list_metadata(self, resource):
"""
List all keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(list)
Raises:
requests.HTTPError on a failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.list(resource)
def create_metadata(self, resource, keys_vals):
"""
Associates new key-value pairs with the given resource.
Will attempt to add all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to assign to
given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.create(resource, keys_vals)
def get_metadata(self, resource, keys):
"""
Gets the values for given keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Returns:
(dictionary)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.get(resource, keys)
def update_metadata(self, resource, keys_vals):
"""
Updates key-value pairs with the given resource.
Will attempt to update all key-value pairs even if some fail.
Keys must already exist.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to update on
the given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.update(resource, keys_vals)
def delete_metadata(self, resource, keys):
"""
Deletes the given key-value pairs associated with the given resource.
Will attempt to delete all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.delete(resource, keys)
Module variables
var CONFIG_HOST
var CONFIG_METADATA_SECTION
var CONFIG_PROJECT_SECTION
var CONFIG_PROTOCOL
var CONFIG_TOKEN
var CONFIG_VOLUME_SECTION
var LATEST_VERSION
Classes
class BossRemote
Remote provides an SDK to the Boss API.
Attributes:
_token_project (string): Django Framework token for auth to the
project service.
_token_metadata (string): Django Framework token for auth to the
metadata service.
_token_volume (string): Django Framework token for auth to the
volume service.
class BossRemote(Remote):
"""
Remote provides an SDK to the Boss API.
Attributes:
_token_project (string): Django Framework token for auth to the
project service.
_token_metadata (string): Django Framework token for auth to the
metadata service.
_token_volume (string): Django Framework token for auth to the
volume service.
"""
def __init__(self, cfg_file_or_dict=None, version=None):
"""
Constructor.
If not config arguments are passed in, ~/.intern/intern.cfg is read by
default. Config data is in INI format. If both cfg_file and cfg_str
are passed in, the value in cfg_str is used.
Args:
version (optional[string]): Version of Boss API to use.
cfg_file_or_dict (optional[string|dict]): Path to config file in
INI format or a dict of config parameters.
Raises:
(FileNotFoundError): if can't load given config file.
(KeyError): if given invalid version.
"""
Remote.__init__(self, cfg_file_or_dict)
if version is None:
version = LATEST_VERSION
# Init the services
self._init_project_service(version)
self._init_metadata_service(version)
self._init_volume_service(version)
def _init_project_service(self, version):
"""
Method to initialize the Project Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
project_cfg = self._load_config_section(CONFIG_PROJECT_SECTION)
self._token_project = project_cfg[CONFIG_TOKEN]
proto = project_cfg[CONFIG_PROTOCOL]
host = project_cfg[CONFIG_HOST]
self._project = ProjectService(host, version)
self._project.base_protocol = proto
self._project.set_auth(self._token_project)
def _init_metadata_service(self, version):
"""
Method to initialize the Metadata Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
metadata_cfg = self._load_config_section(CONFIG_METADATA_SECTION)
self._token_metadata = metadata_cfg[CONFIG_TOKEN]
proto = metadata_cfg[CONFIG_PROTOCOL]
host = metadata_cfg[CONFIG_HOST]
self._metadata = MetadataService(host, version)
self._metadata.base_protocol = proto
self._metadata.set_auth(self._token_metadata)
def _init_volume_service(self, version):
"""
Method to initialize the Volume Service from the config data
Args:
version (string): Version of Boss API to use.
Returns:
None
Raises:
(KeyError): if given invalid version.
"""
volume_cfg = self._load_config_section(CONFIG_VOLUME_SECTION)
self._token_volume = volume_cfg[CONFIG_TOKEN]
proto = volume_cfg[CONFIG_PROTOCOL]
host = volume_cfg[CONFIG_HOST]
self._volume = VolumeService(host, version)
self._volume.base_protocol = proto
self._volume.set_auth(self._token_volume)
def _load_config_section(self, section_name):
"""
Method to load the specific Service section from the config file if it
exists, or fall back to the default
Args:
section_name (str): The desired service section name
Returns:
(dict): the section parameters
"""
if self._config.has_section(section_name):
# Load specific section
section = dict(self._config.items(section_name))
elif self._config.has_section("Default"):
# Load Default section
section = dict(self._config.items("Default"))
else:
raise KeyError((
"'{}' was not found in the configuration file and no default " +
"configuration was provided."
).format(section_name))
# Make sure section is valid
if "protocol" in section and "host" in section and "token" in section:
return section
else:
raise KeyError(
"Missing values in configuration data. " +
"Must contain: protocol, host, token"
)
@property
def token_project(self):
"""
Returns the current token
"""
return self._token_project
@token_project.setter
def token_project(self, value):
self._token_project = value
self.project_service.set_auth(self._token_project)
@property
def token_metadata(self):
"""
Returns metadata for the current token
"""
return self._token_metadata
@token_metadata.setter
def token_metadata(self, value):
self._token_metadata = value
self.metadata_service.set_auth(self._token_metadata)
@property
def token_volume(self):
"""
Get the current token volume
"""
return self._token_volume
@token_volume.setter
def token_volume(self, value):
self._token_volume = value
self.volume_service.set_auth(self._token_volume)
def list_groups(self, filtr=None):
"""
Get the groups the logged in user is a member of.
Optionally filter by 'member' or 'maintainer'.
Args:
filtr (optional[string|None]): ['member'|'maintainer']
Returns:
(list[string]): List of group names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_groups(filtr)
def get_group(self, name, user_name=None):
"""
Get information on the given group or whether or not a user is a member
of the group.
Args:
name (string): Name of group to query.
user_name (optional[string]): Supply None if not interested in
determining if user is a member of the given group.
Returns:
(mixed): Dictionary if getting group information or bool if a user
name is supplied.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_group(name, user_name)
def create_group(self, name):
"""
Create a new group.
Args:
name (string): Name of the group to create.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create_group(name)
def delete_group(self, name):
"""
Delete given group.
Args:
name (string): Name of group.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.delete_group(name)
def list_group_members(self, name):
"""
Get the members of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of member names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_members(name)
def add_group_member(self, grp_name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_member(grp_name, user)
def delete_group_member(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to delete from the group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_member(grp_name, user)
def get_is_group_member(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Note that a group maintainer is not considered a member unless the
user is also explicitly added as a member.
Args:
name (string): Name of group.
user_name (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_member(grp_name, user)
def list_group_maintainers(self, name):
"""
Get the maintainers of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of maintainer names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_maintainers(name)
def add_group_maintainer(self, name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_maintainer(name, user)
def delete_group_maintainer(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_maintainer(grp_name, user)
def get_is_group_maintainer(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Args:
name (string): Name of group.
user (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_maintainer(grp_name, user)
def list_permissions(self, group_name=None, resource=None):
"""
List permission sets associated filtering by group and/or resource.
Args:
group_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_permissions(group_name, resource)
def get_permissions(self, grp_name, resource):
"""
Get permissions associated the group has with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_permissions(grp_name, resource)
def add_permissions(self, grp_name, resource, permissions):
"""
Add additional permissions for the group associated with the resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_permissions(grp_name, resource, permissions)
def update_permissions(self, grp_name, resource, permissions):
"""
Update permissions for the group associated with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.update_permissions(grp_name, resource, permissions)
def delete_permissions(self, grp_name, resource):
"""
Removes permissions from the group for the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_permissions(grp_name, resource)
def get_user_roles(self, user):
"""
Get roles associated with the given user.
Args:
user (string): User name.
Returns:
(list): List of roles that user has.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_roles(user)
def add_user_role(self, user, role):
"""
Add role to given user.
Args:
user (string): User name.
role (string): Role to assign.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user_role(user, role)
def delete_user_role(self, user, role):
"""
Remove role from given user.
Args:
user (string): User name.
role (string): Role to remove.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user_role(user, role)
def get_user(self, user):
"""
Get user's data (first and last name, email, etc).
Args:
user (string): User name.
Returns:
(dictionary): User's data encoded in a dictionary.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user(user)
def get_user_groups(self, user):
"""
Get user's group memberships.
Args:
user (string): User name.
Returns:
(list): User's groups.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_groups(user)
def add_user(
self, user,
first_name=None, last_name=None,
email=None, password=None
):
"""
Add a new user.
Args:
user (string): User name.
first_name (optional[string]): User's first name. Defaults to None.
last_name (optional[string]): User's last name. Defaults to None.
email: (optional[string]): User's email address. Defaults to None.
password: (optional[string]): User's password. Defaults to None.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user(
user, first_name, last_name, email, password)
def delete_user(self, user):
"""
Delete the given user.
Args:
user (string): User name.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user(user)
def _list_resource(self, resource):
"""
List all instances of the given resource type.
Use the specific list_() methods instead:
list_collections()
list_experiments()
list_channels()
list_coordinate_frames()
Args:
resource (intern.resource.boss.BossResource): resource.name may be
an empty string.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return super(BossRemote, self).list_project(resource=resource)
def list_collections(self):
"""
List all collections.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
coll = CollectionResource(name='')
return self._list_resource(coll)
def list_experiments(self, collection_name):
"""
List all experiments that belong to a collection.
Args:
collection_name (string): Name of the parent collection.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
exp = ExperimentResource(
name='', collection_name=collection_name, coord_frame='foo')
return self._list_resource(exp)
def list_channels(self, collection_name, experiment_name):
"""
List all channels belonging to the named experiment that is part
of the named collection.
Args:
collection_name (string): Name of the parent collection.
experiment_name (string): Name of the parent experiment.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
dont_care = 'image'
chan = ChannelResource(
name='', collection_name=collection_name,
experiment_name=experiment_name, type=dont_care)
return self._list_resource(chan)
def list_coordinate_frames(self):
"""
List all coordinate_frames.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
cf = CoordinateFrameResource(name='')
return self._list_resource(cf)
def create_project(self, resource):
"""
Create the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create(resource)
def get_project(self, resource):
"""
Get attributes of the data model object named by the given resource.
Args:
resource (intern.resource.boss.BossResource): resource.name as well
as any parents must be identified to succeed.
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get(resource)
def update_project(self, resource_name, resource):
"""
Updates an entity in the data model using the given resource.
Args:
resource_name (string): Current name of the resource (in case the
resource is getting its name changed).
resource (intern.resource.boss.BossResource): New attributes for
the resource.
Returns:
(intern.resource.boss.BossResource): Returns updated resource of
given type on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.update(resource_name, resource)
def delete_project(self, resource):
"""
Deletes the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Raises:
requests.HTTPError on a failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete(resource)
def list_metadata(self, resource):
"""
List all keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(list)
Raises:
requests.HTTPError on a failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.list(resource)
def create_metadata(self, resource, keys_vals):
"""
Associates new key-value pairs with the given resource.
Will attempt to add all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to assign to
given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.create(resource, keys_vals)
def get_metadata(self, resource, keys):
"""
Gets the values for given keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Returns:
(dictionary)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.get(resource, keys)
def update_metadata(self, resource, keys_vals):
"""
Updates key-value pairs with the given resource.
Will attempt to update all key-value pairs even if some fail.
Keys must already exist.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to update on
the given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.update(resource, keys_vals)
def delete_metadata(self, resource, keys):
"""
Deletes the given key-value pairs associated with the given resource.
Will attempt to delete all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.delete(resource, keys)
Ancestors (in MRO)
- BossRemote
- intern.remote.remote.Remote
- __builtin__.object
Instance variables
var metadata_service
var object_service
var project_service
var token_metadata
Returns metadata for the current token
var token_project
Returns the current token
var token_volume
Get the current token volume
var volume_service
Methods
def __init__(
self, cfg_file_or_dict=None, version=None)
Constructor.
If not config arguments are passed in, ~/.intern/intern.cfg is read by
default. Config data is in INI format. If both cfg_file and cfg_str
are passed in, the value in cfg_str is used.
Args:
version (optional[string]): Version of Boss API to use.
cfg_file_or_dict (optional[string|dict]): Path to config file in
INI format or a dict of config parameters.
Raises
(FileNotFoundError): if can't load given config file.
(KeyError): if given invalid version.
def __init__(self, cfg_file_or_dict=None, version=None):
"""
Constructor.
If not config arguments are passed in, ~/.intern/intern.cfg is read by
default. Config data is in INI format. If both cfg_file and cfg_str
are passed in, the value in cfg_str is used.
Args:
version (optional[string]): Version of Boss API to use.
cfg_file_or_dict (optional[string|dict]): Path to config file in
INI format or a dict of config parameters.
Raises:
(FileNotFoundError): if can't load given config file.
(KeyError): if given invalid version.
"""
Remote.__init__(self, cfg_file_or_dict)
if version is None:
version = LATEST_VERSION
# Init the services
self._init_project_service(version)
self._init_metadata_service(version)
self._init_volume_service(version)
def add_group_maintainer(
self, name, user)
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises
requests.HTTPError on failure.
def add_group_maintainer(self, name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_maintainer(name, user)
def add_group_member(
self, grp_name, user)
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to add to group.
Raises
requests.HTTPError on failure.
def add_group_member(self, grp_name, user):
"""
Add the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_group_member(grp_name, user)
def add_permissions(
self, grp_name, resource, permissions)
Add additional permissions for the group associated with the resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
permissions (list): List of permissions to add to the given resource
Raises
requests.HTTPError on failure.
def add_permissions(self, grp_name, resource, permissions):
"""
Add additional permissions for the group associated with the resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_permissions(grp_name, resource, permissions)
def add_user(
self, user, first_name=None, last_name=None, email=None, password=None)
Add a new user.
Args:
user (string): User name.
first_name (optional[string]): User's first name. Defaults to None.
last_name (optional[string]): User's last name. Defaults to None.
email: (optional[string]): User's email address. Defaults to None.
password: (optional[string]): User's password. Defaults to None.
Raises
requests.HTTPError on failure.
def add_user(
self, user,
first_name=None, last_name=None,
email=None, password=None
):
"""
Add a new user.
Args:
user (string): User name.
first_name (optional[string]): User's first name. Defaults to None.
last_name (optional[string]): User's last name. Defaults to None.
email: (optional[string]): User's email address. Defaults to None.
password: (optional[string]): User's password. Defaults to None.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user(
user, first_name, last_name, email, password)
def add_user_role(
self, user, role)
Add role to given user.
Args:
user (string): User name.
role (string): Role to assign.
Raises
requests.HTTPError on failure.
def add_user_role(self, user, role):
"""
Add role to given user.
Args:
user (string): User name.
role (string): Role to assign.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.add_user_role(user, role)
def create_cutout(
self, resource, resolution, x_range, y_range, z_range, data, time_range=None)
Upload a cutout to the volume service.
Args:
resource (intern.resource.Resource): Resource compatible with cutout operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
data (object): Type depends on implementation.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40.
Returns
(): Return type depends on volume service's implementation.
Raises
RuntimeError when given invalid resource.
Other exceptions may be raised depending on the volume service's implementation.
def create_cutout(self, resource, resolution, x_range, y_range, z_range, data, time_range=None):
"""Upload a cutout to the volume service.
Args:
resource (intern.resource.Resource): Resource compatible with cutout operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
data (object): Type depends on implementation.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40.
Returns:
(): Return type depends on volume service's implementation.
Raises:
RuntimeError when given invalid resource.
Other exceptions may be raised depending on the volume service's implementation.
"""
if not resource.valid_volume():
raise RuntimeError('Resource incompatible with the volume service.')
return self._volume.create_cutout(
resource, resolution, x_range, y_range, z_range, data, time_range)
def create_group(
self, name)
Create a new group.
Args:
name (string): Name of the group to create.
Returns
(bool): True on success.
Raises
requests.HTTPError on failure.
def create_group(self, name):
"""
Create a new group.
Args:
name (string): Name of the group to create.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create_group(name)
def create_metadata(
self, resource, keys_vals)
Associates new key-value pairs with the given resource.
Will attempt to add all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to assign to
given resource.
Raises
HTTPErrorList on failure.
def create_metadata(self, resource, keys_vals):
"""
Associates new key-value pairs with the given resource.
Will attempt to add all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to assign to
given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.create(resource, keys_vals)
def create_project(
self, resource)
Create the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises
requests.HTTPError on failure.
def create_project(self, resource):
"""
Create the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.create(resource)
def delete_group(
self, name)
Delete given group.
Args:
name (string): Name of group.
Returns
(bool): True on success.
Raises
requests.HTTPError on failure.
def delete_group(self, name):
"""
Delete given group.
Args:
name (string): Name of group.
Returns:
(bool): True on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.delete_group(name)
def delete_group_maintainer(
self, grp_name, user)
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises
requests.HTTPError on failure.
def delete_group_maintainer(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user (string): User to add to group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_maintainer(grp_name, user)
def delete_group_member(
self, grp_name, user)
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to delete from the group.
Raises
requests.HTTPError on failure.
def delete_group_member(self, grp_name, user):
"""
Delete the given user to the named group.
Both group and user must already exist for this to succeed.
Args:
name (string): Name of group.
user_name (string): User to delete from the group.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_group_member(grp_name, user)
def delete_metadata(
self, resource, keys)
Deletes the given key-value pairs associated with the given resource.
Will attempt to delete all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Raises
HTTPErrorList on failure.
def delete_metadata(self, resource, keys):
"""
Deletes the given key-value pairs associated with the given resource.
Will attempt to delete all key-value pairs even if some fail.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.delete(resource, keys)
def delete_permissions(
self, grp_name, resource)
Removes permissions from the group for the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Raises
requests.HTTPError on failure.
def delete_permissions(self, grp_name, resource):
"""
Removes permissions from the group for the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_permissions(grp_name, resource)
def delete_project(
self, resource)
Deletes the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Raises
requests.HTTPError on a failure.
def delete_project(self, resource):
"""
Deletes the entity described by the given resource.
Args:
resource (intern.resource.boss.BossResource)
Raises:
requests.HTTPError on a failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete(resource)
def delete_user(
self, user)
Delete the given user.
Args:
user (string): User name.
Raises
requests.HTTPError on failure.
def delete_user(self, user):
"""
Delete the given user.
Args:
user (string): User name.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user(user)
def delete_user_role(
self, user, role)
Remove role from given user.
Args:
user (string): User name.
role (string): Role to remove.
Raises
requests.HTTPError on failure.
def delete_user_role(self, user, role):
"""
Remove role from given user.
Args:
user (string): User name.
role (string): Role to remove.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.delete_user_role(user, role)
def get_bounding_box(
self, resource, resolution, id, bb_type='loose')
Get bounding box containing object specified by id.
Currently only supports 'loose' bounding boxes. The bounding box
returned is cuboid aligned.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
resolution (int): 0 indicates native resolution.
id (int): Id of object of interest.
bb_type (optional[string]): Defaults to 'loose'.
Returns
(dict): {'x_range': [0, 10], 'y_range': [0, 10], 'z_range': [0, 10], 't_range': [0, 10]}
def get_bounding_box(self, resource, resolution, id, bb_type='loose'):
"""Get bounding box containing object specified by id.
Currently only supports 'loose' bounding boxes. The bounding box
returned is cuboid aligned.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
resolution (int): 0 indicates native resolution.
id (int): Id of object of interest.
bb_type (optional[string]): Defaults to 'loose'.
Returns:
(dict): {'x_range': [0, 10], 'y_range': [0, 10], 'z_range': [0, 10], 't_range': [0, 10]}
"""
if not resource.valid_volume():
raise RuntimeError('Resource incompatible with the volume service.')
if bb_type != 'loose' and bb_type != 'tight':
raise RuntimeError("bb_type must be either 'loose' or 'tight'.")
return self._volume.get_bounding_box(resource, resolution, id, bb_type)
def get_cutout(
self, resource, resolution, x_range, y_range, z_range, time_range=None, id_list=[])
Get a cutout from the volume service.
Args:
resource (intern.resource.Resource): Resource compatible with cutout operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40.
id_list (optional [list]): list of object ids to filter the cutout by.
Returns
(): Return type depends on volume service's implementation.
Raises
RuntimeError when given invalid resource.
Other exceptions may be raised depending on the volume service's implementation.
def get_cutout(self, resource, resolution, x_range, y_range, z_range, time_range=None, id_list=[]):
"""Get a cutout from the volume service.
Args:
resource (intern.resource.Resource): Resource compatible with cutout operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40.
id_list (optional [list]): list of object ids to filter the cutout by.
Returns:
(): Return type depends on volume service's implementation.
Raises:
RuntimeError when given invalid resource.
Other exceptions may be raised depending on the volume service's implementation.
"""
if not resource.valid_volume():
raise RuntimeError('Resource incompatible with the volume service.')
return self._volume.get_cutout(
resource, resolution, x_range, y_range, z_range, time_range, id_list)
def get_group(
self, name, user_name=None)
Get information on the given group or whether or not a user is a member
of the group.
Args:
name (string): Name of group to query.
user_name (optional[string]): Supply None if not interested in
determining if user is a member of the given group.
Returns
(mixed): Dictionary if getting group information or bool if a user
name is supplied.
Raises
requests.HTTPError on failure.
def get_group(self, name, user_name=None):
"""
Get information on the given group or whether or not a user is a member
of the group.
Args:
name (string): Name of group to query.
user_name (optional[string]): Supply None if not interested in
determining if user is a member of the given group.
Returns:
(mixed): Dictionary if getting group information or bool if a user
name is supplied.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_group(name, user_name)
def get_ids_in_region(
self, resource, resolution, x_range, y_range, z_range, time_range=[0, 1])
Get all ids in the region defined by x_range, y_range, z_range.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40. Defaults to [0, 1].
Returns
(list[int]): Example: [1, 2, 25].
Raises
requests.HTTPError
TypeError: if resource is not an annotation channel.
def get_ids_in_region(
self, resource, resolution,
x_range, y_range, z_range, time_range=[0, 1]):
"""Get all ids in the region defined by x_range, y_range, z_range.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
resolution (int): 0 indicates native resolution.
x_range (list[int]): x range such as [10, 20] which means x>=10 and x<20.
y_range (list[int]): y range such as [10, 20] which means y>=10 and y<20.
z_range (list[int]): z range such as [10, 20] which means z>=10 and z<20.
time_range (optional [list[int]]): time range such as [30, 40] which means t>=30 and t<40. Defaults to [0, 1].
Returns:
(list[int]): Example: [1, 2, 25].
Raises:
requests.HTTPError
TypeError: if resource is not an annotation channel.
"""
return self._volume.get_ids_in_region(
resource, resolution, x_range, y_range, z_range, time_range)
def get_is_group_maintainer(
self, grp_name, user)
Check if the given user is a member of the named group.
Args:
name (string): Name of group.
user (string): User of interest.
Returns
(bool): False if user not a member.
def get_is_group_maintainer(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Args:
name (string): Name of group.
user (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_maintainer(grp_name, user)
def get_is_group_member(
self, grp_name, user)
Check if the given user is a member of the named group.
Note that a group maintainer is not considered a member unless the
user is also explicitly added as a member.
Args:
name (string): Name of group.
user_name (string): User of interest.
Returns
(bool): False if user not a member.
def get_is_group_member(self, grp_name, user):
"""
Check if the given user is a member of the named group.
Note that a group maintainer is not considered a member unless the
user is also explicitly added as a member.
Args:
name (string): Name of group.
user_name (string): User of interest.
Returns:
(bool): False if user not a member.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_is_group_member(grp_name, user)
def get_metadata(
self, resource, keys)
Gets the values for given keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Returns
(dictionary)
Raises
HTTPErrorList on failure.
def get_metadata(self, resource, keys):
"""
Gets the values for given keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
keys (list)
Returns:
(dictionary)
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.get(resource, keys)
def get_permissions(
self, grp_name, resource)
Get permissions associated the group has with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns
(list): List of permissions.
Raises
requests.HTTPError on failure.
def get_permissions(self, grp_name, resource):
"""
Get permissions associated the group has with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_permissions(grp_name, resource)
def get_project(
self, resource)
Get attributes of the data model object named by the given resource.
Args:
resource (intern.resource.boss.BossResource): resource.name as well
as any parents must be identified to succeed.
Returns
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises
requests.HTTPError on failure.
def get_project(self, resource):
"""
Get attributes of the data model object named by the given resource.
Args:
resource (intern.resource.boss.BossResource): resource.name as well
as any parents must be identified to succeed.
Returns:
(intern.resource.boss.BossResource): Returns resource of type
requested on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get(resource)
def get_user(
self, user)
Get user's data (first and last name, email, etc).
Args:
user (string): User name.
Returns
(dictionary): User's data encoded in a dictionary.
Raises
requests.HTTPError on failure.
def get_user(self, user):
"""
Get user's data (first and last name, email, etc).
Args:
user (string): User name.
Returns:
(dictionary): User's data encoded in a dictionary.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user(user)
def get_user_groups(
self, user)
Get user's group memberships.
Args:
user (string): User name.
Returns
(list): User's groups.
Raises
requests.HTTPError on failure.
def get_user_groups(self, user):
"""
Get user's group memberships.
Args:
user (string): User name.
Returns:
(list): User's groups.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_groups(user)
def get_user_roles(
self, user)
Get roles associated with the given user.
Args:
user (string): User name.
Returns
(list): List of roles that user has.
Raises
requests.HTTPError on failure.
def get_user_roles(self, user):
"""
Get roles associated with the given user.
Args:
user (string): User name.
Returns:
(list): List of roles that user has.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.get_user_roles(user)
def list_channels(
self, collection_name, experiment_name)
List all channels belonging to the named experiment that is part
of the named collection.
Args:
collection_name (string): Name of the parent collection.
experiment_name (string): Name of the parent experiment.
Returns
(list)
Raises
requests.HTTPError on failure.
def list_channels(self, collection_name, experiment_name):
"""
List all channels belonging to the named experiment that is part
of the named collection.
Args:
collection_name (string): Name of the parent collection.
experiment_name (string): Name of the parent experiment.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
dont_care = 'image'
chan = ChannelResource(
name='', collection_name=collection_name,
experiment_name=experiment_name, type=dont_care)
return self._list_resource(chan)
def list_collections(
self)
List all collections.
Returns
(list)
Raises
requests.HTTPError on failure.
def list_collections(self):
"""
List all collections.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
coll = CollectionResource(name='')
return self._list_resource(coll)
def list_coordinate_frames(
self)
List all coordinate_frames.
Returns
(list)
Raises
requests.HTTPError on failure.
def list_coordinate_frames(self):
"""
List all coordinate_frames.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
cf = CoordinateFrameResource(name='')
return self._list_resource(cf)
def list_experiments(
self, collection_name)
List all experiments that belong to a collection.
Args:
collection_name (string): Name of the parent collection.
Returns
(list)
Raises
requests.HTTPError on failure.
def list_experiments(self, collection_name):
"""
List all experiments that belong to a collection.
Args:
collection_name (string): Name of the parent collection.
Returns:
(list)
Raises:
requests.HTTPError on failure.
"""
exp = ExperimentResource(
name='', collection_name=collection_name, coord_frame='foo')
return self._list_resource(exp)
def list_group_maintainers(
self, name)
Get the maintainers of a group.
Args:
name (string): Name of group to query.
Returns
(list[string]): List of maintainer names.
Raises
requests.HTTPError on failure.
def list_group_maintainers(self, name):
"""
Get the maintainers of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of maintainer names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_maintainers(name)
def list_group_members(
self, name)
Get the members of a group.
Args:
name (string): Name of group to query.
Returns
(list[string]): List of member names.
Raises
requests.HTTPError on failure.
def list_group_members(self, name):
"""
Get the members of a group.
Args:
name (string): Name of group to query.
Returns:
(list[string]): List of member names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_group_members(name)
def list_groups(
self, filtr=None)
Get the groups the logged in user is a member of.
Optionally filter by 'member' or 'maintainer'.
Args:
filtr (optional[string|None]): ['member'|'maintainer']
Returns
(list[string]): List of group names.
Raises
requests.HTTPError on failure.
def list_groups(self, filtr=None):
"""
Get the groups the logged in user is a member of.
Optionally filter by 'member' or 'maintainer'.
Args:
filtr (optional[string|None]): ['member'|'maintainer']
Returns:
(list[string]): List of group names.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_groups(filtr)
def list_metadata(
self, resource)
List all keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns
(list)
Raises
requests.HTTPError on a failure.
def list_metadata(self, resource):
"""
List all keys associated with the given resource.
Args:
resource (intern.resource.boss.BossResource)
Returns:
(list)
Raises:
requests.HTTPError on a failure.
"""
self.metadata_service.set_auth(self._token_metadata)
return self.metadata_service.list(resource)
def list_permissions(
self, group_name=None, resource=None)
List permission sets associated filtering by group and/or resource.
Args:
group_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns
(list): List of permissions.
Raises
requests.HTTPError on failure.
def list_permissions(self, group_name=None, resource=None):
"""
List permission sets associated filtering by group and/or resource.
Args:
group_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on.
Returns:
(list): List of permissions.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.list_permissions(group_name, resource)
def list_project(
self, **kwargs)
Perform list operation on the project.
What this does is highly dependent on project's data model.
Args:
(**kwargs): Args are implementation dependent.
Returns
(list)
def list_project(self, **kwargs):
"""Perform list operation on the project.
What this does is highly dependent on project's data model.
Args:
(**kwargs): Args are implementation dependent.
Returns:
(list)
"""
return self._project.list(**kwargs)
def load_config_file(
self, config_handle)
Load config data for the Remote.
Args:
config_handle (io.StringIO): Config data encoded in a string.
Returns
(configparser.ConfigParser)
def load_config_file(self, config_handle):
"""Load config data for the Remote.
Args:
config_handle (io.StringIO): Config data encoded in a string.
Returns:
(configparser.ConfigParser)
"""
cfg_parser = configparser.ConfigParser()
cfg_parser.readfp(config_handle)
return cfg_parser
def reserve_ids(
self, resource, num_ids)
Reserve a block of unique, sequential ids for annotations.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
num_ids (int): Number of ids to reserve.
Returns
(int): First id reserved.
def reserve_ids(self, resource, num_ids):
"""Reserve a block of unique, sequential ids for annotations.
Args:
resource (intern.resource.Resource): Resource compatible with annotation operations.
num_ids (int): Number of ids to reserve.
Returns:
(int): First id reserved.
"""
if not resource.valid_volume():
raise RuntimeError('Resource incompatible with the volume service.')
return self._volume.reserve_ids(resource, num_ids)
def update_metadata(
self, resource, keys_vals)
Updates key-value pairs with the given resource.
Will attempt to update all key-value pairs even if some fail.
Keys must already exist.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to update on
the given resource.
Raises
HTTPErrorList on failure.
def update_metadata(self, resource, keys_vals):
"""
Updates key-value pairs with the given resource.
Will attempt to update all key-value pairs even if some fail.
Keys must already exist.
Args:
resource (intern.resource.boss.BossResource)
keys_vals (dictionary): Collection of key-value pairs to update on
the given resource.
Raises:
HTTPErrorList on failure.
"""
self.metadata_service.set_auth(self._token_metadata)
self.metadata_service.update(resource, keys_vals)
def update_permissions(
self, grp_name, resource, permissions)
Update permissions for the group associated with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on
permissions (list): List of permissions to add to the given resource
Raises
requests.HTTPError on failure.
def update_permissions(self, grp_name, resource, permissions):
"""
Update permissions for the group associated with the given resource.
Args:
grp_name (string): Name of group.
resource (intern.resource.boss.Resource): Identifies which data
model object to operate on
permissions (list): List of permissions to add to the given resource
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
self.project_service.update_permissions(grp_name, resource, permissions)
def update_project(
self, resource_name, resource)
Updates an entity in the data model using the given resource.
Args:
resource_name (string): Current name of the resource (in case the
resource is getting its name changed).
resource (intern.resource.boss.BossResource): New attributes for
the resource.
Returns
(intern.resource.boss.BossResource): Returns updated resource of
given type on success.
Raises
requests.HTTPError on failure.
def update_project(self, resource_name, resource):
"""
Updates an entity in the data model using the given resource.
Args:
resource_name (string): Current name of the resource (in case the
resource is getting its name changed).
resource (intern.resource.boss.BossResource): New attributes for
the resource.
Returns:
(intern.resource.boss.BossResource): Returns updated resource of
given type on success.
Raises:
requests.HTTPError on failure.
"""
self.project_service.set_auth(self._token_project)
return self.project_service.update(resource_name, resource)


GeoMesa HBase Quick Start¶
This tutorial is the fastest and easiest way to get started with GeoMesa using HBase. It is a good stepping-stone on the path to the other tutorials, that present increasingly involved examples of how to use GeoMesa.
About this Tutorial¶
In the spirit of keeping things simple, the code in this tutorial only does a few small things:
- Establishes a new (static) SimpleFeatureType
- Prepares the HBase tables to store this type of data
- Creates a few thousand example SimpleFeatures
- Writes these SimpleFeatures to HBase
- Queries for a given geographic rectangle, time range, and attribute filter, writing out the entries in the result set
- Uses GeoServer to visualize the data (optional)
Prerequisites¶
Before you begin, you must have the following installed and configured:
- Java JDK 1.8
- Apache Maven 3.2.2 or later
- a GitHub client
- an HBase 1.3.x instance
- the GeoMesa HBase distributed runtime installed for your HBase instance (see below)
If you do not have an existing HBase instance, you can easily set one up as detailed next.
Setting up HBase in standalone mode (optional)¶
(Skip this section if you have an existing HBase 1.3.x installation.)
Download the HBase 1.3.1 binary distribution from http://www.apache.org/dyn/closer.cgi/hbase/
Follow the chapter in the HBase Manual for running a standalone instance of HBase (https://hbase.apache.org/book.html#quickstart). Note that this will use the local filesystem instead of HDFS, and will spin up its own instances of HBase and Zookeeper.
Installing the GeoMesa Distributed Runtime¶
Follow the instructions under Deploying the GeoMesa HBase Distributed Runtime JAR and Register the Coprocessors to install GeoMesa in your HBase instance.
Download and Build the Tutorial¶
Pick a reasonable directory on your machine, and run:
$ git clone https://github.com/geomesa/geomesa-tutorials.git
$ cd geomesa-tutorials
Warning
Make sure that you download or checkout the version of the tutorials project that corresponds to your GeoMesa version. See About Tutorial Versions for more details.
To ensure that the quick start works with your environment, modify the pom.xml
to set the appropriate versions for HBase, Hadoop, etc.
For ease of use, the project builds a bundled artifact that contains all the required dependencies in a single JAR. To build, run:
$ mvn clean install -pl geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart -am
Running the Tutorial¶
On the command line, run:
$ java -cp geomesa-tutorials-hbase/geomesa-tutorials-hbase-quickstart/target/geomesa-tutorials-hbase-quickstart-$VERSION.jar \
org.geomesa.example.hbase.HBaseQuickStart \
--hbase.zookeepers <zookeepers> \
--hbase.catalog

where you provide the following arguments:
<zookeepers>
the HBase Zookeeper quorum. If you installed HBase in stand-alone mode, this will belocalhost
. Note that for most use cases, it is preferable to put thehbase-site.xml
from your cluster on the GeoMesa classpath instead of specifying Zookeepers.

the name of the destination table that will accept these test records. This table should either not exist or should be empty
Optionally, you can also specify that the quick start should delete its data upon completion. Use the
--cleanup
flag when you run to enable this behavior.
Once run, you should see the following output:
Loading datastore
Creating schema: GLOBALEVENTID:String,Actor1Name:String,Actor1CountryCode:String,Actor2Name:String,Actor2CountryCode:String,EventCode:String,NumMentions:Integer,NumSources:Integer,NumArticles:Integer,ActionGeo_Type:Integer,ActionGeo_FullName:String,ActionGeo_CountryCode:String,dtg:Date,geom:Point:srid=4326
Generating test data
Writing test data
Wrote 2356 features
Running test queries
Running query BBOX(geom, -120.0,30.0,-75.0,55.0) AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
01 719027236=719027236|UNITED STATES|USA|INDUSTRY||012|1|1|1|3|Central Valley, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.682 34.0186)
02 719027005=719027005|UNITED STATES|USA|||172|2|2|2|3|Long Beach, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-118.189 33.767)
03 719026204=719026204|JUDGE||||0214|6|1|6|3|Los Angeles, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-118.244 34.0522)
04 719025745=719025745|KING||||051|4|2|4|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
05 719026858=719026858|UNITED STATES|USA|||010|20|2|20|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
06 719026964=719026964|UNITED STATES|USA|||081|2|2|2|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
07 719026965=719026965|CALIFORNIA|USA|||081|8|1|8|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
08 719025635=719025635|PARIS|FRA|||010|2|1|2|3|Las Vegas, Nevada, United States|US|2018-01-01T00:00:00.000Z|POINT (-115.137 36.175)
09 719026918=719026918|UNITED STATES|USA|||042|20|5|20|3|Las Vegas, Nevada, United States|US|2018-01-01T00:00:00.000Z|POINT (-115.137 36.175)
10 719027141=719027141|ALABAMA|USA|JUDGE||172|8|1|8|2|Nevada, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.122 38.4199)
Returned 669 total features
Running query BBOX(geom, -120.0,30.0,-75.0,55.0) AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
Returning attributes [GLOBALEVENTID, dtg, geom]
01 719027208=719027208|2018-01-01T00:00:00.000Z|POINT (-89.6812 32.7673)
02 719026313=719026313|2018-01-01T00:00:00.000Z|POINT (-84.388 33.749)
03 719026419=719026419|2018-01-01T00:00:00.000Z|POINT (-84.388 33.749)
04 719026316=719026316|2018-01-01T00:00:00.000Z|POINT (-83.6487 32.9866)
05 719027132=719027132|2018-01-01T00:00:00.000Z|POINT (-81.2793 33.4968)
06 719026819=719026819|2018-01-01T00:00:00.000Z|POINT (-81.9296 33.7896)
07 719026952=719026952|2018-01-01T00:00:00.000Z|POINT (-81.9296 33.7896)
08 719026881=719026881|2018-01-01T00:00:00.000Z|POINT (-82.0193 34.146)
09 719026909=719026909|2018-01-01T00:00:00.000Z|POINT (-82.0193 34.146)
10 719026951=719026951|2018-01-01T00:00:00.000Z|POINT (-82.0193 34.146)
Returned 669 total features
Running query EventCode = '051'
01 719024909=719024909|||MELBOURNE|AUS|051|10|1|10|4|Melbourne, Victoria, Australia|AS|2018-01-01T00:00:00.000Z|POINT (144.967 -37.8167)
02 719025178=719025178|AUSTRALIA|AUS|COMMUNITY||051|20|2|20|4|Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
03 719025965=719025965|MIDWIFE||||051|10|1|10|4|Sydney, New South Wales, Australia|AS|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
04 719025509=719025509|COMMUNITY||AUSTRALIA|AUS|051|2|1|2|1|Australia|AS|2018-01-01T00:00:00.000Z|POINT (135 -25)
05 719025742=719025742|KING||||051|22|3|22|3|San Diego, California, United States|US|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
06 719025745=719025745|KING||||051|4|2|4|2|California, United States|US|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
07 719025743=719025743|AUTHORITIES||||051|60|12|60|3|Wichita, Kansas, United States|US|2018-01-01T00:00:00.000Z|POINT (-97.3375 37.6922)
08 719027205=719027205|UNITED STATES|USA|SIOUX||051|4|1|4|3|Sioux City, Iowa, United States|US|2018-01-01T00:00:00.000Z|POINT (-96.4003 42.5)
09 719025111=719025111|||UNITED STATES|USA|051|2|1|2|3|Pickens County, South Carolina, United States|US|2018-01-01T00:00:00.000Z|POINT (-82.7165 34.9168)
10 719026938=719026938|PITTSBURGH|USA|||051|5|1|5|3|York County, Pennsylvania, United States|US|2018-01-01T00:00:00.000Z|POINT (-77 40.1254)
Returned 138 total features
Running query EventCode = '051' AND dtg DURING 2017-12-31T00:00:00+00:00/2018-01-02T00:00:00+00:00
Returning attributes [GLOBALEVENTID, dtg, geom]
01 719024909=719024909|2018-01-01T00:00:00.000Z|POINT (144.967 -37.8167)
02 719025178=719025178|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
03 719025965=719025965|2018-01-01T00:00:00.000Z|POINT (151.217 -33.8833)
04 719025509=719025509|2018-01-01T00:00:00.000Z|POINT (135 -25)
05 719025742=719025742|2018-01-01T00:00:00.000Z|POINT (-117.157 32.7153)
06 719025745=719025745|2018-01-01T00:00:00.000Z|POINT (-119.746 36.17)
07 719025743=719025743|2018-01-01T00:00:00.000Z|POINT (-97.3375 37.6922)
08 719027205=719027205|2018-01-01T00:00:00.000Z|POINT (-96.4003 42.5)
09 719025111=719025111|2018-01-01T00:00:00.000Z|POINT (-82.7165 34.9168)
10 719026938=719026938|2018-01-01T00:00:00.000Z|POINT (-77 40.1254)
Returned 138 total features
Cleaning up test data
Done
Looking at the Code¶
The source code is meant to be accessible for this tutorial. The main logic is contained in
the generic org.geomesa.example.quickstart.GeoMesaQuickStart
in the geomesa-tutorials-common
module,
which is datastore agnostic. Some relevant methods are:
createDataStore
get a datastore instance from the input configurationcreateSchema
create the schema in the datastore, as a pre-requisite to writing datawriteFeatures
use aFeatureWriter
to write features to the datastorequeryFeatures
run several queries against the datastorecleanup
delete the sample data and dispose of the datastore instance
The quickstart uses a small subset of GDELT data. Code for parsing the data into GeoTools SimpleFeatures is
contained in org.geomesa.example.data.GDELTData
:
getSimpleFeatureType
creates theSimpleFeatureType
representing the datagetTestData
parses an embedded TSV file to createSimpleFeature
objectsgetTestQueries
illustrates several different query types, using CQL (GeoTools’ Contextual Query Language)
Visualize Data With GeoServer (optional)¶
You can use GeoServer to access and visualize the data stored in GeoMesa. In order to use GeoServer, download and install version 2.12.x. Then follow the instructions in Installing GeoMesa HBase in GeoServer to enable GeoMesa.
Register the GeoMesa Store with GeoServer¶
Log into GeoServer using your user and password credentials. Click
“Stores” and “Add new Store”. Select the HBase (GeoMesa)
vector data
source, and fill in the required parameters.
Basic store info:
workspace
this is dependent upon your GeoServer installationdata source name
pick a sensible name, such asgeomesa_quick_start
description
this is strictly decorative;GeoMesa quick start
Connection parameters:
- these are the same parameter values that you supplied on the command line when you ran the tutorial; they describe how to connect to the HBase instance where your data reside
Click “Save”, and GeoServer will search your HBase table for any GeoMesa-managed feature types.
Publish the Layer¶
GeoServer should recognize the gdelt-quickstart
feature type, and
should present that as a layer that can be published. Click on the
“Publish” link.
You will be taken to the “Edit Layer” screen. You will need to enter values for the data bounding boxes. In this case, you can click on the link to compute these values from the data.
Click on the “Save” button when you are done.
Take a Look¶
Click on the “Layer Preview” link in the left-hand gutter. If you don’t
see the quick-start layer on the first page of results, enter the name
of the layer you just created into the search box, and press
<Enter>
.
Once you see your layer, click on the “OpenLayers” link, which will open a new tab. You should see a collection of red dots similar to the following image:
Tweaking the display¶
Here are just a few simple ways you can play with the visualization:
- Click on one of the red points in the display, and GeoServer will report the detail records underneath the map area.
- Shift-click to highlight a region within the map that you would like to zoom into.
- Click on the “Toggle options toolbar” icon in the upper-left corner
of the preview window. The right-hand side of the screen will include
a “Filter” text box. Enter
EventCode = '051'
, and press on the “play” icon. The display will now show only those points matching your filter criterion. This is a CQL filter, which can be constructed in various ways to query your data. You can find more information about CQL from GeoServer’s CQL tutorial.
Generating Heatmaps¶
- To try out server-side processing, you can install the Heatmap SLD from the Map-Reduce Ingest of GDELT tutorial.
- After configuring the SLD, in the URL, change
styles=
to bestyles=heatmap
. Once you press<Enter>
, the display will change to a density heat-map.
Note
For this to work, you will have to first install the WPS module for GeoServer as described in GeoServer Plugins.


Hello!My name is Ilya.I'm from Russia,Moscow.
I'm beginner at front-end development.
I like creating programmes on C/C++, Java, PHP and JavaScript.
Also I like taking photos and playing computer games,for example,DotA 2.
3d shapes


Guidance
Guidance for providers that have to submit a funding claim for 2016 to 2017.
PDF , 215KB , 12 pages
If you use assistive technology (such as a screen reader) and need a version of this document in a more accessible format, please email<EMAIL_ADDRESS>. Please tell us what format you need. It will help us if you say what assistive technology you use.
Relevant for all providers of education and skills training who need to make a funding claim return for:
Funding claims are submitted through the data collections tab on the Hub and must be completed within a 4 day window.
The 2016 to 2017 mid-year claim form will be available in the HUB from 9am Tuesday 7 February for four days and will close at 4pm Friday 10 February. The form will be pre-populated with provider’s earnings following the R06 data collection return. The provider must then add their forecasts for the remainder of the 2016 to 2017 funding year.
Providers will not be able to complete the claim form after the deadline of 4pm on 10 February.
Published: 24 February 2014
Updated: 2 February 2017


| Recorded Crime Offences (Number) by Garda Station, Type of Offence and Year |
|||||||
|---|---|---|---|---|---|---|---|
| 2011 | 2012 | 2013 | 2014 | 2015 | 2016 | ||
| Donnybrook, D.M.R. South Central Division | 03 ,Attempts/threats to murder, assaults, harassments and related offences | 45 | 41 | 41 | 45 | 58 | 54 |
| 06 ,Robbery, extortion and hijacking offences | 19 | 13 | 21 | 24 | 19 | 10 | |
| 07 ,Burglary and related offences | 280 | 268 | 247 | 294 | 291 | 213 | |
| 08 ,Theft and related offences | 703 | 772 | 755 | 811 | 760 | 660 | |
| See Background Notes |