This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.managers package

Classes that manage resources (models, tools, etc.) by using the current Transaction.

Encapsulates the intersection of trans (or trans.sa_session), models, and Controllers.


  • model operations that involve the trans/sa_session (CRUD)
  • security: ownership, accessibility
  • common aspect-oriented operations via new mixins: sharable, annotatable, tagable, ratable

Not responsible for:

  • encoding/decoding ids
  • any http gobblygook
  • formatting of returned data (always python structures)
  • formatting of raised errors

The goal is to have Controllers only handle:

  • query-string/payload parsing and encoding/decoding ids
  • http
  • return formatting
  • control, improve namespacing in Controllers
  • DRY for Controller ops (define here - use in both UI/API Controllers)

In other words, ‘Business logic’ independent of web transactions/user context (trans) should be pushed into models - but logic that requires the context trans should be placed under this module.


galaxy.managers.annotatable module

Mixins for Annotatable model managers and serializers.

class galaxy.managers.annotatable.AnnotatableManagerMixin[source]

Bases: object

annotation_assoc = None

class of AnnotationAssociation (e.g. HistoryAnnotationAssociation)


Return the annotation string made by the item’s owner or None if there is no annotation.

annotate(item, annotation, user=None, flush=True)[source]

Create a new annotation on item or delete the existing if annotation is None.

class galaxy.managers.annotatable.AnnotatableSerializerMixin[source]

Bases: object

serialize_annotation(item, key, user=None, **context)[source]

Get and serialize an item’s annotation.

class galaxy.managers.annotatable.AnnotatableDeserializerMixin[source]

Bases: object

deserialize_annotation(item, key, val, user=None, **context)[source]

Make sure val is a valid annotation and assign it, deleting any existing if val is None.

class galaxy.managers.annotatable.AnnotatableFilterMixin[source]

Bases: object

filter_annotation_contains(item, val)[source]

Test whether val is in the owner’s annotation.

galaxy.managers.api_keys module

class galaxy.managers.api_keys.ApiKeyManager(app)[source]

Bases: object


galaxy.managers.base module

Keeps the older BaseController security and fetching methods and also defines a base ModelManager, ModelSerializer, and ModelDeserializer.

ModelManagers are used for operations on models that occur outside the scope of a single model object, such as:

  • object creation
  • object lookup
  • interactions between 2+ objects of different model classes

(Since these were to replace model Mixins from web/framework/base/controller.py the rule of thumb used there also generally has been applied here: if it uses the trans or sa_session, put it in a manager and not the model.)

ModelSerializers allow flexible conversion of model objects to dictionaries. They control what keys are sent, how values are simplified, can remap keys, and allow both predefined and user controlled key sets.

ModelDeserializers control how a model validates and process an incoming attribute change to a model object.

galaxy.managers.base.security_check(trans, item, check_ownership=False, check_accessible=False)[source]

Security checks for an item: checks if (a) user owns item or (b) item is accessible to user. This is a generic method for dealing with objects uniformly from the older controller mixin code - however whenever possible the managers for a particular model should be used to perform security checks.


Returns the class object that a string denotes. Without this method, we’d have to do eval(<class_name>).

galaxy.managers.base.decode_id(app, id)[source]
galaxy.managers.base.get_object(trans, id, class_name, check_ownership=False, check_accessible=False, deleted=None)[source]

Convenience method to get a model object with the specified checks. This is a generic method for dealing with objects uniformly from the older controller mixin code - however whenever possible the managers for a particular model should be used to load objects.

galaxy.managers.base.munge_lists(listA, listB)[source]

Combine two lists into a single list.

(While allowing them to be None, non-lists, or lists.)

class galaxy.managers.base.ModelManager(app)[source]

Bases: object

Base class for all model/resource managers.

Provides common queries and CRUD operations as a (hopefully) light layer over the ORM.


alias of __builtin__.object

foreign_key_name = None
query(eagerloads=True, **kwargs)[source]

Return a basic query from model_class, filters, order_by, and limit and offset.

Set eagerloads to False to disable them for this query.


Sends kwargs to build the query and returns one and only one model.

by_id(id, **kwargs)[source]

Gets a model by primary id.

list(filters=None, order_by=None, limit=None, offset=None, **kwargs)[source]

Returns all objects matching the given filters

by_ids(ids, filters=None, **kwargs)[source]

Returns an in-order list of models with the matching ids in ids.

create(flush=True, *args, **kwargs)[source]

Generically create a new model.

copy(item, **kwargs)[source]

Clone or copy an item.

update(item, new_values, flush=True, **kwargs)[source]

Given a dictionary of new values, update item and return it.

..note: NO validation or deserialization occurs here.

associate(associate_with, item, foreign_key_name=None)[source]

Generically associate item with associate_with based on foreign_key_name.

query_associated(associated_model_class, item, foreign_key_name=None)[source]

Generically query other items that have been associated with this item.

class galaxy.managers.base.HasAModelManager(app, manager=None, **kwargs)[source]

Bases: object

Mixin used where serializers, deserializers, filter parsers, etc. need some functionality around the model they’re mainly concerned with and would perform that functionality with a manager.

model_manager_class = None

the class used to create this serializer’s generically accessible model_manager

__init__(app, manager=None, **kwargs)[source]

Return an appropriate manager if it exists, instantiate if not.

exception galaxy.managers.base.ModelSerializingError(err_msg=None, type='info', **extra_error_info)[source]

Bases: galaxy.exceptions.InternalServerError

Thrown when request model values can’t be serialized

exception galaxy.managers.base.ModelDeserializingError(err_msg=None, type='info', **extra_error_info)[source]

Bases: galaxy.exceptions.ObjectAttributeInvalidException

Thrown when an incoming value isn’t usable by the model (bad type, out of range, etc.)

exception galaxy.managers.base.SkipAttribute[source]

Bases: exceptions.Exception

Raise this inside a serializer to prevent the returned dictionary from having a the associated key or value for this attribute.

class galaxy.managers.base.ModelSerializer(app, **kwargs)[source]

Bases: galaxy.managers.base.HasAModelManager

Turns models into JSONable dicts.

Maintains a map of requestable keys and the Callable() serializer functions that should be called for those keys. E.g. { ‘x’ : lambda item, key: item.x, … }

Note: if a key to serialize is not listed in the Serializer.serializable_keyset or serializers, it will not be returned.

To serialize call:
my_serializer = MySerializer( app ) … keys_to_serialize = [ ‘id’, ‘name’, ‘attr1’, ‘attr2’, … ] item_dict = MySerializer.serialize( my_item, keys_to_serialize )
static url_for(*args, **kargs)

‘service’ to use for getting urls - use class var to allow overriding when testing

__init__(app, **kwargs)[source]

Set up serializer map, any additional serializable keys, and views here.


Register a map of attribute keys -> serializing functions that will serialize the attribute.

add_view(view_name, key_list, include_keys_from=None)[source]

Add the list of serializable attributes key_list to the serializer’s view dictionary under the key view_name.

If include_keys_from is a proper view name, extend key_list by the list in that view.

serialize(item, keys, **context)[source]

Serialize the model item to a dictionary.

Given model item and the list keys, create and return a dictionary built from each key in keys that also exists in serializers and values of calling the keyed/named serializers on item.


To be called from inside a serializer to skip it.

Handy for config checks, information hiding, etc.

default_serializer(item, key, **context)[source]

Serialize the item’s attribute named key.

serialize_date(item, key, **context)[source]

Serialize a date attribute of item.

serialize_id(item, key, **context)[source]

Serialize an id attribute of item.

serialize_type_id(item, key, **context)[source]

Serialize an type-id for item.

serialize_to_view(item, view=None, keys=None, default_view=None, **context)[source]

Use a predefined list of keys (the string view) and any additional keys listed in keys.

The combinations can be:
view only: return those keys listed in the named view keys only: return those keys listed no view or keys: use the default_view if any view and keys: combine both into one list of keys
class galaxy.managers.base.ModelDeserializer(app, validator=None, **kwargs)[source]

Bases: galaxy.managers.base.HasAModelManager

An object that converts an incoming serialized dict into values that can be directly assigned to an item’s attributes and assigns them.

__init__(app, validator=None, **kwargs)[source]

Set up deserializers and validator.


Register a map of attribute keys -> functions that will deserialize data into attributes to be assigned to the item.

deserialize(item, data, flush=True, **context)[source]

Convert an incoming serialized dict into values that can be directly assigned to an item’s attributes and assign them

default_deserializer(item, key, val, **context)[source]

If the incoming val is different than the item value change it and, in either case, return the value.

deserialize_basestring(item, key, val, convert_none_to_empty=False, **context)[source]
deserialize_bool(item, key, val, **context)[source]
deserialize_int(item, key, val, min=None, max=None, **context)[source]
deserialize_genome_build(item, key, val, **context)[source]

Make sure val is a valid dbkey and assign it.

class galaxy.managers.base.ModelValidator(app, *args, **kwargs)[source]

Bases: galaxy.managers.base.HasAModelManager

An object that inspects a dictionary (generally meant to be a set of new/updated values for the model) and raises an error if a value is not acceptable.

__init__(app, *args, **kwargs)[source]
type(key, val, types)[source]

Check val against the type (or tuple of types) in types.

Raises:exceptions.RequestParameterInvalidException – if not an instance.
basestring(key, val)[source]
bool(key, val)[source]
int(key, val)[source]
nullable_basestring(key, val)[source]

Must be a basestring or None.

int_range(key, val, min=None, max=None)[source]

Must be a int between min and max.

basestring_list(key, val)[source]

Must be a list of basestrings.

genome_build(key, val)[source]

Must be a valid base_string.

Note: no checking against installation’s ref list is done as many data sources consider this an open field.

class galaxy.managers.base.ModelFilterParser(app, **kwargs)[source]

Bases: galaxy.managers.base.HasAModelManager

Converts string tuples (partially converted query string params) of attr, op, val into either:

  • ORM based filters (filters that can be applied by the ORM at the SQL level) or
  • functional filters (filters that use derived values or values not within the SQL tables)

These filters can then be applied to queries.

This abstraction allows ‘smarter’ application of limit and offset at either the SQL level or the generator/list level based on the presence of functional filters. In other words, if no functional filters are present, limit and offset may be applied at the SQL level. If functional filters are present, limit and offset need to applied at the list level.

These might be safely be replaced in the future by creating SQLAlchemy hybrid properties or more thoroughly mapping derived values.

model_class = None

model class

__init__(app, **kwargs)[source]

Set up serializer map, any additional serializable keys, and views here.

date_string_re = None

regex for testing/dicing iso8601 date strings, with optional time and ms, but allowing only UTC timezone

fn_filter_parsers = None

dictionary containing parsing data for functional filters - applied after a query is made


Parse string 3-tuples (attr, op, val) into orm or functional filters.

parse_filter(attr, op, val)[source]

Attempt to parse filter as a custom/fn filter, then an orm filter, and if neither work - raise an error.

Raises:exceptions.RequestParameterInvalidException – if no functional or orm filter can be parsed.
UNDERSCORED_OPS = ('lt', 'le', 'eq', 'ne', 'ge', 'gt')

these are the easier/shorter string equivalents to the python operator fn names that need ‘__’ around them


Parse a boolean from a string.

parse_id_list(id_list_string, sep=', ')[source]

Split id_list_string at sep.

parse_int_list(int_list_string, sep=', ')[source]

Split int_list_string at sep and parse as ints.


Reformats a string containing either seconds from epoch or an iso8601 formated date string into a new date string usable within a filter query.

Seconds from epoch can be a floating point value as well (i.e containing ms).

galaxy.managers.citations module

class galaxy.managers.citations.CitationsManager(app)[source]

Bases: object

parse_citation(citation_elem, tool_directory)[source]
class galaxy.managers.citations.DoiCache(config)[source]

Bases: object

galaxy.managers.citations.parse_citation(elem, directory, citation_manager)[source]

Parse an abstract citation entry from the specified XML element. The directory parameter should be used to find external files for this citation.

class galaxy.managers.citations.CitationCollection[source]

Bases: object

class galaxy.managers.citations.BaseCitation[source]

Bases: object

class galaxy.managers.citations.BibtexCitation(elem, directory, citation_manager)[source]

Bases: galaxy.managers.citations.BaseCitation

__init__(elem, directory, citation_manager)[source]
class galaxy.managers.citations.DoiCitation(elem, directory, citation_manager)[source]

Bases: galaxy.managers.citations.BaseCitation

BIBTEX_UNSET = <object object>
__init__(elem, directory, citation_manager)[source]

galaxy.managers.collections module

class galaxy.managers.collections.DatasetCollectionManager(app)[source]

Bases: object

Abstraction for interfacing with dataset collections instance - ideally abstarcts out model and plugin details.

create(trans, parent, name, collection_type, element_identifiers=None, elements=None, implicit_collection_info=None, trusted_identifiers=None, hide_source_items=False, tags=None)[source]

PRECONDITION: security checks on ability to add to parent occurred during load.

create_dataset_collection(trans, collection_type, element_identifiers=None, elements=None, hide_source_items=None)[source]
set_collection_elements(dataset_collection, dataset_instances)[source]
delete(trans, instance_type, id)[source]
update(trans, instance_type, id, payload)[source]
copy(trans, parent, source, encoded_source_id)[source]

PRECONDITION: security checks on ability to add to parent occurred during load.

history_dataset_collections(history, query)[source]

May seem odd to place it here, but planning to grow sophistication and get plugin types involved so it will likely make sense in the future.

get_dataset_collection_instance(trans, instance_type, id, **kwds)[source]
get_dataset_collection(trans, encoded_id)[source]

galaxy.managers.collections_util module


Cleanup API payload to pass into dataset_collections.

galaxy.managers.collections_util.dictify_dataset_collection_instance(dataset_collection_instance, parent, security, view='element')[source]

galaxy.managers.configuration module

Serializers for Galaxy config file data: ConfigSerializer for all users and a more expanded set of data for admin in AdminConfigSerializer.

Used by both the API and bootstrapped data.

class galaxy.managers.configuration.ConfigSerializer(app)[source]

Bases: galaxy.managers.base.ModelSerializer

Configuration (galaxy.ini) settings viewable by all users

default_serializer(config, key)[source]
class galaxy.managers.configuration.AdminConfigSerializer(app)[source]

Bases: galaxy.managers.configuration.ConfigSerializer

Configuration attributes viewable only by admin users


galaxy.managers.containers module

Manager mixins to unify the interface into things that can contain: Datasets and other (nested) containers.

(e.g. DatasetCollections, Histories, LibraryFolders)

class galaxy.managers.containers.ContainerManagerMixin[source]

Bases: object

A class that tracks/contains two types of items:
  1. some non-container object (such as datasets)
  2. other sub-containers nested within this one

Levels of nesting are not considered here; In other words, each of the methods below only work on the first level of nesting.

contained_class = None

the classes that can be contained

subcontainer_class = None
default_order_by = None

how any contents lists produced are ordered - (string) attribute name to sort on or tuple of attribute names


Returns both types of contents: filtered and in some order.

contained(container, **kwargs)[source]

Returns non-container objects.

subcontainers(container, **kwargs)[source]

Returns only the containers within this one.

class galaxy.managers.containers.LibraryFolderAsContainerManagerMixin[source]

Bases: galaxy.managers.containers.ContainerManagerMixin


alias of galaxy.model.LibraryDataset


alias of galaxy.model.LibraryFolder

order_contents_on = <operator.attrgetter object>
class galaxy.managers.containers.DatasetCollectionAsContainerManagerMixin[source]

Bases: galaxy.managers.containers.ContainerManagerMixin


alias of galaxy.model.DatasetCollectionElement


alias of galaxy.model.DatasetCollection

order_contents_on = <operator.attrgetter object>
class galaxy.managers.containers.ContainableModelMixin[source]

Mixin for that which goes in a container.


Return this item’s parent container or None if unrecorded.

set_parent_container(containable, new_parent_container)[source]

galaxy.managers.context module

Mixins for transaction-like objects.

class galaxy.managers.context.ProvidesAppContext[source]

Bases: object

For transaction-like objects to provide Galaxy convience layer for database and event handling.

Mixed in class must provide app property.

log_action(user=None, action=None, context=None, params=None)[source]

Application-level logging of user actions.

log_event(message, tool_id=None, **kwargs)[source]

Application level logging. Still needs fleshing out (log levels and such) Logging events is a config setting - if False, do not log.


Returns a SQLAlchemy session – currently just gets the current session from the threadlocal session context, but this is provided to allow migration toward a more SQLAlchemy 0.4 style of use.


Returns the application toolbox

class galaxy.managers.context.ProvidesUserContext[source]

Bases: object

For transaction-like objects to provide Galaxy convience layer for reasoning about users.

Mixed in class must provide user, api_inherit_admin, and app properties.

class galaxy.managers.context.ProvidesHistoryContext[source]

Bases: object

For transaction-like objects to provide Galaxy convience layer for reasoning about histories.

Mixed in class must provide user, history, and app properties.


Returns the db_file dataset associated/needed by dataset, or None.


Returns the builds defined by galaxy and the builds defined by the user (chromInfo in history).

galaxy.managers.datasets module

Manager and Serializer for Datasets.

class galaxy.managers.datasets.DatasetManager(app)[source]

Bases: galaxy.managers.base.ModelManager, galaxy.managers.secured.AccessibleManagerMixin, galaxy.managers.deletable.PurgableManagerMixin

Manipulate datasets: the components contained in DatasetAssociations/DatasetInstances/HDAs/LDDAs


alias of galaxy.model.Dataset

foreign_key_name = 'dataset'
create(manage_roles=None, access_roles=None, flush=True, **kwargs)[source]

Create and return a new Dataset object.

copy(dataset, **kwargs)[source]
purge(dataset, flush=True)[source]

Remove the object_store/file for this dataset from storage and mark as purged.

Raises:exceptions.ConfigDoesNotAllowException – if the instance doesn’t allow
is_accessible(dataset, user, **kwargs)[source]

Is this dataset readable/viewable to user?

has_access_permission(dataset, user)[source]

Return T/F if the user has role-based access to the dataset.

class galaxy.managers.datasets.DatasetRBACPermissions(app)[source]

Bases: object

available_roles(trans, dataset, controller='root')[source]
get(dataset, flush=True)[source]
set(dataset, manage_roles, access_roles, flush=True)[source]
set_public_with_single_manager(dataset, user, flush=True)[source]
set_private_to_one_user(dataset, user, flush=True)[source]
class galaxy.managers.datasets.DatasetSerializer(app)[source]

Bases: galaxy.managers.base.ModelSerializer, galaxy.managers.deletable.PurgableSerializerMixin


alias of DatasetManager

serialize_file_name(dataset, key, user=None, **context)[source]

If the config allows or the user is admin, return the file name of the file that contains this dataset’s data.

serialize_extra_files_path(dataset, key, user=None, **context)[source]

If the config allows or the user is admin, return the file path.

serialize_permissions(dataset, key, user=None, **context)[source]
class galaxy.managers.datasets.DatasetDeserializer(app)[source]

Bases: galaxy.managers.base.ModelDeserializer, galaxy.managers.deletable.PurgableDeserializerMixin


alias of DatasetManager

deserialize_permissions(dataset, key, permissions, user=None, **context)[source]

Create permissions for each list of encoded role ids in the (validated) permissions dictionary, where permissions is in the form:

{ 'manage': [ <role id 1>, ... ], 'access': [ <role id 2>, ... ] }
class galaxy.managers.datasets.DatasetAssociationManager(app)[source]

Bases: galaxy.managers.base.ModelManager, galaxy.managers.secured.AccessibleManagerMixin, galaxy.managers.deletable.PurgableManagerMixin

DatasetAssociation/DatasetInstances are intended to be working proxies to a Dataset, associated with either a library or a user/history (HistoryDatasetAssociation).


alias of galaxy.model.DatasetInstance

is_accessible(dataset_assoc, user, **kwargs)[source]

Is this DA accessible to user?

purge(dataset_assoc, flush=True)[source]

Purge this DatasetInstance and the dataset underlying it.


Return the Job that created this dataset or None if not found.


Stops an dataset_assoc’s creating job if all the job’s other outputs are deleted.


Return True if this hda/ldda is a composite type dataset.


see also (whereever we keep information on composite datatypes?)


Return a list of file paths for composite files, an empty list otherwise.

class galaxy.managers.datasets.DatasetAssociationSerializer(app)[source]

Bases: galaxy.managers.datasets._UnflattenedMetadataDatasetAssociationSerializer

serialize(dataset_assoc, keys, **context)[source]

Override to add metadata as flattened keys on the serialized DatasetInstance.

class galaxy.managers.datasets.DatasetAssociationDeserializer(app, validator=None, **kwargs)[source]

Bases: galaxy.managers.base.ModelDeserializer, galaxy.managers.deletable.PurgableDeserializerMixin

deserialize_metadata(dataset_assoc, metadata_key, metadata_dict, **context)[source]
deserialize_metadatum(dataset_assoc, key, val, **context)[source]
class galaxy.managers.datasets.DatasetAssociationFilterParser(app, **kwargs)[source]

Bases: galaxy.managers.base.ModelFilterParser, galaxy.managers.deletable.PurgableFiltersMixin

eq_datatype(dataset_assoc, class_str)[source]

Is the dataset_assoc datatype equal to the registered datatype class_str?

isinstance_datatype(dataset_assoc, class_strs)[source]

Is the dataset_assoc datatype derived from any of the registered datatypes in the comma separated string class_strs?

galaxy.managers.deletable module

Many models in Galaxy are not meant to be removed from the database but only marked as deleted. These models have the boolean attribute ‘deleted’.

Other models are deletable and also may be purged. Most often these are models have some backing/supporting resources that can be removed as well (e.g. Datasets have data files on a drive). Purging these models removes the supporting resources as well. These models also have the boolean attribute ‘purged’.

class galaxy.managers.deletable.DeletableManagerMixin[source]

Bases: object

A mixin/interface for a model that is deletable (i.e. has a ‘deleted’ attr).

Many resources in Galaxy can be marked as deleted - meaning (in most cases) that they are no longer needed, should not be displayed, or may be actually removed by an admin/script.

delete(item, flush=True, **kwargs)[source]

Mark as deleted and return.

undelete(item, flush=True, **kwargs)[source]

Mark as not deleted and return.

class galaxy.managers.deletable.DeletableSerializerMixin[source]

Bases: object

class galaxy.managers.deletable.DeletableDeserializerMixin[source]

Bases: object

deserialize_deleted(item, key, val, **context)[source]

Delete or undelete item based on val then return item.deleted.

class galaxy.managers.deletable.DeletableFiltersMixin[source]

Bases: object

class galaxy.managers.deletable.PurgableManagerMixin[source]

Bases: galaxy.managers.deletable.DeletableManagerMixin

A manager interface/mixin for a resource that allows deleting and purging where purging is often removal of some additional, non-db resource (e.g. a dataset’s file).

purge(item, flush=True, **kwargs)[source]

Mark as purged and return.

Override this in subclasses to do the additional resource removal.

class galaxy.managers.deletable.PurgableSerializerMixin[source]

Bases: galaxy.managers.deletable.DeletableSerializerMixin

class galaxy.managers.deletable.PurgableDeserializerMixin[source]

Bases: galaxy.managers.deletable.DeletableDeserializerMixin

deserialize_purged(item, key, val, **context)[source]

If val is True, purge item and return item.purged.

class galaxy.managers.deletable.PurgableFiltersMixin[source]

Bases: galaxy.managers.deletable.DeletableFiltersMixin

galaxy.managers.folders module

Manager and Serializer for Library Folders.

class galaxy.managers.folders.FolderManager[source]

Bases: object

Interface/service object for interacting with folders.

get(trans, decoded_folder_id, check_manageable=False, check_accessible=True)[source]

Get the folder from the DB.

  • decoded_folder_id (int) – decoded folder id
  • check_manageable (bool) – flag whether the check that user can manage item
  • check_accessible (bool) – flag whether to check that user can access item

the requested folder

Return type:



InconsistentDatabase, RequestParameterInvalidException, InternalServerError

secure(trans, folder, check_manageable=True, check_accessible=True)[source]

Check if (a) user can manage folder or (b) folder is accessible to user.

  • folder (LibraryFolder) – folder item
  • check_manageable (bool) – flag whether to check that user can manage item
  • check_accessible (bool) – flag whether to check that user can access item

the original folder

Return type:


check_manageable(trans, folder)[source]

Check whether the user can manage the folder.

Returns:the original folder
Return type:LibraryFolder
Raises:AuthenticationRequired, InsufficientPermissionsException
check_accessible(trans, folder)[source]

Check whether the folder is accessible to current user. By default every folder is accessible (contents have their own permissions).

get_folder_dict(trans, folder)[source]

Return folder data in the form of a dictionary.

Parameters:folder (LibraryFolder) – folder item
Returns:dict with data about the folder
Return type:dictionary
create(trans, parent_folder_id, new_folder_name, new_folder_description='')[source]

Create a new folder under the given folder.

  • parent_folder_id (int) – decoded id
  • new_folder_name (str) – name of the new folder
  • new_folder_description (str) – description of the folder (optional, defaults to empty string)

the new folder

Return type:




update(trans, folder, name=None, description=None)[source]

Update the given folder’s name or description.

  • folder (LibraryFolder) – the model object
  • name (str) – new name for the library folder
  • description (str) – new description for the library folder

the folder

Return type:



ItemAccessibilityException, InsufficientPermissionsException

delete(trans, folder, undelete=False)[source]

Mark given folder deleted/undeleted based on the flag.

  • folder (LibraryFolder) – the model object
  • undelete (Bool) – flag whether to delete (when False) or undelete

the folder

Return type:




get_current_roles(trans, folder)[source]

Find all roles currently connected to relevant permissions on the folder.

Parameters:folder (LibraryFolder) – the model object
Returns:dict of current roles for all available permission types
Return type:dictionary
can_add_item(trans, folder)[source]

Return true if the user has permissions to add item to the given folder.


Remove the prefix from the encoded folder id.

Parameters:encoded_folder_id (string) – encoded id of the Folder object with ‘F’ prepended
Returns:encoded Folder id without the ‘F’ prefix
Return type:string
decode_folder_id(trans, encoded_folder_id)[source]

Decode the folder id given that it has already lost the prefixed ‘F’.

Parameters:encoded_folder_id (string) – encoded id of the Folder object
Returns:decoded Folder id
Return type:int
cut_and_decode(trans, encoded_folder_id)[source]

Cuts the folder prefix (the prepended ‘F’) and returns the decoded id.

Parameters:encoded_folder_id (string) – encoded id of the Folder object
Returns:decoded Folder id
Return type:int

galaxy.managers.hdas module

Manager and Serializer for HDAs.

HistoryDatasetAssociations (HDAs) are datasets contained or created in a history.

class galaxy.managers.hdas.HDAManager(app)[source]

Bases: galaxy.managers.datasets.DatasetAssociationManager, galaxy.managers.secured.OwnableManagerMixin, galaxy.managers.taggable.TaggableManagerMixin, galaxy.managers.annotatable.AnnotatableManagerMixin

Interface/service object for interacting with HDAs.


alias of galaxy.model.HistoryDatasetAssociation

foreign_key_name = 'history_dataset_association'

alias of galaxy.model.HistoryDatasetAssociationTagAssociation


alias of galaxy.model.HistoryDatasetAssociationAnnotationAssociation


Set up and initialize other managers needed by hdas.

is_accessible(hda, user, **kwargs)[source]

Override to allow owners (those that own the associated history).

is_owner(hda, user, current_history=None, **kwargs)[source]

Use history to see if current user owns HDA.

create(history=None, dataset=None, flush=True, **kwargs)[source]

Create a new hda optionally passing in it’s history and dataset.

..note: to explicitly set hid to None you must pass in hid=None, otherwise it will be automatically set.

copy(hda, history=None, **kwargs)[source]

Copy and return the given HDA.

copy_ldda(history, ldda, **kwargs)[source]

Copy this HDA as a LDDA and return.

purge(hda, flush=True)[source]

Purge this HDA and the dataset underlying it.


Raise error if HDA is still uploading.


Return True if the hda’s job was resubmitted at any point.


Returns a message if an hda is not ready to be used in visualization.

text_data(hda, preview=True)[source]

Get data from text file, truncating if necessary.

class galaxy.managers.hdas.HDASerializer(app)[source]

Bases: galaxy.managers.datasets.DatasetAssociationSerializer, galaxy.managers.taggable.TaggableSerializerMixin, galaxy.managers.annotatable.AnnotatableSerializerMixin


alias of HDAManager

serialize(hda, keys, user=None, **context)[source]

Override to hide information to users not able to access.

serialize_display_apps(hda, key, trans=None, **context)[source]

Return dictionary containing new-style display app urls.

serialize_old_display_applications(hda, key, trans=None, **context)[source]

Return dictionary containing old-style display app urls.

Return a list of dictionaries with links to visualization pages for those visualizations that apply to this hda.

serialize_urls(hda, key, **context)[source]

Return web controller urls useful for this HDA.

class galaxy.managers.hdas.HDADeserializer(app)[source]

Bases: galaxy.managers.datasets.DatasetAssociationDeserializer, galaxy.managers.taggable.TaggableDeserializerMixin, galaxy.managers.annotatable.AnnotatableDeserializerMixin

Interface/service object for validating and deserializing dictionaries into histories.


alias of HDAManager

class galaxy.managers.hdas.HDAFilterParser(app, **kwargs)[source]

Bases: galaxy.managers.datasets.DatasetAssociationFilterParser, galaxy.managers.taggable.TaggableFilterMixin, galaxy.managers.annotatable.AnnotatableFilterMixin


alias of HDAManager


alias of galaxy.model.HistoryDatasetAssociation

galaxy.managers.histories module

Manager and Serializer for histories.

Histories are containers for datasets or dataset collections created (or copied) by users over the course of an analysis.

class galaxy.managers.histories.HistoryManager(app, *args, **kwargs)[source]

Bases: galaxy.managers.sharable.SharableModelManager, galaxy.managers.deletable.PurgableManagerMixin


alias of galaxy.model.History

foreign_key_name = 'history'

alias of galaxy.model.HistoryUserShareAssociation


alias of galaxy.model.HistoryTagAssociation


alias of galaxy.model.HistoryAnnotationAssociation


alias of galaxy.model.HistoryRatingAssociation

__init__(app, *args, **kwargs)[source]
copy(history, user, **kwargs)[source]

Copy and return the given history.

by_user(user, current_history=None, **kwargs)[source]

Get all the histories for a given user (allowing anon users’ theirs) ordered by update time.

is_owner(history, user, current_history=None, **kwargs)[source]

True if the current user is the owner of the given history.

most_recent(user, filters=None, current_history=None, **kwargs)[source]

Return the most recently update history for the user.

If user is anonymous, return the current history. If the user is anonymous and the current history is deleted, return None.

purge(history, flush=True, **kwargs)[source]

Purge this history and all HDAs, Collections, and Datasets inside this history.


Return the current history.

set_current(trans, history)[source]

Set the current history.

set_current_by_id(trans, history_id)[source]

Set the current history by an id.

parse_order_by(order_by_string, default=None)[source]

Return an ORM compatible order_by using the given string


Return the currently running job objects associated with this history.

Where running is defined as new, waiting, queued, running, resubmitted, and upload.

class galaxy.managers.histories.HistorySerializer(app, **kwargs)[source]

Bases: galaxy.managers.sharable.SharableModelSerializer, galaxy.managers.deletable.PurgableSerializerMixin

Interface/service object for serializing histories into dictionaries.


alias of HistoryManager

__init__(app, **kwargs)[source]
serialize_state_ids(history, key, **context)[source]

Return a dictionary keyed to possible dataset states and valued with lists containing the ids of each HDA in that state.

serialize_state_counts(history, key, exclude_deleted=True, exclude_hidden=False, **context)[source]

Return a dictionary keyed to possible dataset states and valued with the number of datasets in this history that have those states.

serialize_history_state(history, key, **context)[source]

Returns the history state based on the states of the HDAs it contains.

serialize_contents(history, key, trans=None, user=None, **context)[source]
serialize_contents_states(history, key, trans=None, **context)[source]

Return a dictionary containing the counts of all contents in each state keyed by the distinct states.

Note: does not include deleted/hidden contents.

serialize_contents_active(history, key, **context)[source]

Return a dictionary keyed with ‘deleted’, ‘hidden’, and ‘active’ with values for each representing the count of contents in each state.

Note: counts for deleted and hidden overlap; In other words, a dataset that’s both deleted and hidden will be added to both totals.

class galaxy.managers.histories.HistoryDeserializer(app)[source]

Bases: galaxy.managers.sharable.SharableModelDeserializer, galaxy.managers.deletable.PurgableDeserializerMixin

Interface/service object for validating and deserializing dictionaries into histories.


alias of HistoryManager

class galaxy.managers.histories.HistoryFilters(app, **kwargs)[source]

Bases: galaxy.managers.sharable.SharableModelFilters, galaxy.managers.deletable.PurgableFiltersMixin


alias of galaxy.model.History


alias of HistoryManager

galaxy.managers.lddas module

class galaxy.managers.lddas.LDDAManager(app)[source]

Bases: object

A fairly sparse manager for LDDAs.


Set up and initialize other managers needed by lddas.

get(trans, id, check_accessible=True)[source]

galaxy.managers.libraries module

Manager and Serializer for libraries.

class galaxy.managers.libraries.LibraryManager(*args, **kwargs)[source]

Bases: object

Interface/service object for interacting with libraries.

__init__(*args, **kwargs)[source]
get(trans, decoded_library_id, check_accessible=True)[source]

Get the library from the DB.

  • decoded_library_id (int) – decoded library id
  • check_accessible (bool) – flag whether to check that user can access item

the requested library

Return type:


create(trans, name, description='', synopsis='')[source]

Create a new library.

update(trans, library, name=None, description=None, synopsis=None)[source]

Update the given library

delete(trans, library, undelete=False)[source]

Mark given library deleted/undeleted based on the flag.

list(trans, deleted=False)[source]

Return a list of libraries from the DB.

Parameters:deleted (boolean (optional)) – if True, show only deleted libraries, if False show only non-deleted
Returns:query that will emit all accessible libraries
Return type:sqlalchemy query
secure(trans, library, check_accessible=True)[source]

Check if library is accessible to user.

  • library (galaxy.model.Library) – library
  • check_accessible (bool) – flag whether to check that user can access library

the original folder

Return type:


check_accessible(trans, library)[source]

Check whether the library is accessible to current user.

get_library_dict(trans, library)[source]

Return library data in the form of a dictionary.

Parameters:library (galaxy.model.Library) – library
Returns:dict with data about the library
Return type:dictionary
get_current_roles(trans, library)[source]

Load all permissions currently related to the given library.

Parameters:library (galaxy.model.Library) – the model object
Return type:dictionary
Returns:dict of current roles for all available permission types
get_access_roles(trans, library)[source]

Load access roles for all library permissions

get_modify_roles(trans, library)[source]

Load modify roles for all library permissions

get_manage_roles(trans, library)[source]

Load manage roles for all library permissions

get_add_roles(trans, library)[source]

Load add roles for all library permissions

set_permission_roles(trans, library, access_roles, modify_roles, manage_roles, add_roles)[source]

Set permissions on the given library.

make_public(trans, library)[source]

Makes the given library public (removes all access roles)

is_public(trans, library)[source]

Return true if lib is public.

galaxy.managers.pages module

Manager and Serializers for Pages.

Pages are markup created and saved by users that can contain Galaxy objects (such as datasets) and are often used to describe or present an analysis from within Galaxy.

class galaxy.managers.pages.PageManager(app, *args, **kwargs)[source]

Bases: galaxy.managers.sharable.SharableModelManager


alias of galaxy.model.Page

foreign_key_name = 'page'

alias of galaxy.model.PageUserShareAssociation


alias of galaxy.model.PageTagAssociation


alias of galaxy.model.PageAnnotationAssociation


alias of galaxy.model.PageRatingAssociation

__init__(app, *args, **kwargs)[source]
copy(trans, page, user, **kwargs)[source]
class galaxy.managers.pages.PageSerializer(app)[source]

Bases: galaxy.managers.sharable.SharableModelSerializer

Interface/service object for serializing pages into dictionaries.

class galaxy.managers.pages.PageDeserializer(app)[source]

Bases: galaxy.managers.sharable.SharableModelDeserializer

Interface/service object for validating and deserializing dictionaries into pages.


alias of PageManager


galaxy.managers.ratable module

Mixins for Ratable model managers and serializers.

class galaxy.managers.ratable.RatableManagerMixin[source]

Bases: object

rating_assoc = None

class of RatingAssociation (e.g. HistoryRatingAssociation)

rating(item, user, as_int=True)[source]

Returns the integer rating given to this item by the user.

Returns the full rating model if as_int is False.


Returns a list of all rating values given to this item.


Returns the average of all ratings given to this item.


Returns the number of ratings given to this item.

rate(item, user, value, flush=True)[source]

Updates or creates a rating for this item and user. Returns the rating

class galaxy.managers.ratable.RatableSerializerMixin[source]

Bases: object

serialize_user_rating(item, key, user=None, **context)[source]

Returns the integer rating given to this item by the user.

serialize_community_rating(item, key, **context)[source]
Returns a dictionary containing:
average the (float) average of all ratings of this object count the number of ratings
class galaxy.managers.ratable.RatableDeserializerMixin[source]

Bases: object

deserialize_rating(item, key, val, user=None, **context)[source]
class galaxy.managers.ratable.RatableFilterMixin[source]

Bases: object

galaxy.managers.rbac_secured module

exception galaxy.managers.rbac_secured.RBACPermissionFailedException(err_msg=None, type='info', **extra_error_info)[source]

Bases: galaxy.exceptions.InsufficientPermissionsException

class galaxy.managers.rbac_secured.RBACPermission(app)[source]

Bases: object

Base class for wrangling/controlling the permissions ORM models (*Permissions, Roles) that control which users can perform certain actions on their associated models (Libraries, Datasets).

permissions_class = None

alias of RBACPermissionFailedException

is_permitted(item, user)[source]
error_unless_permitted(item, user)[source]
grant(item, user, flush=True)[source]
revoke(item, user, flush=True)[source]
class galaxy.managers.rbac_secured.DatasetRBACPermission(app)[source]

Bases: galaxy.managers.rbac_secured.RBACPermission

Base class for the manage and access RBAC permissions used by dataset security.

The DatasetPermissions used by the RBAC agent are associations between a Dataset and a single Role.

DatasetPermissions are typed (but not polymorphic themselves) by a string ‘action’. There are two types:

  • manage permissions : can a role manage the permissions on a dataset
  • access : can a role read/look at/copy a dataset

alias of galaxy.model.DatasetPermissions

action_name = None
by_roles(dataset, roles)[source]
by_role(dataset, role)[source]
set(dataset, roles, flush=True)[source]
clear(dataset, flush=True)[source]
galaxy.managers.rbac_secured.iterable_has_all(iterable, has_these)[source]
exception galaxy.managers.rbac_secured.DatasetManagePermissionFailedException(err_msg=None, type='info', **extra_error_info)[source]

Bases: galaxy.managers.rbac_secured.RBACPermissionFailedException

class galaxy.managers.rbac_secured.ManageDatasetRBACPermission(app)[source]

Bases: galaxy.managers.rbac_secured.DatasetRBACPermission

A class that controls the dataset permissions that control who can manage that dataset’s permissions.

When checking permissions for a user, if any of the user’s roles have permission on the dataset

action_name = 'manage permissions'

alias of DatasetManagePermissionFailedException

is_permitted(dataset, user)[source]
grant(dataset, user, flush=True)[source]
revoke(dataset, user, flush=True)[source]
exception galaxy.managers.rbac_secured.DatasetAccessPermissionFailedException(err_msg=None, type='info', **extra_error_info)[source]

Bases: galaxy.managers.rbac_secured.RBACPermissionFailedException

class galaxy.managers.rbac_secured.AccessDatasetRBACPermission(app)[source]

Bases: galaxy.managers.rbac_secured.DatasetRBACPermission

A class to manage access permissions on a dataset.

An user must have all the Roles of all the access permissions associated with a dataset in order to access it.

action_name = 'access'

alias of DatasetAccessPermissionFailedException

is_permitted(dataset, user)[source]
grant(item, user)[source]
revoke(item, user)[source]
set_private(dataset, user, flush=True)[source]

galaxy.managers.roles module

Manager and Serializer for Roles.

class galaxy.managers.roles.RoleManager(app)[source]

Bases: galaxy.managers.base.ModelManager

Business logic for roles.


alias of galaxy.model.Role

foreign_key_name = 'role'

alias of galaxy.model.UserRoleAssociation


alias of galaxy.model.GroupRoleAssociation

get(trans, decoded_role_id)[source]

Method loads the role from the DB based on the given role id.

Parameters:decoded_role_id (int) – id of the role to load from the DB
Returns:the loaded Role object
Return type:galaxy.model.Role
Raises:InconsistentDatabase, RequestParameterInvalidException, InternalServerError

galaxy.managers.secured module

Accessible models can be read and copied but not modified or deleted.

Owned models can be modified and deleted.

class galaxy.managers.secured.AccessibleManagerMixin[source]

Bases: object

A security interface to check if a User can read/view an item’s.

This can also be thought of as ‘read but not modify’ privileges.

is_accessible(item, user, **kwargs)[source]

Return True if the item accessible to user.

get_accessible(id, user, **kwargs)[source]

Return the item with the given id if it’s accessible to user, otherwise raise an error.

error_unless_accessible(item, user, **kwargs)[source]

Raise an error if the item is NOT accessible to user, otherwise return the item.

list_accessible(user, **kwargs)[source]

Return a list of items accessible to the user, raising an error if ANY are inaccessible.

filter_accessible(user, **kwargs)[source]

Return a list of items accessible to the user.

class galaxy.managers.secured.OwnableManagerMixin[source]

Bases: object

A security interface to check if a User is an item’s owner.

Some resources are associated with the User that created or imported them and these Users can be considered the models’ owner.

This can also be thought of as write/edit privileges.

is_owner(item, user, **kwargs)[source]

Return True if user owns the item.

get_owned(id, user, **kwargs)[source]

Return the item with the given id if owned by the user, otherwise raise an error.

error_unless_owner(item, user, **kwargs)[source]

Raise an error if the item is NOT owned by user, otherwise return the item.

list_owned(user, **kwargs)[source]

Return a list of items owned by the user, raising an error if ANY are not.

filter_owned(user, **kwargs)[source]

Return a list of items owned by the user.

galaxy.managers.sharable module

Superclass Manager and Serializers for Sharable objects.

A sharable Galaxy object:
has an owner/creator User is sharable with other, specific Users is importable (copyable) by users that have access has a slug which can be used as a link to view the resource can be published effectively making it available to all other Users can be rated
class galaxy.managers.sharable.SharableModelManager(app)[source]

Bases: galaxy.managers.base.ModelManager, galaxy.managers.secured.OwnableManagerMixin, galaxy.managers.secured.AccessibleManagerMixin, galaxy.managers.taggable.TaggableManagerMixin, galaxy.managers.annotatable.AnnotatableManagerMixin, galaxy.managers.ratable.RatableManagerMixin

user_share_model = None

the model used for UserShareAssociations with this model


the single character abbreviation used in username_and_slug: e.g. ‘h’ for histories: u/user/h/slug

by_user(user, filters=None, **kwargs)[source]

Return list for all items (of model_class type) associated with the given user.

is_owner(item, user, **kwargs)[source]

Return true if this sharable belongs to user (or user is an admin).

is_accessible(item, user, **kwargs)[source]

If the item is importable, is owned by user, or (the valid) user is in ‘users shared with’ list for the item: return True.

make_importable(item, flush=True)[source]

Makes item accessible–viewable and importable–and sets item’s slug. Does not flush/commit changes, however. Item must have name, user, importable, and slug attributes.

make_non_importable(item, flush=True)[source]

Makes item accessible–viewable and importable–and sets item’s slug. Does not flush/commit changes, however. Item must have name, user, importable, and slug attributes.

publish(item, flush=True)[source]

Set both the importable and published flags on item to True.

unpublish(item, flush=True)[source]

Set the published flag on item to False.

list_published(filters=None, **kwargs)[source]

Return a list of all published items.

get_share_assocs(item, user=None)[source]

Get the UserShareAssociations for the item.

Optionally send in user to test for a single match.

share_with(item, user, flush=True)[source]

Get or create a share for the given user (or users if user is a list).

unshare_with(item, user, flush=True)[source]

Delete a user share (or list of shares) from the database.

list_shared_with(user, filters=None, order_by=None, limit=None, offset=None, **kwargs)[source]

Return a list of those models shared with a particular user.

set_slug(item, new_slug, user, flush=True)[source]

Validate and set the new slug for item.


Returns true if slug is valid.


Returns a slug that is unique among user’s importable items for item’s class.

create_unique_slug(item, flush=True)[source]

Set a new, unique slug on the item.

class galaxy.managers.sharable.SharableModelSerializer(app, **kwargs)[source]

Bases: galaxy.managers.base.ModelSerializer, galaxy.managers.taggable.TaggableSerializerMixin, galaxy.managers.annotatable.AnnotatableSerializerMixin, galaxy.managers.ratable.RatableSerializerMixin

serialize_username_and_slug(item, key, **context)[source]
serialize_users_shared_with(item, key, user=None, **context)[source]

Returns a list of encoded ids for users the item has been shared.

Skipped if the requesting user is not the owner.

class galaxy.managers.sharable.SharableModelDeserializer(app, validator=None, **kwargs)[source]

Bases: galaxy.managers.base.ModelDeserializer, galaxy.managers.taggable.TaggableDeserializerMixin, galaxy.managers.annotatable.AnnotatableDeserializerMixin, galaxy.managers.ratable.RatableDeserializerMixin

deserialize_published(item, key, val, **context)[source]
deserialize_importable(item, key, val, **context)[source]
deserialize_users_shared_with(item, key, val, **context)[source]

Accept a list of encoded user_ids, validate them as users, and then add or remove user shares in order to update the users_shared_with to match the given list finally returning the new list of shares.

class galaxy.managers.sharable.SharableModelFilters(app, **kwargs)[source]

Bases: galaxy.managers.base.ModelFilterParser, galaxy.managers.taggable.TaggableFilterMixin, galaxy.managers.annotatable.AnnotatableFilterMixin, galaxy.managers.ratable.RatableFilterMixin

galaxy.managers.taggable module

Mixins for Taggable model managers and serializers.

class galaxy.managers.taggable.TaggableManagerMixin[source]

Bases: object

tag_assoc = None

class of TagAssociation (e.g. HistoryTagAssociation)


Return a list of tag strings.

set_tags(item, new_tags, user=None)[source]

Set an item’s tags from a list of strings.

class galaxy.managers.taggable.TaggableSerializerMixin[source]

Bases: object

serialize_tags(item, key, **context)[source]

Return tags as a list of strings.

class galaxy.managers.taggable.TaggableDeserializerMixin[source]

Bases: object

deserialize_tags(item, key, val, user=None, **context)[source]

Make sure val is a valid list of tag strings and assign them.

Note: this will erase any previous tags.

class galaxy.managers.taggable.TaggableFilterMixin[source]

Bases: object

filter_has_partial_tag(item, val)[source]

Return True if any tag partially contains val.

filter_has_tag(item, val)[source]

Return True if any tag exactly equals val.

galaxy.managers.tags module

class galaxy.managers.tags.ItemTagAssocInfo(item_class, tag_assoc_class, item_id_col)[source]

Bases: object

__init__(item_class, tag_assoc_class, item_id_col)[source]
class galaxy.managers.tags.TagManager(app)[source]

Bases: object

Manages CRUD operations related to tagging objects.

add_tags_from_list(user, item, new_tags_list)[source]
set_tags_from_list(user, item, new_tags_list)[source]

Returns tag association class for item class.


Returns item id column in class’ item-tag association table.

get_community_tags(item=None, limit=None)[source]

Returns community tags for an item.

remove_item_tag(user, item, tag_name)[source]

Remove a tag from an item.

delete_item_tags(user, item)[source]

Delete tags from an item.

item_has_tag(user, item, tag)[source]

Returns true if item is has a given tag.

apply_item_tag(user, item, name, value=None)[source]
apply_item_tags(user, item, tags_str)[source]

Apply tags to an item.


Build a string from an item’s tags.


Get a Tag object from a tag id.


Get a Tag object from a tag name (string).


Returns a list of raw (tag-name, value) pairs derived from a string; method scrubs tag names and values as well. Return value is a list of (tag_name, tag_value) tuples.

class galaxy.managers.tags.GalaxyTagManager(app)[source]

Bases: galaxy.managers.tags.TagManager

class galaxy.managers.tags.CommunityTagManager(app)[source]

Bases: galaxy.managers.tags.TagManager


galaxy.managers.users module

Manager and Serializer for Users.

class galaxy.managers.users.UserManager(app)[source]

Bases: galaxy.managers.base.ModelManager, galaxy.managers.deletable.PurgableManagerMixin


alias of galaxy.model.User

foreign_key_name = 'user'
create(webapp_name=None, **kwargs)[source]

Create a new user.

by_email(email, filters=None, **kwargs)[source]

Find a user by their email.

by_email_like(email_with_wildcards, filters=None, order_by=None, **kwargs)[source]

Find a user searching with SQL wildcards.


Return True if this user is an admin.

admins(filters=None, **kwargs)[source]

Return a list of admin Users.

error_unless_admin(user, msg='Administrators only', **kwargs)[source]

Raise an error if user is not an admin.

Raises:exceptions.AdminRequiredException – if user is not an admin.

Return True if user is anonymous.

error_if_anonymous(user, msg='Log-in required', **kwargs)[source]

Raise an error if user is anonymous.


Create and return an API key for user.


Return this most recent APIKey for this user or None if none have been created.


Return this most recent APIKey for this user or create one if none have been created.

quota(user, total=False)[source]
tags_used(user, tag_models=None)[source]

Return a list of distinct ‘user_tname:user_value’ strings that the given user has used.

has_requests(user, trans)[source]
class galaxy.managers.users.UserSerializer(app)[source]

Bases: galaxy.managers.base.ModelSerializer, galaxy.managers.deletable.PurgableSerializerMixin


alias of UserManager


Convert a User and associated data to a dictionary representation.

class galaxy.managers.users.UserDeserializer(app, validator=None, **kwargs)[source]

Bases: galaxy.managers.base.ModelDeserializer

Service object for validating and deserializing dictionaries that update/alter users.


alias of UserManager

deserialize_username(item, key, username, trans=None, **context)[source]
class galaxy.managers.users.CurrentUserSerializer(app)[source]

Bases: galaxy.managers.users.UserSerializer


alias of UserManager

serialize(user, keys, **kwargs)[source]

Override to return at least some usage info if user is anonymous.

serialize_current_anonymous_user(user, keys, trans=None, **kwargs)[source]
class galaxy.managers.users.AdminUserFilterParser(app, **kwargs)[source]

Bases: galaxy.managers.base.ModelFilterParser, galaxy.managers.deletable.PurgableFiltersMixin


alias of UserManager


alias of galaxy.model.User

galaxy.managers.visualizations module

Manager and Serializers for Visualizations.

Visualizations are saved configurations/variables used to reproduce a specific view in a Galaxy visualization.

class galaxy.managers.visualizations.VisualizationManager(app, *args, **kwargs)[source]

Bases: galaxy.managers.sharable.SharableModelManager

Handle operations outside and between visualizations and other models.


alias of galaxy.model.Visualization

foreign_key_name = 'visualization'

alias of galaxy.model.VisualizationUserShareAssociation


alias of galaxy.model.VisualizationTagAssociation


alias of galaxy.model.VisualizationAnnotationAssociation


alias of galaxy.model.VisualizationRatingAssociation

__init__(app, *args, **kwargs)[source]
class galaxy.managers.visualizations.VisualizationSerializer(app)[source]

Bases: galaxy.managers.sharable.SharableModelSerializer

Interface/service object for serializing visualizations into dictionaries.


alias of VisualizationManager

class galaxy.managers.visualizations.VisualizationDeserializer(app)[source]

Bases: galaxy.managers.sharable.SharableModelDeserializer

Interface/service object for validating and deserializing dictionaries into visualizations.


alias of VisualizationManager


galaxy.managers.workflows module

class galaxy.managers.workflows.WorkflowsManager(app)[source]

Bases: object

Handle CRUD type operaitons related to workflows. More interesting stuff regarding workflow execution, step sorting, etc… can be found in the galaxy.workflow module.

get_stored_workflow(trans, workflow_id)[source]

Use a supplied ID (UUID or encoded stored workflow ID) to find a workflow.

get_stored_accessible_workflow(trans, workflow_id)[source]

Get a stored workflow from a encoded stored workflow id and make sure it accessible to the user.

get_owned_workflow(trans, encoded_workflow_id)[source]

Get a workflow (non-stored) from a encoded workflow id and make sure it accessible to the user.

check_security(trans, has_workflow, check_ownership=True, check_accessible=True)[source]

check accessibility or ownership of workflows, storedworkflows, and workflowinvocations. Throw an exception or returns True if user has needed level of access.

get_invocation(trans, decoded_invocation_id)[source]
cancel_invocation(trans, decoded_invocation_id)[source]
get_invocation_step(trans, decoded_workflow_invocation_step_id)[source]
update_invocation_step(trans, decoded_workflow_invocation_step_id, action)[source]
build_invocations_query(trans, decoded_stored_workflow_id)[source]
class galaxy.managers.workflows.CreatedWorkflow(stored_workflow, workflow, missing_tools)

Bases: tuple


Alias for field number 2


Alias for field number 0


Alias for field number 1

class galaxy.managers.workflows.WorkflowContentsManager(app)[source]

Bases: galaxy.model.item_attrs.UsesAnnotations

build_workflow_from_dict(trans, data, source=None, add_to_menu=False, publish=False, create_stored_workflow=True, exact_tools=False)[source]
update_workflow_from_dict(trans, stored_workflow, workflow_data)[source]
workflow_to_dict(trans, stored, style='export')[source]

Export the workflow contents to a dictionary ready for JSON-ification and to be sent out via API for instance. There are three styles of export allowed ‘export’, ‘instance’, and ‘editor’. The Galaxy team will do it best to preserve the backward compatibility of the ‘export’ stye - this is the export method meant to be portable across Galaxy instances and over time. The ‘editor’ style is subject to rapid and unannounced changes. The ‘instance’ export option describes the workflow in a context more tied to the current Galaxy instance and includes fields like ‘url’ and ‘url’ and actual unencoded step ids instead of ‘order_index’.

exception galaxy.managers.workflows.MissingToolsException(workflow, errors)[source]

Bases: galaxy.exceptions.MessageException

__init__(workflow, errors)[source]