def __init__(
        self,
        bucket,
        basedir,
        resource_dir=None,
        source_dir=None,
        priority=DEFAULT_S3_PRIORITY,
        region=None,
    ):
        """Constructor for a S3Observer object.

        Run when the object is first created,
        before it's used within an experiment.

        Parameters
        ----------
        bucket
            The name of the bucket you want to store results in.
            Doesn't need to contain `s3://`, but needs to be a valid bucket name
        basedir
            The relative path inside your bucket where you want this experiment to store results
        resource_dir
            Where to store resources for this experiment. By
            default, will be <basedir>/_resources
        source_dir
            Where to store code sources for this experiment. By
            default, will be <basedir>/sources
        priority
            The priority to assign to this observer if
            multiple observers are present
        region
            The AWS region in which you want to create and access
            buckets. Needs to be either set here or configured in your AWS
        """
        import boto3

        if not _is_valid_bucket(bucket):
            raise ValueError(
                "Your chosen bucket name doesn't follow AWS bucket naming rules"
            )
        resource_dir = resource_dir or "/".join([basedir, "_resources"])
        source_dir = source_dir or "/".join([basedir, "_sources"])

        self.basedir = basedir
        self.bucket = bucket
        # Keeping the convention of referring to locations in S3 as `dir`
        # because that is a useful mental model and there isn't a better word
        self.resource_dir = resource_dir
        self.source_dir = source_dir
        self.priority = priority
        self.dir = None
        self.run_entry = None
        self.config = None
        self.info = None
        self.cout = ""
        self.cout_write_cursor = 0
        self.saved_metrics = {}
        if region is not None:
            self.region = region
            self.s3 = boto3.resource("s3", region_name=region)
        else:
            session = boto3.session.Session()
            if session.region_name is not None:
                self.region = session.region_name
                self.s3 = boto3.resource("s3")
            else:
                raise ValueError(
                    "You must either pass in an AWS region name, or have a "
                    "region name specified in your AWS config file"
                )
Constructor for a S3Observer object.

        Run when the object is first created,
        before it's used within an experiment.

        Parameters
        ----------
        bucket
            The name of the bucket you want to store results in.
            Doesn't need to contain `s3://`, but needs to be a valid bucket name
        basedir
            The relative path inside your bucket where you want this experiment to store results
        resource_dir
            Where to store resources for this experiment. By
            default, will be <basedir>/_resources
        source_dir
            Where to store code sources for this experiment. By
            default, will be <basedir>/sources
        priority
            The priority to assign to this observer if
            multiple observers are present
        region
            The AWS region in which you want to create and access
            buckets. Needs to be either set here or configured in your AWS
        
sacred/observers/s3_observer.py