Skip to content

Commit

Permalink
Remove unused function in results.py (#14744)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpwlms authored Jul 24, 2024
1 parent e2832e2 commit e430486
Showing 1 changed file with 1 addition and 46 deletions.
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

0 comments on commit e430486

Please sign in to comment.