Hi, can I change s3 bucket path in the code? I'm i...
# ask-community
j
Hi, can I change s3 bucket path in the code? I'm importing s3_block and storing the flow result to the bucket the problem is I want to store it to s3_path/result/{uuid}/ directory but it's storing on the top level of bucket. can I add the path in the code? like this?
Copy code
s3_block = S3.load('s3_test')
s3_block.append_path(f"result/{uuid}) <--- I'm finding any method like this
this is the example code what I use
Copy code
from prefect.filesystems import S3
s3_block = S3.load('s3_test')
@flow(name="main", persist_result=True, result_storage=s3_block)
def main():
    return "hello world"
c
Hi Jin, the
bucket_path
is an attribute that you can just set on the block: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/filesystems.py#L455-L459 So in your code it would be like:
Copy code
s3_block = S3.load('s3_test')
s3_block.bucket_path = "..."
I think you may want to save the block as well, depending on what you're doing, like:
Copy code
s3_block.save(overwrite=True)
j
Wow thank you so much! That is exactly what I want!
c
Awesome!