Hello Flyte community. I am testing reference task...
# flyte-support
b
Hello Flyte community. I am testing reference tasks and keep getting an error about container_image which isn't mentioned in the documentation. details and trace in thread
*AttributeError:* 'ReferenceTask' object has no attribute '_container_image'
The first step was to register the tasks with
pyflyte register --image ****:latest tasks
I used the name and version from this output for the reference_task below The code for the workflow is
Copy code
from flytekit import reference_task, workflow, Resources

@reference_task(
    project="myproj",
    domain="development",
    name="tasks.helloworld.print_hello_world",
    version=[version from pyflyte register]
)
def ref_print_hello_world() -> str:
    ...


@reference_task(
    project="myproj",
    domain="development",
    name="tasks.todaysdate.print_date",
    version=[version from pyflyte register]
)
def ref_print_date() -> str:
    ...


@workflow
def test() -> str:

    today_is = ref_print_date()
    msg = ref_print_hello_world()
    response = f'test, {msg}\n' 
    response += f'Today is: {today_is}\n'
    return response
then example of task
Copy code
@task(cache=False, requests=Resources(mem="2Gi"), limits=Resources(mem="5Gi")
)
def print_hello_world() -> str:
    """ Say Hello World """
    return "Hello World"
Copy code
Failed with Unknown Exception <class 'AttributeError'> Reason: 'ReferenceTask' object has no attribute '_container_image'
Traceback:
  File "....../python3.11/site-packages/flytekit/clis/sdk_in_container/utils.py", line 141, in invoke
    return super().invoke(ctx)
           ^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/flytekit/clis/sdk_in_container/run.py", line 558, in _run
    remote_entity = remote.register_script(
                    ^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/flytekit/remote/remote.py", line 1048, in register_script
    md5_bytes, serialization_settings, default_inputs, *_get_image_names(entity)
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/flytekit/remote/remote.py", line 1036, in _get_image_names
    image_names.extend(_get_image_names(n.flyte_entity))
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/flytekit/remote/remote.py", line 1031, in _get_image_names
    if isinstance(entity, PythonAutoContainerTask) and isinstance(entity.container_image, ImageSpec):
                                                                  ^^^^^^^^^^^^^^^^^^^^^^

  File "....../python3.11/site-packages/flytekit/core/python_auto_container.py", line 126, in container_image
    return self._container_image
t
this is a bug…
it shouldn’t be trying to look up the image. it’s doing that just to see if it needs to build an image.
but one should’ve already been built.
@glamorous-carpet-83516 right?
b
it shouldn't and the tasks are already registered with a custom image
g
it should. we’re fixing it now
🙌 1
b
What I am attempting to do is use pre-registered tasks, or say "run this compiled task in this container" from a workflow
g
we will merge it tomorrow. you can install it from my branch
👍 1
probably cut a beta release next week.
b
Thank you
t
actually we will be cutting a patch release for this today.
👏 1
thanks for reporting this @boundless-lifeguard-61788
b
@thankful-minister-83577 reference tasks work as expected now. Thank you