This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from upath import UPath | |
def directories_with_boto3( | |
bucket: str, prefix: str, protocol: str = "s3" | |
) -> list[UPath] | None: | |
"""List the top level directories in the S3 bucket relative to the provided prefix.""" | |
path = UPath(bucket + prefix, protocol=protocol) | |
contents = [content for content in path.iterdir() if content.is_dir()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
from typing import Callable | |
def compose(*functions: Callable) -> Callable: | |
return functools.reduce(lambda f, g: lambda x: g(f(x)), functions) | |
def add_four(x): | |
return x + 4 |