osbot-utils 2.31.0__py3-none-any.whl → 2.33.0__py3-none-any.whl

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.
@@ -122,6 +122,11 @@ class Flow(Type_Safe):
122
122
  def captured_logs(self):
123
123
  return ansis_to_texts(self.captured_exec_logs)
124
124
 
125
+ def durations(self):
126
+ return self.flow_stats.durations()
127
+
128
+ def durations__with_tasks_status(self):
129
+ return self.flow_stats.durations__with_tasks_status()
125
130
 
126
131
  async def invoke_flow_target__thread(self, flow): # this is a REALLY important method which is used to pin the flow object to the call stack
127
132
  return await flow.flow_target(*flow.resolved_args, **flow.resolved_kwargs) # which is then used by the Task.find_flow method to find it
@@ -133,6 +138,10 @@ class Flow(Type_Safe):
133
138
  else:
134
139
  self.flow_return_value = self.flow_target(*self.resolved_args, **self.resolved_kwargs) # if the flow is sync, just execute the flow target
135
140
 
141
+ def flow_output(self):
142
+ return dict(output = self.flow_return_value,
143
+ durations = self.durations() )
144
+
136
145
  def f__flow_id(self):
137
146
  return self.cformat.green(self.flow_id)
138
147
 
@@ -5,6 +5,7 @@ from osbot_utils.helpers.flows.schemas.Schema__Task__Stats import Schema__Task
5
5
  from osbot_utils.helpers.flows.schemas.Schema__Flow__Stats import Schema__Flow__Stats
6
6
  from osbot_utils.type_safe.Type_Safe import Type_Safe
7
7
 
8
+ FLOW__ERROR_MESSAGE__TASK_FAILED = 'At least one task failed'
8
9
 
9
10
  class Flow__Stats__Collector(Type_Safe):
10
11
  duration : Duration
@@ -31,6 +32,9 @@ class Flow__Stats__Collector(Type_Safe):
31
32
  if flow_error:
32
33
  _.status = Schema__Flow__Status.FAILED
33
34
  _.error_message = str(flow_error)
35
+ elif _.failed_tasks:
36
+ _.status = Schema__Flow__Status.FAILED
37
+ _.error_message = FLOW__ERROR_MESSAGE__TASK_FAILED
34
38
  else:
35
39
  _.status = Schema__Flow__Status.COMPLETED
36
40
  return self
@@ -44,4 +48,36 @@ class Flow__Stats__Collector(Type_Safe):
44
48
  return self
45
49
 
46
50
  def json(self): # Return JSON representation of the stats.
47
- return self.stats.json()
51
+ return self.stats.json()
52
+
53
+ def durations__with_tasks_status(self):
54
+ with self.stats as _:
55
+ tasks_durations = dict()
56
+ flow_durations = dict(flow_name = _.flow_name ,
57
+ flow_duration = _.duration.duration_seconds,
58
+ flow_status = _.status.value ,
59
+ flow_tasks = tasks_durations )
60
+
61
+ for task_id, flow_task in self.stats.tasks_stats.items():
62
+ task_duration = dict(task_name = flow_task.task_name ,
63
+ task_duration = flow_task.duration.duration_seconds,
64
+ task_status = flow_task.status.value )
65
+ execution_order = flow_task.execution_order
66
+ tasks_durations[execution_order] = task_duration
67
+ return flow_durations
68
+
69
+ def durations(self):
70
+ with self.stats as _:
71
+ if _.status is None:
72
+ flow_durations = dict()
73
+ else:
74
+ tasks_durations = dict()
75
+ flow_durations = dict(flow_name = _.flow_name ,
76
+ flow_duration = _.duration.duration_seconds,
77
+ flow_status = _.status.value ,
78
+ flow_tasks = tasks_durations )
79
+
80
+ for task_id, flow_task in self.stats.tasks_stats.items():
81
+
82
+ tasks_durations[flow_task.task_name] = flow_task.duration.duration_seconds
83
+ return flow_durations
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.31.0
1
+ v2.33.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.31.0
3
+ Version: 2.33.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  License: MIT
6
6
  Author: Dinis Cruz
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
23
23
 
24
24
  Powerful Python util methods and classes that simplify common apis and tasks.
25
25
 
26
- ![Current Release](https://img.shields.io/badge/release-v2.31.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v2.33.0-blue)
27
27
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
28
28
 
29
29
 
@@ -142,12 +142,12 @@ osbot_utils/helpers/duration/decorators/duration.py,sha256=ucJP1fCQEN8ALCDCG9CPz
142
142
  osbot_utils/helpers/duration/decorators/print_duration.py,sha256=w7k3OPiRkL5KqLv0S5o1NVo2y_TeOOvDOb-51YbJjAc,283
143
143
  osbot_utils/helpers/duration/schemas/Schema__Duration.py,sha256=-h32wBcpiVRkEbc_sZoamnRFNGaQQM4YsxqoVzPGe38,209
144
144
  osbot_utils/helpers/duration/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
145
- osbot_utils/helpers/flows/Flow.py,sha256=dFjD3czAZDKvcCCk5yeVdpOWCVWvsn5D_q2AnO8340k,13653
145
+ osbot_utils/helpers/flows/Flow.py,sha256=WxpaWrbLhlkHtZuiTaNE8S9ocpmLcVQQL0C4PGzcDMY,13970
146
146
  osbot_utils/helpers/flows/Task.py,sha256=RfccOCev5XTsNoKuDJzK1JItF-Lm7P6FGCGZyh9swyY,7116
147
147
  osbot_utils/helpers/flows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
148
  osbot_utils/helpers/flows/actions/Flow__Data.py,sha256=rgUggQo_z6KLtNa92KfzRG6ORdT_8ic5zJVuhk_st38,5064
149
149
  osbot_utils/helpers/flows/actions/Flow__Events.py,sha256=g7KBafFeA7tV-v31v_m3MT__cZEX63gh8CehnZwRYU0,2840
150
- osbot_utils/helpers/flows/actions/Flow__Stats__Collector.py,sha256=GOxXUjDXCQs6cx1BQ9Z_a5KpUI4ztZHaQ-L7-85Ybpc,2276
150
+ osbot_utils/helpers/flows/actions/Flow__Stats__Collector.py,sha256=GCszqIGj8yVlr283ZXiejDCof-tbDgynjzAdmhEqBWg,4155
151
151
  osbot_utils/helpers/flows/actions/Task__Stats__Collector.py,sha256=rDYABaHpikIAK0Odleu8-dZ9ECJZYDmgFdd0KvsbByI,1462
152
152
  osbot_utils/helpers/flows/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
153
153
  osbot_utils/helpers/flows/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -365,8 +365,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
365
365
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
366
366
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
367
367
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
368
- osbot_utils/version,sha256=HCRke6XnsWX14IEkvcnr363MBi6BbkbVDkvEZXWN1Dg,8
369
- osbot_utils-2.31.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
370
- osbot_utils-2.31.0.dist-info/METADATA,sha256=cA1LigYUC3D4O8kl4ofRRahn_BQ0MwTtvIIbPSSwf3k,1329
371
- osbot_utils-2.31.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
372
- osbot_utils-2.31.0.dist-info/RECORD,,
368
+ osbot_utils/version,sha256=UzPaV1nLfhdRXaPnxoRowDnXt8jTG9HI_R0xTg5g0TY,8
369
+ osbot_utils-2.33.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
370
+ osbot_utils-2.33.0.dist-info/METADATA,sha256=pDF4s4KDlDj62b11GuDqJN8C6qYse1VL6XrZTWmMHGI,1329
371
+ osbot_utils-2.33.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
372
+ osbot_utils-2.33.0.dist-info/RECORD,,