forked from awslabs/s3-connector-for-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dnnanuti
committed
Mar 21, 2024
1 parent
69e95ae
commit 5ee1e6b
Showing
6 changed files
with
89 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
s3torchconnectorclient/python/src/s3torchconnectorclient/s3_connector_client_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# // SPDX-License-Identifier: BSD | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class S3ConnectorClientConfig: | ||
"""A dataclass exposing configurable parameters for the S3 client.""" | ||
|
||
def __init__( | ||
self, throughput_target_gbps: float = 10.0, part_size: int = 8 * 1024 * 1024 | ||
self, | ||
throughput_target_gbps: float = 10.0, | ||
part_size: int = 8 * 1024 * 1024, | ||
): | ||
"""Returns a config wrapper object. | ||
Args: | ||
throughput_target_gbps(float): Throughput target in Gigabits per second (Gbps) that we are trying to reach. | ||
You can also use get_recommended_throughput_target_gbps() to get recommended value for your system. | ||
10.0 Gbps by default (may change in future). | ||
part_size(int): Size, in bytes, of parts that files will be downloaded or uploaded in. | ||
Note: for saving checkpoints, the inner client will adjust the part size to meet the service limits. | ||
(max number of parts per upload is 10,000, minimum upload part size is 5 MiB). | ||
8MB by default (may change in future). | ||
""" | ||
self.throughput_target_gbps = throughput_target_gbps | ||
self.part_size = part_size |
31 changes: 31 additions & 0 deletions
31
s3torchconnectorclient/python/tst/unit/test_s3_connector_client_config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# // SPDX-License-Identifier: BSD | ||
from hypothesis import given | ||
from hypothesis.strategies import integers, floats | ||
|
||
from s3torchconnectorclient import S3ConnectorClientConfig | ||
|
||
|
||
def test_default(): | ||
config = S3ConnectorClientConfig() | ||
assert config is not None | ||
assert config.part_size == 8 * 1024 * 1024 | ||
assert abs(config.throughput_target_gbps - 10.0) < 1e-9 | ||
|
||
|
||
@given(part_size=integers(min_value=1, max_value=1e12)) | ||
def test_part_size_setup(part_size: int): | ||
config = S3ConnectorClientConfig(part_size=part_size) | ||
assert config is not None | ||
assert config.part_size == part_size | ||
assert abs(config.throughput_target_gbps - 10.0) < 1e-9 | ||
|
||
|
||
@given(throughput_target_gbps_setup=floats(min_value=1.0, max_value=100.0)) | ||
def test_throughput_target_gbps_setup(throughput_target_gbps_setup: float): | ||
config = S3ConnectorClientConfig( | ||
throughput_target_gbps=throughput_target_gbps_setup | ||
) | ||
assert config is not None | ||
assert config.part_size == 8 * 1024 * 1024 | ||
assert abs(config.throughput_target_gbps - throughput_target_gbps_setup) < 1e-9 |