Is there a way to create ContainerTask with a stri...
# flyte-support
q
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
f
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?
q
but how do I pass the input to the command?
f
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
q
yeah, thought that something like that should be possible... the raw container example is way to complicated
f
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 @high-accountant-32689 fyi. Can we find the original example and keep that as well
@quaint-diamond-37493 all the {{.inputs.myinput}} is available
If myinput name is a string or primitive value it will auto expand
q
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
f
Worked
?
q
yeah, I had a typo:
imputs
instead of
inputs
thanks! But I do wonder why the container example doesn't use this simpler mechanism
f
It used to
Can you contribute one
h
That's a good idea. I brought them back in https://github.com/flyteorg/flytesnacks/pull/918
๐Ÿ‘ 2
166 Views