shy-needle-81848
12/06/2024, 12:30 PMTypeError: FlyteFile.__init__() missing 1 required positional argument: 'path'
Code - ff_uploaded = FlyteFile(full_s3_path).from_json(json_data)
Can you help me to understand the use of these methods. I appreciate your help in advancedamp-lion-88352
12/06/2024, 1:16 PMdamp-lion-88352
12/06/2024, 1:16 PMFlyteFile(full_s3_path)
has the method from_json
shy-needle-81848
12/06/2024, 1:25 PMdamp-lion-88352
12/06/2024, 1:26 PMdamp-lion-88352
12/06/2024, 1:26 PMdamp-lion-88352
12/06/2024, 1:27 PMdamp-lion-88352
12/06/2024, 1:39 PM# FlyteFile("<s3://my-s3-bucket/s3_flyte_dir/test.json>")
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_uploaded = FlyteFile(full_s3_path)
return ff_uploaded
@task
def read_ff(ff: FlyteFile):
with open(ff, "r") as f:
print(f.read())
@workflow
def wf():
ff = create_ff()
read_ff(ff=ff)
if __name__ == "__main__":
wf()
damp-lion-88352
12/06/2024, 1:39 PMdamp-lion-88352
12/06/2024, 1:40 PMdamp-lion-88352
12/06/2024, 1:40 PM/Users/future-outlier/miniconda3/envs/dev/bin/python /Users/future-outlier/code/dev/flytekit/build/dataclass_remote_api/json_example.py
21:40:04.824460 INFO file.py:252 - Using flytectl/YAML config
/Users/future-outlier/.flyte/config-sandbox.yaml
21:40:05.927694 INFO utils.py:344 - AsyncTranslate literal to python value.
[Time: 0.000002s]
21:40:05.929111 INFO utils.py:344 - Translate literal to python value.
[Time: 0.001436s]
21:40:05.929437 INFO base_task.py:751 - Invoking json_example.create_ff with
inputs: {}
21:40:05.929748 INFO utils.py:344 - Execute user level code. [Time:
0.000005s]
21:40:05.930230 INFO utils.py:344 - Translate the output to literals. [Time:
0.000136s]
21:40:05.930558 INFO utils.py:344 - dispatch execute. [Time: 0.000513s]
21:40:05.931275 INFO utils.py:344 - AsyncTranslate literal to python value.
[Time: 0.000001s]
21:40:05.931707 INFO utils.py:344 - Translate literal to python value.
[Time: 0.000439s]
21:40:05.932003 INFO base_task.py:751 - Invoking json_example.read_ff with
inputs: {'ff':
/var/folders/3z/bsm4cddd4q18b_jc_2b2my4h0000gn/T/flyte-
2n5ewe9c/sandbox/local_flytekit/02dc0ddab7f02d4e2dba409
d0d639b43/test.json}
21:40:05.933685 INFO data_persistence.py:308 - Getting
<s3://my-s3-bucket/test.json> to
/var/folders/3z/bsm4cddd4q18b_jc_2b2my4h0000gn/T/flyte-
2n5ewe9c/sandbox/local_flytekit/02dc0ddab7f02d4e2dba409
d0d639b43/test.json
21:40:06.003664 INFO utils.py:344 - Download data to local from
<s3://my-s3-bucket/test.json>. [Time: 0.071184s]
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
21:40:06.004358 INFO utils.py:344 - Execute user level code. [Time:
0.071975s]
21:40:06.004840 INFO utils.py:344 - Translate the output to literals. [Time:
0.000006s]
21:40:06.005226 INFO utils.py:344 - dispatch execute. [Time: 0.000455s]
Process finished with exit code 0
damp-lion-88352
12/06/2024, 1:40 PMshy-needle-81848
12/06/2024, 2:05 PMdamp-lion-88352
12/06/2024, 2:05 PMdamp-lion-88352
12/06/2024, 2:05 PMDataClassJSONMixin
damp-lion-88352
12/06/2024, 2:06 PMDataClassJSONMixin
's apidamp-lion-88352
12/06/2024, 2:06 PMshy-needle-81848
12/06/2024, 2:08 PM