Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cache_regions=True in the case of s3fs #1592

Merged
merged 4 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flytekit/core/data_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pathlib
import tempfile
import typing
from typing import Union, cast
from typing import Any, Dict, Union, cast
from uuid import UUID

import fsspec
Expand All @@ -46,7 +46,9 @@


def s3_setup_args(s3_cfg: configuration.S3Config, anonymous: bool = False):
kwargs = {}
kwargs: Dict[str, Any] = {
"cache_regions": True,
}
if s3_cfg.access_key_id:
kwargs[_FSSPEC_S3_KEY_ID] = s3_cfg.access_key_id

Expand Down
8 changes: 4 additions & 4 deletions tests/flytekit/unit/core/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_s3_setup_args_env_empty(mock_os, mock_get_config_file):
mock_os.get.return_value = None
s3c = S3Config.auto()
kwargs = s3_setup_args(s3c)
assert kwargs == {}
assert kwargs == {"cache_regions": True}


@mock.patch("flytekit.configuration.get_config_file")
Expand All @@ -191,7 +191,7 @@ def test_s3_setup_args_env_both(mock_os, mock_get_config_file):
}
mock_os.get.side_effect = lambda x, y: ee.get(x)
kwargs = s3_setup_args(S3Config.auto())
assert kwargs == {"key": "flyte", "secret": "flyte-secret"}
assert kwargs == {"key": "flyte", "secret": "flyte-secret", "cache_regions": True}


@mock.patch("flytekit.configuration.get_config_file")
Expand All @@ -204,7 +204,7 @@ def test_s3_setup_args_env_flyte(mock_os, mock_get_config_file):
}
mock_os.get.side_effect = lambda x, y: ee.get(x)
kwargs = s3_setup_args(S3Config.auto())
assert kwargs == {"key": "flyte", "secret": "flyte-secret"}
assert kwargs == {"key": "flyte", "secret": "flyte-secret", "cache_regions": True}


@mock.patch("flytekit.configuration.get_config_file")
Expand All @@ -218,7 +218,7 @@ def test_s3_setup_args_env_aws(mock_os, mock_get_config_file):
mock_os.get.side_effect = lambda x, y: ee.get(x)
kwargs = s3_setup_args(S3Config.auto())
# not explicitly in kwargs, since fsspec/boto3 will use these env vars by default
assert kwargs == {}
assert kwargs == {"cache_regions": True}


def test_crawl_local_nt(source_folder):
Expand Down