rough-sugar-4818
11/20/2023, 3:55 PMs3fs
). I tried to use FlyteFile("s3://....")
(or FlyteDirectory
) and the .download()
method but ... nothing happens (which is not what I expected haha).
Reading through the source code, I guess there is a clever way to leverage the machinery of flytekit to have a proper initialization of FlyteFile
or FlyteDirectory
in the context of a notebook (maybe using flytekit.current_context()
?), but I'm a bit lost.
Is there a clever way to prototype code in a notebook using native Flyte objects ? Am I the only one trying to work that way with Flyte ? Otherwise how do you prototype code ?freezing-airport-6809
freezing-airport-6809
rough-sugar-4818
11/20/2023, 4:08 PMrough-sugar-4818
11/20/2023, 4:55 PMyou could always download data using Flyte remote.Using
FlyteRemote
, I'm able to do something like that:
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config
from tempfile import mktemp
flyteremote = FlyteRemote(config=Config.auto())
uri = "s3://..."
tmpfile = mktemp()
flyteremote.file_access.get_data(local_path=tmpfile, remote_path=uri)
rough-sugar-4818
11/20/2023, 4:56 PMrough-sugar-4818
11/20/2023, 4:57 PMrough-sugar-4818
11/20/2023, 7:53 PMfrom flytekit.remote import FlyteRemote
from flytekit.types.directory import FlyteDirectory
from flytekit.types.file import FlyteFile
from flytekit.configuration import Config
from tempfile import mktemp, mkdtemp
def download_flyte_directory(uri):
flyteremote = FlyteRemote(config=Config.auto())
tmp_directory = mkdtemp()
flyteremote.file_access.download_directory(local_path=tmp_directory, remote_path=uri)
return FlyteDirectory(tmp_directory)
def download_flyte_file(uri):
flyteremote = FlyteRemote(config=Config.auto())
tmp_file = mktemp()
flyteremote.file_access.download(local_path=tmp_file, remote_path=uri)
return FlyteFile(tmp_file)
my_flyte_file = download_flyte_file("<s3://this_is_a_file.txt>")
my_flyte_directory = download_flyte_directory("<s3://this_is_a_directory/>")
rough-bird-62435
01/10/2024, 8:42 AMfreezing-airport-6809
freezing-airport-6809
rough-bird-62435
01/10/2024, 3:41 PMfreezing-airport-6809
square-electrician-23399
01/10/2024, 4:09 PMfreezing-airport-6809
rough-bird-62435
01/11/2024, 5:02 PM