flytekitplugins-sleep 1.16.27__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flytekitplugins_sleep-1.16.27/PKG-INFO +27 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins/sleep/__init__.py +11 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins/sleep/task.py +46 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/PKG-INFO +27 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/SOURCES.txt +11 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/dependency_links.txt +1 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/entry_points.txt +2 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/namespace_packages.txt +1 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/requires.txt +1 -0
- flytekitplugins_sleep-1.16.27/flytekitplugins_sleep.egg-info/top_level.txt +1 -0
- flytekitplugins_sleep-1.16.27/setup.cfg +4 -0
- flytekitplugins_sleep-1.16.27/setup.py +36 -0
- flytekitplugins_sleep-1.16.27/tests/test_sleep.py +69 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flytekitplugins-sleep
|
|
3
|
+
Version: 1.16.27
|
|
4
|
+
Summary: This package holds the core-sleep plugin for flytekit
|
|
5
|
+
Author: flyteorg
|
|
6
|
+
Author-email: admin@flyte.org
|
|
7
|
+
License: apache2
|
|
8
|
+
Classifier: Intended Audience :: Science/Research
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: flytekit>=1.15.1
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: license
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
Dynamic: summary
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import Any, Callable, Dict, Optional
|
|
5
|
+
|
|
6
|
+
from flytekit.configuration import SerializationSettings
|
|
7
|
+
from flytekit.core.python_function_task import PythonFunctionTask
|
|
8
|
+
from flytekit.core.task import TaskPlugins
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass
|
|
12
|
+
class Sleep:
|
|
13
|
+
"""
|
|
14
|
+
Route a task to the backend ``core-sleep`` plugin.
|
|
15
|
+
|
|
16
|
+
The sleep duration is provided as a normal task input, not plugin config.
|
|
17
|
+
No container is launched; the backend handles the sleep directly.
|
|
18
|
+
|
|
19
|
+
Usage::
|
|
20
|
+
|
|
21
|
+
from flytekitplugins.sleep import Sleep
|
|
22
|
+
from flytekit import task
|
|
23
|
+
from datetime import timedelta
|
|
24
|
+
|
|
25
|
+
@task(task_config=Sleep())
|
|
26
|
+
def sleep_for(duration: timedelta) -> None:
|
|
27
|
+
pass # only runs locally; backend executes the sleep
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SleepFunctionTask(PythonFunctionTask[Sleep]):
|
|
32
|
+
_TASK_TYPE = "core-sleep"
|
|
33
|
+
|
|
34
|
+
def __init__(self, task_config: Optional[Sleep], task_function: Callable, **kwargs):
|
|
35
|
+
super().__init__(
|
|
36
|
+
task_config=task_config or Sleep(),
|
|
37
|
+
task_function=task_function,
|
|
38
|
+
task_type=self._TASK_TYPE,
|
|
39
|
+
**kwargs,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def get_custom(self, settings: SerializationSettings) -> Dict[str, Any]:
|
|
43
|
+
return {}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
TaskPlugins.register_pythontask_plugin(Sleep, SleepFunctionTask)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flytekitplugins-sleep
|
|
3
|
+
Version: 1.16.27
|
|
4
|
+
Summary: This package holds the core-sleep plugin for flytekit
|
|
5
|
+
Author: flyteorg
|
|
6
|
+
Author-email: admin@flyte.org
|
|
7
|
+
License: apache2
|
|
8
|
+
Classifier: Intended Audience :: Science/Research
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Classifier: Topic :: Software Development
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Requires-Dist: flytekit>=1.15.1
|
|
21
|
+
Dynamic: author
|
|
22
|
+
Dynamic: author-email
|
|
23
|
+
Dynamic: classifier
|
|
24
|
+
Dynamic: license
|
|
25
|
+
Dynamic: requires-dist
|
|
26
|
+
Dynamic: requires-python
|
|
27
|
+
Dynamic: summary
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
setup.py
|
|
2
|
+
flytekitplugins/sleep/__init__.py
|
|
3
|
+
flytekitplugins/sleep/task.py
|
|
4
|
+
flytekitplugins_sleep.egg-info/PKG-INFO
|
|
5
|
+
flytekitplugins_sleep.egg-info/SOURCES.txt
|
|
6
|
+
flytekitplugins_sleep.egg-info/dependency_links.txt
|
|
7
|
+
flytekitplugins_sleep.egg-info/entry_points.txt
|
|
8
|
+
flytekitplugins_sleep.egg-info/namespace_packages.txt
|
|
9
|
+
flytekitplugins_sleep.egg-info/requires.txt
|
|
10
|
+
flytekitplugins_sleep.egg-info/top_level.txt
|
|
11
|
+
tests/test_sleep.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flytekitplugins
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flytekit>=1.15.1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
flytekitplugins
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from setuptools import setup
|
|
2
|
+
|
|
3
|
+
PLUGIN_NAME = "sleep"
|
|
4
|
+
|
|
5
|
+
microlib_name = f"flytekitplugins-{PLUGIN_NAME}"
|
|
6
|
+
|
|
7
|
+
__version__ = "1.16.27"
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
title="Sleep",
|
|
11
|
+
title_expanded="Flytekit Sleep Plugin",
|
|
12
|
+
name=microlib_name,
|
|
13
|
+
version=__version__,
|
|
14
|
+
author="flyteorg",
|
|
15
|
+
author_email="admin@flyte.org",
|
|
16
|
+
description="This package holds the core-sleep plugin for flytekit",
|
|
17
|
+
namespace_packages=["flytekitplugins"],
|
|
18
|
+
packages=[f"flytekitplugins.{PLUGIN_NAME}"],
|
|
19
|
+
install_requires=["flytekit>=1.15.1"],
|
|
20
|
+
license="apache2",
|
|
21
|
+
python_requires=">=3.9",
|
|
22
|
+
classifiers=[
|
|
23
|
+
"Intended Audience :: Science/Research",
|
|
24
|
+
"Intended Audience :: Developers",
|
|
25
|
+
"License :: OSI Approved :: Apache Software License",
|
|
26
|
+
"Programming Language :: Python :: 3.9",
|
|
27
|
+
"Programming Language :: Python :: 3.10",
|
|
28
|
+
"Programming Language :: Python :: 3.11",
|
|
29
|
+
"Topic :: Scientific/Engineering",
|
|
30
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
31
|
+
"Topic :: Software Development",
|
|
32
|
+
"Topic :: Software Development :: Libraries",
|
|
33
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
34
|
+
],
|
|
35
|
+
entry_points={"flytekit.plugins": [f"{PLUGIN_NAME}=flytekitplugins.{PLUGIN_NAME}"]},
|
|
36
|
+
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from collections import OrderedDict
|
|
2
|
+
from datetime import timedelta
|
|
3
|
+
|
|
4
|
+
from flytekitplugins.sleep import Sleep
|
|
5
|
+
from flytekitplugins.sleep.task import SleepFunctionTask
|
|
6
|
+
|
|
7
|
+
from flytekit import task, workflow
|
|
8
|
+
from flytekit.configuration import Image, ImageConfig, SerializationSettings
|
|
9
|
+
from flytekit.extend import get_serializable
|
|
10
|
+
|
|
11
|
+
default_img = Image(name="default", fqn="test", tag="tag")
|
|
12
|
+
serialization_settings = SerializationSettings(
|
|
13
|
+
project="proj",
|
|
14
|
+
domain="dom",
|
|
15
|
+
version="123",
|
|
16
|
+
image_config=ImageConfig(default_image=default_img, images=[default_img]),
|
|
17
|
+
env={},
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_task_type():
|
|
22
|
+
@task(task_config=Sleep())
|
|
23
|
+
def sleep_for(duration: timedelta) -> None:
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
assert isinstance(sleep_for, SleepFunctionTask)
|
|
27
|
+
assert sleep_for.task_type == "core-sleep"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_serialization():
|
|
31
|
+
@task(task_config=Sleep())
|
|
32
|
+
def sleep_for(duration: timedelta) -> None:
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
task_spec = get_serializable(OrderedDict(), serialization_settings, sleep_for)
|
|
36
|
+
|
|
37
|
+
assert task_spec.template.type == "core-sleep"
|
|
38
|
+
assert task_spec.template.custom == {}
|
|
39
|
+
|
|
40
|
+
inputs = task_spec.template.interface.inputs
|
|
41
|
+
assert "duration" in inputs
|
|
42
|
+
assert len(inputs) == 1
|
|
43
|
+
|
|
44
|
+
outputs = task_spec.template.interface.outputs
|
|
45
|
+
assert len(outputs) == 0
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_local_execution_calls_function():
|
|
49
|
+
called = []
|
|
50
|
+
|
|
51
|
+
@task(task_config=Sleep())
|
|
52
|
+
def sleep_for(duration: timedelta) -> None:
|
|
53
|
+
called.append(duration)
|
|
54
|
+
|
|
55
|
+
sleep_for(duration=timedelta(seconds=1))
|
|
56
|
+
assert called == [timedelta(seconds=1)]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_workflow_integration():
|
|
60
|
+
@task(task_config=Sleep())
|
|
61
|
+
def sleep_for(duration: timedelta) -> None:
|
|
62
|
+
pass
|
|
63
|
+
|
|
64
|
+
@workflow
|
|
65
|
+
def wf(duration: timedelta) -> None:
|
|
66
|
+
sleep_for(duration=duration)
|
|
67
|
+
|
|
68
|
+
spec = get_serializable(OrderedDict(), serialization_settings, wf)
|
|
69
|
+
assert len(spec.template.nodes) == 1
|