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

Remove unused function in results.py #14744

Merged
merged 1 commit into from
Jul 24, 2024
Merged
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
47 changes: 1 addition & 46 deletions src/prefect/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import prefect
from prefect.blocks.core import Block
from prefect.client.utilities import inject_client
from prefect.exceptions import MissingResult, ObjectAlreadyExists
from prefect.exceptions import MissingResult
from prefect.filesystems import (
LocalFileSystem,
WritableFileSystem,
Expand Down Expand Up @@ -64,51 +64,6 @@ def DEFAULT_STORAGE_KEY_FN():
_default_storages: Dict[Tuple[str, str], WritableFileSystem] = {}


async def _get_or_create_default_storage(block_document_slug: str) -> ResultStorage:
"""
Generate a default file system for storage.
"""
default_storage_name, storage_path = cache_key = (
block_document_slug,
PREFECT_LOCAL_STORAGE_PATH.value(),
)

async def get_storage() -> WritableFileSystem:
try:
return await Block.load(default_storage_name)
except ValueError as e:
if "Unable to find" not in str(e):
raise e

block_type_slug, name = default_storage_name.split("/")
if block_type_slug == "local-file-system":
block = LocalFileSystem(basepath=storage_path)
else:
raise ValueError(
"The default storage block does not exist, but it is of type "
f"'{block_type_slug}' which cannot be created implicitly. Please create "
"the block manually."
)

try:
await block.save(name, overwrite=False)
except ValueError as e:
if "already in use" not in str(e):
raise e
except ObjectAlreadyExists:
# Another client created the block before we reached this line
block = await Block.load(default_storage_name)

return block

try:
return _default_storages[cache_key]
except KeyError:
storage = await get_storage()
_default_storages[cache_key] = storage
return storage


@sync_compatible
async def get_default_result_storage() -> ResultStorage:
"""
Expand Down
Loading