Skip to content

Commit 95b4645

Browse files
authored
Merge pull request #530 from latchbio/ayush/fix-lps
fix launchplans
2 parents be01441 + 5a3818b commit 95b4645

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ Types of changes
1616

1717
# Latch SDK Changelog
1818

19+
## 2.58.2 - 2024-04-03
20+
21+
### Fixed
22+
23+
* Fix issue where `LaunchPlan`s would not be interpreted correctly in custom workflow modules
24+
1925
## 2.58.1 - 2024-04-03
2026

2127
### Fixed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include = ["src/**/*.py", "src/latch_cli/services/init/*"]
1212

1313
[project]
1414
name = "latch"
15-
version = "2.58.1"
15+
version = "2.58.2"
1616
description = "The Latch SDK"
1717
authors = [{ name = "Kenny Workman", email = "[email protected]" }]
1818
maintainers = [

src/latch/resources/launch_plan.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import inspect
2-
from typing import Any, Callable, Dict
1+
from typing import Any
32

4-
from flytekit import LaunchPlan as _LaunchPlan
3+
from flytekit.core.launch_plan import LaunchPlan as _LaunchPlan
4+
from flytekit.core.workflow import PythonFunctionWorkflow
55

66

77
class LaunchPlan:
@@ -26,18 +26,19 @@ class LaunchPlan:
2626
)
2727
"""
2828

29-
def __init__(self, workflow: Callable, name: str, default_params: Dict[str, Any]):
30-
# This constructor is invoked twice when task code is executed.
31-
# 1. When the pyflyte-execute entrypoint is invoked to start task.
32-
# `mod.__name__` of caller is `wf`
33-
# 2. When the PythonAutoContainer loads our module to call our task.
34-
# `mod.__name__` of caller is `wf.__init__`
35-
# LaunchPlans are stored in a global array and redundant additions will
36-
# throw an exception, so we want to create on the first constructor
37-
# call only.
38-
39-
frame = inspect.stack()[1]
40-
mod = inspect.getmodule(frame[0])
41-
if mod.__name__ == "wf":
42-
str_repr = f"wf.__init__.{workflow.__name__}.{name}"
43-
_LaunchPlan.create(str_repr, workflow, default_params)
29+
def __init__(
30+
self,
31+
workflow: PythonFunctionWorkflow,
32+
name: str,
33+
default_params: dict[str, Any],
34+
):
35+
try: # noqa: SIM105
36+
_LaunchPlan.create(
37+
f"{workflow.__module__}.{workflow.__name__}.{name}",
38+
workflow,
39+
default_params,
40+
)
41+
42+
# if the launchplan already exists, the `create` method throws an AssertionError
43+
except AssertionError:
44+
pass

0 commit comments

Comments
 (0)