def configure_object_sources()

in ssiog/training.py [0:0]


def configure_object_sources(args: argparse.Namespace) -> dict[str, Source]:
    sources = dict()
    for prefix in args.prefix:
        if prefix.startswith("gs://"):
            objects = fsspec.filesystem("gcs").ls(prefix.removeprefix("gs://"))
            sources[prefix] = Source("gcs", fs.GcsFileSystem(), objects)
        elif prefix.startswith("gcsfs://"):
            sources[prefix] = Source(
                "fsspec",
                fs.PyFileSystem(fs.FSSpecHandler(gcsfs.GCSFileSystem())),
                fsspec.filesystem("gcs").ls(prefix.removeprefix("gcsfs://")),
            )
        else:
            sources[prefix] = Source(
                "local", fs.LocalFileSystem(), fsspec.filesystem("local").ls(prefix)
            )
    return sources