managers Package¶
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.
- Responsibilities:
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
- and:
- 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.
api_keys
Module¶
base
Module¶
-
galaxy.managers.base.
get_class
(class_name)[source]¶ Returns the class object that a string denotes. Without this method, we’d have to do eval(<class_name>).
-
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.
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.
citations
Module¶
-
class
galaxy.managers.citations.
DoiCitation
(elem, directory, citation_manager)[source]¶ Bases:
galaxy.managers.citations.BaseCitation
-
BIBTEX_UNSET
= <object object>¶
-
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)[source]¶
-
collections_util
Module¶
-
galaxy.managers.collections_util.
api_payload_to_create_params
(payload)[source]¶ Cleanup API payload to pass into dataset_collections.
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.
-
install_model
¶
-
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.
-
model
¶
-
sa_session
¶ 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.
-
-
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.
-
db_builds
¶ Returns the builds defined by galaxy and the builds defined by the user (chromInfo in history).
-
folders
Module¶
Manager and Serializer for Library Folders.
-
class
galaxy.managers.folders.
FolderManager
[source]¶ Bases:
object
Interface/service object for interacting with folders.
-
can_add_item
(trans, folder)[source]¶ Return true if the user has permissions to add item to the given folder.
-
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).
-
check_manageable
(trans, folder)[source]¶ Check whether the user can manage the folder.
Returns: the original folder Return type: LibraryFolder Raises: AuthenticationRequired, InsufficientPermissionsException
-
create
(trans, parent_folder_id, new_folder_name, new_folder_description='')[source]¶ Create a new folder under the given folder.
Parameters: - 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)
Returns: the new folder
Return type: Raises: InsufficientPermissionsException
-
cut_and_decode
(trans, encoded_folder_id)[source]¶ Cuts the folder prefix (the prepended ‘F’) and returns the decoded id.
-
decode_folder_id
(trans, encoded_folder_id)[source]¶ Decode the folder id given that it has already lost the prefixed ‘F’.
-
delete
(trans, folder, undelete=False)[source]¶ Mark given folder deleted/undeleted based on the flag.
Raises: ItemAccessibilityException
-
get
(trans, decoded_folder_id, check_manageable=False, check_accessible=True)[source]¶ Get the folder from the DB.
Parameters: - 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
Returns: the requested 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
-
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
-
secure
(trans, folder, check_manageable=True, check_accessible=True)[source]¶ Check if (a) user can manage folder or (b) folder is accessible to user.
Parameters: - 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
Returns: the original folder
Return type:
-
hdas
Module¶
Manager and Serializer for HDAs.
HistoryDatasetAssociations (HDAs) are datasets contained or created in a history.
-
class
galaxy.managers.hdas.
HDAManager
[source]¶ Bases:
galaxy.managers.base.ModelManager
Interface/service object for interacting with HDAs.
-
can_access_dataset
(trans, hda)[source]¶ Use security agent to see if current user has access to dataset.
-
get
(trans, unencoded_id, check_ownership=True, check_accessible=True)[source]¶ Get an HDA by its unencoded db id, checking ownership (via its history) or accessibility (via dataset shares/permissions).
-
get_hda_dict_with_error
(trans, hda=None, history_id=None, id=None, error_msg='Error')[source]¶ Return truncated serialization of HDA when error raised getting details.
-
get_inaccessible_hda_dict
(trans, hda)[source]¶ Return truncated serialization of HDA when inaccessible to user.
-
-
class
galaxy.managers.hdas.
HistorySerializer
[source]¶ Bases:
galaxy.managers.base.ModelSerializer
Interface/service object for serializing HDAs into dictionaries.
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
(*args, **kwargs)[source]¶ Bases:
galaxy.managers.base.ModelManager
Interface/service object for interacting with HDAs.
-
by_user
(trans, user=None, include_deleted=False, only_deleted=False)[source]¶ Get all the histories for a given user (defaulting to trans.user) ordered by update time and filtered on whether they’ve been deleted.
-
check_accessible
(trans, history)[source]¶ Raises error if the current user can’t access the history.
-
check_ownership
(trans, history)[source]¶ Raises error if the current user is not the owner of the history.
-
get
(trans, unencoded_id, check_ownership=True, check_accessible=True, deleted=None)[source]¶ Get a History from the database by id, verifying ownership.
-
get_history_dict
(trans, history, contents_dictionaries=None)[source]¶ Returns history data in the form of a dictionary.
-
-
class
galaxy.managers.histories.
HistorySerializer
[source]¶ Bases:
galaxy.managers.base.ModelSerializer
Interface/service object for serializing histories into dictionaries.
lddas
Module¶
-
class
galaxy.managers.lddas.
LDDAManager
[source]¶ Bases:
galaxy.managers.base.ModelManager
A fairly sparse manager for LDDAs.
libraries
Module¶
Manager and Serializer for libraries.
-
class
galaxy.managers.libraries.
LibraryManager
(*args, **kwargs)[source]¶ Bases:
object
Interface/service object for interacting with libraries.
-
delete
(trans, library, undelete=False)[source]¶ Mark given library deleted/undeleted based on the flag.
-
get
(trans, decoded_library_id, check_accessible=True)[source]¶ Get the library from the DB.
Parameters: - decoded_library_id (int) – decoded library id
- check_accessible (bool) – flag whether to check that user can access item
Returns: the requested library
Return type:
-
get_current_roles
(trans, library)[source]¶ Load all permissions currently related to the given library.
Parameters: library (Library) – the model object Return type: dictionary Returns: dict of current roles for all available permission types
-
get_library_dict
(trans, library)[source]¶ Return library data in the form of a dictionary.
Parameters: library (Library) – library Returns: dict with data about the library Return type: dictionary
-
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 onlynon-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.
Parameters: - folder (Library) – library
- check_accessible (bool) – flag whether to check that user can access library
Returns: the original folder
Return type:
-
roles
Module¶
Manager and Serializer for Roles.
tags
Module¶
Bases:
object
Manages CRUD operations related to tagging objects.
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.