https://flyte.org logo
#ask-the-community
Title
# ask-the-community
f

Felix Ruess

11/03/2022, 2:37 PM
Is there a way to create ContainerTask with a string input and use that input in the command without writing cumbersome wrapper scripts which need to be part of the image? https://docs.flyte.org/projects/cookbook/en/stable/auto/core/containerization/raw_container.html#container-tasks
k

Ketan (kumare3)

11/03/2022, 2:37 PM
Yes
Just pass it in the command
Also this is an interesting point shell tasks should work- and they should carry your shell scripts - do they not?
For container tasks - In the command you can write the entire script - just use shelex to split it?
f

Felix Ruess

11/03/2022, 2:40 PM
but how do I pass the input to the command?
k

Ketan (kumare3)

11/03/2022, 2:40 PM
Or just write in one block
What do you mean, inputs are all files
Aah you can infact also pass the entire script as an input
You can use Flyte expansion system
Let me share
We used to have an example that shows how to use Flyte engines expansion system
f

Felix Ruess

11/03/2022, 2:45 PM
yeah, thought that something like that should be possible... the raw container example is way to complicated
k

Ketan (kumare3)

11/03/2022, 2:47 PM
Sadly it’s only in Godoc - we lost an example somewhere- I will try to find. But till then - https://pkg.go.dev/github.com/flyteorg/flyteplugins/go/tasks/pluginmachinery/core/template
Cc @Eduardo Apolinario (eapolinario) fyi. Can we find the original example and keep that as well
@Felix Ruess all the {{.inputs.myinput}} is available
If myinput name is a string or primitive value it will auto expand
f

Felix Ruess

11/03/2022, 3:18 PM
Hm... what am I missing?
Copy code
test_input = ContainerTask(
    name="test_container_input",
    image="<http://registry.roboception.de/tools/blender_scripts:testing|registry.roboception.de/tools/blender_scripts:testing>",
    requests=Resources(gpu="1"),
    imputs=kwtypes(objectname=str, dataset=str),
    command=shlex.split("echo {{.inputs.objectname}} {{.inputs.dataset}}")
)

@workflow
def wf(objectname: str):
    test_input(objectname=objectname, dataset="train")
just results in
ValueError: Received unexpected keyword argument objectname in function test_container_input
nevermind stupid typo
k

Ketan (kumare3)

11/03/2022, 3:46 PM
Worked
?
f

Felix Ruess

11/03/2022, 3:59 PM
yeah, I had a typo:
imputs
instead of
inputs
thanks! But I do wonder why the container example doesn't use this simpler mechanism
k

Ketan (kumare3)

11/03/2022, 5:37 PM
It used to
Can you contribute one
e

Eduardo Apolinario (eapolinario)

11/03/2022, 6:07 PM
That's a good idea. I brought them back in https://github.com/flyteorg/flytesnacks/pull/918