#6090 [BUG] FlyteFile from a remote path should be read correctly in a task
Issue created by
Future-Outlier
Describe the bug
right now, this can't work.
from flytekit import task, workflow
from flytekit.types.file import FlyteFile
@task
def create_ff() -> FlyteFile:
full_s3_path = "
s3://my-s3-bucket/test.json"
ff = FlyteFile(full_s3_path)
with open(ff, "r") as f:
content = f.read()
print(content)
print(type(content))
return ff
Expected behavior
This should work.
Additional context to reproduce
Error message
/Users/future-outlier/miniconda3/envs/dev/bin/python /Users/future-outlier/code/dev/flytekit/build/dataclass_remote_api/json_example.py
23
0524.489138 INFO file.py:252 - Using flytectl/YAML config
/Users/future-outlier/.flyte/config-sandbox.yaml
23
0526.822284 INFO utils.py:344 - AsyncTranslate literal to python value.
[Time: 0.000002s]
23
0526.823714 INFO utils.py:344 - Translate literal to python value.
[Time: 0.001452s]
23
0526.824123 INFO base_task.py:751 - Invoking json_example.create_ff with
inputs: {}
23
0526.824461 INFO utils.py:344 - Execute user level code. [Time:
0.000017s]
╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /Users/future-outlier/code/dev/flytekit/build/dataclass_remote_api/json_exam │
│ ple.py:32 in <module> │
│ │
│ ❱ 32 │ wf() │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/workflow.py:308 in │
│
call │
│ │
│ ❱ 308 │ │ │ raise exc │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/workflow.py:301 in │
│
call │
│ │
│ ❱ 301 │ │ │ return flyte_entity_call_handler(self, *args, **input_kwar │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/promise.py:1459 in │
│ flyte_entity_call_handler │
│ │
│ ❱ 1459 │ │ │ result = cast(LocallyExecutable, entity).local_execute(ch │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/workflow.py:327 in │
│ local_execute │
│ │
│ ❱ 327 │ │ function_outputs = self.execute(**kwargs_literals) │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/workflow.py:829 in │
│ execute │
│ │
│ ❱ 829 │ │ return self._workflow_function(**kwargs) │
│ │
│ /Users/future-outlier/code/dev/flytekit/build/dataclass_remote_api/json_exam │
│ ple.py:27 in wf │
│ │
│ ❱ 27 │ ff = create_ff() │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/base_task.py:364 in │
│
call │
│ │
│ ❱ 364 │ │ return flyte_entity_call_handler(self, *args, **kwargs) # typ │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/promise.py:1451 in │
│ flyte_entity_call_handler │
│ │
│ ❱ 1451 │ │ │ return cast(LocallyExecutable, entity).local_execute(ctx, │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/base_task.py:341 in │
│ local_execute │
│ │
│ ❱ 341 │ │ │ outputs_literal_map = self.sandbox_execute(ctx, input_lite │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/base_task.py:421 in │
│ sandbox_execute │
│ │
│ ❱ 421 │ │ return self.dispatch_execute(ctx, input_literal_map) │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/base_task.py:754 in │
│ dispatch_execute │
│ │
│ ❱ 754 │ │ │ │ │ native_outputs = self.execute(**native_inputs) │
│ │
│ /Users/future-outlier/code/dev/flytekit/flytekit/core/python_function_task.p │
│ y:204 in execute │
│ │
│ ❱ 204 │ │ │ return self._task_function(**kwargs) │
│ │
│ /Users/future-outlier/code/dev/flytekit/build/dataclass_remote_api/json_exam │
│ ple.py:10 in create_ff │
│ │
│ ❱ 10 │ with open(ff, "r") as f: │
╰──────────────────────────────────────────────────────────────────────────────╯
FileNotFoundError: [Errno 2] No such file or directory:
'
s3://my-s3-bucket/test.json'
Process finished with exit code 1
Screenshots
No response
Are you sure this issue hasn't been raised already?
• Yes
Have you read the Code of Conduct?
• Yes
flyteorg/flyte