def __init__(
        self,
        bucket: str,
        basedir: PathType,
        resource_dir: Optional[PathType] = None,
        source_dir: Optional[PathType] = None,
        priority: Optional[int] = DEFAULT_GCS_PRIORITY,
    ):
        """Constructor for a GoogleCloudStorageObserver 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.
            Needs to be a valid bucket name without 'gs://'
        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
        """
        if not _is_valid_bucket(bucket):
            raise ValueError(
                "Your chosen bucket name doesn't follow Google Cloud Storage bucket naming rules"
            )
        resource_dir = resource_dir or "/".join([basedir, "_resources"])
        source_dir = source_dir or "/".join([basedir, "_sources"])

        self.basedir = basedir
        self.bucket_id = bucket

        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 = {}

        from google.cloud import storage
        import google.auth.exceptions

        try:
            client = storage.Client()
        except google.auth.exceptions.DefaultCredentialsError as e:
            raise ConnectionError(
                "Could not create Google Cloud Storage observer, are you "
                "sure that you have set environment variable GOOGLE_APPLICATION_CREDENTIALS?"
            ) from e

        self.bucket = client.bucket(bucket)
Constructor for a GoogleCloudStorageObserver 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.
            Needs to be a valid bucket name without 'gs://'
        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
        
sacred/observers/gcs_observer.py