Пример #1
0
    def get_ranking(self,
                    workflow_id: str,
                    order_by: Optional[List[SortColumn]] = None,
                    include_all: Optional[bool] = False) -> Dict:
        """Get serialization of the evaluation ranking for the given workflow.

        Parameters
        ----------
        workflow_id: string
            Unique workflow identifier
        order_by: list(flowserv.model.template.schema.SortColumn), default=None
            Use the given attribute to sort run results. If not given, the
            schema default sort order is used
        include_all: bool, default=False
            Include all entries (True) or at most one entry (False) per user
            group in the returned ranking

        Returns
        -------
        dict
        """
        # Create query string for the order by clause.
        q_order_by = list()
        if order_by is not None:
            for col in order_by:
                c = '{}:{}'.format(col.column_id,
                                   'DESC' if col.sort_desc else 'ASC')
                q_order_by.append(c)
        url = self.urls(route.LEADERBOARD_GET,
                        workflowId=workflow_id,
                        orderBy=','.join(q_order_by),
                        includeAll=include_all)
        return get(url=url)
Пример #2
0
    def list_workflows(self) -> Dict:
        """Get serialized listing of descriptors for all workflows in the
        repository.

        Returns
        -------
        dict
        """
        return get(url=self.urls(route.WORKFLOWS_LIST))
Пример #3
0
    def list_groups(self, workflow_id: Optional[str] = None) -> Dict:
        """Get a listing of all workflow groups. The result contains only those
        groups that the user is a member of. If the workflow identifier is given
        as an additional filter, then the result contains a user's groups for
        that workflow only.

        Parameters
        ----------
        workflow_id: string, optional
            Unique workflow identifier

        Returns
        -------
        dict
        """
        # The request Url depends on whether a workflow identifier is given
        # or not.
        if workflow_id is not None:
            return get(
                url=self.urls(route.WORKFLOWS_GROUPS, workflowId=workflow_id))
        else:
            return get(url=self.urls(route.GROUPS_LIST))
Пример #4
0
    def get_group(self, group_id: str) -> Dict:
        """Get handle for workflow group with the given identifier.

        Parameters
        ----------
        group_id: string
            Unique workflow group identifier

        Returns
        -------
        dict
        """
        return get(url=self.urls(route.GROUPS_GET, userGroupId=group_id))
Пример #5
0
    def whoami_user(self, api_key: str) -> Dict:
        """Get serialization of the given user.

        Parameters
        ----------
        api_key: string
            API key for a logged-in user.

        Returns
        -------
        dict
        """
        return get(url=self.urls(route.USERS_WHOAMI))
Пример #6
0
    def list_users(self, query: Optional[str] = None) -> Dict:
        """Get a listing of registered users. The optional query string is used
        to filter users whose name starts with the given string.

        Parameters
        ----------
        query: string, default=None
            Prefix string to filter users based on their name.

        Returns
        -------
        dict
        """
        return get(url=self.urls(route.USERS_LIST))
Пример #7
0
    def get_run(self, run_id: str) -> Dict:
        """Get handle for the given run.

        Raises an unauthorized access error if the user does not have read
        access to the run.

        Parameters
        ----------
        run_id: string
            Unique run identifier

        Returns
        -------
        dict
        """
        return get(url=self.urls(route.RUNS_GET, runId=run_id))
Пример #8
0
    def get_workflow(self, workflow_id: str) -> Dict:
        """Get serialization of the handle for the given workflow.

        Parameters
        ----------
        workflow_id: string
            Unique workflow identifier

        Returns
        -------
        dict

        Raises
        ------
        flowserv.error.UnknownWorkflowError
        """
        return get(url=self.urls(route.WORKFLOWS_GET, workflowId=workflow_id))
Пример #9
0
    def list_uploaded_files(self, group_id: str) -> Dict:
        """Get a listing of all files that have been uploaded for the given
        workflow group.

        Parameters
        ----------
        group_id: string
            Unique workflow group identifier

        Returns
        -------
        dict

        Raises
        ------
        flowserv.error.UnauthorizedAccessError
        flowserv.error.UnknownWorkflowGroupError
        """
        return get(url=self.urls(route.FILES_LIST, userGroupId=group_id))
Пример #10
0
    def list_runs(self, group_id: str, state: Optional[str] = None):
        """Get a listing of all run handles for the given workflow group.

        Raises an unauthorized access error if the user does not have read
        access to the workflow group.

        Parameters
        ----------
        group_id: string
            Unique workflow group identifier
        state: string, default=None
            State identifier query

        Returns
        -------
        dict
        """
        url = self.urls(route.GROUPS_RUNS, userGroupId=group_id, state=state)
        return get(url=url)