# Buggy code
def inventory(self, cache: snakemake.io.IOCache):
    """Using client.list_blobs(), we want to iterate over the objects in
    the "folder" of a bucket and store information about the IOFiles in the
    provided cache (snakemake.io.IOCache) indexed by bucket/blob name.
    This will be called by the first mention of a remote object, and
    iterate over the entire bucket once (and then not need to again).
    This includes:
     - cache.exist_remote
     - cache_mtime
     - cache.size
    """
    subfolder = os.path.dirname(self.blob.name)
    for blob in self.client.list_blobs(self.bucket_name, prefix=subfolder):
        # By way of being listed, it exists. mtime is a datetime object
        name = "{}/{}".format(blob.bucket.name, blob.name)
        cache.exists_remote[name] = True
        cache.mtime[name] = blob.updated
        cache.size[name] = blob.size

    # Mark bucket and prefix as having an inventory, such that this method is
    # only called once for the subfolder in the bucket.
    cache.has_inventory.add("%s/%s" % (self.bucket_name, subfolder))


# Traceback (TypeError)
Traceback (most recent call last):
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/__init__.py", line 704, in snakemake
keepincomplete=keep_incomplete,
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/workflow.py", line 667, in execute
dag.init()
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/dag.py", line 182, in init
self.update_needrun()
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/dag.py", line 936, in update_needrun
update_needrun(job)
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/dag.py", line 912, in update_needrun
f for f in job.input if f.exists and f.is_newer(output_mintime_)
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/dag.py", line 912, in <listcomp>
f for f in job.input if f.exists and f.is_newer(output_mintime_)
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/io.py", line 195, in wrapper
return func(self, *args, **kwargs)
File "/home/hannes/miniconda3/envs/target-id/lib/python3.6/site-packages/snakemake/io.py", line 419, in is_newer
return self.mtime > time
TypeError: '>' not supported between instances of 'datetime.datetime' and 'float'

# Fixed code
def inventory(self, cache: snakemake.io.IOCache):
    """Using client.list_blobs(), we want to iterate over the objects in
    the "folder" of a bucket and store information about the IOFiles in the
    provided cache (snakemake.io.IOCache) indexed by bucket/blob name.
    This will be called by the first mention of a remote object, and
    iterate over the entire bucket once (and then not need to again).
    This includes:
     - cache.exist_remote
     - cache_mtime
     - cache.size
    """
    subfolder = os.path.dirname(self.blob.name)
    for blob in self.client.list_blobs(self.bucket_name, prefix=subfolder):
        # By way of being listed, it exists. mtime is a datetime object
        name = "{}/{}".format(blob.bucket.name, blob.name)
        cache.exists_remote[name] = True
        cache.mtime[name] = blob.updated.timestamp()
        cache.size[name] = blob.size

    # Mark bucket and prefix as having an inventory, such that this method is
    # only called once for the subfolder in the bucket.
    cache.has_inventory.add("%s/%s" % (self.bucket_name, subfolder))