runnable 0.16.0__py3-none-any.whl → 0.17.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
runnable/context.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Dict, List, Optional
1
+ from typing import Any, Dict, List, Optional
2
2
 
3
3
  from pydantic import BaseModel, ConfigDict, Field, SerializeAsAny
4
4
  from rich.progress import Progress
@@ -29,6 +29,8 @@ class Context(BaseModel):
29
29
  from_sdk: bool = False
30
30
 
31
31
  run_id: str = ""
32
+ object_serialisation: bool = True
33
+ return_objects: Dict[str, Any] = {}
32
34
 
33
35
  tag: str = ""
34
36
  variables: Dict[str, str] = {}
runnable/datastore.py CHANGED
@@ -98,22 +98,33 @@ class ObjectParameter(BaseModel):
98
98
  @computed_field # type: ignore
99
99
  @property
100
100
  def description(self) -> str:
101
- return f"Pickled object stored in catalog as: {self.value}"
101
+ if context.run_context.object_serialisation:
102
+ return f"Pickled object stored in catalog as: {self.value}"
103
+
104
+ return f"Object stored in memory as: {self.value}"
102
105
 
103
106
  @property
104
107
  def file_name(self) -> str:
105
108
  return f"{self.value}{context.run_context.pickler.extension}"
106
109
 
107
110
  def get_value(self) -> Any:
108
- # Get the pickled object
109
- catalog_handler = context.run_context.catalog_handler
111
+ # If there was no serialisation, return the object from the return objects
112
+ if not context.run_context.object_serialisation:
113
+ return context.run_context.return_objects[self.value]
110
114
 
115
+ # If the object was serialised, get it from the catalog
116
+ catalog_handler = context.run_context.catalog_handler
111
117
  catalog_handler.get(name=self.file_name, run_id=context.run_context.run_id)
112
118
  obj = context.run_context.pickler.load(path=self.file_name)
113
119
  os.remove(self.file_name) # Remove after loading
114
120
  return obj
115
121
 
116
122
  def put_object(self, data: Any) -> None:
123
+ if not context.run_context.object_serialisation:
124
+ context.run_context.return_objects[self.value] = data
125
+ return
126
+
127
+ # If the object was serialised, put it in the catalog
117
128
  context.run_context.pickler.dump(data=data, path=self.file_name)
118
129
 
119
130
  catalog_handler = context.run_context.catalog_handler
runnable/executor.py CHANGED
@@ -34,9 +34,7 @@ class BaseExecutor(ABC, BaseModel):
34
34
  service_name: str = ""
35
35
  service_type: str = "executor"
36
36
 
37
- _is_local: bool = (
38
- False # This is a flag to indicate whether the executor is local or not.
39
- )
37
+ _is_local: bool = PrivateAttr(default=False)
40
38
 
41
39
  model_config = ConfigDict(extra="forbid")
42
40
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: runnable
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: Add your description here
5
5
  Author-email: "Vammi, Vijay" <vijay.vammi@astrazeneca.com>
6
6
  License-File: LICENSE
@@ -1,12 +1,12 @@
1
1
  runnable/__init__.py,sha256=KqpLDTD1CfdEj2aDyEkSn2KW-_83qyrRrrWLc5lZVM4,624
2
2
  runnable/catalog.py,sha256=MiEmb-18liAKmgeMdDF41VVn0ZEAVLP8hR33oacQ1zs,4930
3
3
  runnable/cli.py,sha256=01zmzOdynEmLI4vWDtSHQ6y1od_Jlc8G1RF69fi2L8g,8446
4
- runnable/context.py,sha256=pLw_n_5U-FM8-9-41YnkzETX94KrBAZWjxPgjm0O7hk,1305
5
- runnable/datastore.py,sha256=a1pT_P8TNcqQB-di2_uga7y-zS3TqUCb7sFhdxmVKGY,31907
4
+ runnable/context.py,sha256=by5uepmuCP0dmM9BmsliXihSes5QEFejwAsmekcqylE,1388
5
+ runnable/datastore.py,sha256=9y5enzn6AXLHLdwvgkdjGPrBkVlrcjfbaAHsst-lJzg,32466
6
6
  runnable/defaults.py,sha256=3o9IVGryyCE6PoQTOoaIaHHTbJGEzmdXMcwzOhwAYoI,3518
7
7
  runnable/entrypoints.py,sha256=67gPBiIIS4Kd9g6LdoGCraRJPda8K1i7Lp7XcD2iY5k,18913
8
8
  runnable/exceptions.py,sha256=LFbp0-Qxg2PAMLEVt7w2whhBxSG-5pzUEv5qN-Rc4_c,3003
9
- runnable/executor.py,sha256=cS30EC2Pfz8OzzEVcUYrVIyvGboKVUw5jKG2l72-UfM,15606
9
+ runnable/executor.py,sha256=Rafu9EECrNq1LBkJmS6KYCekchP5ufrR04mHWG-JzqQ,15543
10
10
  runnable/graph.py,sha256=jVjikRLR-so3b2ufmNKpEQ_Ny68qN4bcGDAdXBRKiCY,16574
11
11
  runnable/names.py,sha256=vn92Kv9ANROYSZX6Z4z1v_WA3WiEdIYmG6KEStBFZug,8134
12
12
  runnable/nodes.py,sha256=YU9u7r1ESzui1uVtJ1dgwdv1ozyJnF2k-MCFieT8CLI,17519
@@ -16,8 +16,8 @@ runnable/sdk.py,sha256=hwdk2dLmJsOTs2GnOlayw8WfliyeZFpA6Tcnp3tgblg,33370
16
16
  runnable/secrets.py,sha256=PXcEJw-4WPzeWRLfsatcPPyr1zkqgHzdRWRcS9vvpvM,2354
17
17
  runnable/tasks.py,sha256=JnIIYQf3YUidHXIN6hiUIfDnegc7_rJMNXuHW4WS9ig,29378
18
18
  runnable/utils.py,sha256=wqyN7lMW56cBqyE59iDE6_i2HXPkvEUCQ-66UQnIwTA,19993
19
- runnable-0.16.0.dist-info/METADATA,sha256=JMu8mSsxMWr_wF246saRXV80D8_8cXMOPZrK6Pr9X6k,10102
20
- runnable-0.16.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
- runnable-0.16.0.dist-info/entry_points.txt,sha256=I92DYldRrCb9HCsoum8GjC2UsQrWpuw2kawXTZpkIz4,1559
22
- runnable-0.16.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
- runnable-0.16.0.dist-info/RECORD,,
19
+ runnable-0.17.0.dist-info/METADATA,sha256=aPu6b9A_JP90oLpCFcnSJStDaizL5-sXbahPvjWU5Wo,10102
20
+ runnable-0.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
+ runnable-0.17.0.dist-info/entry_points.txt,sha256=I92DYldRrCb9HCsoum8GjC2UsQrWpuw2kawXTZpkIz4,1559
22
+ runnable-0.17.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
23
+ runnable-0.17.0.dist-info/RECORD,,