How to use the flyteidl.admin.task_pb2 function in flyteidl

To help you get started, we’ve selected a few flyteidl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lyft / flytekit / tests / flytekit / unit / common_tests / tasks / test_task.py View on Github external
def test_task_serialization():
    t = get_sample_task()
    with TemporaryConfiguration(
            _os.path.join(_os.path.dirname(_os.path.realpath(__file__)), '../../../common/configs/local.config'),
            internal_overrides={
                'image': 'myflyteimage:v123',
                'project': 'myflyteproject',
                'domain': 'development'
            }
    ):
        s = t.serialize()

    assert isinstance(s, _admin_task_pb2.TaskSpec)
    assert s.template.id.name == 'tests.flytekit.unit.common_tests.tasks.test_task.my_task'
    assert s.template.container.image == 'myflyteimage:v123'
github lyft / flytekit / flytekit / clis / flyte_cli / main.py View on Github external
"""
    _welcome_message()
    client = _friendly_client.SynchronousFlyteClient(host, insecure=insecure)
    files = list(files)
    files.sort()
    _click.secho("Parsing files...", fg='green', bold=True)
    for f in files:
        _click.echo(f"  {f}")

    flyte_entities_list = _extract_files(files)
    for id, flyte_entity in flyte_entities_list:
        try:
            if id.resource_type == _identifier_pb2.LAUNCH_PLAN:
                client.raw.create_launch_plan(_launch_plan_pb2.LaunchPlanCreateRequest(id=id, spec=flyte_entity))
            elif id.resource_type == _identifier_pb2.TASK:
                client.raw.create_task(_task_pb2.TaskCreateRequest(id=id, spec=flyte_entity))
            elif id.resource_type == _identifier_pb2.WORKFLOW:
                client.raw.create_workflow(_workflow_pb2.WorkflowCreateRequest(id=id, spec=flyte_entity))
            else:
                raise _user_exceptions.FlyteAssertion(f"Only tasks, launch plans, and workflows can be called with this function, "
                                      f"resource type {id.resource_type} was passed")
            _click.secho(f"Registered {id}", fg='green')
        except _user_exceptions.FlyteEntityAlreadyExistsException:
            _click.secho(f"Skipping because already registered {id}", fg='cyan')

    _click.echo(f"Finished scanning {len(flyte_entities_list)} files")
github lyft / flytekit / flytekit / models / task.py View on Github external
def to_flyte_idl(self):
        """
        :rtype: flyteidl.admin.task_pb2.TaskClosure
        """
        return _admin_task.TaskClosure(
            compiled_task=self.compiled_task.to_flyte_idl()
        )
github lyft / flytekit / flytekit / models / task.py View on Github external
def to_flyte_idl(self):
        """
        :rtype: flyteidl.admin.task_pb2.Task
        """
        return _admin_task.Task(
            closure=self.closure.to_flyte_idl(),
            id=self.id.to_flyte_idl(),
        )
github lyft / flytekit / flytekit / models / task.py View on Github external
def to_flyte_idl(self):
        """
        :rtype: flyteidl.admin.tasks_pb2.TaskSpec
        """
        return _admin_task.TaskSpec(
            template=self.template.to_flyte_idl()
        )
github lyft / flytekit / flytekit / clients / friendly.py View on Github external
.. note ::

            Overwrites are not supported so any request for a given project, domain, name, and version that exists in
            the database must match the existing definition exactly. Furthermore, as long as the request
            remains identical, calling this method multiple times will result in success.

        :param flytekit.models.core.identifier.Identifier task_identifer: The identifier for this task.
        :param flytekit.models.task.TaskSpec task_spec: This is the actual definition of the task that
            should be created.
        :raises flytekit.common.exceptions.user.FlyteEntityAlreadyExistsException: If an identical version of the
            task is found, this exception is raised.  The client might choose to ignore this exception because the
            identical task is already registered.
        :raises grpc.RpcError:
        """
        super(SynchronousFlyteClient, self).create_task(
            _task_pb2.TaskCreateRequest(
                id=task_identifer.to_flyte_idl(),
                spec=task_spec.to_flyte_idl()
            )