F

Flyte enables you to build & deploy data & ML pipelines, hassle-free. The infinitely scalable and flexible workflow orchestration platform that seamlessly unifies data, ML and analytics stacks. Explore and Join the Flyte Community!

Guidance on ShellTask Resource Overriding

Summary

The user is seeking guidance on overriding task resources for a ShellTask and has encountered a warning about nested tasks when invoking a ShellTask from another task. They suspect the issue may be related to task configuration but cannot find relevant documentation. The user provides a code snippet for a ShellTask and a resource-requesting task, noting that calling a task from another task is generally unsupported, except in specific scenarios. They inquire about defining resources for a ShellTask and suggest using pod templates. The user also shares a solution code snippet for the ShellTask and mentions trying to use map_tasks with ShellTask, which resulted in an error indicating that ShellTasks require two default outputs, stdout and stderr. They question whether ShellTasks are simply running Python subprocesses and consider using a regular task that runs Python subprocesses instead of a ShellTask, asking about the advantages of ShellTasks.

Status
resolved
Tags
    Source
    #ask-the-community
      n

      nuhaj

      9/18/2024

      How can you override task resources to a shellTask? If I call a shelltask from another task I get a warning on the pod about nested tasks I think it might be task_config but can't find documentation

      shell_task = ShellTask(
          name="shell_task",
          debug=True,
          script="""
          {inputs.command} >> {outputs.stdout} 2>> {outputs.stderr}
          """,
          inputs=kwtypes(command=str),
          output_locs=[
              OutputLocation(var="stdout", var_type=FlyteFile, location="stdout.txt"),
              OutputLocation(var="stderr", var_type=FlyteFile, location="stderr.txt"),
          ],
      )
      
      @task(
          requests=Resources(cpu="4", mem="16Gi")
      )
      def call_shell_task(....```
      
      n

      nuhaj

      9/20/2024

      I have tried to use map_tasks with ShellTask. I don't think its supported, the error I got was the output, ShellTasks require two default outputs, stdout and stderr.

        Only tasks with a single output are supported in map tasks.```
      Are Shell tasks just running python subprocess?  <https://github.com/flyteorg/flytekit/blob/2dcbb90f7a331eb2d75a826053fc41f944ad4aa2/flytekit/extras/tasks/shell.py#L52>
      I can use a regular task that runs python subprocess instead of ShellTask and map that task. What advantages do ShellTasks have ?
      
      n

      nuhaj

      9/19/2024

      for anyone that makes it here via a search the solution is

          name="shell_task",
          debug=True,
          script="""
          {inputs.command} &gt;&gt; {outputs.stdout} 2&gt;&gt; {outputs.stderr}
          """,
          inputs=kwtypes(command=str),
          output_locs=[
              OutputLocation(var="stdout", var_type=FlyteFile, location="stdout.txt"),
              OutputLocation(var="stderr", var_type=FlyteFile, location="stderr.txt"),
          ],
      )```
      
      y

      ytong

      9/19/2024

      no these should be just args to the ShellTask constructor, just like inputs… they’re hidden by kwargs so you have to follow up the stack. And yeah, docs could use a boost

      n

      nuhaj

      9/19/2024

      I'm guessing thats by using task_config then. Its not well documented

      y

      ytong

      9/19/2024

      along with pod template and pod template name

      y

      ytong

      9/19/2024

      ShellTask should take requests/limits just like a function task.

      n

      nuhaj

      9/19/2024

      how would I define resources for a shell task ? I think it might be possible with pod templates

      y

      ytong

      9/19/2024

      the only time this is possible is in the dynamic case (because it becomes a new workflow) and in the eager case (wherein the parent task becomes its own orchestrator).

      y

      ytong

      9/19/2024

      in general, you shouldn’t call a task from within another task. this is not supported behavior.