Warning

This document is for an in-development version 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.

Source code for galaxy.managers.display_applications

import logging
from typing import Optional
from urllib.parse import unquote_plus

from pydantic import BaseModel

from galaxy.datatypes.display_applications.util import (
    decode_dataset_user,
    encode_dataset_user,
)
from galaxy.datatypes.registry import Registry
from galaxy.exceptions import MessageException
from galaxy.managers.context import ProvidesUserContext
from galaxy.structured_app import StructuredApp

log = logging.getLogger(__name__)


[docs] class CreateLinkStep(BaseModel): name: str state: Optional[str] = None ready: Optional[bool] = False
[docs] class CreateLinkFeedback(BaseModel): messages: Optional[list[tuple[str, str]]] = None refresh: Optional[bool] = False resource: Optional[str] = None preparable_steps: Optional[list[CreateLinkStep]] = None
[docs] class CreateLinkIncoming(BaseModel): app_name: str dataset_id: str link_name: str kwd: Optional[dict[str, str]] = None
[docs] class DisplayApplication(BaseModel): id: str name: str version: str filename_: str links: list[Link]
[docs] class ReloadFeedback(BaseModel): message: str reloaded: list[Optional[str]] failed: list[Optional[str]]
[docs] class DisplayApplicationsManager: """Interface/service object for sharing logic between controllers."""
[docs] def __init__(self, app: StructuredApp): self._app = app
@property def datatypes_registry(self) -> Registry: return self._app.datatypes_registry
[docs] def index(self) -> list[DisplayApplication]: """ Returns the list of display applications. :returns: list of available display applications :rtype: list """ rval = [] for display_app in self.datatypes_registry.display_applications.values(): rval.append( DisplayApplication( id=display_app.id, name=display_app.name, version=display_app.version, filename_=display_app._filename, links=[Link(name=link.name) for link in display_app.links.values()], ) ) return rval
[docs] def reload(self, ids: list[str]) -> ReloadFeedback: """ Reloads the list of display applications. :param ids: list containing ids of display to be reloaded :type ids: list """ self._app.queue_worker.send_control_task( "reload_display_application", noop_self=True, kwargs={"display_application_ids": ids} ) reloaded, failed = self.datatypes_registry.reload_display_applications(ids) if not reloaded and failed: message = 'Unable to reload any of the {} requested display applications ("{}").'.format( len(failed), '", "'.join(failed), ) elif failed: message = ( 'Reloaded {} display applications ("{}"), but failed to reload {} display applications ("{}").'.format( len(reloaded), '", "'.join(reloaded), len(failed), '", "'.join(failed) ) ) elif not reloaded: message = "You need to request at least one display application to reload." else: message = 'Reloaded {} requested display applications ("{}").'.format(len(reloaded), '", "'.join(reloaded)) return ReloadFeedback(message=message, reloaded=reloaded, failed=failed)
def _can_access_dataset(self, trans, dataset_association, allow_admin=True, additional_roles=None): roles = trans.get_current_user_roles() if additional_roles: roles = roles + additional_roles return (allow_admin and trans.user_is_admin) or trans.app.security_agent.can_access_dataset( roles, dataset_association.dataset )