shy-needle-81848
11/26/2024, 8:16 AMTypeError: Object of type FlyteFile is not JSON serializable
I am getting the same error even if I create a JSON file locally first and then pass S3 URL as remote_path. Any help would be appreciated. Thank youfreezing-airport-6809
shy-needle-81848
11/26/2024, 5:46 PMdef create_flyte_file(data, file_name):
full_s3_path = f"{s3_prefix}{s3_bucket}/{s3_path}/{file_name}"
local_path = os.path.join(flytekit.current_context().working_directory, file_name)
with open(local_path, 'w') as w:
json.dump(data, w)
return FlyteFile(path=local_path, remote_path=full_s3_path)
glamorous-carpet-83516
11/27/2024, 8:27 PMdef create_flyte_file(data, file_name):
full_s3_path = f"/tmp/123"
local_path = os.path.join(flytekit.current_context().working_directory, file_name)
with open(local_path, 'w') as w:
json.dump(data, w)
return FlyteFile(path=local_path, remote_path=full_s3_path)
@task
def t1() -> FlyteFile:
return create_flyte_file({"a": 1, "b": 2}, "test.json")
if __name__ == '__main__':
t1()
glamorous-carpet-83516
11/27/2024, 8:27 PMshy-needle-81848
11/29/2024, 5:10 AMFlyteFile
outside of a Flyte task, such as in a regular Python function, Flyte's automatic data management features are not triggered.glamorous-carpet-83516
11/29/2024, 6:22 AMglamorous-carpet-83516
11/29/2024, 6:22 AMflytefile.upload()
shy-needle-81848
11/29/2024, 3: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 advance