Skip to content

add deprecation warnings #278

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
save state
Signed-off-by: Ayush Kamat <[email protected]>
  • Loading branch information
ayushkamat committed Oct 26, 2023
commit 4ca04e7d2acca49ed17c2729dad2344eec6b871b
45 changes: 16 additions & 29 deletions latch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
Latch platform.
"""

from latch._deprecation import _deprecated, _deprecated_import
from latch.functions.messages import message
import warnings
from typing import Any, Dict

from latch.functions.operators import (
combine,
group_tuple,
Expand All @@ -19,8 +20,8 @@
from latch.resources.map_tasks import map_task
from latch.resources.reference_workflow import workflow_reference
from latch.resources.tasks import (
custom_task,
custom_memory_optimized_task,
custom_task,
large_gpu_task,
large_task,
medium_task,
Expand All @@ -29,35 +30,21 @@
)
from latch.resources.workflow import workflow

message = _deprecated_import("message", "latch.functions.messages")(message)
_deprecation_version = "3.0.0"

combine = _deprecated()(combine)
group_tuple = _deprecated()(group_tuple)
inner_join = _deprecated()(inner_join)
latch_filter = _deprecated()(latch_filter)
left_join = _deprecated()(left_join)
outer_join = _deprecated()(outer_join)
right_join = _deprecated()(right_join)

create_conditional_section = _deprecated_import(
"create_conditional_section", "latch.resources.conditional"
)(create_conditional_section)
def _warn(name: str, import_path: str):
warnings.warn(
f"Importing `{name}` directly from `latch` is deprecated, and will"
f" be removed in version {_deprecation_version}.\n\n Please use"
f" the full import `from {import_path} import {name}`\n",
DeprecationWarning,
)

map_task = _deprecated_import("map_task", "latch.resources.map_tasks")(map_task)

workflow_reference = _deprecated_import(
"workflow_reference", "latch.resources.reference_workflow"
)(workflow_reference)
def message(typ: str, data: Dict[str, Any]):
from latch.functions.messages import message as _message

custom_task = _deprecated_import("custom_task", "latch.resources.tasks")(custom_task)
large_gpu_task = _deprecated_import("large_gpu_task", "latch.resources.tasks")(
large_gpu_task
)
large_task = _deprecated_import("large_task", "latch.resources.tasks")(large_task)
medium_task = _deprecated_import("medium_task", "latch.resources.tasks")(medium_task)
small_gpu_task = _deprecated_import("small_gpu_task", "latch.resources.tasks")(
small_gpu_task
)
small_task = _deprecated_import("small_task", "latch.resources.tasks")(small_task)
_warn("message", "latch.functions.messages")

workflow = _deprecated_import("workflow", "latch.resources.workflow")(workflow)
return _message(typ, data)
52 changes: 26 additions & 26 deletions latch/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@
Text,
)

LatchDir = _deprecated_import("LatchDir", "latch.types.directory")(LatchDir)
LatchOutputDir = _deprecated_import("LatchOutputDir", "latch.types.directory")(
LatchOutputDir
)
# LatchDir = _deprecated_import("LatchDir", "latch.types.directory")(LatchDir)
# LatchOutputDir = _deprecated_import("LatchOutputDir", "latch.types.directory")(
# LatchOutputDir
# )

LatchFile = _deprecated_import("LatchFile", "latch.types.file")(LatchFile)
LatchOutputFile = _deprecated_import("LatchOutputFile", "latch.types.file")(
LatchOutputFile
)
# LatchFile = _deprecated_import("LatchFile", "latch.types.file")(LatchFile)
# LatchOutputFile = _deprecated_import("LatchOutputFile", "latch.types.file")(
# LatchOutputFile
# )

file_glob = _deprecated_import("file_glob", "latch.types.glob")(file_glob)
# file_glob = _deprecated_import("file_glob", "latch.types.glob")(file_glob)

Fork = _deprecated_import("Fork", "latch.types.metadata")(Fork)
ForkBranch = _deprecated_import("ForkBranch", "latch.types.metadata")(ForkBranch)
LatchAppearanceType = _deprecated_import("LatchAppearanceType", "latch.types.metadata")(
LatchAppearanceType
)
LatchAuthor = _deprecated_import("LatchAuthor", "latch.types.metadata")(LatchAuthor)
LatchMetadata = _deprecated_import("LatchMetadata", "latch.types.metadata")(
LatchMetadata
)
LatchParameter = _deprecated_import("LatchParameter", "latch.types.metadata")(
LatchParameter
)
LatchRule = _deprecated_import("LatchRule", "latch.types.metadata")(LatchRule)
Params = _deprecated_import("Params", "latch.types.metadata")(Params)
Section = _deprecated_import("Section", "latch.types.metadata")(Section)
Spoiler = _deprecated_import("Spoiler", "latch.types.metadata")(Spoiler)
Text = _deprecated_import("Text", "latch.types.metadata")(Text)
# Fork = _deprecated_import("Fork", "latch.types.metadata")(Fork)
# ForkBranch = _deprecated_import("ForkBranch", "latch.types.metadata")(ForkBranch)
# LatchAppearanceType = _deprecated_import("LatchAppearanceType", "latch.types.metadata")(
# LatchAppearanceType
# )
# LatchAuthor = _deprecated_import("LatchAuthor", "latch.types.metadata")(LatchAuthor)
# LatchMetadata = _deprecated_import("LatchMetadata", "latch.types.metadata")(
# LatchMetadata
# )
# LatchParameter = _deprecated_import("LatchParameter", "latch.types.metadata")(
# LatchParameter
# )
# LatchRule = _deprecated_import("LatchRule", "latch.types.metadata")(LatchRule)
# Params = _deprecated_import("Params", "latch.types.metadata")(Params)
# Section = _deprecated_import("Section", "latch.types.metadata")(Section)
# Spoiler = _deprecated_import("Spoiler", "latch.types.metadata")(Spoiler)
# Text = _deprecated_import("Text", "latch.types.metadata")(Text)