from tostorchconnector import CredentialProvider, TosClientConfig, ReaderType, TosIterableDataset, TosCheckpoint
endpoint = 'http://tos-cn-beijing.ivolces.com'
ak = '<your-access-key>'
sk = '<your-secret-key>'
shared_prefetch_tasks = 200
shared_upload_part_tasks = 200
with TosCheckpoint(region, endpoint, cred=CredentialProvider(ak, sk),
client_conf=TosClientConfig(shared_prefetch_tasks=shared_prefetch_tasks,
shared_upload_part_tasks=shared_upload_part_tasks)) as checkpoint:
dataset_uri = 'tos://bucket/prefix'
prefetch_concurrency = 256
with TosIterableDataset.from_prefix(dataset_uri, region=region, endpoint=endpoint, cred=CredentialProvider(ak=ak, sk=sk), prefetch_concurrency=prefetch_concurrency) as dataset:
checkpoint_uri = 'tos://bucket/key'
with TosCheckpoint(region, endpoint, cred=CredentialProvider(ak, sk)) as checkpoint:
with checkpoint.reader(checkpoint_uri, reader_type=ReaderType.SEQUENTIAL) as reader:
with TosIterableDataset.from_prefix(dataset_uri, region=region, endpoint=endpoint, cred=CredentialProvider(ak=ak, sk=sk), reader_type=ReaderType.SEQUENTIAL) as dataset: