Example #1
0
 def list_task_executions_paginated(
     self,
     node_execution_identifier,
     limit=100,
     token=None,
     filters=None,
     sort_by=None,
 ):
     """
     :param flytekit.models.core.identifier.NodeExecutionIdentifier node_execution_identifier:
     :param int limit:
     :param Text token: [Optional] If specified, this specifies where in the rows of results to skip before reading.
     If you previously retrieved a page response with token="foo" and you want the next page,
     specify token="foo".
     :param list[flytekit.models.filters.Filter] filters:
     :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
     :rtype: (list[flytekit.models.admin.task_execution.TaskExecution], Text)
     """
     exec_list = super(
         SynchronousFlyteClient, self).list_task_executions_paginated(
             _task_execution_pb2.TaskExecutionListRequest(
                 node_execution_id=node_execution_identifier.to_flyte_idl(),
                 limit=limit,
                 token=token,
                 filters=_filters.FilterList(filters or []).to_flyte_idl(),
                 sort_by=None
                 if sort_by is None else sort_by.to_flyte_idl(),
             ))
     return (
         [
             _task_execution.TaskExecution.from_flyte_idl(e)
             for e in exec_list.task_executions
         ],
         _six.text_type(exec_list.token),
     )
Example #2
0
 def list_node_executions_for_task_paginated(
     self,
     task_execution_identifier,
     limit=100,
     token=None,
     filters=None,
     sort_by=None,
 ):
     """
     This returns nodes spawned by a specific task execution.  This is generally from things like dynamic tasks.
     :param flytekit.models.core.identifier.TaskExecutionIdentifier task_execution_identifier:
     :param int limit: Number to return per page
     :param Text token: [Optional] If specified, this specifies where in the rows of results to skip before reading.
     If you previously retrieved a page response with token="foo" and you want the next page,
     specify token="foo".
     :param list[flytekit.models.filters.Filter] filters:
     :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
     :rtype: list[flytekit.models.node_execution.NodeExecution], Text
     """
     exec_list = self._stub.ListNodeExecutionsForTask(
         _node_execution_pb2.NodeExecutionForTaskListRequest(
             task_execution_id=task_execution_identifier.to_flyte_idl(),
             limit=limit,
             token=token,
             filters=_filters.FilterList(filters or []).to_flyte_idl(),
             sort_by=None if sort_by is None else sort_by.to_flyte_idl(),
         ))
     return (
         [
             _node_execution.NodeExecution.from_flyte_idl(e)
             for e in exec_list.node_executions
         ],
         _six.text_type(exec_list.token),
     )
Example #3
0
def test_filter_list():
    fl = filters.FilterList([
        filters.Equal("domain", "staging"),
        filters.NotEqual("project", "FakeProject")
    ])

    assert fl.to_flyte_idl() == "eq(domain,staging)+neq(project,FakeProject)"
Example #4
0
    def list_launch_plans_paginated(self,
                                    identifier,
                                    limit=100,
                                    token=None,
                                    filters=None,
                                    sort_by=None):
        """
        This returns a page of launch plan meta-information for launch plans in a given project and domain.  Optionally,
        specifying a name will limit the results to only workflows with that name in the given project and domain.

        .. note ::

            This is a paginated API.  Use the token field in the request to specify a page offset token.
            The user of the API is responsible for providing this token.

        .. note ::

            If entries are added to the database between requests for different pages, it is possible to receive
            entries on the second page that also appeared on the first.

        :param flytekit.models.common.NamedEntityIdentifier identifier: NamedEntityIdentifier to list.
        :param int limit: [Optional] The maximum number of entries to return.  Must be greater than 0.  The maximum
            page size is determined by the Flyte Admin Service configuration.  If limit is greater than the maximum
            page size, an exception will be raised.
        :param int token: [Optional] If specified, this specifies where in the rows of results to skip before reading.
            If you previously retrieved a page response with token="foo" and you want the next page,
            specify token="foo". Please see the notes for this function about the caveats of the paginated API.
        :param list[flytekit.models.filters.Filter] filters: [Optional] If specified, the filters will be applied to
            the query.  If the filter is not supported, an exception will be raised.
        :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
        :raises: TODO
        :rtype: list[flytekit.models.launch_plan.LaunchPlan], str
        """
        lp_list = super(
            SynchronousFlyteClient, self).list_launch_plans_paginated(
                resource_list_request=_common_pb2.ResourceListRequest(
                    id=identifier.to_flyte_idl(),
                    limit=limit,
                    token=token,
                    filters=_filters.FilterList(filters or []).to_flyte_idl(),
                    sort_by=None if sort_by is None else sort_by.to_flyte_idl(
                    ),
                ))
        # TODO: tmp workaround
        for pb in lp_list.launch_plans:
            pb.id.resource_type = _identifier.ResourceType.LAUNCH_PLAN
        return (
            [
                _launch_plan.LaunchPlan.from_flyte_idl(pb)
                for pb in lp_list.launch_plans
            ],
            _six.text_type(lp_list.token),
        )
Example #5
0
    def list_executions_paginated(self,
                                  project,
                                  domain,
                                  limit=100,
                                  token=None,
                                  filters=None,
                                  sort_by=None):
        """
        This returns a page of executions in a given project and domain.

        .. note ::

            This is a paginated API.  Use the token field in the request to specify a page offset token.
            The user of the API is responsible for providing this token.

        .. note ::

            If entries are added to the database between requests for different pages, it is possible to receive
            entries on the second page that also appeared on the first.

        :param Text project: Project in which to list executions.
        :param Text domain: Project in which to list executions.
        :param int limit: [Optional] The maximum number of entries to return.  Must be greater than 0.  The maximum
            page size is determined by the Flyte Admin Service configuration.  If limit is greater than the maximum
            page size, an exception will be raised.
        :param Text token: [Optional] If specified, this specifies where in the rows of results to skip before reading.
            If you previously retrieved a page response with token="foo" and you want the next page,
            specify token="foo". Please see the notes for this function about the caveats of the paginated API.
        :param list[flytekit.models.filters.Filter] filters: [Optional] If specified, the filters will be applied to
            the query.  If the filter is not supported, an exception will be raised.
        :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
        :raises: TODO
        :rtype: (list[flytekit.models.execution.Execution], Text)
        """
        exec_list = super(
            SynchronousFlyteClient, self).list_executions_paginated(
                resource_list_request=_common_pb2.ResourceListRequest(
                    id=_common_pb2.NamedEntityIdentifier(project=project,
                                                         domain=domain),
                    limit=limit,
                    token=token,
                    filters=_filters.FilterList(filters or []).to_flyte_idl(),
                    sort_by=None if sort_by is None else sort_by.to_flyte_idl(
                    ),
                ))
        return (
            [
                _execution.Execution.from_flyte_idl(pb)
                for pb in exec_list.executions
            ],
            _six.text_type(exec_list.token),
        )
Example #6
0
    def list_node_executions(
        self,
        workflow_execution_identifier,
        limit: int = 100,
        token: typing.Optional[str] = None,
        filters: typing.List[_filters.Filter] = None,
        sort_by: _admin_common.Sort = None,
        unique_parent_id: str = None,
    ):
        """Get node executions associated with a given workflow execution.

        :param flytekit.models.core.identifier.WorkflowExecutionIdentifier workflow_execution_identifier:
        :param limit: Limit the number of items returned in the response.
        :param token: If specified, this specifies where in the rows of results to skip before reading.
            If you previously retrieved a page response with token="foo" and you want the next page,
            specify ``token="foo"``.
        :param list[flytekit.models.filters.Filter] filters:
        :param flytekit.models.admin.common.Sort sort_by: [Optional] If provided, the results will be sorted.
        :param unique_parent_id: If specified, returns the node executions for the ``unique_parent_id`` node id.
        :rtype: list[flytekit.models.node_execution.NodeExecution], Text
        """
        exec_list = super(
            SynchronousFlyteClient, self).list_node_executions_paginated(
                _node_execution_pb2.NodeExecutionListRequest(
                    workflow_execution_id=workflow_execution_identifier.
                    to_flyte_idl(),
                    limit=limit,
                    token=token,
                    filters=_filters.FilterList(filters or []).to_flyte_idl(),
                    sort_by=None
                    if sort_by is None else sort_by.to_flyte_idl(),
                    unique_parent_id=unique_parent_id,
                ))
        return (
            [
                _node_execution.NodeExecution.from_flyte_idl(e)
                for e in exec_list.node_executions
            ],
            _six.text_type(exec_list.token),
        )