runnable 0.3.0__tar.gz → 0.4.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. {runnable-0.3.0 → runnable-0.4.0}/PKG-INFO +1 -1
  2. {runnable-0.3.0 → runnable-0.4.0}/pyproject.toml +1 -1
  3. {runnable-0.3.0 → runnable-0.4.0}/runnable/__init__.py +12 -1
  4. {runnable-0.3.0 → runnable-0.4.0}/runnable/sdk.py +157 -37
  5. {runnable-0.3.0 → runnable-0.4.0}/LICENSE +0 -0
  6. {runnable-0.3.0 → runnable-0.4.0}/README.md +0 -0
  7. {runnable-0.3.0 → runnable-0.4.0}/runnable/catalog.py +0 -0
  8. {runnable-0.3.0 → runnable-0.4.0}/runnable/cli.py +0 -0
  9. {runnable-0.3.0 → runnable-0.4.0}/runnable/context.py +0 -0
  10. {runnable-0.3.0 → runnable-0.4.0}/runnable/datastore.py +0 -0
  11. {runnable-0.3.0 → runnable-0.4.0}/runnable/defaults.py +0 -0
  12. {runnable-0.3.0 → runnable-0.4.0}/runnable/entrypoints.py +0 -0
  13. {runnable-0.3.0 → runnable-0.4.0}/runnable/exceptions.py +0 -0
  14. {runnable-0.3.0 → runnable-0.4.0}/runnable/executor.py +0 -0
  15. {runnable-0.3.0 → runnable-0.4.0}/runnable/experiment_tracker.py +0 -0
  16. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/__init__.py +0 -0
  17. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/__init__.py +0 -0
  18. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/file_system/__init__.py +0 -0
  19. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/file_system/implementation.py +0 -0
  20. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/k8s_pvc/__init__.py +0 -0
  21. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/k8s_pvc/implementation.py +0 -0
  22. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/catalog/k8s_pvc/integration.py +0 -0
  23. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/__init__.py +0 -0
  24. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/argo/__init__.py +0 -0
  25. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/argo/implementation.py +0 -0
  26. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/argo/specification.yaml +0 -0
  27. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/k8s_job/__init__.py +0 -0
  28. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/k8s_job/implementation_FF.py +0 -0
  29. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/k8s_job/integration_FF.py +0 -0
  30. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/local/__init__.py +0 -0
  31. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/local/implementation.py +0 -0
  32. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/local_container/__init__.py +0 -0
  33. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/local_container/implementation.py +0 -0
  34. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/mocked/__init__.py +0 -0
  35. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/executor/mocked/implementation.py +0 -0
  36. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/experiment_tracker/__init__.py +0 -0
  37. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/experiment_tracker/mlflow/__init__.py +0 -0
  38. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/experiment_tracker/mlflow/implementation.py +0 -0
  39. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/nodes.py +0 -0
  40. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/__init__.py +0 -0
  41. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/chunked_file_system/__init__.py +0 -0
  42. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/chunked_file_system/implementation.py +0 -0
  43. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/chunked_k8s_pvc/__init__.py +0 -0
  44. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/chunked_k8s_pvc/implementation.py +0 -0
  45. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/chunked_k8s_pvc/integration.py +0 -0
  46. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/db/implementation_FF.py +0 -0
  47. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/db/integration_FF.py +0 -0
  48. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/file_system/__init__.py +0 -0
  49. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/file_system/implementation.py +0 -0
  50. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/generic_chunked.py +0 -0
  51. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/k8s_pvc/__init__.py +0 -0
  52. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/k8s_pvc/implementation.py +0 -0
  53. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/run_log_store/k8s_pvc/integration.py +0 -0
  54. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/secrets/__init__.py +0 -0
  55. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/secrets/dotenv/__init__.py +0 -0
  56. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/secrets/dotenv/implementation.py +0 -0
  57. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/secrets/env_secrets/__init__.py +0 -0
  58. {runnable-0.3.0 → runnable-0.4.0}/runnable/extensions/secrets/env_secrets/implementation.py +0 -0
  59. {runnable-0.3.0 → runnable-0.4.0}/runnable/graph.py +0 -0
  60. {runnable-0.3.0 → runnable-0.4.0}/runnable/integration.py +0 -0
  61. {runnable-0.3.0 → runnable-0.4.0}/runnable/interaction.py +0 -0
  62. {runnable-0.3.0 → runnable-0.4.0}/runnable/names.py +0 -0
  63. {runnable-0.3.0 → runnable-0.4.0}/runnable/nodes.py +0 -0
  64. {runnable-0.3.0 → runnable-0.4.0}/runnable/parameters.py +0 -0
  65. {runnable-0.3.0 → runnable-0.4.0}/runnable/pickler.py +0 -0
  66. {runnable-0.3.0 → runnable-0.4.0}/runnable/secrets.py +0 -0
  67. {runnable-0.3.0 → runnable-0.4.0}/runnable/tasks.py +0 -0
  68. {runnable-0.3.0 → runnable-0.4.0}/runnable/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: runnable
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A Compute agnostic pipelining software
5
5
  Home-page: https://github.com/vijayvammi/runnable
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "runnable"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "A Compute agnostic pipelining software"
5
5
  authors = ["Vijay Vammi <mesanthu@gmail.com>"]
6
6
  license = "Apache-2.0"
@@ -24,7 +24,18 @@ from runnable.interaction import (
24
24
  set_parameter,
25
25
  track_this,
26
26
  ) # noqa
27
- from runnable.sdk import Stub, Pipeline, Task, Parallel, Map, Catalog, Success, Fail # noqa
27
+ from runnable.sdk import (
28
+ Stub,
29
+ Pipeline,
30
+ Parallel,
31
+ Map,
32
+ Catalog,
33
+ Success,
34
+ Fail,
35
+ PythonTask,
36
+ NotebookTask,
37
+ ShellTask,
38
+ ) # noqa
28
39
 
29
40
 
30
41
  # TODO: Think of model registry as a central place to store models.
@@ -3,9 +3,9 @@ from __future__ import annotations
3
3
  import logging
4
4
  import os
5
5
  from abc import ABC, abstractmethod
6
- from typing import Any, Dict, List, Optional, Union
6
+ from typing import Any, Callable, Dict, List, Optional, Union
7
7
 
8
- from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, computed_field, field_validator, model_validator
8
+ from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, computed_field, model_validator
9
9
  from rich import print
10
10
  from typing_extensions import Self
11
11
 
@@ -15,11 +15,8 @@ from runnable.nodes import TraversalNode
15
15
 
16
16
  logger = logging.getLogger(defaults.LOGGER_NAME)
17
17
 
18
- StepType = Union["Stub", "Task", "Success", "Fail", "Parallel", "Map"]
19
- TraversalTypes = Union["Stub", "Task", "Parallel", "Map"]
20
-
21
-
22
- ALLOWED_COMMAND_TYPES = ["shell", "python", "notebook"]
18
+ StepType = Union["Stub", "PythonTask", "NotebookTask", "ShellTask", "Success", "Fail", "Parallel", "Map"]
19
+ TraversalTypes = Union["Stub", "PythonTask", "NotebookTask", "ShellTask", "Parallel", "Map"]
23
20
 
24
21
 
25
22
  class Catalog(BaseModel):
@@ -106,10 +103,7 @@ class BaseTraversal(ABC, BaseModel):
106
103
  ...
107
104
 
108
105
 
109
- ## TODO: Add python task, shell task, and notebook task.
110
-
111
-
112
- class Task(BaseTraversal):
106
+ class BaseTask(BaseTraversal):
113
107
  """
114
108
  An execution node of the pipeline.
115
109
  Please refer to [concepts](concepts/task.md) for more information.
@@ -157,41 +151,166 @@ class Task(BaseTraversal):
157
151
 
158
152
  """
159
153
 
160
- command: str = Field(alias="command")
161
- command_type: str = Field(default="python")
162
154
  catalog: Optional[Catalog] = Field(default=None, alias="catalog")
163
155
  overrides: Dict[str, Any] = Field(default_factory=dict, alias="overrides")
164
156
 
157
+ def create_node(self) -> TaskNode:
158
+ if not self.next_node:
159
+ if not (self.terminate_with_failure or self.terminate_with_success):
160
+ raise AssertionError("A node not being terminated must have a user defined next node")
161
+
162
+ print(self.model_dump(exclude_none=True))
163
+ return TaskNode.parse_from_config(self.model_dump(exclude_none=True))
164
+
165
+
166
+ class PythonTask(BaseTask):
167
+ """
168
+ An execution node of the pipeline of python functions.
169
+ Please refer to [concepts](concepts/task.md) for more information.
170
+
171
+ Attributes:
172
+ name (str): The name of the node.
173
+ function (callable): The function to execute.
174
+ catalog (Optional[Catalog]): The catalog to sync data from/to.
175
+ Please see Catalog about the structure of the catalog.
176
+ overrides (Dict[str, Any]): Any overrides to the command.
177
+ Individual tasks can override the global configuration config by referring to the
178
+ specific override.
179
+
180
+ For example,
181
+ ### Global configuration
182
+ ```yaml
183
+ executor:
184
+ type: local-container
185
+ config:
186
+ docker_image: "runnable/runnable:latest"
187
+ overrides:
188
+ custom_docker_image:
189
+ docker_image: "runnable/runnable:custom"
190
+ ```
191
+ ### Task specific configuration
192
+ ```python
193
+ task = PythonTask(name="task", function="function'",
194
+ overrides={'local-container': custom_docker_image})
195
+ ```
196
+
197
+ terminate_with_failure (bool): Whether to terminate the pipeline with a failure after this node.
198
+ terminate_with_success (bool): Whether to terminate the pipeline with a success after this node.
199
+ on_failure (str): The name of the node to execute if the step fails.
200
+
201
+ """
202
+
203
+ function: Callable = Field(exclude=True)
204
+
205
+ @computed_field
206
+ def command_type(self) -> str:
207
+ return "python"
208
+
209
+ @computed_field
210
+ def command(self) -> str:
211
+ module = self.function.__module__
212
+ name = self.function.__name__
213
+
214
+ return f"{module}.{name}"
215
+
216
+
217
+ class NotebookTask(BaseTask):
218
+ """
219
+ An execution node of the pipeline of type notebook.
220
+ Please refer to [concepts](concepts/task.md) for more information.
221
+
222
+ Attributes:
223
+ name (str): The name of the node.
224
+ notebook: The path to the notebook
225
+ catalog (Optional[Catalog]): The catalog to sync data from/to.
226
+ Please see Catalog about the structure of the catalog.
227
+ returns: A list of the names of variables to return from the notebook.
228
+ overrides (Dict[str, Any]): Any overrides to the command.
229
+ Individual tasks can override the global configuration config by referring to the
230
+ specific override.
231
+
232
+ For example,
233
+ ### Global configuration
234
+ ```yaml
235
+ executor:
236
+ type: local-container
237
+ config:
238
+ docker_image: "runnable/runnable:latest"
239
+ overrides:
240
+ custom_docker_image:
241
+ docker_image: "runnable/runnable:custom"
242
+ ```
243
+ ### Task specific configuration
244
+ ```python
245
+ task = NotebookTask(name="task", notebook="evaluation.ipynb",
246
+ overrides={'local-container': custom_docker_image})
247
+ ```
248
+ notebook_output_path (Optional[str]): The path to save the notebook output.
249
+ Only used when command_type is 'notebook', defaults to command+_out.ipynb
250
+ optional_ploomber_args (Optional[Dict[str, Any]]): Any optional ploomber args.
251
+ Only used when command_type is 'notebook', defaults to {}
252
+
253
+ terminate_with_failure (bool): Whether to terminate the pipeline with a failure after this node.
254
+ terminate_with_success (bool): Whether to terminate the pipeline with a success after this node.
255
+ on_failure (str): The name of the node to execute if the step fails.
256
+
257
+ """
258
+
259
+ notebook: str = Field(alias="command")
260
+
165
261
  notebook_output_path: Optional[str] = Field(default=None, alias="notebook_output_path")
166
262
  optional_ploomber_args: Optional[Dict[str, Any]] = Field(default=None, alias="optional_ploomber_args")
167
- output_cell_tag: Optional[str] = Field(default=None, alias="output_cell_tag")
263
+ returns: List[str] = Field(default_factory=list, alias="returns")
168
264
 
169
- @field_validator("command_type", mode="before")
170
- @classmethod
171
- def validate_command_type(cls, value: str) -> str:
172
- if value not in ALLOWED_COMMAND_TYPES:
173
- raise ValueError(f"Invalid command_type: {value}")
174
- return value
265
+ @computed_field
266
+ def command_type(self) -> str:
267
+ return "notebook"
175
268
 
176
- @model_validator(mode="after")
177
- def check_notebook_args(self) -> "Task":
178
- if self.command_type != "notebook":
179
- assert (
180
- self.notebook_output_path is None
181
- ), "Only command_types of 'notebook' can be used with notebook_output_path"
182
269
 
183
- assert (
184
- self.optional_ploomber_args is None
185
- ), "Only command_types of 'notebook' can be used with optional_ploomber_args"
270
+ class ShellTask(BaseTask):
271
+ """
272
+ An execution node of the pipeline of type shell.
273
+ Please refer to [concepts](concepts/task.md) for more information.
186
274
 
187
- assert self.output_cell_tag is None, "Only command_types of 'notebook' can be used with output_cell_tag"
188
- return self
275
+ Attributes:
276
+ name (str): The name of the node.
277
+ command: The shell command to execute.
278
+ catalog (Optional[Catalog]): The catalog to sync data from/to.
279
+ Please see Catalog about the structure of the catalog.
280
+ returns: A list of the names of variables to capture from environment variables of shell.
281
+ overrides (Dict[str, Any]): Any overrides to the command.
282
+ Individual tasks can override the global configuration config by referring to the
283
+ specific override.
189
284
 
190
- def create_node(self) -> TaskNode:
191
- if not self.next_node:
192
- if not (self.terminate_with_failure or self.terminate_with_success):
193
- raise AssertionError("A node not being terminated must have a user defined next node")
194
- return TaskNode.parse_from_config(self.model_dump(exclude_none=True))
285
+ For example,
286
+ ### Global configuration
287
+ ```yaml
288
+ executor:
289
+ type: local-container
290
+ config:
291
+ docker_image: "runnable/runnable:latest"
292
+ overrides:
293
+ custom_docker_image:
294
+ docker_image: "runnable/runnable:custom"
295
+ ```
296
+ ### Task specific configuration
297
+ ```python
298
+ task = ShellTask(name="task", command="exit 0",
299
+ overrides={'local-container': custom_docker_image})
300
+ ```
301
+
302
+ terminate_with_failure (bool): Whether to terminate the pipeline with a failure after this node.
303
+ terminate_with_success (bool): Whether to terminate the pipeline with a success after this node.
304
+ on_failure (str): The name of the node to execute if the step fails.
305
+
306
+ """
307
+
308
+ command: str = Field(alias="command")
309
+ returns: List[str] = Field(default_factory=list, alias="returns")
310
+
311
+ @computed_field
312
+ def command_type(self) -> str:
313
+ return "shell"
195
314
 
196
315
 
197
316
  class Stub(BaseTraversal):
@@ -343,7 +462,8 @@ class Pipeline(BaseModel):
343
462
  A Pipeline is a directed acyclic graph of Steps that define a workflow.
344
463
 
345
464
  Attributes:
346
- steps (List[Stub | Task | Parallel | Map | Success | Fail]): A list of Steps that make up the Pipeline.
465
+ steps (List[Stub | PythonTask | NotebookTask | ShellTask | Parallel | Map | Success | Fail]):
466
+ A list of Steps that make up the Pipeline.
347
467
  start_at (Stub | Task | Parallel | Map): The name of the first Step in the Pipeline.
348
468
  name (str, optional): The name of the Pipeline. Defaults to "".
349
469
  description (str, optional): A description of the Pipeline. Defaults to "".
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes