:pray:*URGENT HELP NEEDED!*:pray: Hi. Dear Communi...
# flyte-support
b
🙏*URGENT HELP NEEDED!*🙏 Hi. Dear Community! I was trying to run the steps of one workflow as container based ones. as described here. BTW when I was trying with the default images on that documentation page (e.x.
<http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2>
) it was ok with default inputs and outputs (e.x.
a:float, b:float, area:float, metadata:str
), BUT when I change them to FlyteFile or something else. it throws an error that "No Such File or Directory called
area
or
metadata
etc. I was thinking it's due to the image build. Is there anybody who has experience on this? or facing the same issues? Thank you.
a
Bear in mind that passing
FlyteDirectory
as input to RawContainer Tasks is not supported yet (it will be in the 1.14 release going out tomorrow)
I don't think it has to do with the base image. Could you share your code?
b
For example.
Copy code
--step definitiion--
save_to_csv = ContainerTask(
    name="save_to_csv_container",
    input_data_dir="/var/inputs",
    output_data_dir="/var/outputs",
    inputs=kwtypes(a=float, b=float),
    outputs=kwtypes(area=float, metadata=str),
    image="<http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2>",
    command=[
        "python",
        "main.py",
        "{{.inputs.a}}",
        "{{.inputs.b}}",
        "/var/outputs",
    ],
)
--main.py--
import sys

def write_output(output_dir, output_file, v):
    with open(f"{output_dir}/{output_file}", "w") as f:
        f.write(str(v))

def main(a, b, output_dir):
    write_output(output_dir, "area", str(float(5.0)))
    write_output(output_dir, "metadata", "[from python rawcontainer]")

if __name__ == "__main__":
    input_path = sys.argv[1]
    output_file = sys.argv[2]
    output_dir = sys.argv[3]

    main(input_path, output_file, output_dir)
This works but the below code doesn't work.
Copy code
--step definitiion--
save_to_csv = ContainerTask(
    name="save_to_csv_container",
    input_data_dir="/var/inputs",
    output_data_dir="/var/outputs",
    inputs=kwtypes(a=str, b=float),                              # a changed to str type
    outputs=kwtypes(area=float, metadata=str),
    image="<http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2>",
    command=[
        "python",
        "main.py",
        "{{.inputs.a}}",
        "{{.inputs.b}}",
        "/var/outputs",
    ],
)
--main.py--
import sys

def write_output(output_dir, output_file, v):
    with open(f"{output_dir}/{output_file}", "w") as f:
        f.write(str(v))

def main(a, b, output_dir):
    write_output(output_dir, "area", str(float(5.0)))
    write_output(output_dir, "metadata", "[from python rawcontainer]")

if __name__ == "__main__":
    input_path = sys.argv[1]
    output_file = sys.argv[2]
    output_dir = sys.argv[3]

    main(input_path, output_file, output_dir)
The code might look weird since I removed some parts. Of course I passed the
a
input to both code as each variable type.
@average-finland-92144 what do you reckon about the above? Thank you.
d
I’ll take a look today
Hi, @bitter-photographer-94114 can you do
docker run --it <http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2> /bin/sh
and
ls
to me?
I want to make sure
main.py
really exist
Copy code
(dev) future@outlier ~ % pyflyte run build/flytesnacks/examples/customizing_dependencies/customizing_dependencies/raw_container.py calculate_ellipse_area_python --a 1 --b 1.0
00:23:00.454852 INFO     file.py:252 - Using flytectl/YAML config /Users/future-outlier/.flyte/config-sandbox.yaml                 
Running Execution on local.
DefaultNamedTupleOutput(area=3.141592653589793, metadata='[from python rawcontainer]')
Copy code
calculate_ellipse_area_python = ContainerTask(
    name="ellipse-area-metadata-python",
    input_data_dir="/var/inputs",
    output_data_dir="/var/outputs",
    inputs=kwtypes(a=str, b=float),
    outputs=kwtypes(area=float, metadata=str),
    image="<http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2>",
    command=[
        "python",
        "calculate-ellipse-area.py",
        "{{.inputs.a}}",
        "{{.inputs.b}}",
        "/var/outputs",
    ],
    metadata=TaskMetadata(cache=True, cache_version="1.0"),
)
it works for me
e
To add your file that's not in the original image, you can use ImageSpec in image field. Like this:
Copy code
ContainerTask(
    name="save_to_csv_container",
    input_data_dir="/var/inputs",
    output_data_dir="/var/outputs",
    inputs=kwtypes(a=float, b=float),
    outputs=kwtypes(area=float, metadata=str),
    image=ImageSpec(
        registry="localhost:30000",
        base_image="<http://ghcr.io/flyteorg/rawcontainers-python:v2|ghcr.io/flyteorg/rawcontainers-python:v2>",
        copy=["main.py"],
    )
b
Can you check if this script is working on your side or not?
@damp-lion-88352 @average-finland-92144 Please check the above code. Thanks in advance!
a
sorry, none of those scripts work for me as is
Copy code
'flytekit.types.file.file.FlyteFile'>. Expected a file, but
hello.txt is not a file.
also try with
flytekit==1.14.0
b
You can add hello.txt file in the same folder with any content and try @average-finland-92144. That was just copying a simple file within python container which should work, but doesn't work.